KFW Network Identity Manager (Beta 2)
authorJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 29 Nov 2005 22:05:23 +0000 (22:05 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 29 Nov 2005 22:05:23 +0000 (22:05 +0000)
All features completed except for:

 * Debug Window

 * KRB5.INI (aka Realm) Editor

 * Column Selection

 * Graphics are incomplete

 * Documentation is incomplete

ticket: new
status: resolved
component: windows
target_version: 1.4.4
tags: pullup

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17516 dc483132-0cff-0310-8789-dd5450dbe970

270 files changed:
src/windows/identity/ChangeLog [new file with mode: 0644]
src/windows/identity/Makefile
src/windows/identity/apiversion.txt [new file with mode: 0644]
src/windows/identity/config/Makefile
src/windows/identity/config/Makefile.w32
src/windows/identity/config/netidmgr_intver.h.in [new file with mode: 0644]
src/windows/identity/config/netidmgr_version.h.in [new file with mode: 0644]
src/windows/identity/doc/Makefile
src/windows/identity/doc/cred_aquisition.h
src/windows/identity/doc/cred_data_types.h
src/windows/identity/doc/cred_main.h
src/windows/identity/doc/cred_msgs.h
src/windows/identity/doc/cred_prop_pages.h
src/windows/identity/doc/images/Thumbs.db [deleted file]
src/windows/identity/doc/images/khimaira_logo_old.jpg [deleted file]
src/windows/identity/doc/images/khimaira_logo_small_old.jpg [deleted file]
src/windows/identity/doc/main_page.h
src/windows/identity/doc/plugin_framework.h
src/windows/identity/doc/plugin_locale.h
src/windows/identity/doc/plugin_main.h
src/windows/identity/doc/plugin_structure.h
src/windows/identity/doc/ui_actions.h
src/windows/identity/doc/ui_context.h
src/windows/identity/doc/ui_main.h
src/windows/identity/doc/ui_menus.h
src/windows/identity/help/Makefile
src/windows/identity/help/html/about_netidmgr.htm [new file with mode: 0644]
src/windows/identity/help/html/act_chpw.htm [moved from src/windows/identity/help/html/menu_exit.htm with 56% similarity]
src/windows/identity/help/html/act_destroy_creds.htm [moved from src/windows/identity/help/html/menu_properties.htm with 56% similarity]
src/windows/identity/help/html/act_import_creds.htm [new file with mode: 0644]
src/windows/identity/help/html/act_new_creds.htm [new file with mode: 0644]
src/windows/identity/help/html/act_renew_creds.htm [new file with mode: 0644]
src/windows/identity/help/html/act_set_default.htm [new file with mode: 0644]
src/windows/identity/help/html/bugs.htm [new file with mode: 0644]
src/windows/identity/help/html/concept_cred_pro.htm [new file with mode: 0644]
src/windows/identity/help/html/concept_ident_pro.htm [new file with mode: 0644]
src/windows/identity/help/html/concept_identity.htm [new file with mode: 0644]
src/windows/identity/help/html/concepts.htm [new file with mode: 0644]
src/windows/identity/help/html/copyright.htm [new file with mode: 0644]
src/windows/identity/help/html/howdoi.htm [new file with mode: 0644]
src/windows/identity/help/html/images/Thumbs.db [deleted file]
src/windows/identity/help/html/images/link.GIF [deleted file]
src/windows/identity/help/html/images/logo.jpg [new file with mode: 0644]
src/windows/identity/help/html/images/logo_shade.jpg [new file with mode: 0644]
src/windows/identity/help/html/images/screen_app_icon.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_main_wnd.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_bar.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_credential.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_file.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_help.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_options.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_menu_view.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_tb_standard.bmp [new file with mode: 0644]
src/windows/identity/help/html/images/screen_tray_icon.bmp [new file with mode: 0644]
src/windows/identity/help/html/khm.css [deleted file]
src/windows/identity/help/html/menu_all.htm [new file with mode: 0644]
src/windows/identity/help/html/menu_credential.htm [new file with mode: 0644]
src/windows/identity/help/html/menu_file.htm
src/windows/identity/help/html/menu_help.htm [new file with mode: 0644]
src/windows/identity/help/html/menu_options.htm [new file with mode: 0644]
src/windows/identity/help/html/menu_view.htm [new file with mode: 0644]
src/windows/identity/help/html/nidmgr.css [new file with mode: 0644]
src/windows/identity/help/html/tb_standard.htm [new file with mode: 0644]
src/windows/identity/help/html/template.htm
src/windows/identity/help/html/use_start.htm [new file with mode: 0644]
src/windows/identity/help/html/using.htm [new file with mode: 0644]
src/windows/identity/help/html/welcome.htm
src/windows/identity/help/html/wnd_main.htm [new file with mode: 0644]
src/windows/identity/help/khhelp.h
src/windows/identity/help/netidmgr.hhp
src/windows/identity/help/popups.txt [new file with mode: 0644]
src/windows/identity/help/popups_newcreds.txt [new file with mode: 0644]
src/windows/identity/help/toc.hhc
src/windows/identity/include/Makefile
src/windows/identity/include/khdefs.h
src/windows/identity/include/kherror.h
src/windows/identity/include/khlist.h
src/windows/identity/include/khmsgtypes.h
src/windows/identity/include/netidmgr.h [moved from src/windows/identity/include/khthread.h with 67% similarity]
src/windows/identity/kconfig/api.c
src/windows/identity/kconfig/kconfig.h
src/windows/identity/kconfig/kconfiginternal.h
src/windows/identity/kconfig/kconfigmain.c
src/windows/identity/kconfig/registry.c
src/windows/identity/kcreddb/attrib.c
src/windows/identity/kcreddb/attrib.h
src/windows/identity/kcreddb/buf.c
src/windows/identity/kcreddb/buf.h
src/windows/identity/kcreddb/credential.c
src/windows/identity/kcreddb/credential.h
src/windows/identity/kcreddb/credset.c
src/windows/identity/kcreddb/credset.h
src/windows/identity/kcreddb/credtype.c
src/windows/identity/kcreddb/credtype.h
src/windows/identity/kcreddb/identity.c
src/windows/identity/kcreddb/identity.h
src/windows/identity/kcreddb/init.c
src/windows/identity/kcreddb/kcreddb.h
src/windows/identity/kcreddb/kcreddbinternal.h
src/windows/identity/kcreddb/kcreddbmain.c
src/windows/identity/kcreddb/type.c
src/windows/identity/kcreddb/type.h
src/windows/identity/kherr/kherr.c
src/windows/identity/kherr/kherr.h
src/windows/identity/kherr/kherrinternal.h
src/windows/identity/kherr/kherrmain.c
src/windows/identity/kmm/kmm.c
src/windows/identity/kmm/kmm.h
src/windows/identity/kmm/kmm_module.c
src/windows/identity/kmm/kmm_plugin.c
src/windows/identity/kmm/kmm_reg.c
src/windows/identity/kmm/kmm_registrar.c
src/windows/identity/kmm/kmmconfig.csv
src/windows/identity/kmm/kmminternal.h
src/windows/identity/kmm/kmmmain.c
src/windows/identity/kmm/kplugin.h
src/windows/identity/kmm/lang/kmm_msgs.mc
src/windows/identity/kmq/consumer.c
src/windows/identity/kmq/init.c
src/windows/identity/kmq/kmq.h
src/windows/identity/kmq/kmqinternal.h
src/windows/identity/kmq/kmqmain.c
src/windows/identity/kmq/msgtype.c
src/windows/identity/kmq/publisher.c
src/windows/identity/nidmgrdll/Makefile
src/windows/identity/nidmgrdll/dllmain.c
src/windows/identity/nidmgrdll/nidmgrdll.rc
src/windows/identity/plugins/common/dynimport.c
src/windows/identity/plugins/common/dynimport.h
src/windows/identity/plugins/common/krb5common.c
src/windows/identity/plugins/common/krb5common.h
src/windows/identity/plugins/krb4/Makefile
src/windows/identity/plugins/krb4/errorfuncs.c
src/windows/identity/plugins/krb4/errorfuncs.h
src/windows/identity/plugins/krb4/images/plugin.ico [new file with mode: 0644]
src/windows/identity/plugins/krb4/krb4configdlg.c
src/windows/identity/plugins/krb4/krb4funcs.c
src/windows/identity/plugins/krb4/krb4funcs.h
src/windows/identity/plugins/krb4/krb4main.c [moved from src/windows/identity/plugins/krb4/main.c with 75% similarity]
src/windows/identity/plugins/krb4/krb4newcreds.c [new file with mode: 0644]
src/windows/identity/plugins/krb4/krb4plugin.c
src/windows/identity/plugins/krb4/krbconfig.csv
src/windows/identity/plugins/krb4/krbcred.h
src/windows/identity/plugins/krb4/lang/en_us/langres.rc
src/windows/identity/plugins/krb4/langres.h
src/windows/identity/plugins/krb4/version.rc [new file with mode: 0644]
src/windows/identity/plugins/krb5/Makefile
src/windows/identity/plugins/krb5/datarep.c
src/windows/identity/plugins/krb5/datarep.h
src/windows/identity/plugins/krb5/errorfuncs.c
src/windows/identity/plugins/krb5/errorfuncs.h
src/windows/identity/plugins/krb5/images/deleted.ico [moved from src/windows/identity/ui/images/wgt_arrow_expand.ico with 77% similarity]
src/windows/identity/plugins/krb5/images/krb5plugin.ico [new file with mode: 0644]
src/windows/identity/plugins/krb5/images/modified.ico [moved from src/windows/identity/ui/images/wgt_arrow_collapse.ico with 72% similarity]
src/windows/identity/plugins/krb5/images/new.ico [new file with mode: 0644]
src/windows/identity/plugins/krb5/images/normal.ico [new file with mode: 0644]
src/windows/identity/plugins/krb5/krb5configcc.c [new file with mode: 0644]
src/windows/identity/plugins/krb5/krb5configdlg.c
src/windows/identity/plugins/krb5/krb5configid.c [new file with mode: 0644]
src/windows/identity/plugins/krb5/krb5configids.c [new file with mode: 0644]
src/windows/identity/plugins/krb5/krb5funcs.c
src/windows/identity/plugins/krb5/krb5funcs.h
src/windows/identity/plugins/krb5/krb5identpro.c
src/windows/identity/plugins/krb5/krb5main.c [moved from src/windows/identity/plugins/krb5/main.c with 92% similarity]
src/windows/identity/plugins/krb5/krb5newcreds.c
src/windows/identity/plugins/krb5/krb5plugin.c
src/windows/identity/plugins/krb5/krb5props.c
src/windows/identity/plugins/krb5/krb5util.c
src/windows/identity/plugins/krb5/krbconfig.csv
src/windows/identity/plugins/krb5/krbcred.h
src/windows/identity/plugins/krb5/lang/en_us/langres.rc
src/windows/identity/plugins/krb5/langres.h
src/windows/identity/plugins/krb5/version.rc [new file with mode: 0644]
src/windows/identity/ui/Makefile
src/windows/identity/ui/aboutwnd.c
src/windows/identity/ui/aboutwnd.h
src/windows/identity/ui/addrchange.c [new file with mode: 0644]
src/windows/identity/ui/addrchange.h [moved from src/windows/identity/plugins/krb4/datarep.h with 65% similarity]
src/windows/identity/ui/appglobal.h
src/windows/identity/ui/appver.rc [new file with mode: 0644]
src/windows/identity/ui/cfg_general_wnd.c
src/windows/identity/ui/cfg_identities_wnd.c
src/windows/identity/ui/cfg_notif_wnd.c
src/windows/identity/ui/cfg_plugins_wnd.c
src/windows/identity/ui/configwnd.c
src/windows/identity/ui/configwnd.h
src/windows/identity/ui/credfuncs.c
src/windows/identity/ui/credfuncs.h
src/windows/identity/ui/credwnd.c
src/windows/identity/ui/credwnd.h
src/windows/identity/ui/htwnd.c
src/windows/identity/ui/htwnd.h
src/windows/identity/ui/images/Thumbs.db [deleted file]
src/windows/identity/ui/images/bitmap1.bmp [deleted file]
src/windows/identity/ui/images/cfg_plugin.ico [new file with mode: 0644]
src/windows/identity/ui/images/chpw.bmp
src/windows/identity/ui/images/help.bmp
src/windows/identity/ui/images/icon1.ico [deleted file]
src/windows/identity/ui/images/id-dis-sm.bmp
src/windows/identity/ui/images/import.bmp
src/windows/identity/ui/images/main_app_old.ico [deleted file]
src/windows/identity/ui/images/text1138.png [deleted file]
src/windows/identity/ui/images/tk-delete.bmp
src/windows/identity/ui/images/tk-new.bmp
src/windows/identity/ui/images/tk-refresh.bmp
src/windows/identity/ui/images/vw-refresh.bmp
src/windows/identity/ui/images/wdg_collapsed.bmp
src/windows/identity/ui/images/wdg_collapsed_hi.bmp
src/windows/identity/ui/images/wdg_expanded.bmp
src/windows/identity/ui/images/wdg_expanded_hi.bmp
src/windows/identity/ui/images/wdg_stick.bmp [new file with mode: 0644]
src/windows/identity/ui/images/wdg_stick_hi.bmp [new file with mode: 0644]
src/windows/identity/ui/images/wdg_stuck.bmp [new file with mode: 0644]
src/windows/identity/ui/images/wdg_stuck_hi.bmp [new file with mode: 0644]
src/windows/identity/ui/khmapp.h
src/windows/identity/ui/lang/en_us/khapp.rc
src/windows/identity/ui/main.c
src/windows/identity/ui/mainmenu.c
src/windows/identity/ui/mainmenu.h
src/windows/identity/ui/mainwnd.c
src/windows/identity/ui/mainwnd.h
src/windows/identity/ui/newcredwnd.c
src/windows/identity/ui/newcredwnd.h
src/windows/identity/ui/notifier.c
src/windows/identity/ui/notifier.h
src/windows/identity/ui/passwnd.h
src/windows/identity/ui/propertywnd.c
src/windows/identity/ui/propertywnd.h
src/windows/identity/ui/reqdaemon.c
src/windows/identity/ui/reqdaemon.h
src/windows/identity/ui/resource.h
src/windows/identity/ui/statusbar.c
src/windows/identity/ui/statusbar.h
src/windows/identity/ui/timer.c
src/windows/identity/ui/timer.h
src/windows/identity/ui/toolbar.c
src/windows/identity/ui/toolbar.h
src/windows/identity/uilib/accel.csv
src/windows/identity/uilib/action.c
src/windows/identity/uilib/actions.csv
src/windows/identity/uilib/alert.c
src/windows/identity/uilib/configui.c
src/windows/identity/uilib/configui.h
src/windows/identity/uilib/creddlg.c
src/windows/identity/uilib/khaction.h
src/windows/identity/uilib/khactiondef.h
src/windows/identity/uilib/khalerts.h
src/windows/identity/uilib/khconfigui.h
src/windows/identity/uilib/khhtlink.h
src/windows/identity/uilib/khnewcred.h
src/windows/identity/uilib/khprops.h
src/windows/identity/uilib/khremote.h
src/windows/identity/uilib/khrescache.h
src/windows/identity/uilib/khtracker.h
src/windows/identity/uilib/khuidefs.h
src/windows/identity/uilib/propsheet.c
src/windows/identity/uilib/propwnd.c
src/windows/identity/uilib/rescache.c
src/windows/identity/uilib/trackerwnd.c
src/windows/identity/uilib/uilibmain.c
src/windows/identity/util/Makefile
src/windows/identity/util/hashtable.c
src/windows/identity/util/hashtable.h
src/windows/identity/util/mstring.c
src/windows/identity/util/mstring.h
src/windows/identity/util/perfstat.c [new file with mode: 0644]
src/windows/identity/util/perfstat.h [new file with mode: 0644]
src/windows/identity/util/sync.c
src/windows/identity/util/sync.h
src/windows/identity/util/utils.h

diff --git a/src/windows/identity/ChangeLog b/src/windows/identity/ChangeLog
new file mode 100644 (file)
index 0000000..ada18d2
--- /dev/null
@@ -0,0 +1,19 @@
+2005-11-29  Jeffrey Altman <jaltman@mit.edu>\r
+\r
+Second Beta of KFW 3.0.0:\r
+\r
+All features completed except for:\r
+\r
+ * Debug Window\r
+\r
+ * KRB5.INI (aka Realm) Editor\r
+\r
+ * Column Selection\r
+\r
+ * Graphics are incomplete\r
+\r
+ * Documentation is incomplete\r
+\r
+\r
+  \r
+\r
index 3a79ee5f58a8481ebe74cd271d2dc2425ef306bf..253d7193538c2c06b8f5688ce1915eaf6b9a4115 100644 (file)
@@ -47,126 +47,137 @@ RMAKE=$(MAKECMD) /nologo clean
 start:\r
 \r
 config: start\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 include: config\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 util: include\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 kherr: util\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 kconfig: kherr\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 kmq: kconfig\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 kcreddb: kmq\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 kmm: kcreddb\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 help: kmm\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 uilib: help\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 nidmgrdll: uilib\r
-       $(ECHO) Entering $@\r
+       $(ECHO) -- Entering $@\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 ui: nidmgrdll\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 # Now build the plugins\r
 plugincommon: ui\r
-       $(ECHO) Entering $@\r
+       $(ECHO) -- Entering $@\r
        $(CD) plugins\common\r
        $(RMAKE)\r
        $(CD) ..\..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 krb5plugin: plugincommon\r
-       $(ECHO) Entering $@\r
+       $(ECHO) -- Entering $@\r
        $(CD) plugins\krb5\r
        $(RMAKE)\r
        $(CD) ..\..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 !ifndef NO_KRB4\r
 finale: krb4plugin\r
 \r
 krb4plugin: plugincommon\r
-       $(ECHO) Entering $@\r
+       $(ECHO) -- Entering $@\r
        $(CD) plugins\krb4\r
        $(RMAKE)\r
        $(CD) ..\..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
+!endif\r
+\r
+!ifdef BUILD_AFS\r
+finale: afsplugin\r
+\r
+afsplugin: plugincommon\r
+       $(ECHO) -- Entering $@\r
+       $(CD) plugins\afs\r
+       $(RMAKE)\r
+       $(CD) ..\..\r
+       $(ECHO) -- Done with $@\r
 !endif\r
 \r
 finale: krb5plugin\r
-       $(ECHO) Done.\r
+       $(ECHO) -- Done.\r
 \r
 pdoc:\r
 \r
 doc: pdoc\r
-       $(ECHO) Entering $@:\r
+       $(ECHO) -- Entering $@:\r
        $(CD) $@\r
        $(RMAKE)\r
        $(CD) ..\r
-       $(ECHO) Done with $@\r
+       $(ECHO) -- Done with $@\r
 \r
 clean::\r
        $(MAKECMD) /nologo CLEANRUN=1\r
diff --git a/src/windows/identity/apiversion.txt b/src/windows/identity/apiversion.txt
new file mode 100644 (file)
index 0000000..44ce760
--- /dev/null
@@ -0,0 +1,54 @@
+# Copyright (c) 2004 Massachusetts Institute of Technology\r
+#\r
+# Permission is hereby granted, free of charge, to any person\r
+# obtaining a copy of this software and associated documentation files\r
+# (the "Software"), to deal in the Software without restriction,\r
+# including without limitation the rights to use, copy, modify, merge,\r
+# publish, distribute, sublicense, and/or sell copies of the Software,\r
+# and to permit persons to whom the Software is furnished to do so,\r
+# subject to the following conditions:\r
+#\r
+# The above copyright notice and this permission notice shall be\r
+# included in all copies or substantial portions of the Software.\r
+#\r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+# SOFTWARE.\r
+\r
+\r
+# This file documents the versions of the API for NetIDMgr.  The\r
+# syntax of the file is:\r
+#\r
+# Version=<api-version number>\r
+# AppVersion=<netidmgr-version>\r
+# Date=<release date> | NOTRELEASED\r
+# # <comments>\r
+# <symbol-name>\r
+# # comment\r
+# Schema:<path-to-schema>\r
+# # comment\r
+\r
+\r
+#----------------------------------------------------------------\r
+Version=1\r
+AppVersion=0.1.0.0\r
+Date=NOTRELEASED\r
+# Original Khimaira API.\r
+\r
+#----------------------------------------------------------------\r
+Version=2\r
+AppVersion=0.1.1.0\r
+Date=Nov 01, 2005\r
+# Alpha release of NetIDMgr\r
+\r
+#----------------------------------------------------------------\r
+Version=3\r
+AppVersion=0.1.2.0\r
+Date=NOTRELEASED\r
+# Beta release\r
+\r
index 686a044ce505f4d85210c8183c344903f4cc8b08..e720bd804c48d9efc737584514f8108da5863a66 100644 (file)
 MODULE=config\r
 !include <Makefile.w32>\r
 \r
-all: mkalldirs mkversion\r
+all: showvars mkalldirs mkversion\r
+\r
+showvars:\r
+       $(ECHO) SRC= $(SRC)\r
+       $(ECHO) DESTDIR = $(DESTDIR)\r
+       $(ECHO) OBJDIR = $(OBJDIR)\r
+       $(ECHO).\r
+       $(ECHO) CC = $(CC)\r
+       $(ECHO) DOXYGEN = $(DOXYGEN)\r
+       $(ECHO) HHC = $(HHC)\r
 \r
 mkalldirs:\r
 !      if !exist($(DESTROOT))\r
@@ -54,7 +63,9 @@ mkalldirs:
 !      endif\r
        $(ECHO) Done creating directories.\r
 \r
-VERSIONINC=$(INCDIR)\khimaira_version.h\r
+VERSIONINT=$(INCDIR)\netidmgr_intver.h\r
+\r
+VERSIONEXT=$(INCDIR)\netidmgr_version.h\r
 \r
 # Version related defines\r
 \r
@@ -75,59 +86,40 @@ kh_fileos=VOS_NT_WINDOWS32
 kh_filetype_app=VFT_APP\r
 kh_filetype_dll=VFT_DLL\r
 \r
-mkversion: $(VERSIONINC)\r
-\r
-$(VERSIONINC): Makefile\r
-       $(CP) << $(VERSIONINC)\r
-/*\r
- * This is an autogenerated file.  Do not modify directly.\r
- * \r
- * File generated by running $(MAKE) in $(MAKEDIR)\r
- * To regenerate, run "$(MAKE) clean" and "$(MAKE) all" on $(MAKEDIR)\r
- */\r
-#ifndef __KHIMAIRA_VERSION_H\r
-#define __KHIMAIRA_VERSION_H\r
-\r
-/* Version number macros */\r
-#define KH_VERSION_MAJOR       $(KHIMAIRA_VERSION_MAJOR)\r
-#define KH_VERSION_MINOR       $(KHIMAIRA_VERSION_MINOR)\r
-#define KH_VERSION_PATCH       $(KHIMAIRA_VERSION_PATCH)\r
-#define KH_VERSION_AUX                 $(KHIMAIRA_VERSION_AUX)\r
-#define KH_VERSION_LIST        $(KHIMAIRA_VERSIONC)\r
-#define KH_VERSION_STRING      "$(KHIMAIRA_VERSION)"\r
-#define KH_VERSION_STRINGW     L"$(KHIMAIRA_VERSION)"\r
-#define KH_VERSION_STRINGC     "$(KHIMAIRA_VERSIONC)"\r
-#define KH_VERSION_STRINGCW    L"$(KHIMAIRA_VERSIONC)"\r
-\r
-/* Version definition macros */\r
-#define KH_VER_FILEFLAGS       $(kh_fileflags)\r
-#define KH_VER_FILEOS          $(kh_fileos)\r
-#define KH_VER_FILETYPEDLL     $(kh_filetype_dll)\r
-#define KH_VER_FILETYPEAPP     $(kh_filetype_app)\r
-\r
-/* Language specific version strings */\r
-#define KH_VERSTR_COMPANY_1033 "$(KHIMAIRA_SRC_COMPANY_1033)"\r
-#define KH_VERSTR_COPYRIGHT_1033 "$(KHIMAIRA_SRC_COPYRIGHT_1033)"\r
-#define KH_VERSTR_PRODUCT_1033 "$(KHIMAIRA_PRODUCT_1033)"\r
-#define KH_VERSTR_VERSION_1033 "$(KHIMAIRA_VERSION_STR_1033)"\r
-\r
-!ifdef KHIMAIRA_COMMENT_STR_1033\r
-#define KH_VERSTR_COMMENT_1033 "$(KHIMAIRA_COMMENT_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_COMMENT_1033\r
+mkversion: $(VERSIONINT) $(VERSIONEXT)\r
+\r
+# Version and build strings\r
+\r
+!if "$(KH_RELEASE)" == "OFFICIAL"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION)\r
+NETIDMGR_COMMENT_STR_1033=Official build.  Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "PRERELEASE"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION) Alpha\r
+NETIDMGR_COMMENT_STR_1033=Prerelease build.  Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "PRIVATE"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION).PRIVATE\r
+NETIDMGR_PRIVATE_STR_1033=Private build.  Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "SPECIAL"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION).SPECIAL\r
+NETIDMGR_SPECIAL_STR_1033=Special build.  Please send bug reports to kfw-bugs@MIT.EDU\r
 !endif\r
-!ifdef KHIMAIRA_PRIVATE_STR_1033\r
-#define KH_VERSTR_PRIVATE_1033 "$(KHIMAIRA_PRIVATE_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_PRIVATE_1033\r
-!endif\r
-!ifdef KHIMAIRA_SPECIAL_STR_1033\r
-#define KH_VERSTR_SPECIAL_1033 "$(KHIMAIRA_SPECIAL_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_SPECIAL_1033\r
+\r
+!if "$(KH_BUILD)" == "DEBUG"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION_STR_1033).DEBUG\r
+!else\r
 !endif\r
-#endif\r
-<<\r
+\r
+NETIDMGR_PRODUCT_1033=NetIDMgr $(NETIDMGR_VERSION_STR_1033)\r
+\r
+!include netidmgr_version.h.in\r
+\r
+!include netidmgr_intver.h.in\r
 \r
 clean::\r
-!      if exist($(VERSIONINC))\r
-       $(RM) $(VERSIONINC)\r
+!      if exist($(VERSIONINT))\r
+       $(RM) $(VERSIONINT)\r
+!      endif\r
+!      if exist($(VERSIONEXT))\r
+       $(RM) $(VERSIONEXT)\r
 !      endif\r
 \r
index 1b862a9ad487d7291417b3e36a7b7dad5f8910a1..5d469c92be0f3943a93ab80d402a501ffa36b435 100644 (file)
@@ -44,17 +44,26 @@ KHIMAIRA_WIN32_CONFIG=1
 #      SPECIAL    : Special build.  Typically one with non-mainline patches.\r
 \r
 # Version info\r
-KHIMAIRA_VERSION_MAJOR=0\r
-KHIMAIRA_VERSION_MINOR=1\r
-KHIMAIRA_VERSION_PATCH=1\r
-KHIMAIRA_VERSION_AUX=0\r
-KHIMAIRA_VERSION=$(KHIMAIRA_VERSION_MAJOR).$(KHIMAIRA_VERSION_MINOR).$(KHIMAIRA_VERSION_PATCH).$(KHIMAIRA_VERSION_AUX)\r
-KHIMAIRA_VERSIONC=$(KHIMAIRA_VERSION_MAJOR),$(KHIMAIRA_VERSION_MINOR),$(KHIMAIRA_VERSION_PATCH),$(KHIMAIRA_VERSION_AUX)\r
+NETIDMGR_VERSION_MAJOR=0\r
+NETIDMGR_VERSION_MINOR=1\r
+NETIDMGR_VERSION_PATCH=2\r
+NETIDMGR_VERSION_AUX=0\r
+\r
+# The API version.  This number must be incremented each time the API\r
+# changes.  Plugins specify the version of the API that they were\r
+# compiled against and the Module Manager uses the API numbers to\r
+# decide whether the plugin is safe to load or not.\r
+#\r
+# Changes to the API version numbers should be documented in\r
+# apiversion.txt at the root of the source tree.\r
+NETIDMGR_VERSION_API=3\r
 \r
-# Source information\r
-KHIMAIRA_SRC_COMPANY_1033=Massachusetts Institute of Technology\r
+NETIDMGR_VERSION=$(NETIDMGR_VERSION_MAJOR).$(NETIDMGR_VERSION_MINOR).$(NETIDMGR_VERSION_PATCH).$(NETIDMGR_VERSION_AUX)\r
+NETIDMGR_VERSIONC=$(NETIDMGR_VERSION_MAJOR),$(NETIDMGR_VERSION_MINOR),$(NETIDMGR_VERSION_PATCH),$(NETIDMGR_VERSION_AUX)\r
 \r
-KHIMAIRA_SRC_COPYRIGHT_1033=(C) 2005 Massachusetts Institute of Technology\r
+# Source information\r
+NETIDMGR_SRC_COMPANY_1033=Massachusetts Institute of Technology\r
+NETIDMGR_SRC_COPYRIGHT_1033=(C) 2005 Massachusetts Institute of Technology\r
 \r
 # Choose the default build type if one is not set\r
 !if ("$(KH_BUILD)" != "DEBUG") && ("$(KH_BUILD)" != "RETAIL")\r
@@ -74,28 +83,7 @@ KH_BUILD=DEBUG
 KH_RELEASE=PRERELEASE\r
 !endif\r
 \r
-# Version and build strings\r
-\r
-!if "$(KH_RELEASE)" == "OFFICIAL"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION)\r
-KHIMAIRA_COMMENT_STR_1033=Official build.\r
-!elseif "$(KH_RELEASE)" == "PRERELEASE"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION) Alpha\r
-KHIMAIRA_COMMENT_STR_1033=Prerelease build.\r
-!elseif "$(KH_RELEASE)" == "PRIVATE"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION).PRIVATE\r
-KHIMAIRA_PRIVATE_STR_1033=Private build.\r
-!elseif "$(KH_RELEASE)" == "SPECIAL"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION).SPECIAL\r
-KHIMAIRA_SPECIAL_STR_1033=Special build.\r
-!endif\r
-\r
-!if "$(KH_BUILD)" == "DEBUG"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION_STR_1033).DEBUG\r
-!else\r
-!endif\r
-\r
-KHIMAIRA_PRODUCT_1033=NetIDMgr $(KHIMAIRA_VERSION_STR_1033)\r
+# Actual build environment settings\r
 \r
 # See what compiler we are using\r
 # TODO: Update this to support other compilers\r
@@ -110,7 +98,11 @@ KH_CLVER=vc7
 !      error MODULE must be specified\r
 !endif\r
 !ifndef KH_ROOT\r
+! ifndef PISMERE\r
+!   error Either KH_ROOT or PISMERE must be defined\r
+! else\r
 KH_ROOT=$(PISMERE)\athena\auth\krb5\src\windows\identity\r
+! endif\r
 !endif\r
 \r
 !ifdef NODEBUG\r
@@ -126,7 +118,7 @@ OUTPRE=$(OUTPRE3)^\
 \r
 \r
 # Output directory structure\r
-DESTROOT=$(KH_ROOT)\dest\r
+DESTROOT=$(KH_ROOT)\obj\r
 OBJROOT=$(KH_ROOT)\obj\r
 SRC=$(KH_ROOT)\r
 \r
@@ -134,7 +126,7 @@ DESTDIR=$(DESTROOT)\$(CPU)\$(OUTPRE_DBG)
 OBJDIR=$(OBJROOT)\$(CPU)\$(OUTPRE_DBG)\r
 \r
 OBJ=$(OBJDIR)\$(MODULE)\r
-INCDIR=$(DESTDIR)\include\r
+INCDIR=$(DESTDIR)\inc\r
 #BINDIR=$(DESTDIR)\bin\r
 BINDIR=$(KH_ROOT)\$(OUTPRE)\r
 #LIBDIR=$(DESTDIR)\lib\r
@@ -182,7 +174,7 @@ HHC=hhc
 KFWINCDIR=$(KH_KFWPATH)\inc\r
 kfwincflags = -I$(KFWINCDIR)\krb5 -I$(KFWINCDIR)\krb5\KerberosIV -I$(KFWINCDIR)\loadfuncs -I$(KFWINCDIR)\r
 KFWLIBDIR=$(KH_KFWPATH)\lib\$(CPU)\r
-!else\r
+!else if defined(PISMERE)\r
 KFWINCDIR=$(PISMERE)\athena\auth\krb5\src\include\r
 kfwincflags = -I$(KFWINCDIR) -I$(PISMERE)\athena\util\loadfuncs -I$(PISMERE)\athena\auth\krb5\src\include\kerberosIV -I$(PISMERE)\athena\auth\krb4\include\r
 KFWLIBDIR=$(PISMERE)\target\lib\$(CPU)\$(OUTPRE_DBG)\r
@@ -275,4 +267,6 @@ etag::
 \r
 .SUFFIXES: .h\r
 \r
+.SILENT:\r
+\r
 !endif\r
diff --git a/src/windows/identity/config/netidmgr_intver.h.in b/src/windows/identity/config/netidmgr_intver.h.in
new file mode 100644 (file)
index 0000000..d1863c4
--- /dev/null
@@ -0,0 +1,34 @@
+$(VERSIONINT): Makefile\r
+       $(CP) << $(VERSIONINT)\r
+/*\r
+ * This is an autogenerated file.  Do not modify directly.\r
+ * \r
+ * File generated by running $(MAKE) in $(MAKEDIR)\r
+ * To regenerate, run "$(MAKE) clean" and "$(MAKE) all" on $(MAKEDIR)\r
+ */\r
+#ifndef __NETIDMGR_VERSION_INTERNAL_H\r
+#define __NETIDMGR_VERSION_INTERNAL_H\r
+\r
+#include<netidmgr_version.h>\r
+\r
+/* Language specific version strings */\r
+#define KH_VERSTR_COMPANY_1033 "$(NETIDMGR_SRC_COMPANY_1033)"\r
+#define KH_VERSTR_COPYRIGHT_1033 "$(NETIDMGR_SRC_COPYRIGHT_1033)"\r
+#define KH_VERSTR_PRODUCT_1033 "$(NETIDMGR_PRODUCT_1033)"\r
+#define KH_VERSTR_VERSION_1033 "$(NETIDMGR_VERSION_STR_1033)"\r
+\r
+!ifdef NETIDMGR_COMMENT_STR_1033\r
+#define KH_VERSTR_COMMENT_1033 "$(NETIDMGR_COMMENT_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_COMMENT_1033\r
+!endif\r
+!ifdef NETIDMGR_PRIVATE_STR_1033\r
+#define KH_VERSTR_PRIVATE_1033 "$(NETIDMGR_PRIVATE_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_PRIVATE_1033\r
+!endif\r
+!ifdef NETIDMGR_SPECIAL_STR_1033\r
+#define KH_VERSTR_SPECIAL_1033 "$(NETIDMGR_SPECIAL_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_SPECIAL_1033\r
+!endif\r
+#endif\r
+<<\r
+\r
diff --git a/src/windows/identity/config/netidmgr_version.h.in b/src/windows/identity/config/netidmgr_version.h.in
new file mode 100644 (file)
index 0000000..2be3943
--- /dev/null
@@ -0,0 +1,62 @@
+$(VERSIONEXT): Makefile\r
+       $(CP) << $(VERSIONEXT)\r
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+#ifndef __NETIDMGR_VERSION_H\r
+#define __NETIDMGR_VERSION_H\r
+\r
+#include<windows.h>\r
+\r
+/* Version number macros */\r
+#define KH_VERSION_MAJOR       $(NETIDMGR_VERSION_MAJOR)\r
+#define KH_VERSION_MINOR       $(NETIDMGR_VERSION_MINOR)\r
+#define KH_VERSION_PATCH       $(NETIDMGR_VERSION_PATCH)\r
+#define KH_VERSION_AUX                 $(NETIDMGR_VERSION_AUX)\r
+\r
+#define KH_VERSION_API          $(NETIDMGR_VERSION_API)\r
+\r
+#define KH_VERSION_LIST        $(NETIDMGR_VERSIONC)\r
+#define KH_VERSION_STRING      "$(NETIDMGR_VERSION)"\r
+#define KH_VERSION_STRINGW     L"$(NETIDMGR_VERSION)"\r
+#define KH_VERSION_STRINGC     "$(NETIDMGR_VERSIONC)"\r
+#define KH_VERSION_STRINGCW    L"$(NETIDMGR_VERSIONC)"\r
+#define KH_VERSION_STRINGAPI    "$(NETIDMGR_VERSION_API)"\r
+\r
+/* Version definition macros */\r
+#define KH_VER_FILEFLAGMASK     0x17L\r
+#define KH_VER_FILEFLAGS       $(kh_fileflags)\r
+#define KH_VER_FILEOS          $(kh_fileos)\r
+#define KH_VER_FILETYPEDLL     $(kh_filetype_dll)\r
+#define KH_VER_FILETYPEAPP     $(kh_filetype_app)\r
+\r
+/* Special macros for NetIDMgr special string resources */\r
+#define NIMV_MODULE             "NIDM_Module"\r
+#define NIMV_PLUGINS            "NIDM_Plugins"\r
+#define NIMV_APIVER             "NIDM_APIVers"\r
+#define NIMV_SUPPORT            "NIDM_Support"\r
+\r
+#endif\r
+<<\r
+\r
index 71e9f0f16f50ceadac27c03a543dd0ddca15e116..b9cc463b3b8ada719c9bfd40e9f8f0b808bb1763 100644 (file)
@@ -25,8 +25,6 @@
 MODULE=doc\r
 !include <../config/Makefile.w32>\r
 \r
-CONFFILE=$(OBJ)\DoxyConf.cfg\r
-\r
 all: mkdirs docs\r
 \r
 docs:\r
@@ -43,10 +41,9 @@ INTERNAL_DOCS = NO
 \r
 WARN_LOGFILE = "$(OBJ)\doxywarnings.txt"\r
 \r
-INPUT = "$(SRC)\include"\r
+INPUT =  "$(SRC)\include"\r
 INPUT += "$(SRC)\kconfig"\r
 INPUT += "$(SRC)\kcreddb"\r
-INPUT += "$(SRC)\khlog"\r
 INPUT += "$(SRC)\kmq"\r
 INPUT += "$(SRC)\ui"\r
 INPUT += "$(SRC)\uilib"\r
@@ -54,6 +51,9 @@ INPUT += "$(SRC)\util"
 INPUT += "$(SRC)\doc"\r
 INPUT += "$(SRC)\kmm"\r
 INPUT += "$(SRC)\kherr"\r
+!ifndef NO_AFS\r
+INPUT += "$(SRC)\plugins\afs"\r
+!endif\r
 \r
 IMAGE_PATH = "$(SRC)\doc\images"\r
 \r
index 1adb3b8f5826a70054ae840c8c1fe6386e4cc6a0..251b5b2c71c3933ff3d9a06197a5f86223ed7594 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
        khui_new_creds_by_type * t;\r
 \r
        c = (khui_new_creds *) vparam;\r
-       t = malloc(sizeof(*t));\r
+       t = PMALLOC(sizeof(*t));\r
        ZeroMemory(t, sizeof(*t));\r
 \r
        t->type = my_cred_type;\r
index 3257520e1f2823eac222cdf0538857015b9b6eed..8fa7b1f36187792c8925d9225275791ddba9de34 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index e8f7d2999368c1fbb6bc25a716a42d2f93cb0dd7..b5be8ad5a2ba9792cac5f7c66ed6d7264163b3c1 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index a1b2c2cc270ec9c36ea347cef83714aaa464d68b..49f644c91f980a4c525743c71aaa733609b4ce9a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 5e844833f4538df08afcb210b8429ce0dbf9533b..e4d41b1064e7948e3f5230ca725130ca11dceab7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
diff --git a/src/windows/identity/doc/images/Thumbs.db b/src/windows/identity/doc/images/Thumbs.db
deleted file mode 100644 (file)
index 371f5d6..0000000
Binary files a/src/windows/identity/doc/images/Thumbs.db and /dev/null differ
diff --git a/src/windows/identity/doc/images/khimaira_logo_old.jpg b/src/windows/identity/doc/images/khimaira_logo_old.jpg
deleted file mode 100644 (file)
index 10e8fde..0000000
Binary files a/src/windows/identity/doc/images/khimaira_logo_old.jpg and /dev/null differ
diff --git a/src/windows/identity/doc/images/khimaira_logo_small_old.jpg b/src/windows/identity/doc/images/khimaira_logo_small_old.jpg
deleted file mode 100644 (file)
index 94d8d19..0000000
Binary files a/src/windows/identity/doc/images/khimaira_logo_small_old.jpg and /dev/null differ
index 545e9ee174fa699ad618304226e5501fbf2d17c6..2a74e8f4a1d4682492c6ad929cdaddaf7f19de85 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -78,6 +78,9 @@
 \r
     (Contributor list goes here)\r
 \r
+    At the moment, no contributers have come forward to accept\r
+    responsibility.\r
+\r
     <a href="http://web.mit.edu/is">Information Services and\r
     Technology</a> at <a href="http://web.mit.edu">Massachusetts\r
     Institute of Technology</a>\r
@@ -86,7 +89,7 @@
 /*! \page bugs Reporting bugs\r
 \r
     NetIDMgr bugs can be reported to \r
-    <a href="mailto:khimaira@mit.edu">khimaira@mit.edu</a> for now.\r
+    <a href="mailto:kfw-bugs@mit.edu">kfw-bugs@mit.edu</a> for now.\r
 \r
     In the future, there will actually be a place to track NetIDMgr bugs.\r
 \r
 \r
 /*! \page releases Prior releases\r
 \r
-    - <b>0.1.1</b> (Charles Manson) <em>[soon]</em>\n\r
-      First alpha release.  As stable as Charles Manson, hence the\r
-      name.\r
+    - <b>0.1.1</b> First Alpha release <em>Nov 01, 2005</em>\n\r
+      Released along with Kerberos for Windows 3.0.0 beta.\r
 \r
     - <b>0.1.2</b> (tbd) <em>[tbd]</em>\n\r
-      First beta release.\r
 */\r
index dbf1600803552e18c0d8baee4ea29e24405a5c8e..c714284ece097e5bad62c580173d4b5a958096d6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 3cb65a422191825f2ee14d1704bd011fc2c114a6..6c3774fa54469b91e83d78a1572557473f1faaa2 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index ed8d038e20cbbe7c67f0d1e52ef0643d9e9cbec6..ed06c6d0860e0c51b22f5075463cf1f601b36d4b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 8c57b0300e85e582fac5bf0d9648a132b2d9a599..b41ff3a07c04483ee13237ed3bfa88bb727d0ca6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index ab3848ed3bfd1ac6540ab7949e1c554bac8768f6..de4e802e312975cccd8c942bf9ec4970f3fa0e7c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 8ef325049d286cfb877b5b3f66f8a93d7a7f6b7b..b9bfadd6bb7e119c41e945fea70e6fa95d249643 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 0f9ab661c4975553c1fec9628570af2dd38a0373..8cf735c044975350bffe974b542bfaa1ec66cfa4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index c7a95a36409776e6ae4ae5ad1c7ad78fa0a8f3f2..09cc16e6761aa35248bea97a84d64a214db8e8f5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 2b823d85a641cfba9a5faaba2134649eacf6bfd8..c45a83f80ada7dee25382db592127109c527a5d2 100644 (file)
@@ -25,7 +25,7 @@
 MODULE=help\r
 !include <..\config\Makefile.w32>\r
 \r
-CHMFILE=$(DOCDIR)\netidmgr.chm\r
+CHMFILE=$(BINDIR)\netidmgr.chm\r
 \r
 INCFILES=$(INCDIR)\khhelp.h\r
 \r
diff --git a/src/windows/identity/help/html/about_netidmgr.htm b/src/windows/identity/help/html/about_netidmgr.htm
new file mode 100644 (file)
index 0000000..76c5f9f
--- /dev/null
@@ -0,0 +1,67 @@
+<html>\r
+<head>\r
+  <title>About Network Identity Manager</title>\r
+  <meta name="description" content="About NetIDMgr">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>About Network Identity Manager</h1>\r
+\r
+<p>\r
+This is strictly an informative page about the origins of Network\r
+Identity Manager.\r
+</p>\r
+\r
+<h3>In the beginning</h3>\r
+\r
+<p>\r
+Network Identity Manager was conceived as an identity management\r
+solution to make up for the shortcomings of Leash32 (distributed with\r
+MIT Kerberos for Windows) and AFSCREDS (distributed with OpenAFS).\r
+</p>\r
+\r
+<p>\r
+The work started as Unified Credentials Manager, a final project for\r
+the MIT course 6.831 : User Interface Design and Implementation,\r
+taught by <a href="http://people.csail.mit.edu/rcm/">Professor Rob\r
+Miller</a>.  By the time actual code was written, it was named\r
+Khimaira (which was later changed to Network Identity Manager around\r
+October, 2005).  Traces of the name Khimaira might still exist in the\r
+source code.\r
+</p>\r
+\r
+<p>\r
+A presentation given about Khimaira at the <a\r
+href="http://www.pmw.org/afsbpw05/">AFS and Kerberos Best Practices\r
+Workshop 2005</a> can be found on the workshop website and <a\r
+href="http://web.mit.edu/asanka/www/misc.shtml">here</a>.\r
+</p>\r
+\r
+<p>\r
+The work on Khimaira was funded by <a\r
+href="http://web.mit.edu">MIT</a> <a\r
+href="http://web.mit.edu/ist/">Information Services and\r
+Technology</a>.\r
+</p>\r
+\r
+<h3>Design</h3>\r
+\r
+<p>\r
+A plugin based architecture was chosen so that support for additional\r
+credential types and features could be added without making changes to\r
+the mainline code.  In addition to making the application easily\r
+extensible, this also allows the AFS plugin to be maintained within\r
+the OpenAFS code base and separates the code supporting Kerberos 5 and\r
+Kerberos 4.  Furthermore, it is anticipated that this would encourage\r
+third party developers to develop plugins for NetIDMgr.\r
+</p>\r
+\r
+<p>\r
+More information about the concepts used in the design of Network\r
+Identity Manager can be found <a href="concepts.htm">here</a>.\r
+</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
similarity index 56%
rename from src/windows/identity/help/html/menu_exit.htm
rename to src/windows/identity/help/html/act_chpw.htm
index 2130df192f9ba5e81cac66be9104183d18a3238c..5e39963da075ddd8f9d3b853f4159e63c693c83d 100644 (file)
@@ -3,7 +3,9 @@
   <title>title</title>\r
   <meta name="description" content="">\r
   <meta name="keywords" content="">\r
-  <link rel="stylesheet" type="text/css" href="khm.css">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
 </head>\r
+<body>\r
 \r
+</body>\r
 </html>
\ No newline at end of file
similarity index 56%
rename from src/windows/identity/help/html/menu_properties.htm
rename to src/windows/identity/help/html/act_destroy_creds.htm
index 2130df192f9ba5e81cac66be9104183d18a3238c..5e39963da075ddd8f9d3b853f4159e63c693c83d 100644 (file)
@@ -3,7 +3,9 @@
   <title>title</title>\r
   <meta name="description" content="">\r
   <meta name="keywords" content="">\r
-  <link rel="stylesheet" type="text/css" href="khm.css">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
 </head>\r
+<body>\r
 \r
+</body>\r
 </html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/act_import_creds.htm b/src/windows/identity/help/html/act_import_creds.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/act_new_creds.htm b/src/windows/identity/help/html/act_new_creds.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/act_renew_creds.htm b/src/windows/identity/help/html/act_renew_creds.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/act_set_default.htm b/src/windows/identity/help/html/act_set_default.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/bugs.htm b/src/windows/identity/help/html/bugs.htm
new file mode 100644 (file)
index 0000000..a2e8d34
--- /dev/null
@@ -0,0 +1,33 @@
+<html>\r
+<head>\r
+  <title>Reporting Bugs</title>\r
+  <meta name="description" content="Reporting bugs and feature requests">\r
+  <meta name="keywords" content="bugs,features">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Reporting Bugs</h1>\r
+\r
+<p>If you encounter a bug in the software, please email \r
+<a href="mailto:kfw-bugs@MIT.EDU" class="mail">kfw-bugs@MIT.EDU</a>\r
+and report it.  Please include as much information as possible to\r
+enable us to reproduce the problem.\r
+</p>\r
+\r
+<p><a href="mailto:kerberos@MIT.EDU" class="mail">kerberos@MIT.EDU</a>\r
+is a mailing list set up for discussing Kerberos issues. It is\r
+gatewayed to the Usenet newsgroup 'comp.protocols.kerberos'. If you\r
+prefer to read it via mail, send a request to kerberos-request@MIT.EDU\r
+to get added or subscribe via the web page:</p>\r
+\r
+<p> <a href="http://mailman.mit.edu/mailman/listinfo/kerberos"\r
+class="external">\r
+http://mailman.mit.edu/mailman/listinfo/kerberos</a></p>\r
+\r
+<p>Information about Kerberos mailing lists can be found at <a\r
+href="http://web.mit.edu/kerberos/mail-lists.html"\r
+class="external">http://web.mit.edu/kerberos/mail-lists.html</a></p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/concept_cred_pro.htm b/src/windows/identity/help/html/concept_cred_pro.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/concept_ident_pro.htm b/src/windows/identity/help/html/concept_ident_pro.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/concept_identity.htm b/src/windows/identity/help/html/concept_identity.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/concepts.htm b/src/windows/identity/help/html/concepts.htm
new file mode 100644 (file)
index 0000000..5e39963
--- /dev/null
@@ -0,0 +1,11 @@
+<html>\r
+<head>\r
+  <title>title</title>\r
+  <meta name="description" content="">\r
+  <meta name="keywords" content="">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/copyright.htm b/src/windows/identity/help/html/copyright.htm
new file mode 100644 (file)
index 0000000..32453f7
--- /dev/null
@@ -0,0 +1,48 @@
+<html>\r
+<head>\r
+  <title>License</title>\r
+  <meta name="description" content="License agreement">\r
+  <meta name="keywords" content="license">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Network Identity Manager License</h1>\r
+\r
+<p>This software is being provided to you, the LICENSEE, by the\r
+Massachusetts Institute of Technology (M.I.T) under the following\r
+license. By obtaining, using and/or copying this software, you agree\r
+that you have read, understood, and will comply with these terms and\r
+conditions:</p>\r
+\r
+<p>Permission to use, copy, modify and distribute this software and its\r
+documentation for any purpose and without fee or royalty is hereby\r
+granted, provided that you agree to comply with the following\r
+copyright notice and statements, including the disclaimer, and that\r
+the same appear on ALL copies of the software and documentation,\r
+including modifications that you make for internal use or for\r
+distribution:</p>\r
+\r
+<p>Copyright 1992-2005 by the Massachusetts Institute of Technology. All\r
+rights reserved.</p>\r
+\r
+<p>THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS\r
+OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not\r
+limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF\r
+MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE\r
+OF THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD\r
+PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</p>\r
+\r
+<p>The name of the Massachusetts Institute of Technology or M.I.T. may\r
+NOT be used in advertising or publicity pertaining to distribution of\r
+the software. Title to copyright in this software and any associated\r
+documentation shall at all times remain with M.I.T., and USER agrees\r
+to preserve same.</p>\r
+\r
+<p>Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,\r
+OLC, X Window System, and Zephyr are trademarks of the Massachusetts\r
+Institute of Technology (MIT). No commercial use of these trademarks\r
+may be made without prior written permission of MIT.</p>\r
+\r
+</body>\r
+</html>\r
diff --git a/src/windows/identity/help/html/howdoi.htm b/src/windows/identity/help/html/howdoi.htm
new file mode 100644 (file)
index 0000000..3995335
--- /dev/null
@@ -0,0 +1,37 @@
+<html>\r
+<head>\r
+  <title>How do I ...</title>\r
+  <meta name="description" content="How do I ...">\r
+  <meta name="keywords" content="howto, how do I">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>How do I ...</h1>\r
+\r
+<h3>Startup</h3>\r
+<ul>\r
+\r
+  <li><a href="use_start.htm">Start NetIDMgr or open the NetIDMgr\r
+  window</a></li>\r
+\r
+</ul>\r
+\r
+<h3>Credentials related actions</h3>\r
+<ul>\r
+\r
+  <li><a href="act_new_creds.htm">Get new credentials</a></li>\r
+\r
+  <li><a href="act_destroy_creds.htm">Destroy credentials</a></li>\r
+\r
+  <li><a href="act_import_creds.htm">Import credentials from the MSLSA\r
+  cache</a></li>\r
+\r
+  <li><a href="act_renew_creds.htm">Renew credentials</a></li>\r
+\r
+  <li><a href="act_chpw.htm">Change password</a></li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/images/Thumbs.db b/src/windows/identity/help/html/images/Thumbs.db
deleted file mode 100644 (file)
index 01828e4..0000000
Binary files a/src/windows/identity/help/html/images/Thumbs.db and /dev/null differ
diff --git a/src/windows/identity/help/html/images/link.GIF b/src/windows/identity/help/html/images/link.GIF
deleted file mode 100644 (file)
index 1af792f..0000000
Binary files a/src/windows/identity/help/html/images/link.GIF and /dev/null differ
diff --git a/src/windows/identity/help/html/images/logo.jpg b/src/windows/identity/help/html/images/logo.jpg
new file mode 100644 (file)
index 0000000..1121f64
Binary files /dev/null and b/src/windows/identity/help/html/images/logo.jpg differ
diff --git a/src/windows/identity/help/html/images/logo_shade.jpg b/src/windows/identity/help/html/images/logo_shade.jpg
new file mode 100644 (file)
index 0000000..44f13a1
Binary files /dev/null and b/src/windows/identity/help/html/images/logo_shade.jpg differ
diff --git a/src/windows/identity/help/html/images/screen_app_icon.bmp b/src/windows/identity/help/html/images/screen_app_icon.bmp
new file mode 100644 (file)
index 0000000..78fd535
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_app_icon.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_main_wnd.bmp b/src/windows/identity/help/html/images/screen_main_wnd.bmp
new file mode 100644 (file)
index 0000000..77ab8be
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_main_wnd.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_bar.bmp b/src/windows/identity/help/html/images/screen_menu_bar.bmp
new file mode 100644 (file)
index 0000000..947cd10
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_bar.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_credential.bmp b/src/windows/identity/help/html/images/screen_menu_credential.bmp
new file mode 100644 (file)
index 0000000..eecddd2
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_credential.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_file.bmp b/src/windows/identity/help/html/images/screen_menu_file.bmp
new file mode 100644 (file)
index 0000000..a67e597
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_file.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_help.bmp b/src/windows/identity/help/html/images/screen_menu_help.bmp
new file mode 100644 (file)
index 0000000..2d5261f
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_help.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_options.bmp b/src/windows/identity/help/html/images/screen_menu_options.bmp
new file mode 100644 (file)
index 0000000..4fba5d6
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_options.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_menu_view.bmp b/src/windows/identity/help/html/images/screen_menu_view.bmp
new file mode 100644 (file)
index 0000000..9dfb871
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_menu_view.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_tb_standard.bmp b/src/windows/identity/help/html/images/screen_tb_standard.bmp
new file mode 100644 (file)
index 0000000..bd07cf2
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_tb_standard.bmp differ
diff --git a/src/windows/identity/help/html/images/screen_tray_icon.bmp b/src/windows/identity/help/html/images/screen_tray_icon.bmp
new file mode 100644 (file)
index 0000000..b2fb1ee
Binary files /dev/null and b/src/windows/identity/help/html/images/screen_tray_icon.bmp differ
diff --git a/src/windows/identity/help/html/khm.css b/src/windows/identity/help/html/khm.css
deleted file mode 100644 (file)
index 82c4d57..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-BODY {         font-family:helvetica,sans-serif;\r
-       font-size:8pt; \r
-       font-style:normal; \r
-       background-color:white; }\r
-\r
-H1 {   font-size: 10pt;\r
-       border:solid 1px black;\r
-       padding:5px;\r
-       background-color:lightgrey      \r
-       }\r
-\r
-H2 { }\r
-\r
diff --git a/src/windows/identity/help/html/menu_all.htm b/src/windows/identity/help/html/menu_all.htm
new file mode 100644 (file)
index 0000000..8118a81
--- /dev/null
@@ -0,0 +1,41 @@
+<html>\r
+<head>\r
+  <title>The Menu Bar</title>\r
+  <meta name="description" content="The Menu Bar">\r
+  <meta name="keywords" content="menu bar">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+<h1>The Menu Bar</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the submenu, or\r
+choose from the list below.  You can activate the menu bar using <span\r
+class="pre">F10</span>.  Alternatively, you can activate each\r
+individual submenu by pressing <span class="pre">Alt +\r
+&lt;key&gt;</span> where <span class="pre">key</span> is the\r
+highlighted character on the submenu.\r
+</p>\r
+\r
+<map id="menu_bar_map">\r
+<area shape = "rect" coords = "1,0,24,20" href = "menu_file.htm">\r
+<area shape = "rect" coords = "26,1,84,20" href = "menu_credential.htm">\r
+<area shape = "rect" coords = "85,1,118,20" href = "menu_view.htm">\r
+<area shape = "rect" coords = "122,1,165,20" href = "menu_options.htm">\r
+<area shape = "rect" coords = "166,2,199,20" href = "menu_help.htm">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_bar.bmp" usemap="#menu_bar_map"/>\r
+</p>\r
+\r
+<ul>\r
+  <li><a href="menu_file.htm">File menu</li>\r
+  <li><a href="menu_credential.htm">Credential menu</li>\r
+  <li><a href="menu_view.htm">View menu</li>\r
+  <li><a href="menu_options.htm">Options menu</li>\r
+  <li><a href="menu_help.htm">Help menu</li>\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/menu_credential.htm b/src/windows/identity/help/html/menu_credential.htm
new file mode 100644 (file)
index 0000000..b17533e
--- /dev/null
@@ -0,0 +1,86 @@
+<html>\r
+<head>\r
+  <title>Credential Menu</title>\r
+  <meta name="description" content="credential menu">\r
+  <meta name="keywords" content="credential menu">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Credential Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below.  You can activate the by pressing <span\r
+class="pre">Alt + C</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action.  You can use the hot key to trigger the action\r
+without invoking the <span class="pre">Credential</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "10,24,214,45" href = "#new">\r
+<area shape = "rect" coords = "8,49,212,70" href = "#renew">\r
+<area shape = "rect" coords = "11,72,199,89" href = "#destroy">\r
+<area shape = "rect" coords = "13,96,213,113" href = "#def">\r
+<area shape = "rect" coords = "14,114,210,133" href = "#search">\r
+<area shape = "rect" coords = "8,137,211,159" href = "#chpw">\r
+<area shape = "rect" coords = "10,165,213,185" href = "#import">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_credential.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+  <li><a name="new" /> <span class="title">New Credentials ...</span>:\r
+  Opens the new credentials acquisition dialog box.  If an identity\r
+  was selected, then that identity would be made the default for the\r
+  new credentials acquisition.  However, it can easily be changed in\r
+  the dialog.\r
+  <p>\r
+  See <span class="pre"><a href="act_new_creds.htm">New Credentials\r
+  Action</a></span> for more information.\r
+  </p></li>\r
+\r
+  <li><a name="renew"/> <span class="title">Renew credentials</span>:\r
+  Renews the selected credentials or identity.  This action requires\r
+  that the selected credentials be renewable.\r
+  <p>\r
+  See <span class="pre"><a href="act_renew_creds.htm">Renew\r
+  Credentials Action</a></span> for more information.</p></li>\r
+  \r
+  <li><a name="destroy"/> <span class="title">Destroy\r
+  credentials...</span>: Destroys the selected credentials.</li>\r
+\r
+  <li><a name="def"/> <span class="title">Set as default</span>: Sets\r
+  the selected identity as the default, if it is not already the\r
+  default.  The implications of this operation is dependent on the\r
+  current <a href="concept_ident_pro.htm">identity provider</a>.\r
+  <p>\r
+  See <span class="pre"><a href="act_set_default.htm">Set As Default\r
+  Action</a></span> for more information.</p></li>\r
+\r
+  <li><a name="search" /> <span class="title">Allow applications to\r
+  search</span>: This action is currently not implemented.</li>\r
+\r
+  <li><a name="chpw" /> <span class="title">Change password...</span>:\r
+  Changes the password for the selected identity.  However, once the\r
+  new password dialog opens, you can change the identity for which the\r
+  password is getting changed.</li>\r
+\r
+  <li><a name="import" /> <span class="title">Import\r
+  Credentials</span>: Import any existing credentials from external\r
+  sources.  With the Kerberos 5 <a\r
+  href="concept_cred_pro.htm">credentials provider</a>, the Kerberos\r
+  tickets from the Microsoft Windows LSA cache will be imported to MIT\r
+  Kerberos ticket caches.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
index 021f71f5a4fb8564c809a67a082bc7c673d9b2a6..91f73dfa89462bad65f365da57c44b7b9ae3579b 100644 (file)
@@ -1,18 +1,46 @@
 <html>\r
 <head>\r
-  <title>File menu</title>\r
-  <meta name="description" content="">\r
-  <meta name="keywords" content="">\r
-  <link rel="stylesheet" type="text/css" href="khm.css">\r
+  <title>File Menu</title>\r
+  <meta name="description" content="File menu">\r
+  <meta name="keywords" content="file menu">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
 </head>\r
+<body>\r
 \r
-<h1>File menu</h1>\r
+<h1>File Menu</h1>\r
 \r
-<p>Menu items</p>\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below.  You can activate the by pressing <span\r
+class="pre">Alt + F</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action.  You can use the hot key to trigger the action\r
+without invoking the <span class="pre">File</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "7,24,146,43" href = "#properties">\r
+<area shape = "rect" coords = "8,46,146,67" href = "#exit">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_file.bmp" usemap="#menumap"/>\r
+</p>\r
 \r
 <ul>\r
-<li><a href="menu_properties.htm">Properties...</a></li>\r
-<li><a href="menu_exit.htm">Exit...</a></li>\r
+\r
+  <li><a name="properties"/>\r
+  <span class="title">Properties...</span>: Displays a property\r
+  sheet for the selected credential, identity or credential type.</li>\r
+\r
+  <li><a name="exit" />\r
+  <span class="title">Exit</span>: Exits Network Identity Manager</li>\r
+\r
 </ul>\r
 \r
+</body>\r
 </html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/menu_help.htm b/src/windows/identity/help/html/menu_help.htm
new file mode 100644 (file)
index 0000000..d955454
--- /dev/null
@@ -0,0 +1,60 @@
+<html>\r
+<head>\r
+  <title>Help Menu</title>\r
+  <meta name="description" content="Help Menu">\r
+  <meta name="keywords" content="help menu">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Help Menu</h1>\r
+\r
+<p>\r
+You can activate the menu by pressing <span class="pre">Alt + H</span>\r
+and you can activate each action by pressing the highlighted character.\r
+</p>\r
+\r
+<p>\r
+You can invoke help anytime by pressing the <span\r
+class="pre">F1</span> key or if you are in a dialog box, by clicking\r
+the question mark icon in the title bar and then clicking on the\r
+dialog box control that you want help with.\r
+</p>\r
+\r
+<p>\r
+This is the help menu.  While it is ironic that the help menu itself\r
+needs to be explained, we have decided to include it here just for\r
+completeness.  It is bad enough that it is the last menu on the menu\r
+bar.  We didn't want to pile on any more disrespect by not documenting\r
+it.  We encourage you to not read this and just go ahead and click any\r
+item on this menu.  It is guaranteed that nothing bad will happen.\r
+This is not a generalization that would extend to, say, the <a\r
+href="menu_credential.htm">Credentials</a> menu.  If anything bad\r
+happens, please file a bug report at <a\r
+href="mailto:kfw-bugs@mit.edu">kfw-bugs@mit.edu</a>.\r
+</p>\r
+\r
+<p>\r
+<img src="images/screen_menu_help.bmp"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+  <li><a name="ctx" /><span class="title">Context</span>: Provides\r
+  context sensitive help.  You can invoke help at any time by pressing\r
+  <span class="pre">F1</span></li>\r
+\r
+  <li><a name="contents" /><span class="title">Contents</span>: Opens\r
+  the table of contents for the user documentation</li>\r
+\r
+  <li><a name="index" /><span class="title">Index</span>: Opens the\r
+  index for the user documentation</li>\r
+\r
+  <li><a name="about" /><span class="title">About</span>: Opens a\r
+  dialog box containing information about this version of NetIDMgr as\r
+  well as the modules that are currently loaded.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/menu_options.htm b/src/windows/identity/help/html/menu_options.htm
new file mode 100644 (file)
index 0000000..4d5bea9
--- /dev/null
@@ -0,0 +1,49 @@
+<html>\r
+<head>\r
+  <title>Options Menu</title>\r
+  <meta name="description" content="options menu">\r
+  <meta name="keywords" content="options menu">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Options Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below.  You can activate the by pressing <span\r
+class="pre">Alt + O</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action.  You can use the hot key to trigger the action\r
+without invoking the <span class="pre">Options</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "10,23,93,41" href = "#general">\r
+<area shape = "rect" coords = "12,41,94,60" href = "#idents">\r
+<area shape = "rect" coords = "10,59,104,74" href = "#notifs">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_options.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+<li><a name="general" /><span class="title">General ...</span>: Opens\r
+the NetIDMgr general configuration panel.</li>\r
+\r
+<li><a name="idents" /><span class="title">Identities ...</span>:\r
+Opens the identities configuration panel.</li>\r
+\r
+<li><a name="notifs" /><span class="title">Notifications ...</span>:\r
+Opens the Notifications control panel.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/menu_view.htm b/src/windows/identity/help/html/menu_view.htm
new file mode 100644 (file)
index 0000000..94920e1
--- /dev/null
@@ -0,0 +1,90 @@
+<html>\r
+<head>\r
+  <title>View Menu</title>\r
+  <meta name="description" content="View menu">\r
+  <meta name="keywords" content="view menu">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>View Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below.  You can activate the by pressing <span\r
+class="pre">Alt + V</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action.  You can use the hot key to trigger the action\r
+without invoking the <span class="pre">View</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "4,23,146,40" href = "#choosecol">\r
+<area shape = "rect" coords = "11,40,152,56" href = "#layout">\r
+<area shape = "rect" coords = "10,56,150,74" href = "#toolbars">\r
+<area shape = "rect" coords = "15,80,142,103" href = "#debugwnd">\r
+<area shape = "rect" coords = "8,104,151,128" href = "#refresh">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_view.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+<li><a name="choosecol" /> <span class="title">Choolse Columns\r
+...</span>: Invokes a dialog where you can choose which columns are\r
+displayed in the view window.  If you change the columns, or their\r
+order, a new custom layout will be created for you which you can later\r
+use using the <span class="pre">Layout</span> submenu later.</li>\r
+\r
+<li><a name="layout" /> <span class="title">Layout</span>: Opens a\r
+submenu where you can select the layout for the credentials\r
+display.\r
+   <ul>\r
+\r
+      <li><span class="title">By Identity</span>: A predefined layout\r
+      where the credentials will be grouped by identity and by\r
+      credentials type, in that order.</li>\r
+\r
+      <li><span class="title">By Type</span>: A predefined layout\r
+      where the credentials are grouped by credentials type</li>\r
+\r
+      <li><span class="title">By Location</span>: A predefined layout\r
+      where the credentials are grouped by the location where they are\r
+      stored in.  For Kerberos 5, the location is the name of the\r
+      credentials cache in which the tickets are stored, and for AFS,\r
+      the locatino is always the cache manager.  Individual <a\r
+      href="concept_cred_pro.htm">credential providers</a> choose the\r
+      interpretation of the <span class="pre">location</span> property\r
+      as the concept of location changes from type to type.</li>\r
+\r
+      <li><span class="title">Custom</span>: The custom layout.  If\r
+      you customize the layout by adding, removing or reordering the\r
+      columns, then NetIDMgr will create a new custom layout using the\r
+      customizations.  You can choose this option to revisit that layout</li>\r
+\r
+   </ul>\r
+</li>\r
+\r
+<li><a name="toolbars" />\r
+<span class="title">Toolbars</span>: Enable or disable toolbars.</li>\r
+\r
+<li><a name="debugwnd" /> <span class="title">Debug window...</span>:\r
+Displays a debug window which contains a history of actions and any\r
+debug information for each action that was supplied by each <a\r
+href="concept_cred_pro.htm">credentials provider</a><li>\r
+\r
+<li><a name="refresh" /> <span class="title">Refresh</span>: Refresh\r
+the credentials view.  This queries each <a\r
+href="concept_cred_pro.htm">credential provider</a> for any\r
+credentials and redraws the credentials view.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/nidmgr.css b/src/windows/identity/help/html/nidmgr.css
new file mode 100644 (file)
index 0000000..16c4510
--- /dev/null
@@ -0,0 +1,71 @@
+BODY {\r
+   font-family:helvetica,sans-serif;\r
+   font-size:8pt; \r
+   font-style:normal; \r
+   background-color:white;\r
+   margin-top: 0;\r
+   margin-left: 0;\r
+   margin-right: 0;\r
+   }\r
+\r
+H1 {\r
+   font-size: 10pt;\r
+   border-bottom:1px solid black;\r
+   padding:5px;\r
+   background-color:#eeeeee;\r
+   }\r
+\r
+H2 {\r
+   }\r
+\r
+H3 {\r
+   font-size: 9pt;\r
+   border-bottom: 1px solid lightgrey;\r
+   padding: 5px;\r
+   }\r
+\r
+H4 {\r
+   font-size: 9pt;\r
+   font-style: italic;\r
+   border-bottom: 1px dashed lightgrey;\r
+   margin-left: 10px;\r
+   }\r
+\r
+P  {\r
+   margin-left: 5px;\r
+   margin-right: 5px;\r
+   }\r
+\r
+P.caption {\r
+   margin-left: 5px;\r
+   margin-right: 5px;\r
+   font-style: italic;\r
+}\r
+\r
+DIV.inline {\r
+   float: left;\r
+}\r
+\r
+DIV.sidebar {\r
+   float: right;\r
+   background-color:#ffffb9;\r
+   border: 1px solid #ffff00;\r
+}\r
+\r
+A.external {\r
+}\r
+\r
+A.mail {\r
+}\r
+\r
+IMG {\r
+   border: 0;\r
+}\r
+\r
+SPAN.pre {\r
+   font-family: courier;\r
+}\r
+\r
+SPAN.title {\r
+   font-weight: bold;\r
+}
\ No newline at end of file
diff --git a/src/windows/identity/help/html/tb_standard.htm b/src/windows/identity/help/html/tb_standard.htm
new file mode 100644 (file)
index 0000000..945063f
--- /dev/null
@@ -0,0 +1,68 @@
+<html>\r
+<head>\r
+  <title>Standard Toolbar</title>\r
+  <meta name="description" content="Standard Toolbar">\r
+  <meta name="keywords" content="standard toolbar">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Standard Toolbar</h1>\r
+\r
+<p>The standard toolbar appears below along with descriptions of what\r
+each button does.\r
+</p>\r
+\r
+<p>\r
+<img src="images/screen_tb_standard.bmp" />\r
+</p>\r
+\r
+<ol>\r
+\r
+  <li><span class="title">New credentials</span>: Equivalent to\r
+  selecting <span class="pre"><a href="menu_credential.htm#new">New\r
+  credentials...</a></span> from the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.\r
+  <p>\r
+  See <a href="act_new_creds.htm">New Credentials Action</a> for more\r
+  information.</p></li>\r
+\r
+  <li><span class="title">Renew credentials</span>: Equivalent to\r
+  selecting <span class="pre"><a\r
+  href="menu_credential.htm#renew">Renew Credentials</a></span> from\r
+  the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.\r
+  <p>\r
+  See <a href="act_renew_creds.htm">Renew Credentials Action</a> for\r
+  more information.</li>\r
+\r
+  <li><span class="title">Import credentials</span>: Equivalent to\r
+  selecting <span class="pre"><a\r
+  href="menu_credential.htm#import">Import Credentials</a></span> from\r
+  the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.\r
+  </li>\r
+\r
+  <li><span class="title">Destroy credentials</span>: Equivalent to\r
+  selecting <span class="pre"><a\r
+  href="menu_credential.htm#destroy">Destroy Credentials</a></span>\r
+  from the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+  <li><span class="title">Change password</span>: Equivalent to\r
+  selecting <span class="pre"><a\r
+  href="menu_credential.htm#chpw">Change Password ...</a></span> from\r
+  the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+  <li><span class="title">Refresh view</span>: Equivalent to selecting\r
+  <span class="pre"><a href="menu_credential.htm#refresh">Refresh\r
+  View</a></span> from the <span class="pre"><a\r
+  href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+  <li><span class="title">Help</span>: Displays documentation</li>\r
+\r
+</ol>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
index 2130df192f9ba5e81cac66be9104183d18a3238c..5e39963da075ddd8f9d3b853f4159e63c693c83d 100644 (file)
@@ -3,7 +3,9 @@
   <title>title</title>\r
   <meta name="description" content="">\r
   <meta name="keywords" content="">\r
-  <link rel="stylesheet" type="text/css" href="khm.css">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
 </head>\r
+<body>\r
 \r
+</body>\r
 </html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/use_start.htm b/src/windows/identity/help/html/use_start.htm
new file mode 100644 (file)
index 0000000..9791979
--- /dev/null
@@ -0,0 +1,65 @@
+<html>\r
+<head>\r
+  <title>Starting NetIDMgr</title>\r
+  <meta name="description" content="starting NetIDMgr">\r
+  <meta name="keywords" content="starting">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Starting NetIDMgr</h1>\r
+\r
+<h3>Opening the NetIDMgr window from the notification icon</h3>\r
+\r
+<p>Depending on how you have installed NetIDMgr, it may start as soon\r
+as you login, or it may need to be started manually.  NetIDMgr is a\r
+tray application.  Hence it doesn't appear on your task bar.  This is\r
+based on the assumption that you don't need to run NetIDMgr very\r
+often, and helps reduce clutter on the desktop.</p>\r
+\r
+<div class="sidebar">\r
+<img src="images/screen_tray_icon.bmp"/>\r
+<p class="caption">Figure 1: NetIDMgr notification icon</p>\r
+</div>\r
+\r
+<p>When NetIDMgr is running, it places an icon in the system\r
+notification area (sometimes referred to as the "system tray") as\r
+shown in figure 1.</p>\r
+\r
+<p>Clicking on this icon brings up the NetIDMgr window.  Right\r
+clicking on the icon, on the other hand, brings up a menu.</p>\r
+\r
+<h3>Starting NetIDMgr from the Start Menu or command line</h3>\r
+\r
+<div class="sidebar">\r
+<img src="images/screen_app_icon.bmp" />\r
+<p class="caption">Figure 2: NetIDMgr application icon</p>\r
+</div>\r
+\r
+<p>If NetIDMgr was not configured to start automatically when you\r
+login to Windows, then you need to start it either from the\r
+commandline or the start menu.  The start menu application icon is\r
+under "Kerberos for Windows" as shown in figure 2.</p>\r
+\r
+<p>Alternatively, you can type 'netidmgr' at a command shell to start\r
+NetIDMgr as well.  When starting this way, you may specify additional\r
+<a href="html/cmdline_netidmgr.htm">command line options</a>.</p>\r
+\r
+<h3>Configuring startup options</h3>\r
+\r
+<p>\r
+Note that you can configure options related to the startup of NetIDMgr\r
+by using the NetIDMgr configuration dialog box.  You can use the menu\r
+items under the <span class="pre">Options</span> menu to invoke the\r
+configuration dialog.\r
+</p>\r
+\r
+<p>\r
+Only one instance of NetIDMgr can be running at any one time.\r
+Attempting to start NetIDMgr while it is still running will not do\r
+anything, unless you provide any command line options that trigger\r
+some action in the running application instance.\r
+</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/using.htm b/src/windows/identity/help/html/using.htm
new file mode 100644 (file)
index 0000000..2d84df2
--- /dev/null
@@ -0,0 +1,47 @@
+<html>\r
+<head>\r
+  <title>Using NetIDMgr</title>\r
+  <meta name="description" content="Using NetIDMgr">\r
+  <meta name="keywords" content="using">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Using NetIDMgr</h1>\r
+\r
+<p>\r
+Depending on how NetIDMgr was installed, it might already be running\r
+in the system notification area or it might need to be started\r
+manually. See the topic <a href="html/use_start.htm">starting\r
+NetIDMgr</a> for details.  Essentially, to open the NetIDMgr window,\r
+you either have to click the application icon in the system\r
+notification area, select the icon from the start menu, or type\r
+'netidmgr' at a command prompt.\r
+</p>\r
+\r
+<p>\r
+Once you open the NetIDMgr window, you will be presented with a view\r
+of your existing credentials, or a message notifying you that you\r
+don't have any.  The credentials view should be fairly self\r
+explanatory, but if there's any doubt, more information <a\r
+href="wnd_main.htm">can be found here.</a>\r
+</p>\r
+\r
+<p>\r
+Brief overviews of how to perform common tasks are linked below:\r
+</p>\r
+\r
+<ul>\r
+  <li><a href="act_new_creds.htm">Getting new credentials</a></li>\r
+  <li><a href="act_destroy_creds.htm">Destroying credentials</a></li>\r
+  <li><a href="act_import_creds.htm">Import credentials from the MSLSA cache</a></li>\r
+  <li><a href="act_renew_creds.htm">Renew credentials</a></li>\r
+  <li><a href="act_chpw.htm">Change password</a></li>\r
+</ul>\r
+\r
+<p>\r
+A more comprehensive list of how-to topics can be found in the <span\r
+class="pre"><a href="howdoi.htm">How do I...</a></span> section.</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
index 32d7d05b26ffa0c56582ee8fe210aa2c8b581f47..9cd7bc43ef77fbace28e6150f14af7dd1d19b46c 100644 (file)
@@ -1,24 +1,70 @@
 <html>\r
 <head>\r
-  <title>Welcome to Khimaira</title>\r
+  <title>Welcome to the Network Identity Manager</title>\r
   <meta name="description" content="Welcome">\r
   <meta name="keywords" content="welcome">\r
-  <link rel="stylesheet" type="text/css" href="khm.css">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
 </head>\r
 \r
-<h1>Welcome to Khimaira</h1>\r
+<h1>Welcome to the Network Identity Manager</h1>\r
 \r
-<p>Khimaira is a credentials manager that lets you manage Kerberos,\r
-AFS and other types of credentials.\r
+<div class="inline">\r
+<img src="images/logo.jpg"/>\r
+</div>\r
+\r
+<p>\r
+The Network Identity Manager (or NetIDMgr for short) allows you to\r
+manage your credentials (Kerberos tickets, AFS tokens, etc.) on a per\r
+identity basis.\r
+</p>\r
+\r
+<p>\r
+NetIDMgr is extensible using plugins.  In fact, most of the features\r
+are implemented in plugins, some of which are themselves extensible.\r
+Support for additional protocols and credential types can be added by\r
+installing the appropriate plugins.\r
+</p>\r
+\r
+<p>\r
+This version is distributed as a part of the MIT Kerberos for Windows\r
+product along with the Kerberos 5 and Kerberos 4 plugins.  The OpenAFS\r
+plugin, which is required for supporting OpenAFS tokens, is\r
+distributed separately.\r
 </p>\r
 \r
-<p>The following web sites provide more information about Kerberos and\r
-AFS:</p>\r
+<ul>\r
+<li><a href="copyright.htm">Legal information</a></li>\r
+<li><a href="bugs.htm">Reporting problems</a></li>\r
+</ul>\r
+\r
+<h3>Getting started</h3>\r
 \r
 <ul>\r
-<li><a class="external" href="http://web.mit.edu/kerberos">http://web.mit.edu/kerbeors</a></li>\r
-<li><a class="external" href="http://openafs.org">http://openafs.org</a></li>\r
+<li><a href="concepts.htm">NetIDMgr concepts</a></li>\r
+<li><a href="using.htm">Using NetIDMgr</a></li>\r
+<li><a href="howdoi.htm">How do I ...</a></li>\r
 </ul>\r
 \r
+<h3>Information for developers</h3>\r
+\r
+<p>\r
+If you are interested in developing plugins or extending the features\r
+of NetIDMgr, your first stop should be the NetIDMgr SDK.  This is\r
+included in the Kerberos for Windows SDK, which itself is a part of\r
+the Kerberos for Windows distribution.\r
+</p>\r
+\r
+<h3>External links</h3>\r
+\r
+<ul>\r
+<li><a class="external" href="http://web.mit.edu/kerberos">http://web.mit.edu/kerbeors</a>:\r
+\r
+MIT Kerberos distribution\r
+</li>\r
+<li><a class="external" href="http://openafs.org">http://openafs.org</a>:\r
+\r
+OpenAFS\r
+</li>\r
+</ul>\r
 \r
 </html>
\ No newline at end of file
diff --git a/src/windows/identity/help/html/wnd_main.htm b/src/windows/identity/help/html/wnd_main.htm
new file mode 100644 (file)
index 0000000..575e7ba
--- /dev/null
@@ -0,0 +1,89 @@
+<html>\r
+<head>\r
+  <title>Main Window</title>\r
+  <meta name="description" content="Main Window">\r
+  <meta name="keywords" content="main window">\r
+  <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Main Window</h1>\r
+\r
+<p>The main window of Network Identity Manager is structured as follows</p>\r
+\r
+<map id="main_wnd_map">\r
+  <area shape = "rect" coords = "7,34,243,56" href = "menu_all.htm" />\r
+  <area shape = "rect" coords = "6,56,364,90" href = "tb_standard.htm" />\r
+  <area shape = "rect" coords = "6,112,613,164" href = "#cred1" />\r
+  <area shape = "rect" coords = "246,162,288,197" href = "#cred2" />\r
+  <area shape = "rect" coords = "72,196,107,245" href = "#credtype1" />\r
+  <area shape = "rect" coords = "69,278,107,315" href = "#credtype2" />\r
+  <area shape = "rect" coords = "236,332,294,367" href = "#cred3" />\r
+</map>\r
+\r
+<img src="images/screen_main_wnd.bmp" usemap="#main_wnd_map"/>\r
+\r
+<ol>\r
+  <li>Menu bar</li>\r
+  <li>Tool bar</li>\r
+\r
+  <li><a name="cred1" /> An identity with a valid Kerberos 5 initial\r
+  ticket</li>\r
+\r
+  <li><a name="cred2" /> An identity with valid Kerberos 5 tickets and\r
+  AFS tokens</li> \r
+\r
+  <li><a name="credtype1" /> A set of Kerberos 5 tickets</li>\r
+\r
+  <li><a name="credtype2" /> A set of AFS tokens</li>\r
+\r
+  <li>An identity with expired Kerberos 5 tickets</li>\r
+\r
+</ol>\r
+\r
+<h3>Identity views</h3>\r
+\r
+<p>\r
+The default credentials view organizes them grouped by identity name\r
+and then by credential type.  Each credential is then shown under each\r
+group heading sorted by the credential name.  The default headings for\r
+the credential view provides you with a minimal amount of information\r
+to reduce clutter.  If you wish you can add columns to the display\r
+using the <span class="pre">Choose columns...</span> action on the\r
+<span class="pre"><a href="html/menu_view.htm">View</a></span> menu.\r
+</p>\r
+\r
+<p>\r
+The header backgrounds and the credential rows change color if the\r
+credentials are about to expire or are expired.  \r
+\r
+<ul> \r
+\r
+<li> <span style="background-color:#fbc74d">Headers</span> mean that\r
+credentials at that level will expire unless renewed.  Credentials\r
+will have a warning icon next to them.<br/>\r
+\r
+The threshold for this can be set as the <span class="pre">Warn</span>\r
+parameter in the <span class="pre">Notifications</span> configuration\r
+panel.</li>\r
+\r
+<li> <span style="background-color:#f08575">Headers</span> mean that\r
+credentials at that level will expire in a few minutes.  Credentials\r
+will have a critical icon next to them.<br/>\r
+\r
+The threshold for this can be set as the <span class="pre">Warn\r
+again</span> parameter in the <span class="pre">Notifications</span>\r
+configuration panel.  </li>\r
+\r
+<li> <span style="background-color:#ff9090">Headers</span> mean that\r
+the credentials at that level have expired.  Credentials will have an\r
+expired icon next to them.<br/>\r
+\r
+The threshold for this is always zero.\r
+</li>\r
+\r
+</ul> \r
+</p> \r
+\r
+</body>\r
+</html>\r
index 4ffa6d8f597174a5c70dc69c097870d9ca9f3c71..1324c3dc45ee93808d2f2523053fccdab4862943 100644 (file)
@@ -1,10 +1,13 @@
+#define NIDM_HELPFILE              L"netidmgr.chm"\r
 \r
 #define IDH_WELCOME                1000\r
-#define IDH_MENU_FILE              1001\r
-#define IDH_MENU_CRED              1002\r
-#define IDH_MENU_VIEW              1003\r
-#define IDH_MENU_OPTIONS           1004\r
-#define IDH_MENU_HELP              1005\r
+#define IDH_WIN_MAIN               1001\r
+\r
+#define IDH_MENU_FILE              1501\r
+#define IDH_MENU_CRED              1502\r
+#define IDH_MENU_VIEW              1503\r
+#define IDH_MENU_OPTIONS           1504\r
+#define IDH_MENU_HELP              1505\r
 \r
 #define IDH_ACTION_PROPERTIES      2000\r
 #define IDH_ACTION_EXIT            2001\r
index 8e0d5a5979e54ccc473ac8adb0e501f603593d54..9930dc5bced3672a6b4dcf7a70dfc091b14cadbc 100644 (file)
@@ -3,16 +3,27 @@ Auto Index=Yes
 Compatibility=1.1 or later\r
 Compiled file=netidmgr.chm\r
 Contents file=toc.hhc\r
+Default Window=MainHelpWnd\r
 Default topic=html/welcome.htm\r
 Display compile progress=No\r
 Index file=Index.hhk\r
 Language=0x409 English (United States)\r
 Title=NetIDMgr\r
 \r
+[WINDOWS]\r
+MainHelpWnd="NetIDMgr Help","toc.hhc","Index.hhk","html/welcome.htm","html/welcome.htm",,,,,0x42120,,0x384e,[271,372,593,566],0x830000,,,,,,0\r
+\r
+\r
+[ALIAS]\r
+IDH_WELCOME=html\welcome.htm\r
 \r
 [MAP]\r
 #include khhelp.h\r
 \r
+[TEXT POPUPS]\r
+khhelp.h\r
+popups_newcreds.txt\r
+\r
 [INFOTYPES]\r
 Category:Concepts\r
 CategoryDesc:Authentication, authorization and related concepts.\r
diff --git a/src/windows/identity/help/popups.txt b/src/windows/identity/help/popups.txt
new file mode 100644 (file)
index 0000000..7d58703
--- /dev/null
@@ -0,0 +1 @@
+foo \r
diff --git a/src/windows/identity/help/popups_newcreds.txt b/src/windows/identity/help/popups_newcreds.txt
new file mode 100644 (file)
index 0000000..7d58703
--- /dev/null
@@ -0,0 +1 @@
+foo \r
index cde5119a3f62410223c267ee2802f1ad8659dbe1..106c22054ab31f490049b8976e29ed65ee4a63cf 100644 (file)
        <param name="Category" value="Concepts">\r
        <param name="CategoryDesc" value="Authentication, authorization and related concepts.">\r
        <param name="Category" value="Usage">\r
-       <param name="CategoryDesc" value="Usage instructions for Khimaira">\r
+       <param name="CategoryDesc" value="Usage instructions for Network Identity Manager">\r
        <param name="Window Styles" value="0x800025">\r
 </OBJECT>\r
 <UL>\r
        <LI> <OBJECT type="text/sitemap">\r
-               <param name="Name" value="Welcome to Khimaira">\r
+               <param name="Name" value="Welcome to Network Identity Manager">\r
                <param name="Local" value="html\welcome.htm">\r
                </OBJECT>\r
        <LI> <OBJECT type="text/sitemap">\r
-               <param name="Name" value="Using Khimaira">\r
+               <param name="Name" value="How do I ...">\r
+               <param name="Local" value="html\howdoi.htm">\r
+               </OBJECT>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="About NetIDMgr">\r
+               <param name="Local" value="html\about_netidmgr.htm">\r
                </OBJECT>\r
        <UL>\r
                <LI> <OBJECT type="text/sitemap">\r
-                       <param name="Name" value="Menus">\r
-                       </OBJECT>\r
-               <UL>\r
-                       <LI> <OBJECT type="text/sitemap">\r
-                               <param name="Name" value="File...">\r
-                               <param name="Local" value="html\menu_file.htm">\r
-                               </OBJECT>\r
-               </UL>\r
-               <LI> <OBJECT type="text/sitemap">\r
-                       <param name="Name" value="Actions">\r
-                       </OBJECT>\r
-               <UL>\r
-                       <LI> <OBJECT type="text/sitemap">\r
-                               <param name="Name" value="Properties">\r
-                               <param name="Local" value="html\menu_properties.htm">\r
-                               </OBJECT>\r
-                       <LI> <OBJECT type="text/sitemap">\r
-                               <param name="Name" value="Exit">\r
-                               <param name="Local" value="html\menu_exit.htm">\r
-                               </OBJECT>\r
-               </UL>\r
+                       <param name="Name" value="Reporting bugs">\r
+                       <param name="Local" value="html\bugs.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="License agreement">\r
+                       <param name="Local" value="html\copyright.htm">\r
+                       </OBJECT>\r
+       </UL>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="Concepts">\r
+               <param name="Local" value="html\concepts.htm">\r
+               </OBJECT>\r
+       <UL>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Identities">\r
+                       <param name="Local" value="html\concept_identity.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Identity Provider">\r
+                       <param name="Local" value="html\concept_ident_pro.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Credentials Provider">\r
+                       <param name="Local" value="html\concept_cred_pro.htm">\r
+                       </OBJECT>\r
+       </UL>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="Using NetIDMgr">\r
+               <param name="Local" value="html\using.htm">\r
+               </OBJECT>\r
+       <UL>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Starting">\r
+                       <param name="Local" value="html\use_start.htm">\r
+                       </OBJECT>\r
+       </UL>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="Menus">\r
+               <param name="Local" value="html\menu_all.htm">\r
+               </OBJECT>\r
+       <UL>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="File Menu">\r
+                       <param name="Local" value="html\menu_file.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Credential menu">\r
+                       <param name="Local" value="html\menu_credential.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="View Menu">\r
+                       <param name="Local" value="html\menu_view.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Options Menu">\r
+                       <param name="Local" value="html\menu_options.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Help Menu">\r
+                       <param name="Local" value="html\menu_help.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Standard Toolbar">\r
+                       <param name="Local" value="html\tb_standard.htm">\r
+                       </OBJECT>\r
+       </UL>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="Actions">\r
+               </OBJECT>\r
+       <UL>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="New Credentials">\r
+                       <param name="Local" value="html\act_new_creds.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Renew Credentials">\r
+                       <param name="Local" value="html\act_renew_creds.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Destroy Credentials">\r
+                       <param name="Local" value="html\act_destroy_creds.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Set As Default">\r
+                       <param name="Local" value="html\act_set_default.htm">\r
+                       </OBJECT>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Change Password">\r
+                       <param name="Local" value="html\act_chpw.htm">\r
+                       </OBJECT>\r
+       </UL>\r
+       <LI> <OBJECT type="text/sitemap">\r
+               <param name="Name" value="Windows and dialogs">\r
+               </OBJECT>\r
+       <UL>\r
+               <LI> <OBJECT type="text/sitemap">\r
+                       <param name="Name" value="Main Window">\r
+                       <param name="Local" value="html\wnd_main.htm">\r
+                       </OBJECT>\r
        </UL>\r
 </UL>\r
 </BODY></HTML>\r
index 17182d57a1dad80348221a9b95379b00004740a1..be4ddf9a28fab8f9fef0e543f53b7372a8aa46bf 100644 (file)
@@ -29,7 +29,8 @@ INCFILES= \
        $(INCDIR)\khdefs.h      \\r
        $(INCDIR)\kherror.h     \\r
        $(INCDIR)\khlist.h      \\r
-       $(INCDIR)\khmsgtypes.h\r
+       $(INCDIR)\khmsgtypes.h  \\r
+       $(INCDIR)\netidmgr.h\r
 \r
 all: $(INCFILES)\r
 \r
index 427926306b90eb8b0f31bbc1e4b093177add0f8e..4a0251107bcff5c361dae8d0d0122af786e69fee 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index d56fa7dc7356b68533a02c3fa09e88b17f54233c..f11e285109b68004e6904569a092ce17f606f889 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -66,7 +66,7 @@
 #define KHM_ERROR_TOO_LONG          (KHM_ERROR_BASE + 2)\r
 \r
 /*! \brief One or more parameters supplied to a function were invalid */\r
-#define KHM_ERROR_INVALID_PARM      (KHM_ERROR_BASE + 3)\r
+#define KHM_ERROR_INVALID_PARAM      (KHM_ERROR_BASE + 3)\r
 \r
 /*! \brief A duplicate.\r
 \r
 */\r
 #define KHM_ERROR_PARTIAL           (KHM_ERROR_BASE + 20)\r
 \r
+/*! \brief An incompatibility was found */\r
+#define KHM_ERROR_INCOMPATIBLE      (KHM_ERROR_BASE + 21)\r
+\r
 /*@}*/ /*kherror_codes*/\r
 \r
 /*! \brief Tests whether a return value indicates success */\r
index 330cfc498d4cd32a43c8886385dda33839b60a92..2eb85864a68696c5dd1b087c21d40c89f5f880b5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 8348bbf95ea5b855f7273db1f77e9b296f51494b..dfc39e2f0bbadfc39e9d4745d86d803ece4335bd 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
  */\r
 #define KMSG_CRED_PP_DESTROY        131\r
 \r
+/*! \brief An IP address change occurred\r
+\r
+    There are no parameters for this message.  The NetIDMgr\r
+    application handles this message and depending on configuration,\r
+    posts message for the individual credentials providers to either\r
+    obtain new credentials or renew old ones.\r
+ */\r
+#define KMSG_CRED_ADDR_CHANGE        140\r
+\r
 /*! \brief Check if a KMSG_CRED subtype is a credentials acquisition message\r
 \r
     Dialog messages are those that deal with the new or initial\r
  */\r
 #define KMSG_ALERT_SHOW 1\r
 \r
+/*! \brief Add an alert to the alert queue\r
+\r
+    Message parameters:\r
+    - \b vparam : held pointer to a ::khui_alert object\r
+\r
+    \note the ::khui_alert object will be released when the queued\r
+        messages are displayed.\r
+ */\r
+#define KMSG_ALERT_QUEUE 2\r
+\r
+/*! \brief Show the next queued alert\r
+\r
+    There are no message parameters\r
+ */\r
+#define KMSG_ALERT_SHOW_QUEUED 3\r
+\r
+/*! \brief Check if there are any queued messages and, if so, update the statusbar\r
+\r
+    There are no message parameters\r
+ */\r
+#define KMSG_ALERT_CHECK_QUEUE 4\r
+\r
 /*@}*/\r
 \r
 /*! \defgroup kmq_msg_ident KMSG_IDENT Subtypes\r
similarity index 67%
rename from src/windows/identity/include/khthread.h
rename to src/windows/identity/include/netidmgr.h
index b7354c468889f291e5c859f8ad252c367435af00..94e188ff1c3e8d581f07ad32dfc0be812899e9d5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 /* $Id$ */\r
 \r
-/* Not exported */\r
-#ifndef __KHIMAIRA_KTHREAD_H\r
-#define __KHIMAIRA_KTHREAD_H\r
+#ifndef __NETIDMGR_H\r
+#define __NETIDMGR_H\r
 \r
-#ifdef _WIN32\r
-#define khm_mutex CRITICAL_SECTION\r
+#include "khdefs.h"\r
 \r
-#define khp_mutex_init(pcs) InitializeCriticalSection(pcs)\r
-#define khp_mutex_destroy(pcs) DeleteCriticalSection(pcs)\r
-#define khp_mutex_lock(pcs) EnterCriticalSection(pcs)\r
-#define khp_mutex_unlock(pcs) LeaveCriticalSection(pcs)\r
-#define khp_mutex_trylock(pcs) (!TryEnterCriticalSection(pcs))\r
+#include "utils.h"\r
+#include "khuidefs.h"\r
+#include "kmq.h"\r
+#include "khmsgtypes.h"\r
+#include "kcreddb.h"\r
+#include "kherr.h"\r
+#include "kherror.h"\r
+#include "kconfig.h"\r
+#include "kmm.h"\r
+#include "kplugin.h"\r
 \r
 #endif\r
-\r
-#endif
\ No newline at end of file
index 3d69c998e5225664c7158b3ca46932ab26d39c25..39e72ecf5c88a27304d55ab872d7f3ff6b59550d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -41,9 +41,9 @@ void init_kconf(void) {
         /* we are the first */\r
         InitializeCriticalSection(&cs_conf_global);\r
         EnterCriticalSection(&cs_conf_global);\r
-        conf_root = khc_create_empty_space();\r
-        conf_root->name = wcsdup(L"Root");\r
-        conf_root->regpath = wcsdup(CONFIG_REGPATHW);\r
+        conf_root = khcint_create_empty_space();\r
+        conf_root->name = PWCSDUP(L"Root");\r
+        conf_root->regpath = PWCSDUP(CONFIG_REGPATHW);\r
         conf_root->refcount++;\r
         conf_status = 1;\r
         InitializeCriticalSection(&cs_conf_handle);\r
@@ -61,20 +61,20 @@ void exit_kconf(void) {
         conf_init = 0;\r
         conf_status = 0;\r
 \r
-        khc_free_space(conf_root);\r
+        khcint_free_space(conf_root);\r
 \r
         EnterCriticalSection(&cs_conf_handle);\r
         while(conf_free_handles) {\r
             LPOP(&conf_free_handles, &h);\r
             if(h) {\r
-                free(h);\r
+                PFREE(h);\r
             }\r
         }\r
 \r
         while(conf_handles) {\r
             LPOP(&conf_handles, &h);\r
             if(h) {\r
-                free(h);\r
+                PFREE(h);\r
             }\r
         }\r
         LeaveCriticalSection(&cs_conf_handle);\r
@@ -85,20 +85,21 @@ void exit_kconf(void) {
     }\r
 }\r
 \r
-kconf_handle * khc_handle_from_space(kconf_conf_space * s, khm_int32 flags)\r
+kconf_handle * \r
+khcint_handle_from_space(kconf_conf_space * s, khm_int32 flags)\r
 {\r
     kconf_handle * h;\r
 \r
     EnterCriticalSection(&cs_conf_handle);\r
     LPOP(&conf_free_handles, &h);\r
     if(!h) {\r
-        h = malloc(sizeof(kconf_handle));\r
-               assert(h != NULL);\r
+        h = PMALLOC(sizeof(kconf_handle));\r
+        assert(h != NULL);\r
     }\r
     ZeroMemory((void *) h, sizeof(kconf_handle));\r
 \r
     h->magic = KCONF_HANDLE_MAGIC;\r
-    khc_space_hold(s);\r
+    khcint_space_hold(s);\r
     h->space = s;\r
     h->flags = flags;\r
 \r
@@ -109,7 +110,8 @@ kconf_handle * khc_handle_from_space(kconf_conf_space * s, khm_int32 flags)
 }\r
 \r
 /* must be called with cs_conf_global held */\r
-void khc_handle_free(kconf_handle * h)\r
+void \r
+khcint_handle_free(kconf_handle * h)\r
 {\r
     kconf_handle * lower;\r
 \r
@@ -133,7 +135,7 @@ void khc_handle_free(kconf_handle * h)
     while(h) {\r
         LDELETE(&conf_handles, h);\r
         if(h->space) {\r
-            khc_space_release(h->space);\r
+            khcint_space_release(h->space);\r
             h->space = NULL;\r
         }\r
         lower = h->lower;\r
@@ -143,16 +145,17 @@ void khc_handle_free(kconf_handle * h)
     LeaveCriticalSection(&cs_conf_handle);\r
 }\r
 \r
-kconf_handle * khc_handle_dup(kconf_handle * o)\r
+kconf_handle * \r
+khcint_handle_dup(kconf_handle * o)\r
 {\r
     kconf_handle * h;\r
     kconf_handle * r;\r
 \r
-    r = khc_handle_from_space(o->space, o->flags);\r
+    r = khcint_handle_from_space(o->space, o->flags);\r
     h = r;\r
 \r
     while(o->lower) {\r
-        h->lower = khc_handle_from_space(o->lower->space, o->lower->flags);\r
+        h->lower = khcint_handle_from_space(o->lower->space, o->lower->flags);\r
 \r
         o = o->lower;\r
         h = h->lower;\r
@@ -161,21 +164,26 @@ kconf_handle * khc_handle_dup(kconf_handle * o)
     return r;\r
 }\r
 \r
-void khc_space_hold(kconf_conf_space * s) {\r
+void \r
+khcint_space_hold(kconf_conf_space * s) {\r
     InterlockedIncrement(&(s->refcount));\r
 }\r
 \r
-void khc_space_release(kconf_conf_space * s) {\r
+void \r
+khcint_space_release(kconf_conf_space * s) {\r
     LONG l = InterlockedDecrement(&(s->refcount));\r
     if(!l) {\r
         EnterCriticalSection(&cs_conf_global);\r
 \r
-        if(s->regkey_machine)\r
-            RegCloseKey(s->regkey_machine);\r
-        if(s->regkey_user)\r
-            RegCloseKey(s->regkey_user);\r
-        s->regkey_machine = NULL;\r
-        s->regkey_user = NULL;\r
+        /* check again */\r
+        if (!l) {\r
+            if(s->regkey_machine)\r
+                RegCloseKey(s->regkey_machine);\r
+            if(s->regkey_user)\r
+                RegCloseKey(s->regkey_user);\r
+            s->regkey_machine = NULL;\r
+            s->regkey_user = NULL;\r
+        }\r
 \r
         LeaveCriticalSection(&cs_conf_global);\r
     }\r
@@ -407,7 +415,8 @@ khcint_RegCreateKeyEx(HKEY hKey,
 }\r
 \r
 \r
-HKEY khc_space_open_key(kconf_conf_space * s, khm_int32 flags) {\r
+HKEY \r
+khcint_space_open_key(kconf_conf_space * s, khm_int32 flags) {\r
     HKEY hk = NULL;\r
     int nflags = 0;\r
     DWORD disp;\r
@@ -479,7 +488,8 @@ HKEY khc_space_open_key(kconf_conf_space * s, khm_int32 flags) {
     }\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_shadow_space(khm_handle upper, khm_handle lower)\r
 {\r
     kconf_handle * h;\r
 \r
@@ -487,7 +497,7 @@ KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!khc_is_handle(upper))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     h = (kconf_handle *) upper;\r
 \r
@@ -495,7 +505,7 @@ KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)
     if(h->lower) {\r
         LeaveCriticalSection(&cs_conf_handle);\r
         EnterCriticalSection(&cs_conf_global);\r
-        khc_handle_free(h->lower);\r
+        khcint_handle_free(h->lower);\r
         LeaveCriticalSection(&cs_conf_global);\r
         EnterCriticalSection(&cs_conf_handle);\r
         h->lower = NULL;\r
@@ -507,7 +517,7 @@ KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)
 \r
         l = (kconf_handle *) lower;\r
         LeaveCriticalSection(&cs_conf_handle);\r
-        lc = khc_handle_dup(l);\r
+        lc = khcint_handle_dup(l);\r
         EnterCriticalSection(&cs_conf_handle);\r
         h->lower = lc;\r
     }\r
@@ -516,17 +526,19 @@ KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-kconf_conf_space * khc_create_empty_space(void) {\r
+kconf_conf_space * \r
+khcint_create_empty_space(void) {\r
     kconf_conf_space * r;\r
 \r
-    r = malloc(sizeof(kconf_conf_space));\r
-       assert(r != NULL);\r
+    r = PMALLOC(sizeof(kconf_conf_space));\r
+    assert(r != NULL);\r
     ZeroMemory(r,sizeof(kconf_conf_space));\r
 \r
     return r;\r
 }\r
 \r
-void khc_free_space(kconf_conf_space * r) {\r
+void \r
+khcint_free_space(kconf_conf_space * r) {\r
     kconf_conf_space * c;\r
 \r
     if(!r)\r
@@ -534,15 +546,15 @@ void khc_free_space(kconf_conf_space * r) {
 \r
     LPOP(&r->children, &c);\r
     while(c) {\r
-        khc_free_space(c);\r
+        khcint_free_space(c);\r
         LPOP(&r->children, &c);\r
     }\r
 \r
     if(r->name)\r
-        free(r->name);\r
+        PFREE(r->name);\r
 \r
     if(r->regpath)\r
-        free(r->regpath);\r
+        PFREE(r->regpath);\r
 \r
     if(r->regkey_machine)\r
         RegCloseKey(r->regkey_machine);\r
@@ -550,10 +562,13 @@ void khc_free_space(kconf_conf_space * r) {
     if(r->regkey_user)\r
         RegCloseKey(r->regkey_user);\r
 \r
-    free(r);\r
+    PFREE(r);\r
 }\r
 \r
-khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size_t n_sname, khm_int32 flags, kconf_conf_space **result) {\r
+khm_int32 \r
+khcint_open_space_int(kconf_conf_space * parent, \r
+                      wchar_t * sname, size_t n_sname, \r
+                      khm_int32 flags, kconf_conf_space **result) {\r
     kconf_conf_space * p;\r
     kconf_conf_space * c;\r
     HKEY pkey = NULL;\r
@@ -566,10 +581,10 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
         p = parent;\r
 \r
     if(n_sname >= KCONF_MAXCCH_NAME || n_sname <= 0)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-       /*SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t >\r
-          n_sname * wchar_t */\r
+    /*SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t >\r
+      n_sname * wchar_t */\r
     wcsncpy(buf, sname, n_sname);\r
     buf[n_sname] = L'\0';\r
 \r
@@ -587,7 +602,7 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
     LeaveCriticalSection(&cs_conf_global);\r
 \r
     if(c) {\r
-        khc_space_hold(c);\r
+        khcint_space_hold(c);\r
         *result = c;\r
         return KHM_ERROR_SUCCESS;\r
     }\r
@@ -598,14 +613,14 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
         registry key in HKLM or HKCU.  If it existed as a schema, we\r
         would have already retured it above. */\r
         if(flags & KCONF_FLAG_USER)\r
-            pkey = khc_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_USER);\r
+            pkey = khcint_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_USER);\r
 \r
         if((!pkey || \r
             (khcint_RegOpenKeyEx(pkey, buf, 0, KEY_READ, &ckey) != \r
              ERROR_SUCCESS)) \r
            && (flags & KCONF_FLAG_MACHINE)) {\r
 \r
-            pkey = khc_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+            pkey = khcint_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
             if(!pkey || \r
                (khcint_RegOpenKeyEx(pkey, buf, 0, KEY_READ, &ckey) != \r
                 ERROR_SUCCESS)) {\r
@@ -620,15 +635,15 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
         }\r
     }\r
 \r
-    c = khc_create_empty_space();\r
+    c = khcint_create_empty_space();\r
     \r
     /*SAFE: buf: is of known length < KCONF_MAXCCH_NAME */\r
-    c->name = wcsdup(buf);\r
+    c->name = PWCSDUP(buf);\r
 \r
     /*SAFE: p->regpath: is valid since it was set using this same\r
       function. */\r
     /*SAFE: buf: see above */\r
-    c->regpath = malloc((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t));\r
+    c->regpath = PMALLOC((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t));\r
 \r
     assert(c->regpath != NULL);\r
 \r
@@ -642,7 +657,7 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
     wcscat(c->regpath, buf);\r
 #pragma warning( pop )\r
 \r
-    khc_space_hold(c);\r
+    khcint_space_hold(c);\r
 \r
     EnterCriticalSection(&cs_conf_global);\r
     TADDCHILD(p,c);\r
@@ -652,7 +667,9 @@ khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, khm_handle * result) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, \r
+               khm_handle * result) {\r
     kconf_handle * h;\r
     kconf_conf_space * p;\r
     kconf_conf_space * c = NULL;\r
@@ -665,7 +682,7 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
     }\r
 \r
     if(!result || (parent && !khc_is_handle(parent)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(!parent)\r
         p = conf_root;\r
@@ -674,7 +691,7 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
         p = khc_space_from_handle(parent);\r
     }\r
 \r
-    khc_space_hold(p);\r
+    khcint_space_hold(p);\r
 \r
     /* if none of these flags are specified, make it seem like all of\r
        them were */\r
@@ -684,15 +701,15 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
         flags |= KCONF_FLAG_USER | KCONF_FLAG_MACHINE | KCONF_FLAG_SCHEMA;\r
 \r
     if(cspace == NULL) {\r
-        khc_space_release(p);\r
-        *result = (khm_handle) khc_handle_from_space(p, flags);\r
+        khcint_space_release(p);\r
+        *result = (khm_handle) khcint_handle_from_space(p, flags);\r
         return KHM_ERROR_SUCCESS;\r
     }\r
 \r
     if(FAILED(StringCbLength(cspace, KCONF_MAXCB_PATH, &cbsize))) {\r
-        khc_space_release(p);\r
+        khcint_space_release(p);\r
         *result = NULL;\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     str = cspace;\r
@@ -714,7 +731,7 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
             if(flags & KCONF_FLAG_TRAILINGVALUE) {\r
                 /* we are at the value component */\r
                 c = p;\r
-                khc_space_hold(c);\r
+                khcint_space_hold(c);\r
                 break;\r
             } else\r
                 end = str + wcslen(str);  /* safe because cspace was\r
@@ -728,7 +745,7 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
                                  || *end == L'/'\r
 #endif\r
                                  )) {\r
-            khc_space_release(p);\r
+            khcint_space_release(p);\r
             p = c;\r
             c = NULL;\r
             str = end+1;\r
@@ -737,30 +754,32 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
             break;\r
     }\r
 \r
-    khc_space_release(p);\r
+    khcint_space_release(p);\r
     if(KHM_SUCCEEDED(rv)) {\r
-        *result = khc_handle_from_space(c, flags);\r
+        *result = khcint_handle_from_space(c, flags);\r
     } else\r
         *result = NULL;\r
 \r
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_close_space(khm_handle csp) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_close_space(khm_handle csp) {\r
     if(!khc_is_config_running())\r
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!khc_is_handle(csp))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    khc_handle_free((kconf_handle *) csp);\r
+    khcint_handle_free((kconf_handle *) csp);\r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_read_string(khm_handle pconf, \r
-                                        wchar_t * pvalue, \r
-                                        wchar_t * buf, \r
-                                        khm_size * bufsize) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_string(khm_handle pconf, \r
+                wchar_t * pvalue, \r
+                wchar_t * buf, \r
+                khm_size * bufsize) \r
 {\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -815,10 +834,10 @@ KHMEXP khm_int32 KHMAPI khc_read_string(khm_handle pconf,
         c = khc_space_from_handle(conf);\r
 \r
         if(khc_is_user_handle(conf))\r
-            hku = khc_space_open_key(c, KHM_PERM_READ);\r
+            hku = khcint_space_open_key(c, KHM_PERM_READ);\r
 \r
         if(khc_is_machine_handle(conf))\r
-            hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+            hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
         size = (DWORD) *bufsize;\r
         if(hku) {\r
@@ -919,7 +938,8 @@ _exit:
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_int32 * buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_int32 * buf) {\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -927,7 +947,7 @@ KHMEXP khm_int32 KHMAPI khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_i
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!buf || !pvalue)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     do {\r
         DWORD size;\r
@@ -975,10 +995,10 @@ KHMEXP khm_int32 KHMAPI khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_i
         c = khc_space_from_handle(conf);\r
 \r
         if(khc_is_user_handle(conf))\r
-            hku = khc_space_open_key(c, KHM_PERM_READ);\r
+            hku = khcint_space_open_key(c, KHM_PERM_READ);\r
 \r
         if(khc_is_machine_handle(conf))\r
-            hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+            hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
         size = sizeof(DWORD);\r
         if(hku) {\r
@@ -1040,7 +1060,8 @@ _exit:
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_read_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 * buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 * buf) {\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -1093,10 +1114,10 @@ KHMEXP khm_int32 KHMAPI khc_read_int64(khm_handle pconf, wchar_t * pvalue, khm_i
         c = khc_space_from_handle(conf);\r
 \r
         if(khc_is_user_handle(conf))\r
-            hku = khc_space_open_key(c, KHM_PERM_READ);\r
+            hku = khcint_space_open_key(c, KHM_PERM_READ);\r
 \r
         if(khc_is_machine_handle(conf))\r
-            hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+            hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
         size = sizeof(khm_int64);\r
         if(hku) {\r
@@ -1158,7 +1179,9 @@ _exit:
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_read_binary(khm_handle pconf, wchar_t * pvalue, void * buf, khm_size * bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_binary(khm_handle pconf, wchar_t * pvalue, \r
+                void * buf, khm_size * bufsize) {\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -1209,10 +1232,10 @@ KHMEXP khm_int32 KHMAPI khc_read_binary(khm_handle pconf, wchar_t * pvalue, void
         c = khc_space_from_handle(conf);\r
 \r
         if(khc_is_user_handle(conf))\r
-            hku = khc_space_open_key(c, KHM_PERM_READ);\r
+            hku = khcint_space_open_key(c, KHM_PERM_READ);\r
 \r
         if(khc_is_machine_handle(conf))\r
-            hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+            hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
         size = (DWORD) *bufsize;\r
         if(hku) {\r
@@ -1280,10 +1303,10 @@ _exit:
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_write_string(\r
-    khm_handle pconf, \r
-    wchar_t * pvalue, \r
-    wchar_t * buf) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_string(khm_handle pconf, \r
+                 wchar_t * pvalue, \r
+                 wchar_t * buf) \r
 {\r
     HKEY pk = NULL;\r
     kconf_conf_space * c;\r
@@ -1311,7 +1334,7 @@ KHMEXP khm_int32 KHMAPI khc_write_string(
             pvalue, \r
             KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
             &conf)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         free_space = 1;\r
 #if 0\r
         wchar_t * back, *forward;\r
@@ -1329,23 +1352,23 @@ KHMEXP khm_int32 KHMAPI khc_write_string(
     }\r
 \r
     if(!khc_is_handle(conf) || !buf) {\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
     c = khc_space_from_handle(conf);\r
 \r
     if(FAILED(StringCbLength(buf, KCONF_MAXCB_STRING, &cbsize))) {\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
     cbsize += sizeof(wchar_t);\r
 \r
     if(khc_is_user_handle(conf)) {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
     } else {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
     }\r
 \r
     hr = RegSetValueEx(pk, value, 0, REG_SZ, (LPBYTE) buf, (DWORD) cbsize);\r
@@ -1359,10 +1382,10 @@ _exit:
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_write_int32(\r
-                                        khm_handle pconf, \r
-                                        wchar_t * pvalue, \r
-                                        khm_int32 buf) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int32(khm_handle pconf, \r
+                wchar_t * pvalue, \r
+                khm_int32 buf) \r
 {\r
     HKEY pk = NULL;\r
     kconf_conf_space * c;\r
@@ -1389,7 +1412,7 @@ KHMEXP khm_int32 KHMAPI khc_write_int32(
             pvalue, \r
             KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
             &conf)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         free_space = 1;\r
 #if 0\r
         wchar_t * back, *forward;\r
@@ -1407,14 +1430,14 @@ KHMEXP khm_int32 KHMAPI khc_write_int32(
     }\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle( conf);\r
 \r
     if(khc_is_user_handle(conf)) {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
     } else {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
     }\r
 \r
     hr = RegSetValueEx(pk, value, 0, REG_DWORD, (LPBYTE) &buf, sizeof(khm_int32));\r
@@ -1428,7 +1451,8 @@ KHMEXP khm_int32 KHMAPI khc_write_int32(
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 buf) {\r
     HKEY pk = NULL;\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -1454,7 +1478,7 @@ KHMEXP khm_int32 KHMAPI khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_
             pvalue, \r
             KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
             &conf)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         free_space = 1;\r
 #if 0\r
         wchar_t * back, *forward;\r
@@ -1472,14 +1496,14 @@ KHMEXP khm_int32 KHMAPI khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_
     }\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle( conf);\r
 \r
     if(khc_is_user_handle(conf)) {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
     } else {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
     }\r
 \r
     hr = RegSetValueEx(pk, value, 0, REG_QWORD, (LPBYTE) &buf, sizeof(khm_int64));\r
@@ -1493,7 +1517,10 @@ KHMEXP khm_int32 KHMAPI khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_write_binary(khm_handle pconf, wchar_t * pvalue, void * buf, khm_size bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_binary(khm_handle pconf, \r
+                 wchar_t * pvalue, \r
+                 void * buf, khm_size bufsize) {\r
     HKEY pk = NULL;\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -1519,7 +1546,7 @@ KHMEXP khm_int32 KHMAPI khc_write_binary(khm_handle pconf, wchar_t * pvalue, voi
             pvalue, \r
             KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
             &conf)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         free_space = 1;\r
 #if 0\r
         wchar_t * back, *forward;\r
@@ -1537,14 +1564,14 @@ KHMEXP khm_int32 KHMAPI khc_write_binary(khm_handle pconf, wchar_t * pvalue, voi
     }\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle(conf);\r
 \r
     if(khc_is_user_handle(conf)) {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
     } else {\r
-        pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+        pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
     }\r
 \r
     hr = RegSetValueEx(pk, value, 0, REG_BINARY, buf, (DWORD) bufsize);\r
@@ -1558,7 +1585,9 @@ KHMEXP khm_int32 KHMAPI khc_write_binary(khm_handle pconf, wchar_t * pvalue, voi
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_name(khm_handle conf, wchar_t * buf, khm_size * bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_name(khm_handle conf, \r
+                          wchar_t * buf, khm_size * bufsize) {\r
     kconf_conf_space * c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -1566,7 +1595,7 @@ KHMEXP khm_int32 KHMAPI khc_get_config_space_name(khm_handle conf, wchar_t * buf
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle(conf);\r
 \r
@@ -1597,26 +1626,28 @@ KHMEXP khm_int32 KHMAPI khc_get_config_space_name(khm_handle conf, wchar_t * buf
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_parent(khm_handle conf, khm_handle * parent) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_parent(khm_handle conf, khm_handle * parent) {\r
     kconf_conf_space * c;\r
 \r
     if(!khc_is_config_running())\r
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle(conf);\r
 \r
     if(c == conf_root || c->parent == conf_root)\r
         *parent = NULL;\r
     else\r
-        *parent = khc_handle_from_space(c->parent, khc_handle_flags(conf));\r
+        *parent = khcint_handle_from_space(c->parent, khc_handle_flags(conf));\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_type(khm_handle conf, wchar_t * value) {\r
     HKEY hkm = NULL;\r
     HKEY hku = NULL;\r
     kconf_conf_space * c;\r
@@ -1633,8 +1664,8 @@ KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value) {
     c = (kconf_conf_space *) conf;\r
 \r
     if(!khc_is_machine_handle(conf))\r
-        hku = khc_space_open_key(c, KHM_PERM_READ);\r
-    hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+        hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+    hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
     if(hku)\r
         hr = RegQueryValueEx(hku, value, NULL, &type, NULL, NULL);\r
@@ -1673,7 +1704,8 @@ KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value) {
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_value_exists(khm_handle conf, wchar_t * value) {\r
     HKEY hku = NULL;\r
     HKEY hkm = NULL;\r
     kconf_conf_space * c;\r
@@ -1685,13 +1717,13 @@ KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value) {
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     c = khc_space_from_handle(conf);\r
 \r
     if(!khc_is_machine_handle(conf))\r
-        hku = khc_space_open_key(c, KHM_PERM_READ);\r
-    hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+        hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+    hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
 \r
     if(hku && (RegQueryValueEx(hku, value, NULL, &t, NULL, NULL) == ERROR_SUCCESS))\r
         rv |= KCONF_FLAG_USER;\r
@@ -1710,7 +1742,77 @@ KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value) {
     return rv;\r
 }\r
 \r
-khm_boolean khc_is_valid_name(wchar_t * name)\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_value(khm_handle conf, wchar_t * value, khm_int32 flags) {\r
+    HKEY hku = NULL;\r
+    HKEY hkm = NULL;\r
+    kconf_conf_space * c;\r
+    khm_int32 rv = KHM_ERROR_NOT_FOUND;\r
+    DWORD t;\r
+    LONG l;\r
+\r
+    if(!khc_is_config_running())\r
+        return KHM_ERROR_NOT_READY;\r
+\r
+    if(!khc_is_handle(conf))\r
+        return KHM_ERROR_INVALID_PARAM;\r
+\r
+    c = khc_space_from_handle(conf);\r
+\r
+    if(!khc_is_machine_handle(conf))\r
+        hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+    hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+\r
+    if((flags == 0 ||\r
+        (flags & KCONF_FLAG_USER)) &&\r
+       hku && (RegQueryValueEx(hku, value, NULL, \r
+                               &t, NULL, NULL) == ERROR_SUCCESS)) {\r
+        l = RegDeleteValue(hku, value);\r
+        if (l == ERROR_SUCCESS)\r
+            rv = KHM_ERROR_SUCCESS;\r
+        else\r
+            rv = KHM_ERROR_UNKNOWN;\r
+    }\r
+    if((flags == 0 ||\r
+        (flags & KCONF_FLAG_MACHINE)) &&\r
+       hkm && (RegQueryValueEx(hkm, value, NULL, \r
+                               &t, NULL, NULL) == ERROR_SUCCESS)) {\r
+        l = RegDeleteValue(hkm, value);\r
+        if (l == ERROR_SUCCESS)\r
+            rv = (rv == KHM_ERROR_UNKNOWN)?KHM_ERROR_PARTIAL: \r
+                KHM_ERROR_SUCCESS;\r
+        else\r
+            rv = (rv == KHM_ERROR_SUCCESS)?KHM_ERROR_PARTIAL:\r
+                KHM_ERROR_UNKNOWN;\r
+    }\r
+\r
+    return rv;\r
+}\r
+\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_space(khm_handle conf) {\r
+    /* TODO: implement this */\r
+\r
+    /*\r
+       - mark this space as well as all child spaces as\r
+         'delete-on-close' using flags.  Mark should indicate which\r
+         repository to delete the space from. (user/machine)\r
+\r
+       - When each subspace is released, check if it has been marked\r
+         for deletion.  If so, delete the marked spaces as well as\r
+         removing the space from kconf space tree.\r
+\r
+       - When removing a subspace from a space, check if the parent\r
+         space has any children left.  If there are none, check if the\r
+         parent space is also marked for deletion.\r
+    */\r
+    assert(FALSE);\r
+\r
+    return 0;\r
+}\r
+\r
+khm_boolean \r
+khcint_is_valid_name(wchar_t * name)\r
 {\r
     size_t cbsize;\r
     if(FAILED(StringCbLength(name, KCONF_MAXCB_NAME, &cbsize)))\r
@@ -1718,9 +1820,10 @@ khm_boolean khc_is_valid_name(wchar_t * name)
     return TRUE;\r
 }\r
 \r
-khm_int32 khc_validate_schema(kconf_schema * schema,\r
-                              int begin,\r
-                              int *end)\r
+khm_int32 \r
+khcint_validate_schema(kconf_schema * schema,\r
+                       int begin,\r
+                       int *end)\r
 {\r
     int i;\r
     int state = 0;\r
@@ -1730,18 +1833,18 @@ khm_int32 khc_validate_schema(kconf_schema * schema,
     while(!end_found) {\r
         switch(state) {\r
             case 0: /* initial.  this record should start a config space */\r
-                if(!khc_is_valid_name(schema[i].name) ||\r
+                if(!khcint_is_valid_name(schema[i].name) ||\r
                     schema[i].type != KC_SPACE)\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 state = 1;\r
                 break;\r
 \r
             case 1: /* we are inside a config space, in the values area */\r
-                if(!khc_is_valid_name(schema[i].name))\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                if(!khcint_is_valid_name(schema[i].name))\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 if(schema[i].type == KC_SPACE) {\r
-                    if(KHM_FAILED(khc_validate_schema(schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_validate_schema(schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                     state = 2;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     end_found = 1;\r
@@ -1752,26 +1855,26 @@ khm_int32 khc_validate_schema(kconf_schema * schema,
                         schema[i].type != KC_INT32 &&\r
                         schema[i].type != KC_INT64 &&\r
                         schema[i].type != KC_BINARY)\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                 }\r
                 break;\r
 \r
             case 2: /* we are inside a config space, in the subspace area */\r
                 if(schema[i].type == KC_SPACE) {\r
-                    if(KHM_FAILED(khc_validate_schema(schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_validate_schema(schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     end_found = 1;\r
                     if(end)\r
                         *end = i;\r
                 } else {\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 }\r
                 break;\r
 \r
             default:\r
                 /* unreachable */\r
-                return KHM_ERROR_INVALID_PARM;\r
+                return KHM_ERROR_INVALID_PARAM;\r
         }\r
         i++;\r
     }\r
@@ -1779,7 +1882,9 @@ khm_int32 khc_validate_schema(kconf_schema * schema,
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin, int * end)\r
+khm_int32 \r
+khcint_load_schema_i(khm_handle parent, kconf_schema * schema, \r
+                     int begin, int * end)\r
 {\r
     int i;\r
     int state = 0;\r
@@ -1791,8 +1896,9 @@ khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin,
     while(!end_found) {\r
         switch(state) {\r
             case 0: /* initial.  this record should start a config space */\r
-                if(KHM_FAILED(khc_open_space(parent, schema[i].name, KHM_FLAG_CREATE, &h)))\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                if(KHM_FAILED(khc_open_space(parent, schema[i].name, \r
+                                             KHM_FLAG_CREATE, &h)))\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 thisconf = khc_space_from_handle(h);\r
                 thisconf->schema = schema + (begin + 1);\r
                 state = 1;\r
@@ -1801,8 +1907,8 @@ khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin,
             case 1: /* we are inside a config space, in the values area */\r
                 if(schema[i].type == KC_SPACE) {\r
                     thisconf->nSchema = i - (begin + 1);\r
-                    if(KHM_FAILED(khc_load_schema_i(h, schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_load_schema_i(h, schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                     state = 2;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     thisconf->nSchema = i - (begin + 1);\r
@@ -1815,21 +1921,21 @@ khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin,
 \r
             case 2: /* we are inside a config space, in the subspace area */\r
                 if(schema[i].type == KC_SPACE) {\r
-                    if(KHM_FAILED(khc_load_schema_i(h, schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_load_schema_i(h, schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     end_found = 1;\r
                     if(end)\r
                         *end = i;\r
                     khc_close_space(h);\r
                 } else {\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 }\r
                 break;\r
 \r
             default:\r
                 /* unreachable */\r
-                return KHM_ERROR_INVALID_PARM;\r
+                return KHM_ERROR_INVALID_PARAM;\r
         }\r
         i++;\r
     }\r
@@ -1837,7 +1943,8 @@ khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin,
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_load_schema(khm_handle conf, kconf_schema * schema)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_load_schema(khm_handle conf, kconf_schema * schema)\r
 {\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -1845,19 +1952,21 @@ KHMEXP khm_int32 KHMAPI khc_load_schema(khm_handle conf, kconf_schema * schema)
         return KHM_ERROR_NOT_READY;\r
 \r
     if(conf && !khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    if(KHM_FAILED(khc_validate_schema(schema, 0, NULL)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+    if(KHM_FAILED(khcint_validate_schema(schema, 0, NULL)))\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_conf_global);\r
-    rv = khc_load_schema_i(conf, schema, 0, NULL);        \r
+    rv = khcint_load_schema_i(conf, schema, 0, NULL);        \r
     LeaveCriticalSection(&cs_conf_global);\r
 \r
     return rv;\r
 }\r
 \r
-khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begin, int * end)\r
+khm_int32 \r
+khcint_unload_schema_i(khm_handle parent, kconf_schema * schema, \r
+                       int begin, int * end)\r
 {\r
     int i;\r
     int state = 0;\r
@@ -1870,7 +1979,7 @@ khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begi
         switch(state) {\r
             case 0: /* initial.  this record should start a config space */\r
                 if(KHM_FAILED(khc_open_space(parent, schema[i].name, 0, &h)))\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 thisconf = khc_space_from_handle(h);\r
                 if(thisconf->schema == (schema + (begin + 1))) {\r
                     thisconf->schema = NULL;\r
@@ -1881,8 +1990,8 @@ khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begi
 \r
             case 1: /* we are inside a config space, in the values area */\r
                 if(schema[i].type == KC_SPACE) {\r
-                    if(KHM_FAILED(khc_unload_schema_i(h, schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_unload_schema_i(h, schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                     state = 2;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     end_found = 1;\r
@@ -1894,21 +2003,21 @@ khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begi
 \r
             case 2: /* we are inside a config space, in the subspace area */\r
                 if(schema[i].type == KC_SPACE) {\r
-                    if(KHM_FAILED(khc_unload_schema_i(h, schema, i, &i)))\r
-                        return KHM_ERROR_INVALID_PARM;\r
+                    if(KHM_FAILED(khcint_unload_schema_i(h, schema, i, &i)))\r
+                        return KHM_ERROR_INVALID_PARAM;\r
                 } else if(schema[i].type == KC_ENDSPACE) {\r
                     end_found = 1;\r
                     if(end)\r
                         *end = i;\r
                     khc_close_space(h);\r
                 } else {\r
-                    return KHM_ERROR_INVALID_PARM;\r
+                    return KHM_ERROR_INVALID_PARAM;\r
                 }\r
                 break;\r
 \r
             default:\r
                 /* unreachable */\r
-                return KHM_ERROR_INVALID_PARM;\r
+                return KHM_ERROR_INVALID_PARAM;\r
         }\r
         i++;\r
     }\r
@@ -1916,7 +2025,8 @@ khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begi
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_unload_schema(khm_handle conf, kconf_schema * schema)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_unload_schema(khm_handle conf, kconf_schema * schema)\r
 {\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -1924,22 +2034,22 @@ KHMEXP khm_int32 KHMAPI khc_unload_schema(khm_handle conf, kconf_schema * schema
         return KHM_ERROR_NOT_READY;\r
 \r
     if(conf && !khc_is_handle(conf))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    if(KHM_FAILED(khc_validate_schema(schema, 0, NULL)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+    if(KHM_FAILED(khcint_validate_schema(schema, 0, NULL)))\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_conf_global);\r
-    rv = khc_unload_schema_i(conf, schema, 0, NULL);        \r
+    rv = khcint_unload_schema_i(conf, schema, 0, NULL);        \r
     LeaveCriticalSection(&cs_conf_global);\r
 \r
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_enum_subspaces(\r
-    khm_handle conf,\r
-    khm_handle prev,\r
-    khm_handle * next)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_enum_subspaces(khm_handle conf,\r
+                   khm_handle prev,\r
+                   khm_handle * next)\r
 {\r
     kconf_conf_space * s;\r
     kconf_conf_space * c;\r
@@ -1951,7 +2061,7 @@ KHMEXP khm_int32 KHMAPI khc_enum_subspaces(
 \r
     if(!khc_is_handle(conf) || next == NULL ||\r
         (prev != NULL && !khc_is_handle(prev)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     s = khc_space_from_handle(conf);\r
 \r
@@ -1965,7 +2075,7 @@ KHMEXP khm_int32 KHMAPI khc_enum_subspaces(
         {\r
             HKEY hk_conf;\r
 \r
-            hk_conf = khc_space_open_key(s, 0);\r
+            hk_conf = khcint_space_open_key(s, 0);\r
             if(hk_conf) {\r
                 wchar_t name[KCONF_MAXCCH_NAME];\r
                 khm_handle h;\r
@@ -1989,7 +2099,7 @@ KHMEXP khm_int32 KHMAPI khc_enum_subspaces(
         {\r
             HKEY hk_conf;\r
 \r
-            hk_conf = khc_space_open_key(s, KCONF_FLAG_MACHINE);\r
+            hk_conf = khcint_space_open_key(s, KCONF_FLAG_MACHINE);\r
             if(hk_conf) {\r
                 wchar_t name[KCONF_MAXCCH_NAME];\r
                 khm_handle h;\r
@@ -2033,7 +2143,7 @@ KHMEXP khm_int32 KHMAPI khc_enum_subspaces(
         khc_close_space(prev);\r
 \r
     if(c) {\r
-        *next = khc_handle_from_space(c, khc_handle_flags(conf));\r
+        *next = khcint_handle_from_space(c, khc_handle_flags(conf));\r
         rv = KHM_ERROR_SUCCESS;\r
     } else {\r
         *next = NULL;\r
@@ -2043,31 +2153,42 @@ KHMEXP khm_int32 KHMAPI khc_enum_subspaces(
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_write_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf)\r
 {\r
     size_t cb;\r
+    wchar_t vbuf[KCONF_MAXCCH_STRING];\r
     wchar_t *tb;\r
     khm_int32 rv;\r
 \r
     if(!khc_is_config_running())\r
         return KHM_ERROR_NOT_READY;\r
     if(!khc_is_handle(conf) || buf == NULL || value == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(multi_string_to_csv(NULL, &cb, buf) != KHM_ERROR_TOO_LONG)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
+\r
+    if (cb < sizeof(vbuf))\r
+        tb = vbuf;\r
+    else\r
+        tb = PMALLOC(cb);\r
+\r
+    assert(tb != NULL);\r
 \r
-    tb = malloc(cb);\r
-       assert(tb != NULL);\r
     multi_string_to_csv(tb, &cb, buf);\r
     rv = khc_write_string(conf, value, tb);\r
 \r
-    free(tb);\r
+    if (tb != vbuf)\r
+        PFREE(tb);\r
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khc_read_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf, khm_size * bufsize)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_multi_string(khm_handle conf, wchar_t * value, \r
+                      wchar_t * buf, khm_size * bufsize)\r
 {\r
+    wchar_t vbuf[KCONF_MAXCCH_STRING];\r
     wchar_t * tb;\r
     khm_size cbbuf;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -2076,14 +2197,19 @@ KHMEXP khm_int32 KHMAPI khc_read_multi_string(khm_handle conf, wchar_t * value,
         return KHM_ERROR_NOT_READY;\r
 \r
     if(!bufsize)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     rv = khc_read_string(conf, value, NULL, &cbbuf);\r
     if(rv != KHM_ERROR_TOO_LONG)\r
         return rv;\r
 \r
-    tb = malloc(cbbuf);\r
-       assert(tb != NULL);\r
+    if (cbbuf < sizeof(vbuf))\r
+        tb = vbuf;\r
+    else\r
+        tb = PMALLOC(cbbuf);\r
+\r
+    assert(tb != NULL);\r
+\r
     rv = khc_read_string(conf, value, tb, &cbbuf);\r
 \r
     if(KHM_FAILED(rv))\r
@@ -2092,7 +2218,8 @@ KHMEXP khm_int32 KHMAPI khc_read_multi_string(khm_handle conf, wchar_t * value,
     rv = csv_to_multi_string(buf, bufsize, tb);\r
 \r
 _exit:\r
-    free(tb);\r
+    if (tb != vbuf)\r
+        PFREE(tb);\r
 \r
     return rv;\r
 }\r
index 22d923bd6fc813b4d06f155efc2e98a33d308c1c..d2226be2010f0ede1b78f9b5cca12a50ed585a57 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -228,7 +228,9 @@ typedef struct kconf_schema_t {
         and settings \a flags to the required flags.\r
 \r
 */\r
-KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, khm_handle * result);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, \r
+               khm_handle * result);\r
 \r
 /*! \brief Set the shadow space for a configuration handle\r
 \r
@@ -250,11 +252,13 @@ KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_
 \r
     Specify NULL for \a lower to remove any prior shadow.\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_shadow_space(khm_handle upper, khm_handle lower);\r
 \r
 /*! \brief Close a handle opened with khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_close_space(khm_handle conf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_close_space(khm_handle conf);\r
 \r
 /*! \brief Read a string value from a configuration space\r
 \r
@@ -295,18 +299,18 @@ KHMEXP khm_int32 KHMAPI khc_close_space(khm_handle conf);
         the required buffer if \a buf is NULL or insufficient.\r
 \r
     \retval KHM_ERROR_NOT_READY The configuration provider has not started\r
-    \retval KHM_ERROR_INVALID_PARM One or more of the supplied parameters are not valid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid\r
     \retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string\r
     \retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient.  The required size is in bufsize.\r
     \retval KHM_ERROR_SUCCESS Success.  The number of bytes copied is in bufsize.\r
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_read_string(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    wchar_t * buf, \r
-    khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_string(khm_handle conf, \r
+                wchar_t * value, \r
+                wchar_t * buf, \r
+                khm_size * bufsize);\r
 \r
 /*! \brief Read a multi-string value from a configuration space\r
 \r
@@ -355,18 +359,18 @@ KHMEXP khm_int32 KHMAPI khc_read_string(
         the required buffer if \a buf is NULL or insufficient.\r
 \r
     \retval KHM_ERROR_NOT_READY The configuration provider has not started\r
-    \retval KHM_ERROR_INVALID_PARM One or more of the supplied parameters are not valid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid\r
     \retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string\r
     \retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient.  The required size is in bufsize.\r
     \retval KHM_ERROR_SUCCESS Success.  The number of bytes copied is in bufsize.\r
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_read_multi_string(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    wchar_t * buf, \r
-    khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_multi_string(khm_handle conf, \r
+                      wchar_t * value, \r
+                      wchar_t * buf, \r
+                      khm_size * bufsize);\r
 \r
 /*! \brief Read a 32 bit integer value from a configuration space\r
 \r
@@ -405,14 +409,14 @@ KHMEXP khm_int32 KHMAPI khc_read_multi_string(
     \retval KHM_ERROR_NOT_READY The configuration provider has not started.\r
     \retval KHM_ERROR_SUCCESS Success.  The value that was read was placed in \a buf\r
     \retval KHM_ERROR_NOT_FOUND The specified value was not found\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not of the correct type.\r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_read_int32(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    khm_int32 * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int32(khm_handle conf, \r
+               wchar_t * value, \r
+               khm_int32 * buf);\r
 \r
 /*! \brief Read a 64 bit integer value from a configuration space\r
 \r
@@ -451,15 +455,15 @@ KHMEXP khm_int32 KHMAPI khc_read_int32(
     \retval KHM_ERROR_NOT_READY The configuration provider has not started\r
     \retval KHM_ERROR_SUCCESS Success.  The value that was read was placed in \a buf\r
     \retval KHM_ERROR_NOT_FOUND The specified value was not found\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not the correct data type.\r
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_read_int64(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    khm_int64 * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int64(khm_handle conf, \r
+               wchar_t * value, \r
+               khm_int64 * buf);\r
 \r
 /*! \brief Read a binary value from a configuration space\r
 \r
@@ -499,15 +503,15 @@ KHMEXP khm_int32 KHMAPI khc_read_int64(
 \r
     \retval KHM_ERROR_SUCCESS Success. The data was copied to \a buf.  The number of bytes copied is stored in \a bufsize\r
     \retval KHM_ERROR_NOT_FOUND The specified value was not found\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_read_binary(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    void * buf, \r
-    khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_binary(khm_handle conf, \r
+                wchar_t * value, \r
+                void * buf, \r
+                khm_size * bufsize);\r
 \r
 /*! \brief Write a string value to a configuration space\r
 \r
@@ -543,10 +547,10 @@ KHMEXP khm_int32 KHMAPI khc_read_binary(
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_write_string(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    wchar_t * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_string(khm_handle conf, \r
+                 wchar_t * value, \r
+                 wchar_t * buf);\r
 \r
 /*! \brief Write a multi-string value to a configuration space\r
 \r
@@ -584,10 +588,10 @@ KHMEXP khm_int32 KHMAPI khc_write_string(
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_write_multi_string(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    wchar_t * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_multi_string(khm_handle conf, \r
+                       wchar_t * value, \r
+                       wchar_t * buf);\r
 \r
 /*! \brief Write a 32 bit integer value to a configuration space\r
 \r
@@ -619,10 +623,10 @@ KHMEXP khm_int32 KHMAPI khc_write_multi_string(
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_write_int32(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    khm_int32 buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int32(khm_handle conf, \r
+                wchar_t * value, \r
+                khm_int32 buf);\r
 \r
 /*! \brief Write a 64 bit integer value to a configuration space\r
 \r
@@ -654,10 +658,10 @@ KHMEXP khm_int32 KHMAPI khc_write_int32(
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_write_int64(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    khm_int64 buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int64(khm_handle conf, \r
+                wchar_t * value, \r
+                khm_int64 buf);\r
 \r
 /*! \brief Write a binary value to a configuration space\r
 \r
@@ -689,18 +693,19 @@ KHMEXP khm_int32 KHMAPI khc_write_int64(
 \r
     \see khc_open_space()\r
 */\r
-KHMEXP khm_int32 KHMAPI khc_write_binary(\r
-    khm_handle conf, \r
-    wchar_t * value, \r
-    void * buf, \r
-    khm_size bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_binary(khm_handle conf, \r
+                 wchar_t * value, \r
+                 void * buf, \r
+                 khm_size bufsize);\r
 \r
 /*! \brief Get the type of a value in a configuration space\r
 \r
     \return The return value is the type of the specified value, or\r
         KC_NONE if the value does not exist.\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_type(khm_handle conf, wchar_t * value);\r
 \r
 /*! \brief Check which configuration stores contain a specific value.\r
 \r
@@ -716,7 +721,49 @@ KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value);
         and ::KCONF_FLAG_SCHEMA indicating which stores contain the\r
         value.\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_value_exists(khm_handle conf, wchar_t * value);\r
+\r
+/*! \brief Remove a value from a configuration space\r
+\r
+    Removes a value from one or more configuration stores.\r
+\r
+    A value can exist in multiple configuration stores.  Only the\r
+    values that are stored in writable stores can be removed.  When\r
+    the function searches for values to remove, it will only look in\r
+    configuration stores that are specified in the handle.  In\r
+    addition, the configuration stores affected can be further\r
+    narrowed by specifying them in the \a flags parameter.  If \a\r
+    flags is zero, then all the stores visible to the handle are\r
+    searched.  If \a flags specifies ::KCONF_FLAG_USER or\r
+    ::KCONF_FLAG_MACHINE or both, then only the specified stores are\r
+    searched, provided that the stores are visible to the handle.\r
+\r
+    This function only operates on the topmost configuration space\r
+    visible to the handle.  If the configuration handle is shadowed,\r
+    the shadowed configuration spaces are unaffected by the removal.\r
+\r
+    \param[in] conf Handle to configuration space to remove value from\r
+\r
+    \param[in] value Value to remove\r
+\r
+    \param[in] flags Specifies which configuration stores will be\r
+        affected by the removal.  See above.\r
+\r
+    \retval KHM_ERROR_SUCCESS The value was removed from all the\r
+        specified configuration stores.\r
+\r
+    \retval KHM_ERROR_NOT_FOUND The value was not found.\r
+\r
+    \retval KHM_ERROR_UNKNOWN An unknown error occurred while trying\r
+        to remove the value.\r
+\r
+    \retval KHM_ERROR_PARTIAL The value was successfully removed from\r
+        one or more stores, but the operation failed on one or more\r
+        other stores.\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_value(khm_handle conf, wchar_t * value, khm_int32 flags);\r
 \r
 /*! \brief Get the name of a configuration space\r
 \r
@@ -729,10 +776,10 @@ KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value);
         pointed to by \a buf.  On exit, holds the number of bytes\r
         copied into the buffer including the NULL terminator.\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_name(\r
-    khm_handle conf, \r
-    wchar_t * buf, \r
-    khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_name(khm_handle conf, \r
+                          wchar_t * buf, \r
+                          khm_size * bufsize);\r
 \r
 /*! \brief Get a handle to the parent space\r
 \r
@@ -742,9 +789,9 @@ KHMEXP khm_int32 KHMAPI khc_get_config_space_name(
         call succeeds.  Receives NULL otherwise.  The returned handle\r
         must be closed using khc_close_space()\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_parent(\r
-    khm_handle conf, \r
-    khm_handle * parent);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_parent(khm_handle conf, \r
+                            khm_handle * parent);\r
 \r
 /*! \brief Load a configuration schema into the specified configuration space\r
 \r
@@ -756,15 +803,15 @@ KHMEXP khm_int32 KHMAPI khc_get_config_space_parent(
 \r
     \see khc_unload_schema()\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_load_schema(\r
-    khm_handle conf, \r
-    kconf_schema * schema);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_load_schema(khm_handle conf, \r
+                kconf_schema * schema);\r
 \r
 /*! \brief Unload a schema from a configuration space\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_unload_schema(\r
-    khm_handle conf, \r
-    kconf_schema * schema);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_unload_schema(khm_handle conf, \r
+                  kconf_schema * schema);\r
 \r
 /*! \brief Enumerate the subspaces of a configuration space\r
 \r
@@ -788,7 +835,7 @@ KHMEXP khm_int32 KHMAPI khc_unload_schema(
     \retval KHM_ERROR_SUCCESS The call succeeded.  There is a valid\r
         handle to a configuration space in \a first_subspace.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM Either \a conf or \a prev was not a\r
+    \retval KHM_ERROR_INVALID_PARAM Either \a conf or \a prev was not a\r
         valid configuration space handle or \a first_subspace is NULL.\r
         Note that \a prev can be NULL.\r
 \r
@@ -813,10 +860,10 @@ KHMEXP khm_int32 KHMAPI khc_unload_schema(
        However, the returned handle has the same domain restrictions\r
        as \a conf.\r
  */\r
-KHMEXP khm_int32 KHMAPI khc_enum_subspaces(\r
-    khm_handle conf,\r
-    khm_handle prev,\r
-    khm_handle * next);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_enum_subspaces(khm_handle conf,\r
+                   khm_handle prev,\r
+                   khm_handle * next);\r
 \r
 /*@}*/\r
 \r
index 1b4b70170c5e79e06449d5766ce8ea2bdd0e92db..6d5a63cbf985063295d421660e9efe3b32b6b95a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -62,7 +62,8 @@ typedef struct kconf_conf_space_t {
     TDCL(struct kconf_conf_space_t);\r
 } kconf_conf_space;\r
 \r
-#define KCONF_SPACE_FLAG_SCHEMA 32\r
+//#define KCONF_SPACE_FLAG_SCHEMA 0x00000020\r
+#define KCONF_SPACE_FLAG_DELETED 0x00000040\r
 \r
 typedef struct kconf_conf_handle_t {\r
     khm_int32   magic;\r
@@ -100,15 +101,25 @@ void exit_kconf(void);
 #define khc_is_machine_handle(h)    (((kconf_handle *) h)->flags & KCONF_FLAG_MACHINE)\r
 #define khc_handle_flags(h)         (((kconf_handle *) h)->flags)\r
 \r
-kconf_handle * khc_handle_from_space(kconf_conf_space * s, khm_int32 flags);\r
-void khc_handle_free(kconf_handle * h);\r
+kconf_handle *\r
+khcint_handle_from_space(kconf_conf_space * s, khm_int32 flags);\r
 \r
-kconf_conf_space * khc_create_empty_space(void);\r
-void khc_free_space(kconf_conf_space * r);\r
+void\r
+khcint_handle_free(kconf_handle * h);\r
 \r
-void khc_space_hold(kconf_conf_space * s);\r
-void khc_space_release(kconf_conf_space * s);\r
+kconf_conf_space *\r
+khcint_create_empty_space(void);\r
 \r
-HKEY khc_space_open_key(kconf_conf_space * s, khm_int32 flags);\r
+void\r
+khcint_free_space(kconf_conf_space * r);\r
+\r
+void\r
+khcint_space_hold(kconf_conf_space * s);\r
+\r
+void\r
+khcint_space_release(kconf_conf_space * s);\r
+\r
+HKEY\r
+khcint_space_open_key(kconf_conf_space * s, khm_int32 flags);\r
 \r
 #endif\r
index 8a9d6578c9ecff7b82fd7d8b5b07bfd77341575b..c49364ab28f6dff0edf3d5c8a2ededae38f45656 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 4a7b46682b3a46bd5ab8cd8b592297c9fada40c5..03b49b2c032b1b09b314f3cce6ccea9794e15943 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index e43540dc5123496b845ada1769d7180dee1fb3af..badfb2b497be054853aeb41950a535c8b8025293 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -33,27 +33,31 @@ kcdb_attrib_i ** kcdb_attrib_tbl = NULL;
 kcdb_attrib_i ** kcdb_property_tbl = NULL;\r
 kcdb_attrib_i * kcdb_attribs = NULL;\r
 \r
-void kcdb_attrib_add_ref_func(const void * key, void * va)\r
+void \r
+kcdb_attrib_add_ref_func(const void * key, void * va)\r
 {\r
     kcdb_attrib_hold((kcdb_attrib_i *) va);\r
 }\r
 \r
-void kcdb_attrib_del_ref_func(const void * key, void * va)\r
+void \r
+kcdb_attrib_del_ref_func(const void * key, void * va)\r
 {\r
     kcdb_attrib_release((kcdb_attrib_i *) va);\r
 }\r
 \r
-void kcdb_attrib_msg_completion(kmq_message * m) \r
+void \r
+kcdb_attrib_msg_completion(kmq_message * m) \r
 {\r
     if(m && m->vparam) {\r
         kcdb_attrib_release((kcdb_attrib_i *) m->vparam);\r
     }\r
 }\r
 \r
-khm_int32 kcdb_attrib_hold(kcdb_attrib_i * ai)\r
+khm_int32 \r
+kcdb_attrib_hold(kcdb_attrib_i * ai)\r
 {\r
     if(!ai)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     ai->refcount++;\r
@@ -61,10 +65,11 @@ khm_int32 kcdb_attrib_hold(kcdb_attrib_i * ai)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai)\r
+khm_int32 \r
+kcdb_attrib_release(kcdb_attrib_i * ai)\r
 {\r
     if(!ai)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     ai->refcount--;\r
@@ -72,16 +77,18 @@ khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-void kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)\r
+void \r
+kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)\r
 {\r
     kcdb_attrib_hold(ai);\r
     kmq_post_message(KMSG_KCDB, KMSG_KCDB_ATTRIB, op, (void *) ai);\r
 }\r
 \r
-khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle vcred, \r
-                                  khm_int32 attr, \r
-                                  void * buf, \r
-                                  khm_size * pcb_buf)\r
+khm_int32 KHMAPI \r
+kcdb_attr_sys_cb(khm_handle vcred, \r
+                 khm_int32 attr, \r
+                 void * buf, \r
+                 khm_size * pcb_buf)\r
 {\r
     kcdb_cred * c;\r
 \r
@@ -192,27 +199,28 @@ khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle vcred,
     }\r
 }\r
 \r
-void kcdb_attrib_init(void)\r
+void \r
+kcdb_attrib_init(void)\r
 {\r
     kcdb_attrib attrib;\r
     wchar_t sbuf[256];\r
 \r
     InitializeCriticalSection(&cs_attrib);\r
-    kcdb_attrib_namemap = hash_new_hashtable(\r
-        KCDB_ATTRIB_HASH_SIZE,\r
-        hash_string,\r
-        hash_string_comp,\r
-        kcdb_attrib_add_ref_func,\r
-        kcdb_attrib_del_ref_func);\r
+    kcdb_attrib_namemap = \r
+        hash_new_hashtable(KCDB_ATTRIB_HASH_SIZE,\r
+                           hash_string,\r
+                           hash_string_comp,\r
+                           kcdb_attrib_add_ref_func,\r
+                           kcdb_attrib_del_ref_func);\r
 \r
     kcdb_attrib_tbl = \r
-        malloc(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
+        PMALLOC(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
     assert(kcdb_attrib_tbl != NULL);\r
     ZeroMemory(kcdb_attrib_tbl, \r
                sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
 \r
     kcdb_property_tbl = \r
-        malloc(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
+        PMALLOC(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
     assert(kcdb_property_tbl != NULL);\r
     ZeroMemory(kcdb_property_tbl, \r
                sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
@@ -468,23 +476,25 @@ void kcdb_attrib_init(void)
     kcdb_attrib_register(&attrib, NULL);\r
 }\r
 \r
-void kcdb_attrib_exit(void)\r
+void \r
+kcdb_attrib_exit(void)\r
 {\r
     DeleteCriticalSection(&cs_attrib);\r
     \r
     if(kcdb_attrib_tbl)\r
-        free(kcdb_attrib_tbl);\r
+        PFREE(kcdb_attrib_tbl);\r
 \r
     if(kcdb_property_tbl)\r
-        free(kcdb_property_tbl);\r
+        PFREE(kcdb_property_tbl);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)\r
 {\r
     kcdb_attrib_i * ai;\r
 \r
     if(!name)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     ai = hash_lookup(kcdb_attrib_namemap, (void *) name);\r
@@ -499,7 +509,8 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)
     }\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)\r
 {\r
     kcdb_attrib_i * ai;\r
     size_t cb_name;\r
@@ -511,7 +522,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
     if(!attrib ||\r
         KHM_FAILED(kcdb_type_get_info(attrib->type, NULL)) ||\r
         !attrib->name)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(FAILED(StringCbLength(attrib->name, KCDB_MAXCB_NAME, &cb_name)))\r
         return KHM_ERROR_TOO_LONG;\r
@@ -535,50 +546,51 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
         (!attrib->compute_cb ||\r
         attrib->compute_min_cbsize <= 0 ||\r
         attrib->compute_max_cbsize < attrib->compute_min_cbsize))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if ((attrib->flags & KCDB_ATTR_FLAG_ALTVIEW) &&\r
         KHM_FAILED(kcdb_attrib_get_info(attrib->alt_id,\r
                                         NULL)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     prop = !!(attrib->flags & KCDB_ATTR_FLAG_PROPERTY);\r
 \r
     EnterCriticalSection(&cs_attrib);\r
 \r
-    if(\r
-        !prop && \r
-        (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID)) \r
+    if(!prop && \r
+       (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID)) \r
     {\r
         if(KHM_FAILED(kcdb_attrib_next_free_id(&attr_id))) {\r
             LeaveCriticalSection(&cs_attrib);\r
             return KHM_ERROR_NO_RESOURCES;\r
         }\r
-    } else if (\r
-        prop &&\r
-        (attrib->id < KCDB_ATTR_MIN_PROP_ID || attrib->id > KCDB_ATTR_MAX_PROP_ID))\r
-    {\r
+    } else if (prop &&\r
+               (attrib->id < KCDB_ATTR_MIN_PROP_ID || \r
+                attrib->id > KCDB_ATTR_MAX_PROP_ID)) {\r
+\r
         if(KHM_FAILED(kcdb_attrib_next_free_prop_id(&attr_id))) {\r
             LeaveCriticalSection(&cs_attrib);\r
             return KHM_ERROR_NO_RESOURCES;\r
         }\r
+\r
     } else {\r
         attr_id = attrib->id;\r
     }\r
 \r
 #ifdef DEBUG\r
     assert(!prop || (attr_id >= KCDB_ATTR_MIN_PROP_ID && attr_id <= KCDB_ATTR_MAX_PROP_ID));\r
-    assert(prop || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));\r
+    assert(prop  || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));\r
 #endif\r
 \r
     if((!prop && kcdb_attrib_tbl[attr_id]) ||\r
-        (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID])) \r
-    {\r
+       (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID])) {\r
+\r
         LeaveCriticalSection(&cs_attrib);\r
         return KHM_ERROR_DUPLICATE;\r
+\r
     }\r
 \r
-    ai = malloc(sizeof(kcdb_attrib_i));\r
+    ai = PMALLOC(sizeof(kcdb_attrib_i));\r
     ZeroMemory(ai, sizeof(kcdb_attrib_i));\r
 \r
     ai->attr.type = attrib->type;\r
@@ -588,14 +600,14 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
     ai->attr.compute_cb = attrib->compute_cb;\r
     ai->attr.compute_max_cbsize = attrib->compute_max_cbsize;\r
     ai->attr.compute_min_cbsize = attrib->compute_min_cbsize;\r
-    ai->attr.name = malloc(cb_name);\r
+    ai->attr.name = PMALLOC(cb_name);\r
     StringCbCopy(ai->attr.name, cb_name, attrib->name);\r
     if(cb_short_desc) {\r
-        ai->attr.short_desc = malloc(cb_short_desc);\r
+        ai->attr.short_desc = PMALLOC(cb_short_desc);\r
         StringCbCopy(ai->attr.short_desc, cb_short_desc, attrib->short_desc);\r
     }\r
     if(cb_long_desc) {\r
-        ai->attr.long_desc = malloc(cb_long_desc);\r
+        ai->attr.long_desc = PMALLOC(cb_long_desc);\r
         StringCbCopy(ai->attr.long_desc, cb_long_desc, attrib->long_desc);\r
     }\r
 \r
@@ -632,7 +644,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_info(
     else if(id >= KCDB_ATTR_MIN_PROP_ID && id <= KCDB_ATTR_MAX_PROP_ID)\r
         prop = TRUE;\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     if(prop)\r
@@ -679,7 +691,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_describe(
     khm_boolean prop;\r
 \r
     if(!cbsize)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(id >= 0 && id <= KCDB_ATTR_MAX_ID)\r
         prop = FALSE;\r
@@ -734,7 +746,7 @@ khm_int32 kcdb_attrib_next_free_prop_id(khm_int32 * id)
     int i;\r
 \r
     if(!id)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     for(i=0;i < KCDB_ATTR_MAX_PROPS; i++) {\r
@@ -757,7 +769,7 @@ khm_int32 kcdb_attrib_next_free_id(khm_int32 * id)
     int i;\r
 \r
     if(!id)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_attrib);\r
     for(i=0;i<= KCDB_ATTR_MAX_ID; i++) {\r
@@ -785,7 +797,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_count(
     int i;\r
 \r
     if(pcount == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     eq_flags &= and_flags;\r
 \r
@@ -819,7 +831,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_ids(
     int i;\r
 \r
     if(plist == NULL || pcsize == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     eq_flags &= and_flags;\r
 \r
index 5199aec9263322397312e6fecba5f6c72adb1cf6..f5647d67a670b7077b53d18124d23d9f60a1b0ee 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -52,4 +52,4 @@ khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai);
 void kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai);\r
 khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle cred, khm_int32 attr, void * buf, khm_size * pcb_buf);\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index 0f50be25d0e2e262976fc0e9306d2c06b5cef0c5..1811bc126d27f0a3b83d988182add56d44b1c910 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -29,7 +29,7 @@
 \r
 void kcdb_buf_new(kcdb_buf * buf, khm_size n_fields)\r
 {\r
-    buf->buffer = malloc(KCDB_BUF_CBBUF_INITIAL);\r
+    buf->buffer = PMALLOC(KCDB_BUF_CBBUF_INITIAL);\r
     buf->cb_buffer = KCDB_BUF_CBBUF_INITIAL;\r
     buf->cb_used = 0;\r
 \r
@@ -40,7 +40,7 @@ void kcdb_buf_new(kcdb_buf * buf, khm_size n_fields)
 \r
     buf->n_fields = n_fields;\r
     buf->nc_fields = UBOUNDSS(n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
-    buf->fields = malloc(sizeof(buf->fields[0]) * buf->n_fields);\r
+    buf->fields = PMALLOC(sizeof(buf->fields[0]) * buf->n_fields);\r
     ZeroMemory(buf->fields, sizeof(buf->fields[0]) * buf->n_fields);\r
 }\r
 \r
@@ -49,13 +49,13 @@ void kcdb_buf_delete(kcdb_buf * buf)
     buf->cb_buffer = 0;\r
     buf->cb_used = 0;\r
     if(buf->buffer)\r
-        free(buf->buffer);\r
+        PFREE(buf->buffer);\r
     buf->buffer = NULL;\r
 \r
     buf->n_fields = 0;\r
     buf->nc_fields = 0;\r
     if(buf->fields)\r
-        free(buf->fields);\r
+        PFREE(buf->fields);\r
     buf->fields = NULL;\r
 }\r
 \r
@@ -73,11 +73,11 @@ static void kcdb_buf_assert_size(kcdb_buf * buf, khm_size cbsize)
 \r
     assert(new_size > buf->cb_buffer && new_size > 0);\r
 \r
-    new_buf = malloc(new_size);\r
+    new_buf = PMALLOC(new_size);\r
     assert(new_buf != NULL);\r
 \r
     memcpy(new_buf, buf->buffer, buf->cb_used);\r
-    free(buf->buffer);\r
+    PFREE(buf->buffer);\r
     buf->buffer = new_buf;\r
 }\r
 \r
@@ -106,13 +106,13 @@ void kcdb_buf_alloc(kcdb_buf * buf, khm_size slot, khm_ui_2 id, khm_size cbsize)
 \r
         ns = UBOUNDSS((slot + 1), KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
 \r
-        nf = malloc(sizeof(buf->fields[0]) * ns);\r
+        nf = PMALLOC(sizeof(buf->fields[0]) * ns);\r
         memcpy(nf, buf->fields, sizeof(buf->fields[0]) * buf->n_fields);\r
 \r
         if(ns > buf->n_fields)\r
             memset(&(nf[buf->n_fields]), 0, sizeof(buf->fields[0]) * (ns - buf->n_fields));\r
 \r
-        free(buf->fields);\r
+        PFREE(buf->fields);\r
         buf->fields = nf;\r
         buf->nc_fields = ns;\r
     }\r
@@ -191,13 +191,13 @@ void kcdb_buf_dup(kcdb_buf * dest, const kcdb_buf * src)
 \r
     dest->cb_buffer = cb_buf;\r
     dest->cb_used = src->cb_used;\r
-    dest->buffer = malloc(cb_buf);\r
+    dest->buffer = PMALLOC(cb_buf);\r
     memcpy(dest->buffer, src->buffer, src->cb_used);\r
 \r
     nc_fields = UBOUNDSS(src->n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
     dest->nc_fields = nc_fields;\r
     dest->n_fields = src->n_fields;\r
-    dest->fields = malloc(nc_fields * sizeof(dest->fields[0]));\r
+    dest->fields = PMALLOC(nc_fields * sizeof(dest->fields[0]));\r
     memcpy(dest->fields, src->fields, src->n_fields * sizeof(dest->fields[0]));\r
     if(dest->n_fields < dest->nc_fields)\r
         memset(&(dest->fields[dest->n_fields]), 0, (src->nc_fields - src->n_fields) * sizeof(dest->fields[0]));\r
@@ -293,7 +293,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_get_attr(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_get_attr(record, attr_id, attr_type, buffer, pcb_buf);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib(\r
@@ -308,7 +308,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_get_attrib(record, attr_name, attr_type, buffer, pcb_buf);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_get_attr_string(\r
@@ -323,7 +323,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_get_attr_string(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_get_attr_string(record, attr_id, buffer, pcbbuf, flags);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib_string(\r
@@ -338,7 +338,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib_string(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_get_attrib_string(record, attr_name, buffer, pcbbuf, flags);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_set_attr(\r
@@ -352,7 +352,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_set_attr(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_set_attr(record, attr_id, buffer, cbbuf);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_set_attrib(\r
@@ -366,7 +366,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_set_attrib(
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_set_attrib(record, attr_name, buffer, cbbuf);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_hold(khm_handle  record)\r
@@ -376,7 +376,7 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_hold(khm_handle  record)
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_hold(record);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_buf_release(khm_handle record)\r
@@ -386,6 +386,6 @@ KHMEXP khm_int32 KHMAPI kcdb_buf_release(khm_handle record)
     else if(kcdb_is_active_identity(record))\r
         return kcdb_identity_release(record);\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
index 3ff1f041dd727cdbe781754b4444e42611b834d8..f47bd0a2a0ebe9464f2cedeea193fc91ac949fa6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 1fe1dcd97375c7f0123fbe3f72d910c212d1c87a..335521e126768e74e0e0e8fe036bd09c79eb4002 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -59,11 +59,11 @@ void kcdb_cred_exit(void)
     can be called by kcdb_cred_dup with a write lock on l_creds and in other\r
     places with a read lock on l_creds.  New credentials must be creatable while\r
     holding either lock. */\r
-KHMEXP khm_int32 KHMAPI kcdb_cred_create(\r
-    wchar_t *   name, \r
-    khm_handle  identity,\r
-    khm_int32   cred_type,\r
-    khm_handle * result) \r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_create(wchar_t *   name, \r
+                 khm_handle  identity,\r
+                 khm_int32   cred_type,\r
+                 khm_handle * result) \r
 {\r
     kcdb_cred * cred;\r
     size_t cb_name;\r
@@ -71,20 +71,18 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_create(
     if(!name || !result ||\r
         FAILED(StringCbLength(name, KCDB_CRED_MAXCB_NAME, &cb_name)) ||\r
         KHM_FAILED(kcdb_credtype_get_info(cred_type, NULL)) ||\r
-        KHM_FAILED(kcdb_identity_hold(identity))\r
-        )\r
-    {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        KHM_FAILED(kcdb_identity_hold(identity))) {\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     cb_name += sizeof(wchar_t);\r
 \r
-    cred = malloc(sizeof(kcdb_cred));\r
+    cred = PMALLOC(sizeof(kcdb_cred));\r
     ZeroMemory(cred, sizeof(kcdb_cred));\r
 \r
     cred->magic = KCDB_CRED_MAGIC;\r
     cred->identity = identity;\r
-    cred->name = malloc(cb_name);\r
+    cred->name = PMALLOC(cb_name);\r
     StringCbCopy(cred->name, cb_name, name);\r
     cred->type = cred_type;\r
 \r
@@ -107,9 +105,8 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_create(
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_cred_update(\r
-    khm_handle vdest,\r
-    khm_handle vsrc)\r
+KHMEXP khm_int32 KHMAPI kcdb_cred_update(khm_handle vdest,\r
+                                         khm_handle vsrc)\r
 {\r
     khm_int32 rv = KHM_ERROR_EQUIVALENT;\r
     kcdb_cred * src;\r
@@ -126,7 +123,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_update(
     kcdb_cred_lock_write();\r
 \r
     if(!kcdb_cred_is_active_cred(vsrc) ||\r
-        !kcdb_cred_is_active_cred(vdest))\r
+       !kcdb_cred_is_active_cred(vdest))\r
         goto _exit;\r
 \r
     src = (kcdb_cred *) vsrc;\r
@@ -192,24 +189,23 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_dup(
     khm_handle vnewcred;\r
 \r
     if(!pnewcred)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     *pnewcred = NULL;\r
 \r
     kcdb_cred_lock_write();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
     cred = (kcdb_cred *) vcred;\r
 \r
-    if(KHM_FAILED(kcdb_cred_create(\r
-        cred->name,\r
-        cred->identity,\r
-        cred->type,\r
-        &vnewcred))) \r
+    if(KHM_FAILED(kcdb_cred_create(cred->name,\r
+                                   cred->identity,\r
+                                   cred->type,\r
+                                   &vnewcred))) \r
     {\r
         code = KHM_ERROR_UNKNOWN;\r
         goto _exit;\r
@@ -236,20 +232,20 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_serial(
     kcdb_cred * c;\r
 \r
     if(!pserial)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        LockReleaseRead(&l_creds);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        kcdb_cred_unlock_read();\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     c = (kcdb_cred *) vcred;\r
 \r
     *pserial = c->id;\r
 \r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
@@ -261,12 +257,12 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_identity(
     kcdb_cred * c;\r
 \r
     if(!kcdb_is_identity(id))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     kcdb_cred_lock_write();\r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
         kcdb_cred_unlock_write();\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     c = (kcdb_cred *) vcred;\r
@@ -289,20 +285,20 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_type(
     kcdb_cred * c;\r
 \r
     if(!type)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        LockReleaseRead(&l_creds);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        kcdb_cred_unlock_read();\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     c = (kcdb_cred *) vcred;\r
 \r
     *type = c->type;\r
 \r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
@@ -316,7 +312,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attrib(
     khm_int32 attr_id = -1;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_id(name, &attr_id)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     return kcdb_cred_set_attr(\r
         cred,\r
@@ -338,20 +334,20 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr(
     khm_int32 code = KHM_ERROR_SUCCESS;\r
 \r
     if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     kcdb_cred_lock_write();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
         kcdb_cred_unlock_write();\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     cred = (kcdb_cred *) vcred;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
         kcdb_cred_unlock_write();\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED)\r
@@ -371,7 +367,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr(
     if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
         kcdb_cred_unlock_write();\r
         kcdb_attrib_release_info(attrib);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(!(type->isValid(buffer,cbbuf))) {\r
@@ -380,7 +376,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_attr(
     }\r
 \r
     if((type->dup(buffer, cbbuf, NULL, &cbdest)) != KHM_ERROR_TOO_LONG) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -450,12 +446,12 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attrib_string(
         flags);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr(\r
-    khm_handle vcred, \r
-    khm_int32 attr_id,\r
-    khm_int32 * attr_type,\r
-    void * buffer, \r
-    khm_size * pcbbuf)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_get_attr(khm_handle vcred, \r
+                   khm_int32 attr_id,\r
+                   khm_int32 * attr_type,\r
+                   void * buffer, \r
+                   khm_size * pcbbuf)\r
 {\r
     khm_int32 code = KHM_ERROR_SUCCESS;\r
     kcdb_cred * cred = NULL;\r
@@ -463,10 +459,10 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr(
     kcdb_type * type = NULL;\r
 \r
     if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
@@ -477,9 +473,9 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr(
     if(attr_type)\r
         *attr_type = attrib->type;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -511,7 +507,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr(
     }\r
 \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     if(type)\r
         kcdb_type_release_info(type);\r
     if(attrib)\r
@@ -533,10 +529,10 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr_string(
     kcdb_type * type = NULL;\r
 \r
     if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -545,17 +541,18 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr_string(
         goto _exit;\r
     }\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
     cred = (kcdb_cred *) vcred;\r
 \r
     if(!buffer && !pcbbuf) {\r
-        /* in this case the caller is only trying to determine if the field\r
-            contains data.  We assume that computed fields are always non-null. */\r
+        /* in this case the caller is only trying to determine if the\r
+            field contains data.  We assume that computed fields are\r
+            always non-null. */\r
         code = (kcdb_cred_val_exist(cred, attr_id) ||\r
             (attrib->flags & KCDB_ATTR_FLAG_COMPUTED))?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
         goto _exit;\r
@@ -565,27 +562,32 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr_string(
         void * buf;\r
         khm_size cbbuf;\r
 \r
-        code = attrib->compute_cb(\r
-            vcred,\r
-            attr_id,\r
-            NULL,\r
-            &cbbuf);\r
+        code = attrib->compute_cb(vcred,\r
+                                  attr_id,\r
+                                  NULL,\r
+                                  &cbbuf);\r
         if(code == KHM_ERROR_TOO_LONG) {\r
-            buf = malloc(cbbuf);\r
-            code = attrib->compute_cb(\r
-                vcred,\r
-                attr_id,\r
-                buf,\r
-                &cbbuf);\r
+            wchar_t vbuf[KCDB_MAXCCH_NAME];\r
+\r
+            if (cbbuf < sizeof(vbuf))\r
+                buf = vbuf;\r
+            else\r
+                buf = PMALLOC(cbbuf);\r
+\r
+            code = attrib->compute_cb(vcred,\r
+                                      attr_id,\r
+                                      buf,\r
+                                      &cbbuf);\r
             if(KHM_SUCCEEDED(code)) {\r
-                code = type->toString(\r
-                    buf,\r
-                    cbbuf,\r
-                    buffer,\r
-                    pcbbuf,\r
-                    flags);\r
+                code = type->toString(buf,\r
+                                      cbbuf,\r
+                                      buffer,\r
+                                      pcbbuf,\r
+                                      flags);\r
             }\r
-            free(buf);\r
+\r
+            if (buf != vbuf)\r
+                PFREE(buf);\r
         }\r
     } else {\r
         if(kcdb_cred_buf_exist(cred, attr_id)) {\r
@@ -600,7 +602,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr_string(
     }\r
 \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     if(type)\r
         kcdb_type_release_info(type);\r
     if(attrib)\r
@@ -620,12 +622,12 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_name(
     size_t cbsize;\r
 \r
     if(!cbbuf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -650,7 +652,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_name(
 \r
 _exit:\r
 \r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     return code;\r
 }\r
 \r
@@ -662,12 +664,12 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_identity(
     kcdb_cred * cred;\r
 \r
     if(!identity)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -678,7 +680,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_identity(
     *identity = cred->identity;\r
     \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     return code;\r
 }\r
 \r
@@ -689,8 +691,8 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_hold(khm_handle vcred)
 \r
     kcdb_cred_lock_write();\r
 \r
-    if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+    if(!kcdb_cred_is_cred(vcred)) {\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -710,8 +712,8 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_release(khm_handle vcred)
 \r
     kcdb_cred_lock_write();\r
 \r
-    if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+    if(!kcdb_cred_is_cred(vcred)) {\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -731,20 +733,17 @@ void kcdb_cred_check_and_delete(khm_handle vcred)
 {\r
     kcdb_cred * cred;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if(!kcdb_cred_is_cred(vcred)) {\r
         goto _exit;\r
     }\r
 \r
     cred = (kcdb_cred *) vcred;\r
 \r
-    if(!(cred->flags & KCDB_CRED_FLAG_DELETED))\r
-        goto _exit;\r
-\r
     if(cred->refcount)\r
         goto _exit;\r
 \r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     kcdb_cred_lock_write();\r
     if(!kcdb_cred_is_cred(vcred)) {\r
         /* did we lose the race? */\r
@@ -759,8 +758,8 @@ void kcdb_cred_check_and_delete(khm_handle vcred)
     LeaveCriticalSection(&cs_creds);\r
 \r
     kcdb_buf_delete(&cred->buf);\r
-    free(cred->name);\r
-    free(cred);\r
+    PFREE(cred->name);\r
+    PFREE(cred);\r
 \r
     /*TODO: notifications */\r
 \r
@@ -769,7 +768,7 @@ _exit2:
     return;\r
 \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_cred_delete(khm_handle vcred)\r
@@ -780,7 +779,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_delete(khm_handle vcred)
     kcdb_cred_lock_write();\r
 \r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -796,10 +795,10 @@ _exit:
     return code;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attrib(\r
-    khm_handle cred1, \r
-    khm_handle cred2, \r
-    wchar_t * name)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_comp_attrib(khm_handle cred1, \r
+                       khm_handle cred2, \r
+                       wchar_t * name)\r
 {\r
     khm_int32 attr_id;\r
 \r
@@ -809,10 +808,10 @@ KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attrib(
     return kcdb_creds_comp_attr(cred1, cred2, attr_id);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attr(\r
-    khm_handle vcred1, \r
-    khm_handle vcred2, \r
-    khm_int32 attr_id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_comp_attr(khm_handle vcred1, \r
+                     khm_handle vcred2, \r
+                     khm_int32 attr_id)\r
 {\r
     khm_int32 code = 0;\r
     kcdb_cred * cred1;\r
@@ -826,7 +825,7 @@ KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attr(
     cred1 = (kcdb_cred *) vcred1;\r
     cred2 = (kcdb_cred *) vcred2;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if(\r
         !kcdb_cred_is_active_cred(vcred1) ||\r
         !kcdb_cred_is_active_cred(vcred2))\r
@@ -858,6 +857,7 @@ KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attr(
         goto _exit;\r
 \r
     if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED) {\r
+        khm_octet  vbuf[KCDB_MAXCB_NAME * 2];\r
         void * buf1 = NULL;\r
         void * buf2 = NULL;\r
         khm_size cb1;\r
@@ -865,31 +865,43 @@ KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attr(
 \r
         code = 0;\r
 \r
-        if(attrib->compute_cb(vcred1, attr_id, NULL, &cb1) != KHM_ERROR_TOO_LONG)\r
+        if(attrib->compute_cb(vcred1, attr_id, \r
+                              NULL, &cb1) != KHM_ERROR_TOO_LONG)\r
             goto _exit_1;\r
 \r
-        if(attrib->compute_cb(vcred2, attr_id, NULL, &cb2) != KHM_ERROR_TOO_LONG)\r
+        if(attrib->compute_cb(vcred2, attr_id, \r
+                              NULL, &cb2) != KHM_ERROR_TOO_LONG)\r
             goto _exit_1;\r
 \r
         if(cb1) {\r
-            buf1 = malloc(cb1);\r
+            if (cb1 < sizeof(vbuf))\r
+                buf1 = vbuf;\r
+            else\r
+                buf1 = PMALLOC(cb1);\r
+\r
             if(KHM_FAILED(attrib->compute_cb(vcred1, attr_id, buf1, &cb1)))\r
                 goto _exit_1;\r
         }\r
+\r
         if(cb2) {\r
-            buf2 = malloc(cb2);\r
+            if (cb1 + cb2 < sizeof(vbuf))\r
+                buf2 = vbuf + cb1;\r
+            else\r
+                buf2 = PMALLOC(cb2);\r
+\r
             if(KHM_FAILED(attrib->compute_cb(vcred2, attr_id, buf2, &cb2)))\r
                 goto _exit_1;\r
         }\r
-        code = type->comp(\r
-            buf1, cb1,\r
-            buf2, cb2);\r
-_exit_1:\r
-        if(buf1)\r
-            free(buf1);\r
-        if(buf2)\r
-            free(buf2);\r
 \r
+        code = type->comp(buf1, cb1,\r
+                          buf2, cb2);\r
+_exit_1:\r
+        if(buf1 && (buf1 < (void *)vbuf || \r
+                    buf1 >= (void*)(vbuf + sizeof(vbuf))))\r
+            PFREE(buf1);\r
+        if(buf2 && (buf2 < (void *)vbuf ||\r
+                    buf2 >= (void *)(vbuf + sizeof(vbuf))))\r
+            PFREE(buf2);\r
     } else {\r
         code = type->comp(\r
             kcdb_cred_buf_get(cred1, attr_id),\r
@@ -899,7 +911,7 @@ _exit_1:
     }\r
 \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     if(attrib)\r
         kcdb_attrib_release_info(attrib);\r
     if(type)\r
@@ -907,17 +919,17 @@ _exit:
     return code;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_creds_is_equal(\r
-    khm_handle vcred1,\r
-    khm_handle vcred2)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_is_equal(khm_handle vcred1,\r
+                    khm_handle vcred2)\r
 {\r
     khm_int32 code = 0;\r
     kcdb_cred * cred1;\r
     kcdb_cred * cred2;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if(!kcdb_cred_is_active_cred(vcred1) ||\r
-        !kcdb_cred_is_active_cred(vcred2))\r
+       !kcdb_cred_is_active_cred(vcred2))\r
         goto _exit;\r
 \r
     if(vcred1 == vcred2) {\r
@@ -929,19 +941,30 @@ KHMEXP khm_int32 KHMAPI kcdb_creds_is_equal(
     cred2 = vcred2;\r
 \r
     if(cred1->identity == cred2->identity &&\r
-        cred1->type == cred2->type &&\r
-        !wcscmp(cred1->name, cred2->name)) {\r
+       cred1->type == cred2->type &&\r
+       !wcscmp(cred1->name, cred2->name)) {\r
+\r
+        kcdb_credtype * type;\r
+\r
         code = TRUE;\r
+\r
+        if (KHM_SUCCEEDED(kcdb_credtype_get_info(cred1->type, &type))) {\r
+            if (type->is_equal &&\r
+                (*type->is_equal)(vcred1, vcred2, NULL))\r
+                code = 0;\r
+\r
+            kcdb_credtype_release_info(type);\r
         }\r
+    }\r
 \r
 _exit:\r
-    LockReleaseRead(&l_creds);\r
+    kcdb_cred_unlock_read();\r
     return code;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_cred_get_flags(\r
-    khm_handle vcred,\r
-    khm_int32 * pflags)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_get_flags(khm_handle vcred,\r
+                    khm_int32 * pflags)\r
 {\r
     khm_int32 f;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -949,12 +972,12 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_flags(
     int release_lock = TRUE;\r
 \r
     if (pflags == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    LockObtainRead(&l_creds);\r
+    kcdb_cred_lock_read();\r
     if (!kcdb_cred_is_active_cred(vcred)) {\r
         *pflags = 0;\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -995,16 +1018,16 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_flags(
     /* Commented out: this is a read operation.  We shouldn't attempt\r
        to lock for writing */\r
     if (f != cred->flags) {\r
-        LockReleaseRead(&l_creds);\r
-        LockObtainWrite(&l_creds);\r
+        kcdb_cred_unlock_read();\r
+        kcdb_cred_lock_write();\r
         /* Did we lose a race? */\r
         if (kcdb_cred_is_active_cred(vcred))\r
             cred->flags = f;\r
         else {\r
-            rv = KHM_ERROR_INVALID_PARM;\r
+            rv = KHM_ERROR_INVALID_PARAM;\r
             f = 0;\r
         }\r
-        LockReleaseWrite(&l_creds);\r
+        kcdb_cred_unlock_write();\r
         release_lock = FALSE;\r
     }\r
 #endif\r
@@ -1013,7 +1036,7 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_flags(
 \r
  _exit:\r
     if (release_lock)\r
-        LockReleaseRead(&l_creds);\r
+        kcdb_cred_unlock_read();\r
 \r
     return rv;\r
 }\r
@@ -1026,9 +1049,9 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_flags(
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
     kcdb_cred * cred;\r
 \r
-    LockObtainWrite(&l_creds);\r
+    kcdb_cred_lock_write();\r
     if(!kcdb_cred_is_active_cred(vcred)) {\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -1042,6 +1065,6 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_set_flags(
         (flags & mask);\r
 \r
  _exit:\r
-    LockReleaseWrite(&l_creds);\r
+    kcdb_cred_unlock_write();\r
     return rv;\r
 }\r
index 8104f686b4c05633b8ef0fca3f17a2d70e71fa32..9cb70ab4d25f89b6d89e2879e366f1e69921897d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -58,6 +58,7 @@ extern khm_ui_8 kcdb_cred_id;
 \r
 #define kcdb_cred_is_cred(c)        ((c) && ((kcdb_cred *) c)->magic == KCDB_CRED_MAGIC)\r
 #define kcdb_cred_is_active_cred(c) (kcdb_cred_is_cred(c) && !(((kcdb_cred *) c)->flags & KCDB_CRED_FLAG_DELETED))\r
+\r
 #define kcdb_cred_lock_read()       (LockObtainRead(&l_creds))\r
 #define kcdb_cred_unlock_read()     (LockReleaseRead(&l_creds))\r
 #define kcdb_cred_lock_write()      (LockObtainWrite(&l_creds))\r
index 3a39d48a63e30998bbbd549846725d7f3d06dfbf..869cd8409da749c2fc5a362feaf2e6b49bdeb553 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -52,8 +52,11 @@ void kcdb_credset_exit(void)
 /* called on an unreleased credset, or with credset::cs held */\r
 void kcdb_credset_buf_new(kcdb_credset * cs)\r
 {\r
-    cs->clist = malloc(KCDB_CREDSET_INITIAL_SIZE * sizeof(kcdb_credset_credref));\r
-    ZeroMemory(cs->clist, KCDB_CREDSET_INITIAL_SIZE * sizeof(kcdb_credset_credref));\r
+    cs->clist = PMALLOC(KCDB_CREDSET_INITIAL_SIZE * \r
+                        sizeof(kcdb_credset_credref));\r
+    ZeroMemory(cs->clist, \r
+               KCDB_CREDSET_INITIAL_SIZE * \r
+               sizeof(kcdb_credset_credref));\r
     cs->nc_clist = KCDB_CREDSET_INITIAL_SIZE;\r
     cs->nclist = 0;\r
 }\r
@@ -61,7 +64,7 @@ void kcdb_credset_buf_new(kcdb_credset * cs)
 /* called on an unreleased credset, or with credset::cs held */\r
 void kcdb_credset_buf_delete(kcdb_credset * cs)\r
 {\r
-    free(cs->clist);\r
+    PFREE(cs->clist);\r
     cs->nc_clist = 0;\r
     cs->nclist = 0;\r
 }\r
@@ -80,7 +83,7 @@ void kcdb_credset_buf_assert_size(kcdb_credset * cs, khm_int32 nclist)
 \r
         memcpy(new_clist, cs->clist, cs->nclist * sizeof(kcdb_credset_credref));\r
 \r
-        free(cs->clist);\r
+        PFREE(cs->clist);\r
 \r
         cs->clist = new_clist;\r
     }\r
@@ -90,7 +93,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_create(khm_handle * result)
 {\r
     kcdb_credset * cs;\r
 \r
-    cs = malloc(sizeof(kcdb_credset));\r
+    cs = PMALLOC(sizeof(kcdb_credset));\r
     ZeroMemory(cs, sizeof(kcdb_credset));\r
 \r
     cs->magic = KCDB_CREDSET_MAGIC;\r
@@ -115,7 +118,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_delete(khm_handle vcredset)
     int i;\r
 \r
     if(!kcdb_credset_is_credset(vcredset)) {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     cs = (kcdb_credset *) vcredset;\r
@@ -137,7 +140,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_delete(khm_handle vcredset)
     LeaveCriticalSection(&(cs->cs));\r
     DeleteCriticalSection(&(cs->cs));\r
 \r
-    free(cs);\r
+    PFREE(cs);\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
@@ -153,14 +156,14 @@ cl1 and cl2.
 \r
 cl1 and cl2 will be modified.\r
 */\r
-khm_int32 kcdb_credset_collect_core(\r
-    kcdb_credset * cs1,\r
-    kcdb_cred ** cl1,\r
-    khm_int32 ncl1,\r
-    kcdb_credset * cs2,\r
-    kcdb_cred ** cl2,\r
-    khm_int32 ncl2,\r
-    khm_int32 * delta)\r
+khm_int32 \r
+kcdb_credset_collect_core(kcdb_credset * cs1,\r
+                          kcdb_cred ** cl1,\r
+                          khm_int32 ncl1,\r
+                          kcdb_credset * cs2,\r
+                          kcdb_cred ** cl2,\r
+                          khm_int32 ncl2,\r
+                          khm_int32 * delta)\r
 {\r
     int i, j;\r
     int ldelta = 0;\r
@@ -243,10 +246,10 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect(
         (cs_dest && !kcdb_credset_is_credset(cs_dest)) ||\r
         (cs_src == cs_dest)) /* works because credsets use shared\r
                                 handles */\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(identity && !kcdb_is_active_identity(identity))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(cs_src)\r
         cs = (kcdb_credset *) cs_src;\r
@@ -268,9 +271,9 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect(
        the ones we want */\r
 \r
     if(rcs->nclist > 0)\r
-        r_sel = malloc(sizeof(kcdb_cred *) * rcs->nclist);\r
+        r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);\r
     if(cs->nclist > 0)\r
-        c_sel = malloc(sizeof(kcdb_cred *) * cs->nclist);\r
+        c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);\r
     nr_sel = 0;\r
     nc_sel = 0;\r
 \r
@@ -307,9 +310,9 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect(
     LeaveCriticalSection(&(cs->cs));\r
 \r
     if(r_sel)\r
-        free(r_sel);\r
+        PFREE(r_sel);\r
     if(c_sel)\r
-        free(c_sel);\r
+        PFREE(c_sel);\r
 \r
     return code;\r
 }\r
@@ -335,7 +338,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect_filtered(
         (cs_dest && !kcdb_credset_is_credset(cs_dest)) ||\r
         (cs_src == cs_dest)) /* works because credsets use shared\r
                                 handles */\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(cs_src)\r
         cs = (kcdb_credset *) cs_src;\r
@@ -363,9 +366,9 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect_filtered(
 #endif\r
 \r
     if(rcs->nclist)\r
-        r_sel = malloc(sizeof(kcdb_cred *) * rcs->nclist);\r
+        r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);\r
     if(cs->nclist)\r
-        c_sel = malloc(sizeof(kcdb_cred *) * cs->nclist);\r
+        c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);\r
     nr_sel = 0;\r
     nc_sel = 0;\r
 \r
@@ -408,9 +411,9 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_collect_filtered(
     LeaveCriticalSection(&(cs->cs));\r
 \r
     if(r_sel)\r
-        free(r_sel);\r
+        PFREE(r_sel);\r
     if(c_sel)\r
-        free(c_sel);\r
+        PFREE(c_sel);\r
 \r
     return code;\r
 }\r
@@ -421,7 +424,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_flush(khm_handle vcredset)
     kcdb_credset * cs;\r
 \r
     if(!kcdb_credset_is_credset(vcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) vcredset;\r
 \r
@@ -459,11 +462,11 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_extract(
     int i;\r
 \r
     if(!kcdb_credset_is_credset(destcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(sourcecredset) {\r
         if(!kcdb_credset_is_credset(sourcecredset))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
     } else {\r
         sourcecredset = kcdb_root_credset;\r
     }\r
@@ -538,11 +541,11 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_extract_filtered(
     int i;\r
 \r
     if(!kcdb_credset_is_credset(destcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(sourcecredset) {\r
         if(!kcdb_credset_is_credset(sourcecredset))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
     } else {\r
         sourcecredset = kcdb_root_credset;\r
         isRoot = 1;\r
@@ -611,7 +614,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_apply(khm_handle vcredset, kcdb_cred_apply_
     int i;\r
 \r
     if(vcredset != NULL && !kcdb_credset_is_credset(vcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(vcredset == NULL) {\r
         cs = kcdb_root_credset;\r
@@ -654,7 +657,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_get_cred(
     khm_int32 code = KHM_ERROR_SUCCESS;\r
 \r
     if(!kcdb_credset_is_credset(vcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) vcredset;\r
 \r
@@ -692,7 +695,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_find_filtered(
 \r
     if((credset && !kcdb_credset_is_credset(credset)) ||\r
         (!f || !cred))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(credset)\r
         cs = (kcdb_credset *) credset;\r
@@ -743,10 +746,10 @@ kcdb_credset_find_cred(khm_handle vcredset,
     int idx;\r
 \r
     if (!kcdb_credset_is_credset(vcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if (!kcdb_cred_is_active_cred(vcred_src))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) vcredset;\r
 \r
@@ -784,7 +787,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_del_cred(
     khm_int32 code = KHM_ERROR_SUCCESS;\r
 \r
     if(!kcdb_credset_is_credset(vcredset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) vcredset;\r
 \r
@@ -793,7 +796,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_del_cred(
 \r
     EnterCriticalSection(&(cs->cs));\r
     if(idx < 0 || idx >= cs->nclist) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -828,7 +831,7 @@ khm_int32 kcdb_credset_update_cred_ref(
     int i;\r
 \r
     if(!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -858,7 +861,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_del_cred_ref(
     int i;\r
 \r
     if(!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -892,7 +895,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_add_cred(
     khm_int32 code = KHM_ERROR_SUCCESS;\r
 \r
     if(!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -958,7 +961,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_purge(khm_handle credset)
     int i,j;\r
 \r
     if(!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -996,7 +999,7 @@ kcdb_credset_seal(khm_handle credset) {
     kcdb_credset * cs;\r
 \r
     if (!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -1013,7 +1016,7 @@ kcdb_credset_unseal(khm_handle credset) {
     khm_int32 rv;\r
 \r
     if (!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -1046,7 +1049,9 @@ int __cdecl kcdb_creds_comp_wrapper(const void * a, const void * b)
         return 0;\r
     }\r
 \r
-    return comp((khm_handle) ((kcdb_credset_credref *)a)->cred, (khm_handle) ((kcdb_credset_credref *)b)->cred, rock);\r
+    return comp((khm_handle) ((kcdb_credset_credref *)a)->cred, \r
+                (khm_handle) ((kcdb_credset_credref *)b)->cred, \r
+                rock);\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kcdb_credset_sort(\r
@@ -1058,7 +1063,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_sort(
     kcdb_credset * cs;\r
 \r
     if(!kcdb_credset_is_credset(credset))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cs = (kcdb_credset *) credset;\r
 \r
@@ -1089,31 +1094,42 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_comp_generic(
     int i;\r
     khm_int32 r = 0;\r
     khm_int32 f1, f2;\r
+    khm_int32 t1, t2;\r
     khm_int32 pt;\r
 \r
     for(i=0; i<o->nFields; i++) {\r
         if (o->fields[i].order & KCDB_CRED_COMP_INITIAL_FIRST) {\r
 \r
-            kcdb_cred_get_flags(cred1, &f1);\r
-            kcdb_cred_get_flags(cred2, &f2);\r
+            if (o->fields[i].attrib == KCDB_ATTR_TYPE_NAME ||\r
+                o->fields[i].attrib == KCDB_ATTR_TYPE) {\r
 \r
-            if (((f1 ^ f2) & KCDB_CRED_FLAG_INITIAL) == 0) {\r
-                kcdb_cred_get_type(cred1, &f1);\r
-                kcdb_cred_get_type(cred2, &f2);\r
+                kcdb_cred_get_type(cred1, &t1);\r
+                kcdb_cred_get_type(cred2, &t2);\r
                 kcdb_identity_get_type(&pt);\r
 \r
-                if (f1 == f2)\r
+                if (t1 == t2)\r
                     r = 0;\r
-                else if (f1 == pt)\r
+                else if (t1 == pt)\r
                     r = -1;\r
-                else if (f2 == pt)\r
+                else if (t2 == pt)\r
                     r = 1;\r
                 else\r
                     r = 0;\r
-            } else if (f1 & KCDB_CRED_FLAG_INITIAL)\r
-                r = -1;\r
-            else\r
-                r = 1;\r
+\r
+            } else {\r
+\r
+                kcdb_cred_get_flags(cred1, &f1);\r
+                kcdb_cred_get_flags(cred2, &f2);\r
+\r
+                if (((f1 ^ f2) & KCDB_CRED_FLAG_INITIAL) == 0)\r
+                    r = 0;\r
+                else if (f1 & KCDB_CRED_FLAG_INITIAL)\r
+                    r = -1;\r
+                else\r
+                    r = 1;\r
+\r
+            }\r
+\r
         } else {\r
             r = 0;\r
         }\r
index c19246540dd7bb7567610c6fb19980f439741645..cd216fdd2588406f12ba31337029c343b5f4dd22 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -63,8 +63,8 @@ typedef struct kcdb_credset_t {
 \r
 #define kcdb_credset_is_sealed(c) ((c)->seal_count != 0)\r
 \r
-#define KCDB_CREDSET_INITIAL_SIZE 1024\r
-#define KCDB_CREDSET_GROWTH_FACTOR 1024\r
+#define KCDB_CREDSET_INITIAL_SIZE 256\r
+#define KCDB_CREDSET_GROWTH_FACTOR 256\r
 \r
 void kcdb_credset_init(void);\r
 void kcdb_credset_exit(void);\r
index dc2b7b85a06f3ef3636f5c4b9fa92a743249ce04..e57b22b5309ebfde62d7e1edea2c479c195317e1 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -34,14 +34,15 @@ void kcdb_credtype_init(void)
 {\r
     InitializeCriticalSection(&cs_credtype);\r
     kcdb_credtypes = NULL;\r
-    kcdb_credtype_tbl = malloc(sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
+\r
+    kcdb_credtype_tbl = PMALLOC(sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
     ZeroMemory(kcdb_credtype_tbl, sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
 }\r
 \r
 void kcdb_credtype_exit(void)\r
 {\r
     /*TODO:Free up the cred types */\r
-    free(kcdb_credtype_tbl);\r
+    PFREE(kcdb_credtype_tbl);\r
     DeleteCriticalSection(&cs_credtype);\r
 }\r
 \r
@@ -59,19 +60,20 @@ void kcdb_credtype_check_and_delete(khm_int32 id)
         kcdb_credtype_tbl[id] = NULL;\r
         LDELETE(&kcdb_credtypes, ict);\r
 \r
-        free(ict->ct.name);\r
+        PFREE(ict->ct.name);\r
         if(ict->ct.short_desc)\r
-            free(ict->ct.short_desc);\r
+            PFREE(ict->ct.short_desc);\r
         if(ict->ct.long_desc)\r
-            free(ict->ct.long_desc);\r
+            PFREE(ict->ct.long_desc);\r
         if(ict->ct.sub)\r
             kmq_delete_subscription(ict->ct.sub);\r
 \r
-        free(ict);\r
+        PFREE(ict);\r
     }\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 * new_id) \r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_credtype_register(kcdb_credtype * type, khm_int32 * new_id) \r
 {\r
     khm_int32 id;\r
     kcdb_credtype_i * ict;\r
@@ -81,17 +83,17 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 *
     int i;\r
 \r
     if(!type)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(type->id >= KCDB_CREDTYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(type->name) {\r
         if(FAILED(StringCbLength(type->name, KCDB_MAXCB_NAME, &cb_name)))\r
             return KHM_ERROR_TOO_LONG;\r
         cb_name += sizeof(wchar_t);\r
     } else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(type->short_desc) {\r
         if(FAILED(StringCbLength(type->short_desc, KCDB_MAXCB_SHORT_DESC, &cb_short_desc)))\r
@@ -108,7 +110,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 *
         cb_long_desc = 0;\r
 \r
     if(type->sub == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
 \r
@@ -133,19 +135,19 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 *
         }\r
     }\r
 \r
-    ict = malloc(sizeof(kcdb_credtype_i));\r
+    ict = PMALLOC(sizeof(kcdb_credtype_i));\r
     ZeroMemory(ict, sizeof(kcdb_credtype_i));\r
 \r
-    ict->ct.name = malloc(cb_name);\r
+    ict->ct.name = PMALLOC(cb_name);\r
     StringCbCopy(ict->ct.name, cb_name, type->name);\r
 \r
     if(cb_short_desc) {\r
-        ict->ct.short_desc = malloc(cb_short_desc);\r
+        ict->ct.short_desc = PMALLOC(cb_short_desc);\r
         StringCbCopy(ict->ct.short_desc, cb_short_desc, type->short_desc);\r
     }\r
 \r
     if(cb_long_desc) {\r
-        ict->ct.long_desc = malloc(cb_long_desc);\r
+        ict->ct.long_desc = PMALLOC(cb_long_desc);\r
         StringCbCopy(ict->ct.long_desc, cb_long_desc, type->long_desc);\r
     }\r
 \r
@@ -155,6 +157,8 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 *
 \r
     ict->ct.sub = type->sub;\r
 \r
+    ict->ct.is_equal = type->is_equal;\r
+\r
     kcdb_credtype_tbl[id] = ict;\r
 \r
     LPUSH(&kcdb_credtypes, ict);\r
@@ -176,7 +180,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_get_info(
     int found = 0;\r
 \r
     if(id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     if(kcdb_credtype_tbl[id] && \r
@@ -204,7 +208,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_release_info(kcdb_credtype * type)
     kcdb_credtype_i * ict;\r
 \r
     if(!type)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     ict = (kcdb_credtype_i *) type;\r
     return kcdb_credtype_release(ict);\r
@@ -215,7 +219,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_unregister(khm_int32 id)
     kcdb_credtype_i * ict;\r
 \r
     if(id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     ict = kcdb_credtype_tbl[id];\r
@@ -259,7 +263,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_describe(
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!cbbuf || id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     t = kcdb_credtype_tbl[id];\r
@@ -306,7 +310,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_get_name(
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!cbbuf || id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     t = kcdb_credtype_tbl[id];\r
@@ -340,7 +344,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_get_id(
 \r
     *id = 0;\r
     if(!name)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     for(i=0;i <= KCDB_CREDTYPE_MAX_ID; i++) {\r
@@ -379,7 +383,7 @@ khm_int32 kcdb_credtype_get_next_free_id(khm_int32 * id)
 khm_int32 kcdb_credtype_hold(kcdb_credtype_i * ict) {\r
     \r
     if(!ict)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     ict->refcount++;\r
@@ -390,7 +394,7 @@ khm_int32 kcdb_credtype_hold(kcdb_credtype_i * ict) {
 khm_int32 kcdb_credtype_release(kcdb_credtype_i * ict) {\r
     \r
     if(!ict)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_credtype);\r
     ict->refcount--;\r
index 6e46db303e613bf51d92ff66a9a37d02250fe256..aa605d73078d277e67c021800250a3797917718c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -52,4 +52,4 @@ void kcdb_credtype_msg_completion(kmq_message * m);
 void kcdb_credtype_post_message(khm_int32 op, kcdb_credtype * type);\r
 khm_int32 kcdb_credtype_get_next_free_id(khm_int32 * id);\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index d6ae129d6c9da4a7718552efc36f4204dac5a911..43dd425c4a46756b29e7d89fccb7ea103dd540f7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -27,7 +27,7 @@
 #include<kcreddbinternal.h>\r
 #include<assert.h>\r
 \r
-CRITICAL_SECTION cs_ident;\r
+static CRITICAL_SECTION cs_ident;\r
 hashtable * kcdb_identities_namemap = NULL;\r
 khm_int32 kcdb_n_identities = 0;\r
 kcdb_identity * kcdb_identities = NULL;\r
@@ -37,6 +37,16 @@ khm_int32  kcdb_ident_cred_type = KCDB_CREDTYPE_INVALID;
 /* primary credentials type */\r
 khm_ui_4 kcdb_ident_refresh_cycle = 0;\r
 khm_boolean kcdb_checked_config = FALSE;\r
+khm_boolean kcdb_checking_config = FALSE;\r
+\r
+KHMEXP khm_boolean KHMAPI\r
+kcdb_identity_is_equal(khm_handle identity1,\r
+                       khm_handle identity2)\r
+{\r
+\r
+    return (identity1 == identity2);\r
+\r
+}\r
 \r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identity_set_provider(khm_handle sub)\r
@@ -95,7 +105,7 @@ KHMEXP khm_int32 KHMAPI
 kcdb_identity_get_type(khm_int32 * ptype)\r
 {\r
     if (!ptype)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     *ptype = kcdb_ident_cred_type;\r
@@ -146,6 +156,7 @@ kcdbint_ident_exit(void) {
     DeleteCriticalSection(&cs_ident);\r
 }\r
 \r
+/* NOT called with cs_ident held */\r
 KHMEXP khm_boolean KHMAPI \r
 kcdb_identity_is_valid_name(const wchar_t * name)\r
 {\r
@@ -174,7 +185,7 @@ kcdb_identity_create(const wchar_t *name,
     size_t namesize;\r
 \r
     if(!result || !name)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     *result = NULL;\r
 \r
@@ -197,9 +208,10 @@ kcdb_identity_create(const wchar_t *name,
     /* nope. create it */\r
     if((flags & ~KCDB_IDENT_FLAGMASK_RDWR) ||\r
        (flags & (KCDB_IDENT_FLAG_DEFAULT |\r
-                 KCDB_IDENT_FLAG_SEARCHABLE))) {\r
+                 KCDB_IDENT_FLAG_SEARCHABLE |\r
+                 KCDB_IDENT_FLAG_STICKY))) {\r
         /* can't specify this flag in create */\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(!kcdb_identity_is_valid_name(name)) {\r
@@ -211,13 +223,13 @@ kcdb_identity_create(const wchar_t *name,
     StringCbLength(name, KCDB_IDENT_MAXCB_NAME, &namesize);\r
     namesize += sizeof(wchar_t);\r
 \r
-    id = malloc(sizeof(kcdb_identity));\r
+    id = PMALLOC(sizeof(kcdb_identity));\r
     ZeroMemory(id, sizeof(kcdb_identity));\r
     id->magic = KCDB_IDENT_MAGIC;\r
-    id->name = malloc(namesize);\r
+    id->name = PMALLOC(namesize);\r
     StringCbCopy(id->name, namesize, name);\r
 \r
-    id->flags = (flags & KCDB_IDENT_FLAGMASK_LOCAL);\r
+    id->flags = (flags & KCDB_IDENT_FLAGMASK_RDWR);\r
     id->flags |= KCDB_IDENT_FLAG_ACTIVE;\r
     LINIT(id);\r
 \r
@@ -228,8 +240,8 @@ kcdb_identity_create(const wchar_t *name,
         kcdb_identity_hold((khm_handle) id_tmp);\r
         *result = (khm_handle) id_tmp;\r
 \r
-        free(id->name);\r
-        free(id);\r
+        PFREE(id->name);\r
+        PFREE(id);\r
 \r
         id = NULL;\r
     } else {\r
@@ -245,7 +257,7 @@ kcdb_identity_create(const wchar_t *name,
                                                   0,\r
                                                   &h_cfg))) {\r
             /* don't need to set the KCDB_IDENT_FLAG_CONFIG flags\r
-               since kcdb_identity_get_conifg() sets it for us. */\r
+               since kcdb_identity_get_config() sets it for us. */\r
             khm_int32 sticky;\r
 \r
             if (KHM_SUCCEEDED(khc_read_int32(h_cfg, L"Sticky", &sticky)) &&\r
@@ -276,7 +288,7 @@ kcdb_identity_delete(khm_handle vid) {
 \r
     EnterCriticalSection(&cs_ident);\r
     if(!kcdb_is_identity(vid)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -301,8 +313,8 @@ kcdb_identity_delete(khm_handle vid) {
         LDELETE(&kcdb_identities, id);\r
 \r
         if (id->name)\r
-            free(id->name);\r
-        free(id);\r
+            PFREE(id->name);\r
+        PFREE(id);\r
     }\r
     /* else, we have an identity that is not active, but has\r
        outstanding references.  We have to wait until those references\r
@@ -323,36 +335,45 @@ kcdb_identity_delete(khm_handle vid) {
 \r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identity_set_flags(khm_handle vid, \r
-                        khm_int32 flag) {\r
+                        khm_int32 flag,\r
+                        khm_int32 mask) {\r
     kcdb_identity * id;\r
     khm_int32 oldflags;\r
     khm_int32 newflags;\r
     khm_int32 delta = 0;\r
     khm_int32 rv;\r
 \r
+    if (mask == 0)\r
+        return KHM_ERROR_SUCCESS;\r
+\r
     if(!kcdb_is_active_identity(vid))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     id = (kcdb_identity *) vid;\r
 \r
-    if((flag & ~(KCDB_IDENT_FLAGMASK_RDWR | KCDB_IDENT_FLAG_INVERT)) ||\r
-        ((flag & KCDB_IDENT_FLAG_INVALID) && (flag & KCDB_IDENT_FLAG_VALID)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+    flag &= mask;\r
+\r
+    if((mask & ~KCDB_IDENT_FLAGMASK_RDWR) ||\r
+       ((flag & KCDB_IDENT_FLAG_INVALID) && (flag & KCDB_IDENT_FLAG_VALID)))\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    if(flag & KCDB_IDENT_FLAG_DEFAULT) {\r
+    if((mask & KCDB_IDENT_FLAG_DEFAULT) &&\r
+       (flag & KCDB_IDENT_FLAG_DEFAULT)) {\r
         /* kcdb_identity_set_default already does checking for\r
            redundant transitions */\r
-        rv = kcdb_identity_set_default((flag & KCDB_IDENT_FLAG_INVERT)?NULL: vid);\r
+        rv = kcdb_identity_set_default(vid);\r
 \r
         if(KHM_FAILED(rv))\r
             return rv;\r
 \r
+        mask &= ~KCDB_IDENT_FLAG_DEFAULT;\r
         flag &= ~KCDB_IDENT_FLAG_DEFAULT;\r
     }\r
 \r
-    if(flag & KCDB_IDENT_FLAG_SEARCHABLE) {\r
-        if(flag & KCDB_IDENT_FLAG_INVERT) {\r
-            EnterCriticalSection(&cs_ident);\r
+    EnterCriticalSection(&cs_ident);\r
+\r
+    if(mask & KCDB_IDENT_FLAG_SEARCHABLE) {\r
+        if(!(flag & KCDB_IDENT_FLAG_SEARCHABLE)) {\r
             if(id->flags & KCDB_IDENT_FLAG_SEARCHABLE) {\r
                 LeaveCriticalSection(&cs_ident);\r
                 rv = kcdb_identpro_set_searchable(vid, FALSE);\r
@@ -363,9 +384,7 @@ kcdb_identity_set_flags(khm_handle vid,
                     delta |= KCDB_IDENT_FLAG_SEARCHABLE;\r
                 }\r
             }\r
-            LeaveCriticalSection(&cs_ident);\r
         } else {\r
-            EnterCriticalSection(&cs_ident);\r
             if(!(id->flags & KCDB_IDENT_FLAG_SEARCHABLE)) {\r
                 LeaveCriticalSection(&cs_ident);\r
                 rv = kcdb_identpro_set_searchable(vid, TRUE);\r
@@ -376,29 +395,50 @@ kcdb_identity_set_flags(khm_handle vid,
                     delta |= KCDB_IDENT_FLAG_SEARCHABLE;\r
                 }\r
             }\r
-            LeaveCriticalSection(&cs_ident);\r
         }\r
 \r
         flag &= ~KCDB_IDENT_FLAG_SEARCHABLE;\r
+        mask &= ~KCDB_IDENT_FLAG_SEARCHABLE;\r
+    }\r
+\r
+    if (mask & KCDB_IDENT_FLAG_STICKY) {\r
+        if ((flag ^ id->flags) & KCDB_IDENT_FLAG_STICKY) {\r
+            khm_handle h_conf;\r
+\r
+            if (KHM_SUCCEEDED(kcdb_identity_get_config(vid, \r
+                                                       KHM_FLAG_CREATE, \r
+                                                       &h_conf))) {\r
+                khc_write_int32(h_conf, L"Sticky",\r
+                                !!(flag & KCDB_IDENT_FLAG_STICKY));\r
+                khc_close_space(h_conf);\r
+            }\r
+\r
+            id->flags = \r
+                ((id->flags & ~KCDB_IDENT_FLAG_STICKY) |\r
+                 (flag & KCDB_IDENT_FLAG_STICKY));\r
+\r
+            delta |= KCDB_IDENT_FLAG_STICKY;\r
+        }\r
+\r
+        flag &= ~KCDB_IDENT_FLAG_STICKY;\r
+        mask &= ~KCDB_IDENT_FLAG_STICKY;\r
     }\r
 \r
     /* deal with every other flag */\r
 \r
-    EnterCriticalSection(&cs_ident);\r
     oldflags = id->flags;\r
-    if(flag & KCDB_IDENT_FLAG_INVERT) {\r
-        flag &= ~KCDB_IDENT_FLAG_INVERT;\r
-        id->flags &= ~flag;\r
-    } else {\r
-        id->flags |= flag;\r
 \r
-        if(flag & KCDB_IDENT_FLAG_VALID)\r
-            id->flags &= ~KCDB_IDENT_FLAG_INVALID;\r
-        if(flag & KCDB_IDENT_FLAG_INVALID)\r
-            id->flags &= ~KCDB_IDENT_FLAG_VALID;\r
-    }\r
+    id->flags = (id->flags & ~mask) | (flag & mask);\r
+\r
+    if (flag & KCDB_IDENT_FLAG_VALID)\r
+        id->flags &= ~KCDB_IDENT_FLAG_INVALID;\r
+    if (flag & KCDB_IDENT_FLAG_INVALID)\r
+        id->flags &= ~KCDB_IDENT_FLAG_VALID;\r
+\r
     newflags = id->flags;\r
+\r
     LeaveCriticalSection(&cs_ident);\r
+\r
     delta |= newflags ^ oldflags;\r
 \r
     if((delta & KCDB_IDENT_FLAG_HIDDEN)) {\r
@@ -427,7 +467,7 @@ kcdb_identity_get_flags(khm_handle vid,
     *flags = 0;\r
 \r
     if(!kcdb_is_active_identity(vid))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     id = (kcdb_identity *) vid;\r
 \r
@@ -444,7 +484,7 @@ kcdb_identity_get_name(khm_handle vid,
     kcdb_identity * id;\r
 \r
     if(!kcdb_is_active_identity(vid) || !pcbsize)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     id = (kcdb_identity *) vid;\r
 \r
@@ -469,7 +509,7 @@ kcdb_identity_get_default(khm_handle * pvid) {
     khm_handle def;\r
 \r
     if (pvid == NULL)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     def = kcdb_def_identity;\r
@@ -492,15 +532,16 @@ kcdbint_ident_set_default(khm_handle vid,
     kcdb_identity * old_def;\r
     khm_int32 rv;\r
 \r
-    if(vid != NULL && !kcdb_is_active_identity(vid))\r
-        return KHM_ERROR_INVALID_PARM;\r
+    if (vid != NULL && !kcdb_is_active_identity(vid))\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     new_def = (kcdb_identity *)vid;\r
 \r
-    if(new_def != NULL && (new_def->flags & KCDB_IDENT_FLAG_DEFAULT))\r
+    if (new_def != NULL && (new_def->flags & KCDB_IDENT_FLAG_DEFAULT))\r
         return KHM_ERROR_SUCCESS;\r
 \r
-    if(new_def == NULL && kcdb_def_identity == NULL)\r
+    if ((new_def == NULL && kcdb_def_identity == NULL) ||\r
+        (new_def == kcdb_def_identity))\r
         return KHM_ERROR_SUCCESS;\r
 \r
     /* first check with the identity provider if this operation\r
@@ -561,7 +602,7 @@ kcdb_identity_get_config(khm_handle vid,
     if(kcdb_is_active_identity(vid)) {\r
         id = (kcdb_identity *) vid;\r
     } else {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     hkcdb = kcdb_get_config();\r
@@ -609,7 +650,7 @@ kcdb_identity_hold(khm_handle vid) {
         id = vid;\r
         InterlockedIncrement(&(id->refcount));\r
     } else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     return ERROR_SUCCESS;\r
 }\r
 \r
@@ -631,7 +672,7 @@ kcdb_identity_release(khm_handle vid) {
             LeaveCriticalSection(&cs_ident);\r
         }\r
     } else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     return ERROR_SUCCESS;\r
 }\r
 \r
@@ -651,6 +692,7 @@ kcdbint_idref_proc(khm_handle cred, void * r) {
 \r
     if (KHM_SUCCEEDED(kcdb_cred_get_identity(cred, &vid))) {\r
         if (result->ident == (kcdb_identity *) vid) {\r
+\r
             result->count++;\r
             kcdb_cred_get_flags(cred, &flags);\r
 \r
@@ -684,12 +726,11 @@ kcdb_identity_refresh(khm_handle vid) {
     kcdb_identity * ident;\r
     khm_int32 code = KHM_ERROR_SUCCESS;\r
     struct kcdb_idref_result result;\r
-    khm_int32 flags;\r
 \r
     EnterCriticalSection(&cs_ident);\r
 \r
     if (!kcdb_is_active_identity(vid)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -699,20 +740,20 @@ kcdb_identity_refresh(khm_handle vid) {
     result.flags = 0;\r
     result.count = 0;\r
 \r
+    LeaveCriticalSection(&cs_ident);\r
+\r
     kcdb_credset_apply(NULL, kcdbint_idref_proc, &result);\r
 \r
     if (result.count == 0)\r
         result.flags |= KCDB_IDENT_FLAG_EMPTY;\r
 \r
-    kcdb_identity_set_flags(vid, result.flags);\r
-    kcdb_identity_get_flags(vid, &flags);\r
-    flags &= KCDB_IDENT_FLAGMASK_RDWR;\r
-    flags &= ~(KCDB_IDENT_FLAG_DEFAULT |\r
-               KCDB_IDENT_FLAG_SEARCHABLE);\r
-    flags ^= result.flags;\r
-    if (flags != 0)\r
-        kcdb_identity_set_flags(vid, flags | KCDB_IDENT_FLAG_INVERT);\r
+    kcdb_identity_set_flags(vid, result.flags,\r
+                            KCDB_IDENT_FLAGMASK_RDWR &\r
+                            ~(KCDB_IDENT_FLAG_DEFAULT |\r
+                              KCDB_IDENT_FLAG_SEARCHABLE |\r
+                              KCDB_IDENT_FLAG_STICKY));\r
 \r
+    EnterCriticalSection(&cs_ident);\r
     ident->refresh_cycle = kcdb_ident_refresh_cycle;\r
 \r
  _exit:\r
@@ -727,6 +768,7 @@ kcdb_identity_refresh(khm_handle vid) {
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identity_refresh_all(void) {\r
     kcdb_identity * ident;\r
+    kcdb_identity * next;\r
     khm_int32 code = KHM_ERROR_SUCCESS;\r
     int hit_count;\r
 \r
@@ -744,7 +786,9 @@ kcdb_identity_refresh_all(void) {
 \r
         for (ident = kcdb_identities; \r
              ident != NULL;\r
-             ident = LNEXT(ident)) {\r
+             ident = next) {\r
+\r
+            next = LNEXT(ident);\r
 \r
             if (!kcdb_is_active_identity(ident) ||\r
                 ident->refresh_cycle == kcdb_ident_refresh_cycle)\r
@@ -753,13 +797,16 @@ kcdb_identity_refresh_all(void) {
             kcdb_identity_hold((khm_handle) ident);\r
 \r
             LeaveCriticalSection(&cs_ident);\r
+\r
             kcdb_identity_refresh((khm_handle) ident);\r
+\r
             EnterCriticalSection(&cs_ident);\r
 \r
             kcdb_identity_release((khm_handle) ident);\r
 \r
             hit_count++;\r
         }\r
+\r
     } while (hit_count > 0);\r
 \r
     LeaveCriticalSection(&cs_ident);\r
@@ -786,7 +833,7 @@ kcdb_identity_set_attr(khm_handle vid,
     EnterCriticalSection(&cs_ident);\r
     if(!kcdb_is_active_identity(vid)) {\r
         LeaveCriticalSection(&cs_ident);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     id = (kcdb_identity *) vid;\r
@@ -798,7 +845,7 @@ kcdb_identity_set_attr(khm_handle vid,
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
         LeaveCriticalSection(&cs_ident);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
 #if 0\r
@@ -828,7 +875,7 @@ kcdb_identity_set_attr(khm_handle vid,
     if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
         LeaveCriticalSection(&cs_ident);\r
         kcdb_attrib_release_info(attrib);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(!(type->isValid(buffer,cbbuf))) {\r
@@ -837,7 +884,7 @@ kcdb_identity_set_attr(khm_handle vid,
     }\r
 \r
     if((type->dup(buffer, cbbuf, NULL, &cbdest)) != KHM_ERROR_TOO_LONG) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -869,8 +916,7 @@ _exit:
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_set_attrib(\r
-                         khm_handle vid,\r
+kcdb_identity_set_attrib(khm_handle vid,\r
                          wchar_t * attr_name,\r
                          void * buffer,\r
                          khm_size cbbuf)\r
@@ -878,7 +924,7 @@ kcdb_identity_set_attrib(
     khm_int32 attr_id = -1;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_id(attr_name, &attr_id)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     return kcdb_identity_set_attr(\r
         vid,\r
@@ -888,8 +934,7 @@ kcdb_identity_set_attrib(
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_get_attr(\r
-                       khm_handle vid,\r
+kcdb_identity_get_attr(khm_handle vid,\r
                        khm_int32 attr_id,\r
                        khm_int32 * attr_type,\r
                        void * buffer,\r
@@ -902,7 +947,7 @@ kcdb_identity_get_attr(
     khm_size slot;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
@@ -916,7 +961,7 @@ kcdb_identity_get_attr(
     EnterCriticalSection(&cs_ident);\r
 \r
     if(!kcdb_is_active_identity(vid)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -967,8 +1012,7 @@ _exit:
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_get_attrib(\r
-                         khm_handle vid,\r
+kcdb_identity_get_attrib(khm_handle vid,\r
                          wchar_t * attr_name,\r
                          khm_int32 * attr_type,\r
                          void * buffer,\r
@@ -979,12 +1023,11 @@ kcdb_identity_get_attrib(
     if(KHM_FAILED(kcdb_attrib_get_id(attr_name, &attr_id)))\r
         return KHM_ERROR_NOT_FOUND;\r
 \r
-    return kcdb_identity_get_attr(\r
-        vid,\r
-        attr_id,\r
-        attr_type,\r
-        buffer,\r
-        pcbbuf);\r
+    return kcdb_identity_get_attr(vid,\r
+                                  attr_id,\r
+                                  attr_type,\r
+                                  buffer,\r
+                                  pcbbuf);\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
@@ -1002,7 +1045,7 @@ kcdb_identity_get_attr_string(
     khm_size slot;\r
 \r
     if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
@@ -1013,7 +1056,7 @@ kcdb_identity_get_attr_string(
     EnterCriticalSection(&cs_ident);\r
 \r
     if(!kcdb_is_active_identity(vid)) {\r
-        code = KHM_ERROR_INVALID_PARM;\r
+        code = KHM_ERROR_INVALID_PARAM;\r
         goto _exit;\r
     }\r
 \r
@@ -1090,6 +1133,7 @@ kcdb_identity_get_attrib_string(
 /*****************************************/\r
 /* Identity provider interface functions */\r
 \r
+/* NOT called with cs_ident held */\r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identpro_validate_name(const wchar_t * name)\r
 {\r
@@ -1139,7 +1183,7 @@ kcdb_identpro_validate_identity(khm_handle identity)
     khm_handle sub;\r
 \r
     if(!kcdb_is_active_identity(identity))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     if(kcdb_ident_sub != NULL) {\r
@@ -1237,49 +1281,47 @@ kcdb_identpro_compare_name(
                            const wchar_t * name2)\r
 {\r
     khm_handle sub;\r
-       kcdb_ident_name_xfer namex;\r
-       khm_int32 rv = 0;\r
+    kcdb_ident_name_xfer namex;\r
+    khm_int32 rv = 0;\r
 \r
-       EnterCriticalSection(&cs_ident);\r
-       if(kcdb_ident_sub != NULL) {\r
+    EnterCriticalSection(&cs_ident);\r
+    if(kcdb_ident_sub != NULL) {\r
         sub = kcdb_ident_sub;\r
-       } else {\r
+    } else {\r
         sub = NULL;\r
-               /* Generally in kcdb_identpro_* functions we don't emulate\r
-                  any behavior if the provider is not available, but lacking\r
-                  a way to make this known, we emulate here */\r
-               rv = wcscmp(name1, name2);\r
-       }\r
-       LeaveCriticalSection(&cs_ident);\r
+        /* Generally in kcdb_identpro_* functions we don't emulate\r
+           any behavior if the provider is not available, but lacking\r
+           a way to make this known, we emulate here */\r
+        rv = wcscmp(name1, name2);\r
+    }\r
+    LeaveCriticalSection(&cs_ident);\r
 \r
     if(sub != NULL) {\r
-               ZeroMemory(&namex, sizeof(namex));\r
-               namex.name_src = name1;\r
-               namex.name_alt = name2;\r
-\r
-               kmq_send_sub_msg(\r
-                       sub,\r
-                       KMSG_IDENT,\r
-                       KMSG_IDENT_COMPARE_NAME,\r
-                       0,\r
-                       (void *) &namex);\r
-\r
-               rv = namex.result;\r
-    }\r
+        ZeroMemory(&namex, sizeof(namex));\r
+        namex.name_src = name1;\r
+        namex.name_alt = name2;\r
 \r
-       return rv;\r
+        kmq_send_sub_msg(sub,\r
+                         KMSG_IDENT,\r
+                         KMSG_IDENT_COMPARE_NAME,\r
+                         0,\r
+                         (void *) &namex);\r
+\r
+        rv = namex.result;\r
+    }\r
+    \r
+    return rv;\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-kcdb_identpro_set_default(\r
-                          khm_handle identity)\r
+kcdb_identpro_set_default(khm_handle identity)\r
 {\r
     khm_handle sub;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if((identity != NULL) && \r
        !kcdb_is_active_identity(identity))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     if(kcdb_ident_sub != NULL) {\r
@@ -1311,7 +1353,7 @@ kcdb_identpro_set_searchable(
        khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
        if(!kcdb_is_active_identity(identity))\r
-               return KHM_ERROR_INVALID_PARM;\r
+               return KHM_ERROR_INVALID_PARAM;\r
 \r
        EnterCriticalSection(&cs_ident);\r
        if(kcdb_ident_sub != NULL) {\r
@@ -1342,7 +1384,7 @@ kcdb_identpro_update(khm_handle identity)
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!kcdb_is_active_identity(identity))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     if(kcdb_ident_sub != NULL) {\r
@@ -1354,12 +1396,11 @@ kcdb_identpro_update(khm_handle identity)
     LeaveCriticalSection(&cs_ident);\r
 \r
     if(sub != NULL) {\r
-        rv = kmq_send_sub_msg(\r
-            sub,\r
-            KMSG_IDENT,\r
-            KMSG_IDENT_UPDATE,\r
-            0,\r
-            (void *) identity);\r
+        rv = kmq_send_sub_msg(sub,\r
+                              KMSG_IDENT,\r
+                              KMSG_IDENT_UPDATE,\r
+                              0,\r
+                              (void *) identity);\r
     }\r
 \r
     return rv;\r
@@ -1372,7 +1413,7 @@ kcdb_identpro_notify_create(khm_handle identity)
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!kcdb_is_active_identity(identity))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_ident);\r
     if(kcdb_ident_sub != NULL) {\r
@@ -1439,7 +1480,7 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_enum(
 \r
     if ((name_buf == NULL && pcb_buf == NULL && pn_idents == NULL) ||\r
         (name_buf != NULL && pcb_buf == NULL))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     eq_flags &= and_flags;\r
 \r
@@ -1450,6 +1491,9 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_enum(
         khm_handle h_idents = NULL;\r
         khm_handle h_ident = NULL;\r
 \r
+        kcdb_checked_config = TRUE;\r
+        kcdb_checking_config = TRUE;\r
+\r
         h_kcdb = kcdb_get_config();\r
         if (!h_kcdb)\r
             goto _config_check_cleanup;\r
@@ -1457,8 +1501,8 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_enum(
             goto _config_check_cleanup;\r
 \r
         while(KHM_SUCCEEDED(khc_enum_subspaces(h_idents,\r
-                                             h_ident,\r
-                                             &h_ident))) {\r
+                                               h_ident,\r
+                                               &h_ident))) {\r
 \r
             wchar_t wname[KCDB_IDENT_MAXCCH_NAME];\r
             khm_size cb;\r
@@ -1470,10 +1514,14 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_enum(
                                                      &cb)))\r
                 continue;\r
 \r
+            LeaveCriticalSection(&cs_ident);\r
+\r
             if (KHM_SUCCEEDED(kcdb_identity_create(wname,\r
-                                                 KCDB_IDENT_FLAG_CREATE,\r
-                                                 &t_id)))\r
+                                                   KCDB_IDENT_FLAG_CREATE,\r
+                                                   &t_id)))\r
                 kcdb_identity_release(t_id);\r
+\r
+            EnterCriticalSection(&cs_ident);\r
         }\r
 \r
     _config_check_cleanup:\r
@@ -1482,7 +1530,7 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_enum(
         if (h_idents)\r
             khc_close_space(h_idents);\r
 \r
-        kcdb_checked_config = TRUE;\r
+        kcdb_checking_config = FALSE;\r
     }\r
 \r
     for ( id = kcdb_identities;\r
index 6c7e26ee8602b08ec5e7743190584a27f85f8d51..be0205d9637ea89b06a655f11cc7b89a40a4efad 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -38,13 +38,11 @@ typedef struct kcdb_identity_t {
     khm_int32 refcount;\r
     kcdb_buf  buf;\r
     khm_ui_4  refresh_cycle;\r
-    struct kcdb_identity_t * next;\r
-    struct kcdb_identity_t * prev;\r
+    LDCL(struct kcdb_identity_t);\r
 } kcdb_identity;\r
 \r
 #define KCDB_IDENT_MAGIC 0x31938d4f\r
 \r
-extern CRITICAL_SECTION cs_ident;\r
 extern hashtable * kcdb_identities_namemap;\r
 extern khm_int32 kcdb_n_identities;\r
 extern kcdb_identity * kcdb_identities; /* all identities */\r
index 2df3f3e3f9bc252788cb30eafa56d8161a093623..13ef4da5524333792e8a6642c15ead3b38d1f8f3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index e5be0f4629882babad8bd557f9e9016598d4457f..e49c750d512a67967befdd019eacec998f8688c7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -110,12 +110,6 @@ Functions, macros etc. for manipulating identities.
     \note  Only to be used with kcdb_identity_create() */\r
 #define KCDB_IDENT_FLAG_CREATE      0x10000000L\r
 \r
-/*! \brief Inverts the accompanying flags.\r
-\r
-    \note Only to be used with kcdb_identity_set_flags()\r
-    \see kcdb_identity_set_flags() */\r
-#define KCDB_IDENT_FLAG_INVERT      0x40000000L\r
-\r
 /*! \brief Has configuration information\r
 \r
     Indicates that the identity has persistent configuration\r
@@ -132,12 +126,6 @@ Functions, macros etc. for manipulating identities.
         no longer have this flag. */\r
 #define KCDB_IDENT_FLAG_ACTIVE      0x02000000L\r
 \r
-/*! \brief Sticky identity\r
-\r
-    Sticky identities are identities that are always visible in the\r
-    credentials display even if no credentials are associated with it.\r
- */\r
-#define KCDB_IDENT_FLAG_STICKY      0x04000000L\r
 \r
 /*! \brief The identity has custom attributes assigned\r
  */\r
@@ -237,17 +225,18 @@ Functions, macros etc. for manipulating identities.
  */\r
 #define KCDB_IDENT_FLAG_CRED_RENEW  0x00000400L\r
 \r
-/*! \brief Bit mask for local flags\r
+/*! \brief Sticky identity\r
 \r
-    Local flags are those local to the KCDB.\r
+    Sticky identities are identities that are always visible in the\r
+    credentials display even if no credentials are associated with it.\r
  */\r
-#define KCDB_IDENT_FLAGMASK_LOCAL  0x0000ffffL\r
+#define KCDB_IDENT_FLAG_STICKY      0x00000800L\r
 \r
 /*! \brief Read/write flags mask.\r
 \r
     A bitmask that correspond to all the read/write flags in the mask.\r
 */\r
-#define KCDB_IDENT_FLAGMASK_RDWR   0x000007ffL\r
+#define KCDB_IDENT_FLAGMASK_RDWR   0x00000fffL\r
 \r
 /*@}*/\r
 \r
@@ -434,15 +423,10 @@ kcdb_identity_delete(khm_handle id);
 \r
 /*! \brief Set or unset the specified flags in the specified identity.\r
 \r
-    Only flags that are in KCDB_IDENT_FLAGMASK_RDWR can be specifed\r
-    in the flags parameter.  The only exception is the\r
-    KCDB_IDENT_FLAG_INVERT flag which controls whether the flags are\r
-    to be set or reset.\r
-\r
-    If the ::KCDB_IDENT_FLAG_INVERT flag is not specified in \a flags,\r
-    then any flags set in \a flags will also be set in the identity.\r
-    If the ::KCDB_IDENT_FLAG_INVERT is specified, then any flag set in\r
-    \a flags will be reset in the identity.\r
+    Only flags that are in KCDB_IDENT_FLAGMASK_RDWR can be specifed in\r
+    the \a flags parameter or the \a mask parameter.  The flags set in\r
+    the \a mask parameter of the identity will be set to the\r
+    corresponding values in the \a flags parameter.\r
 \r
     If ::KCDB_IDENT_FLAG_INVALID is set using this function, then the\r
     ::KCDB_IDENT_FLAG_VALID will be automatically reset, and vice\r
@@ -459,9 +443,8 @@ kcdb_identity_delete(khm_handle id);
     - ::KCDB_IDENT_FLAG_SEARCHABLE : Setting this will result in the\r
       identity provider getting notified of the change. If the\r
       identity provider indicates that searchable flag should not be\r
-      set or reset (according to KCDB_IDENT_FLAG_INVERT setting) on\r
-      the identity, then kcdb_identity_set_flags() will return an\r
-      error.\r
+      set or reset on the identity, then kcdb_identity_set_flags()\r
+      will return an error.\r
 \r
     \note kcdb_identity_set_flags() is not atomic.  Even if the\r
     function returns a failure code, some flags in the identity may\r
@@ -471,7 +454,8 @@ kcdb_identity_delete(khm_handle id);
 */\r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identity_set_flags(khm_handle id, \r
-                        khm_int32 flags);\r
+                        khm_int32 flags,\r
+                        khm_int32 mask);\r
 \r
 /*! \brief Return all the flags for the identity\r
 \r
@@ -612,6 +596,14 @@ kcdb_identity_get_provider(khm_handle * sub);
 KHMEXP khm_int32 KHMAPI \r
 kcdb_identity_get_type(khm_int32 * ptype);\r
 \r
+/*! \brief Returns TRUE if the two identities are equal\r
+\r
+    Also returns TRUE if both identities are NULL.\r
+ */\r
+KHMEXP khm_boolean KHMAPI\r
+kcdb_identity_is_equal(khm_handle identity1,\r
+                       khm_handle identity2);\r
+\r
 /*! \brief Set an attribute in an identity by attribute id\r
 \r
     \param[in] buffer A pointer to a buffer containing the data to\r
@@ -716,7 +708,7 @@ kcdb_identity_get_attrib(khm_handle identity,
     \retval KHM_ERROR_SUCCESS Success\r
     \retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
         or was not defined for this identity\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
         supplied buffer was insufficient\r
 */\r
@@ -799,7 +791,7 @@ kcdb_identity_get_attrib_string(khm_handle identity,
         buffer was insufficient.  If \a pn_idents was valid, it\r
         contains the number of identities.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM None of the parameters \a name_buf,\r
+    \retval KHM_ERROR_INVALID_PARAM None of the parameters \a name_buf,\r
         \a pcb_buf and \a pn_idents were supplied, or \a pcb_buf was\r
         NULL when \a name_buf was not.\r
 \r
@@ -898,6 +890,7 @@ typedef khm_int32
     - zero if \a cred1 == \a cred2\r
     - a postive value if \a cred1 > \a cred2\r
     \see kcdb_credset_sort()\r
+    \see ::kcdb_credtype\r
 */\r
 typedef khm_int32 \r
 (KHMAPI *kcdb_cred_comp_func)(khm_handle cred1, \r
@@ -1353,7 +1346,7 @@ kcdb_credset_purge(khm_handle credset);
     \retval KHM_ERROR_EXIT The supplied function signalled the\r
         processing to be aborted.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
 */\r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_credset_apply(khm_handle credset, \r
@@ -1525,6 +1518,13 @@ kcdb_cred_comp_generic(khm_handle cred1,
  */\r
 #define KCDB_CRED_FLAGMASK_ALL     0x0000ffff\r
 \r
+/*! \brief External flags\r
+\r
+    These are flags that are provided by the credentials providers.\r
+    The other flags are internal to KCDB and should not be modified.\r
+ */\r
+#define KCDB_CRED_FLAGMASK_EXT     (KCDB_CRED_FLAG_INITIAL | KCDB_CRED_FLAG_EXPIRED | KCDB_CRED_FLAG_INVALID | KCDB_CRED_FLAG_RENEWABLE)\r
+\r
 /*! \brief Bitmask indicating dditive flags \r
 \r
     Additive flags are special flags which are added to exiting\r
@@ -1748,7 +1748,7 @@ kcdb_cred_get_name(khm_handle cred,
     \retval KHM_ERROR_SUCCESS Success\r
     \retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
         or was not defined for this credential\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
         supplied buffer was insufficient\r
 */\r
@@ -1972,7 +1972,7 @@ kcdb_creds_is_equal(khm_handle cred1,
         field was successfully copied to \a s_buf and the size of the\r
         buffer used was copied to \a pcb_s_buf.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
 \r
     \retval KHM_ERROR_TOO_LONG Either \a s_buf was \a NULL or the size\r
         indicated by \a pcb_s_buf was too small to contain the string\r
@@ -2088,7 +2088,7 @@ typedef khm_int32
     \retval KHM_ERROR_SUCCESS The data was successfully copied.  The\r
         number of bytes copied is in \a pcb_data_dst\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters is incorrect.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters is incorrect.\r
 \r
     \retval KHM_ERROR_TOO_LONG Either \a data_dst was NULL or the size\r
         of the buffer was insufficient.  The required size is in \a\r
@@ -2317,7 +2317,7 @@ FtIntervalToString(LPFILETIME data,
     order in which the \a number \a unit specifications are given and\r
     the same unit may be repeated multiple times.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM The given string was invalid or had\r
+    \retval KHM_ERROR_INVALID_PARAM The given string was invalid or had\r
         a token that could not be parsed.  It can also mean that \a\r
         pft was NULL or \a str was NULL.\r
 \r
@@ -2443,15 +2443,19 @@ typedef struct tag_kcdb_attrib {
     khm_int32 flags;            /*!< Flags. Combination of \ref\r
                                   kcdb_credattr_flags "attribute\r
                                   flags" */\r
+\r
     khm_int32 type;             /*!< Type of the attribute.  Must be valid. */\r
+\r
     wchar_t * short_desc;       /*!< Short description. (Localized,\r
                                   optional) */\r
+\r
     wchar_t * long_desc;        /*!< Long description. (Localized,\r
                                   optional) */\r
 \r
     kcdb_attrib_compute_cb compute_cb;\r
                                 /*!< Callback.  Required if \a flags\r
                                   specify ::KCDB_ATTR_FLAG_COMPUTED. */\r
+\r
     khm_size compute_min_cbsize;\r
                                 /*!< Minimum number of bytes required\r
                                   to store this attribute.  Required\r
@@ -2807,25 +2811,37 @@ typedef struct tag_kcdb_credtype {
     wchar_t * name;     /*!< name (less than KCDB_MAXCB_NAME bytes) */\r
     khm_int32 id;\r
     wchar_t * short_desc;       /*!< short localized description (less\r
-                                     than KCDB_MAXCB_SHORT_DESC\r
-                                     bytes) */\r
+                                  than KCDB_MAXCB_SHORT_DESC bytes) */\r
     wchar_t * long_desc;        /*!< long localized descriptionn (less\r
-                                     than KCDB_MAXCB_LONG_DESC\r
-                                     bytes) */\r
+                                  than KCDB_MAXCB_LONG_DESC bytes) */\r
     khm_handle sub;             /*!< Subscription for credentials type\r
-                                     hander.  This should be a valid\r
-                                     subscription constructed through\r
-                                     a call to\r
-                                     kmq_create_subscription() and\r
-                                     must handle KMSG_CRED messages\r
-                                     that are marked as being sent to\r
-                                     type specific subscriptions.\r
-\r
-                                     The subscription will be\r
-                                     automatically deleted with a call\r
-                                     to kmq_delete_subscription() when\r
-                                     the credentials type is\r
-                                     unregistered.*/\r
+                                  hander.  This should be a valid\r
+                                  subscription constructed through a\r
+                                  call to kmq_create_subscription()\r
+                                  and must handle KMSG_CRED messages\r
+                                  that are marked as being sent to\r
+                                  type specific subscriptions.\r
+\r
+                                  The subscription will be\r
+                                  automatically deleted with a call to\r
+                                  kmq_delete_subscription() when the\r
+                                  credentials type is unregistered.*/\r
+\r
+    kcdb_cred_comp_func is_equal; /*!< Used to as an additional clause\r
+                                  when comparing two credentials for\r
+                                  equality.  The function this is\r
+                                  actually a comparison function, it\r
+                                  should return zero if the two\r
+                                  credentials are equal and non-zero\r
+                                  if they are not.  The addtional \a\r
+                                  rock parameter is always zero.\r
+\r
+                                  It can be assumed that the identity,\r
+                                  name and credentials have already\r
+                                  been found to be equal among the\r
+                                  credentials and the credential type\r
+                                  is the type that is being\r
+                                  registered.*/\r
 \r
 #ifdef _WIN32\r
     HICON icon;\r
@@ -2895,7 +2911,7 @@ typedef struct tag_kcdb_credtype {
 \r
     \retval KHM_ERROR_SUCCESS The credential type was successfully registered.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more of the parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more of the parameters were invalid\r
 \r
     \retval KHM_ERROR_TOO_LONG One or more of the string fields in \a\r
         type exceeded the character limit for that field.\r
@@ -2976,7 +2992,7 @@ kcdb_credtype_unregister(khm_int32 id);
     \retval KHM_ERROR_TOO_LONG Either \a buf was NULL or the supplied\r
         buffer was not large enough.  The required size is in \a cbbuf.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM Invalid parameter.\r
+    \retval KHM_ERROR_INVALID_PARAM Invalid parameter.\r
  */\r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_credtype_get_name(khm_int32 id,\r
@@ -3011,7 +3027,7 @@ kcdb_credtype_get_sub(khm_int32 id);
 \r
    \retval KHM_ERROR_SUCCESS The call succeeded\r
    \retval KHM_ERROR_TOO_LONG Either \a buf was NULL or the supplied buffer was insufficient.  The required size is specified in \a cbbuf.\r
-   \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+   \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
  */\r
 KHMEXP khm_int32 KHMAPI \r
 kcdb_credtype_describe(khm_int32 id,\r
@@ -3119,7 +3135,7 @@ kcdb_buf_get_attrib(khm_handle  record,
     \retval KHM_ERROR_SUCCESS Success\r
     \retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
         or was not defined for this record\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
         supplied buffer was insufficient\r
 */\r
index 699954cf016c14f951f0828e8fab312a5657dd51..f7bf4e7bd0d22fd320869307a35ebf0395a0e7a3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -57,4 +57,5 @@ void kcdb_init(void);
 void kcdb_exit(void);\r
 khm_handle kcdb_get_config(void);\r
 \r
-#endif
\ No newline at end of file
+\r
+#endif\r
index 796084a99572a35612eba8ccb2ccaa829f2a5cb7..8f8a01b0645bf8725fb325bd14afdc81e9b32407 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index e41694544bebf140701ad99a28d6904e7a77dbc9..004beb62f9487c3b7b44e2852a98caa880901691 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -46,7 +46,7 @@ khm_int32 KHMAPI kcdb_type_void_toString(
     size_t cbsize;\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cbsize = sizeof(GENERIC_VOID_STR);\r
 \r
@@ -87,7 +87,7 @@ khm_int32 KHMAPI kcdb_type_void_dup(
     khm_size * cbd_dst)\r
 {\r
     if(!cbd_dst)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     *cbd_dst = 0;\r
 \r
@@ -108,12 +108,12 @@ khm_int32 KHMAPI kcdb_type_string_toString(
     wchar_t * sd;\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     sd = (wchar_t *) d;\r
 \r
     if(FAILED(StringCbLength(sd, KCDB_TYPE_MAXCB, &cbsize)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cbsize += sizeof(wchar_t);\r
 \r
@@ -162,7 +162,7 @@ khm_int32 KHMAPI kcdb_type_string_dup(
     size_t cbsize;\r
 \r
     if(!cbd_dst)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(cbd_src == KCDB_CBSIZE_AUTO) {\r
         cbd_src = KCDB_TYPE_MAXCB;\r
@@ -205,7 +205,7 @@ khm_int32 KHMAPI kcdb_type_date_toString(
     int today = 0;\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     ft = (FILETIME *) d;\r
 \r
@@ -355,7 +355,7 @@ KHMEXP khm_int32 KHMAPI FtIntervalToString(LPFILETIME data, wchar_t * buffer, kh
     wchar_t * t;\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     s = *((__int64 *) data) / 10000000i64;\r
 \r
     m = s / 60;\r
@@ -511,7 +511,7 @@ khm_int32 KHMAPI kcdb_type_int32_toString(
     wchar_t ibuf[12];\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     StringCbPrintf(ibuf, sizeof(ibuf), L"%d", *((khm_int32 *) d));\r
     StringCbLength(ibuf, sizeof(ibuf), &cbsize);\r
@@ -573,7 +573,7 @@ khm_int32 KHMAPI kcdb_type_int64_toString(
     wchar_t ibuf[22];\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     StringCbPrintf(ibuf, sizeof(ibuf), L"%I64d", *((__int64 *) d));\r
     StringCbLength(ibuf, sizeof(ibuf), &cbsize);\r
@@ -636,7 +636,7 @@ khm_int32 KHMAPI kcdb_type_data_toString(
     size_t cbsize;\r
 \r
     if(!cb_buf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cbsize = sizeof(GENERIC_DATA_STR);\r
 \r
@@ -677,7 +677,7 @@ khm_int32 KHMAPI kcdb_type_data_dup(
     khm_size * cbd_dst)\r
 {\r
     if(!cbd_dst)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     *cbd_dst = cbd_src;\r
 \r
@@ -712,7 +712,7 @@ void kcdb_type_init(void)
         hash_string_comp,\r
         kcdb_type_add_ref,\r
         kcdb_type_del_ref);\r
-    kcdb_type_tbl = malloc(sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
+    kcdb_type_tbl = PMALLOC(sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
     ZeroMemory(kcdb_type_tbl, sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
     kcdb_types = NULL;\r
 \r
@@ -815,7 +815,7 @@ void kcdb_type_del_ref(const void *key, void *vt)
 khm_int32 kcdb_type_hold(kcdb_type_i * t)\r
 {\r
     if(!t)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_type);\r
     t->refcount++;\r
@@ -827,7 +827,7 @@ khm_int32 kcdb_type_hold(kcdb_type_i * t)
 khm_int32 kcdb_type_release(kcdb_type_i * t)\r
 {\r
     if(!t)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_type);\r
     t->refcount--;\r
@@ -840,7 +840,7 @@ khm_int32 kcdb_type_release(kcdb_type_i * t)
 void kcdb_type_exit(void)\r
 {\r
     EnterCriticalSection(&cs_type);\r
-    free(kcdb_type_tbl);\r
+    PFREE(kcdb_type_tbl);\r
     /*TODO: free up the individual types */\r
     LeaveCriticalSection(&cs_type);\r
     DeleteCriticalSection(&cs_type);\r
@@ -860,8 +860,8 @@ void kcdb_type_check_and_delete(khm_int32 id)
         LDELETE(&kcdb_types, t);\r
         /* must already be out of the hash-table, otherwise refcount should not\r
             be zero */\r
-        free(t->type.name);\r
-        free(t);\r
+        PFREE(t->type.name);\r
+        PFREE(t);\r
     }\r
     LeaveCriticalSection(&cs_type);\r
 }\r
@@ -873,7 +873,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_get_id(wchar_t *name, khm_int32 * id)
 \r
     if(FAILED(StringCbLength(name, KCDB_MAXCB_NAME, &cbsize))) {\r
         /* also fails of name is NULL */\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     EnterCriticalSection(&cs_type);\r
@@ -894,7 +894,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_get_info(khm_int32 id, kcdb_type ** info)
     kcdb_type_i * t;\r
 \r
     if(id < 0 || id > KCDB_TYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_type);\r
     t = kcdb_type_tbl[id];\r
@@ -922,7 +922,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_get_name(khm_int32 id, wchar_t * buffer, khm_s
     kcdb_type_i * t;\r
 \r
     if(id < 0 || id > KCDB_TYPE_MAX_ID || !cbbuf)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     t = kcdb_type_tbl[id];\r
 \r
@@ -957,25 +957,25 @@ KHMEXP khm_int32 KHMAPI kcdb_type_register(kcdb_type * type, khm_int32 * new_id)
         !type->isValid || \r
         !type->toString || \r
         !type->name)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if((type->flags & KCDB_TYPE_FLAG_CB_MIN) &&\r
         (type->cb_min < 0 || type->cb_min > KCDB_TYPE_MAXCB))\r
     {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if((type->flags & KCDB_TYPE_FLAG_CB_MAX) &&\r
         (type->cb_max < 0 || type->cb_max > KCDB_TYPE_MAXCB))\r
     {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if((type->flags & KCDB_TYPE_FLAG_CB_MIN) &&\r
         (type->flags & KCDB_TYPE_FLAG_CB_MAX) &&\r
         (type->cb_max < type->cb_min))\r
     {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     if(FAILED(StringCbLength(type->name, KCDB_MAXCB_NAME, &cbsize)))\r
@@ -988,7 +988,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_register(kcdb_type * type, khm_int32 * new_id)
         kcdb_type_get_next_free(&type_id);\r
     } else if(type->id < 0 || type->id > KCDB_TYPE_MAX_ID) {\r
         LeaveCriticalSection(&cs_type);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     } else if(kcdb_type_tbl[type->id]) {\r
         LeaveCriticalSection(&cs_type);\r
         return KHM_ERROR_DUPLICATE;\r
@@ -1001,10 +1001,10 @@ KHMEXP khm_int32 KHMAPI kcdb_type_register(kcdb_type * type, khm_int32 * new_id)
         return KHM_ERROR_NO_RESOURCES;\r
     }\r
 \r
-    t = malloc(sizeof(kcdb_type_i));\r
+    t = PMALLOC(sizeof(kcdb_type_i));\r
     ZeroMemory(t, sizeof(kcdb_type_i));\r
 \r
-    t->type.name = malloc(cbsize);\r
+    t->type.name = PMALLOC(cbsize);\r
     StringCbCopy(t->type.name, cbsize, type->name);\r
 \r
     t->type.comp = type->comp;\r
@@ -1036,7 +1036,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_unregister(khm_int32 id)
     kcdb_type_i * t;\r
 \r
     if(id < 0 || id > KCDB_TYPE_MAX_ID)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_type);\r
     t = kcdb_type_tbl[id];\r
@@ -1065,7 +1065,7 @@ KHMEXP khm_int32 KHMAPI kcdb_type_get_next_free(khm_int32 * id)
     int i;\r
 \r
     if(!id)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     /* do a linear search because this function only gets called a few times */\r
     EnterCriticalSection(&cs_type);\r
@@ -1246,7 +1246,7 @@ KHMEXP khm_int32 KHMAPI IntervalStringToFt(FILETIME * pft, wchar_t * str)
     }\r
 \r
     if(!str || FAILED(StringCbLength(str, MAX_IVL_SPECLIST_LEN, &cb)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     b = str;\r
     t = 0;\r
@@ -1269,7 +1269,7 @@ KHMEXP khm_int32 KHMAPI IntervalStringToFt(FILETIME * pft, wchar_t * str)
             b++;\r
 \r
         if(!*b) /* no unit specified */\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
 \r
         e = b;\r
 \r
@@ -1282,7 +1282,7 @@ KHMEXP khm_int32 KHMAPI IntervalStringToFt(FILETIME * pft, wchar_t * str)
         }\r
 \r
         if(i==MAX_IVL_UNITS)\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
 \r
         t += f * ivspecs[i].mul;\r
 \r
index 9d8b52e252135be43d5ec9a4f3525e92b4c6ec26..f7ef26ac446493c5eb49095075fb49fd15e51306 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -213,4 +213,4 @@ khm_int32 KHMAPI kcdb_type_data_dup(
     void * d_dst,\r
     khm_size * cbd_dst);\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index 04b45238b4ae3147f72ad1fdcd2091431ed5145a..cc4b9d3cc86508da0662173d936328e12bed317f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -41,10 +41,12 @@ kherr_handler_node * ctx_handlers = NULL;
 khm_size n_ctx_handlers;\r
 khm_size nc_ctx_handlers;\r
 \r
-khm_ui_4 ctx_serial = 0;\r
+kherr_serial ctx_serial = 0;\r
 \r
 #ifdef DEBUG\r
-static void DebugPrintf(wchar_t * fmt, ...) {\r
+#define DEBUG_CONTEXT\r
+\r
+KHMEXP void kherr_debug_printf(wchar_t * fmt, ...) {\r
     va_list vl;\r
     wchar_t buf[1024];\r
 \r
@@ -56,7 +58,8 @@ static void DebugPrintf(wchar_t * fmt, ...) {
 #endif\r
 \r
 KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h,\r
-                                         khm_int32 filter) {\r
+                                         khm_int32 filter,\r
+                                         kherr_serial serial) {\r
 \r
     assert(h);\r
 \r
@@ -64,17 +67,17 @@ KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h,
     if( ctx_handlers == NULL) {\r
         nc_ctx_handlers = CTX_ALLOC_INCR;\r
         n_ctx_handlers = 0;\r
-        ctx_handlers = malloc(sizeof(*ctx_handlers) * nc_ctx_handlers);\r
+        ctx_handlers = PMALLOC(sizeof(*ctx_handlers) * nc_ctx_handlers);\r
         /* No need to initialize */\r
     } else if (n_ctx_handlers == nc_ctx_handlers) {\r
         khm_size new_nc;\r
         kherr_handler_node * new_ctxs;\r
 \r
         new_nc = nc_ctx_handlers + CTX_ALLOC_INCR;\r
-        new_ctxs = malloc(sizeof(*new_ctxs) * new_nc);\r
-        memmove(new_ctxs, ctx_handlers, n_ctx_handlers);\r
+        new_ctxs = PMALLOC(sizeof(*new_ctxs) * new_nc);\r
+        memcpy(new_ctxs, ctx_handlers, n_ctx_handlers * sizeof(*new_ctxs));\r
 \r
-        free(ctx_handlers);\r
+        PFREE(ctx_handlers);\r
         ctx_handlers = new_ctxs;\r
         nc_ctx_handlers = new_nc;\r
     }\r
@@ -87,15 +90,21 @@ KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h,
 \r
     ctx_handlers[n_ctx_handlers].h = h;\r
     ctx_handlers[n_ctx_handlers].filter = filter;\r
+    ctx_handlers[n_ctx_handlers].serial = serial;\r
+\r
+    n_ctx_handlers++;\r
+\r
     LeaveCriticalSection(&cs_error);\r
 }\r
 \r
-KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h) {\r
+KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h,\r
+                                            kherr_serial serial) {\r
     khm_size i;\r
     EnterCriticalSection(&cs_error);\r
 \r
     for (i=0 ; i < n_ctx_handlers; i++) {\r
-        if (ctx_handlers[i].h == h) {\r
+        if (ctx_handlers[i].h == h &&\r
+            ctx_handlers[i].serial == serial) {\r
             break;\r
         }\r
     }\r
@@ -114,9 +123,25 @@ KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h) {
 void notify_ctx_event(enum kherr_ctx_event e, kherr_context * c) {\r
     khm_size i;\r
 \r
+    kherr_ctx_handler h;\r
+\r
     for (i=0; i<n_ctx_handlers; i++) {\r
-        if (ctx_handlers[i].filter & e)\r
-            ctx_handlers[i].h(e,c);\r
+        if (ctx_handlers[i].h && (ctx_handlers[i].filter & e) &&\r
+            (ctx_handlers[i].serial == 0 ||\r
+             ctx_handlers[i].serial == c->serial)) {\r
+            if (IsBadCodePtr((FARPROC) ctx_handlers[i].h)) {\r
+                ctx_handlers[i].h = NULL;\r
+            } else {\r
+                h = ctx_handlers[i].h;\r
+                (*h)(e,c);\r
+\r
+                /* a context handler is allowed to remove itself\r
+                   during a callback.  It is, however, not allowed to\r
+                   remove anything else. */\r
+                if (h != ctx_handlers[i].h)\r
+                    i--;\r
+            }\r
+        }\r
     }\r
 }\r
 \r
@@ -127,8 +152,8 @@ void attach_this_thread(void) {
     if (t)\r
         return;\r
 \r
-    t = malloc(sizeof(kherr_thread) + \r
-               sizeof(kherr_context *) * THREAD_STACK_SIZE);\r
+    t = PMALLOC(sizeof(kherr_thread) + \r
+                sizeof(kherr_context *) * THREAD_STACK_SIZE);\r
     t->nc_ctx = THREAD_STACK_SIZE;\r
     t->n_ctx = 0;\r
     t->ctx = (kherr_context **) &t[1];\r
@@ -145,7 +170,7 @@ void detach_this_thread(void) {
         for(i=0; i < t->n_ctx; i++) {\r
             kherr_release_context(t->ctx[i]);\r
         }\r
-        free(t);\r
+        PFREE(t);\r
         TlsSetValue(tls_error, 0);\r
     }\r
 }\r
@@ -182,13 +207,13 @@ void push_context(kherr_context * c) {
         cb_new = sizeof(kherr_thread) + \r
             sizeof(kherr_context *) * nc_new;\r
 \r
-        nt = malloc(cb_new);\r
+        nt = PMALLOC(cb_new);\r
         memcpy(nt, t, sizeof(kherr_thread) +\r
                sizeof(kherr_context *) * t->n_ctx);\r
         nt->ctx = (kherr_context **) &nt[1];\r
         nt->nc_ctx = nc_new;\r
 \r
-        free(t);\r
+        PFREE(t);\r
         t = nt;\r
         TlsSetValue(tls_error, t);\r
     }\r
@@ -220,10 +245,11 @@ kherr_event * get_empty_event(void) {
     kherr_event * e;\r
 \r
     EnterCriticalSection(&cs_error);\r
-    if(evt_free_list)\r
+    if(evt_free_list) {\r
         LPOP(&evt_free_list, &e);\r
-    else\r
-        e = malloc(sizeof(*e));\r
+    } else {\r
+        e = PMALLOC(sizeof(*e));\r
+    }\r
     LeaveCriticalSection(&cs_error);\r
     ZeroMemory(e, sizeof(*e));\r
     e->severity = KHERR_NONE;\r
@@ -235,61 +261,63 @@ kherr_event * get_empty_event(void) {
 void free_event_params(kherr_event * e) {\r
     if(parm_type(e->p1) == KEPT_STRINGT) {\r
         assert((void *) parm_data(e->p1));\r
-        free((void*) parm_data(e->p1));\r
+        PFREE((void*) parm_data(e->p1));\r
         e->p1 = (kherr_param) 0;\r
     }\r
     if(parm_type(e->p2) == KEPT_STRINGT) {\r
         assert((void *) parm_data(e->p2));\r
-        free((void*) parm_data(e->p2));\r
+        PFREE((void*) parm_data(e->p2));\r
         e->p2 = (kherr_param) 0;\r
     }\r
     if(parm_type(e->p3) == KEPT_STRINGT) {\r
         assert((void *) parm_data(e->p3));\r
-        free((void*) parm_data(e->p3));\r
+        PFREE((void*) parm_data(e->p3));\r
         e->p3 = (kherr_param) 0;\r
     }\r
     if(parm_type(e->p4) == KEPT_STRINGT) {\r
         assert((void *) parm_data(e->p4));\r
-        free((void*) parm_data(e->p4));\r
+        PFREE((void*) parm_data(e->p4));\r
         e->p4 = (kherr_param) 0;\r
     }\r
 }\r
 \r
 void free_event(kherr_event * e) {\r
+\r
+    EnterCriticalSection(&cs_error);\r
+\r
     assert(e->magic == KHERR_EVENT_MAGIC);\r
 \r
-#ifdef DEBUG\r
-    DebugPrintf(L"Freeing event 0x%x\n", e);\r
+#ifdef DEBUG_CONTEXT\r
+    kherr_debug_printf(L"Freeing event 0x%x\n", e);\r
     if (!(e->flags & KHERR_RF_STR_RESOLVED))\r
         resolve_event_strings(e);\r
     if (e->short_desc)\r
-        DebugPrintf(L"  Desc(S):[%s]\n", e->short_desc);\r
+        kherr_debug_printf(L"  Desc(S):[%s]\n", e->short_desc);\r
     if (e->long_desc)\r
-        DebugPrintf(L"  Desc(L):[%s]\n", e->long_desc);\r
+        kherr_debug_printf(L"  Desc(L):[%s]\n", e->long_desc);\r
     if (e->suggestion)\r
-        DebugPrintf(L"  Suggest:[%s]\n", e->suggestion);\r
+        kherr_debug_printf(L"  Suggest:[%s]\n", e->suggestion);\r
     if (e->facility)\r
-        DebugPrintf(L"  Facility:[%s]\n", e->facility);\r
+        kherr_debug_printf(L"  Facility:[%s]\n", e->facility);\r
 #endif\r
 \r
     if(e->flags & KHERR_RF_FREE_SHORT_DESC) {\r
         assert(e->short_desc);\r
-        free((void *) e->short_desc);\r
+        PFREE((void *) e->short_desc);\r
     }\r
     if(e->flags & KHERR_RF_FREE_LONG_DESC) {\r
         assert(e->long_desc);\r
-        free((void *) e->long_desc);\r
+        PFREE((void *) e->long_desc);\r
     }\r
     if(e->flags & KHERR_RF_FREE_SUGGEST) {\r
         assert(e->suggestion);\r
-        free((void *) e->suggestion);\r
+        PFREE((void *) e->suggestion);\r
     }\r
 \r
     free_event_params(e);\r
 \r
     ZeroMemory(e, sizeof(e));\r
 \r
-    EnterCriticalSection(&cs_error);\r
     LPUSH(&evt_free_list, e);\r
     LeaveCriticalSection(&cs_error);\r
 }\r
@@ -301,7 +329,7 @@ kherr_context * get_empty_context(void) {
     if(ctx_free_list)\r
         LPOP(&ctx_free_list, &c);\r
     else {\r
-        c = malloc(sizeof(kherr_context));\r
+        c = PMALLOC(sizeof(kherr_context));\r
     }\r
  \r
     ZeroMemory(c,sizeof(*c));\r
@@ -325,8 +353,8 @@ void free_context(kherr_context * c) {
     kherr_event * e;\r
 \r
     assert(c->magic == KHERR_CONTEXT_MAGIC);\r
-#ifdef DEBUG\r
-    DebugPrintf(L"Freeing context 0x%x\n", c);\r
+#ifdef DEBUG_CONTEXT\r
+    kherr_debug_printf(L"Freeing context 0x%x\n", c);\r
 #endif\r
 \r
     EnterCriticalSection(&cs_error);\r
@@ -351,12 +379,11 @@ void free_context(kherr_context * c) {
     LPUSH(&ctx_free_list,c);\r
     LeaveCriticalSection(&cs_error);\r
 \r
-#ifdef DEBUG\r
-    DebugPrintf(L"Done with context 0x%x\n", c);\r
+#ifdef DEBUG_CONTEXT\r
+    kherr_debug_printf(L"Done with context 0x%x\n", c);\r
 #endif\r
 }\r
 \r
-\r
 void add_event(kherr_context * c, kherr_event * e)\r
 {\r
     EnterCriticalSection(&cs_error);\r
@@ -466,7 +493,7 @@ static void resolve_string_resource(kherr_event * e,
                 *str = NULL;\r
             } else {\r
                 bytes = (chars + 1) * sizeof(wchar_t);\r
-                s = malloc(bytes);\r
+                s = PMALLOC(bytes);\r
                 assert(s);\r
                 StringCbCopy(s, bytes, tbuf);\r
                 *str = s;\r
@@ -515,7 +542,7 @@ static void resolve_msg_resource(kherr_event * e,
                 tbuf[--chars] = L'\0';\r
 \r
             bytes = (chars + 1) * sizeof(wchar_t);\r
-            s = malloc(bytes);\r
+            s = PMALLOC(bytes);\r
             assert(s);\r
             StringCbCopy(s, bytes, tbuf);\r
             *str = s;\r
@@ -551,7 +578,7 @@ static void resolve_string(kherr_event * e,
                               (va_list *) args);\r
 \r
         if ((e->flags & mask) == free_if) {\r
-            free((void *) *str);\r
+            PFREE((void *) *str);\r
         }\r
 \r
         e->flags &= ~mask;\r
@@ -562,7 +589,7 @@ static void resolve_string(kherr_event * e,
             wchar_t * s;\r
 \r
             bytes = (chars + 1) * sizeof(wchar_t);\r
-            s = malloc(bytes);\r
+            s = PMALLOC(bytes);\r
             assert(s);\r
             StringCbCopy(s, bytes, tbuf);\r
             *str = s;\r
@@ -704,9 +731,7 @@ kherr_report(enum kherr_severity severity,
     if(!c) {\r
         /* the reason why we are doing it this way is because p1..p4,\r
            the descriptions and the suggestion may contain allocations\r
-           that has to be freed.  In terms of performance we are\r
-           assuming that this case doesn't happen that much. Har\r
-           har */\r
+           that has to be freed. */\r
         free_event(e);\r
         e = NULL;\r
     } else {\r
@@ -908,7 +933,7 @@ KHMEXP void KHMAPI kherr_push_new_context(khm_int32 flags)
 \r
 kherr_param dup_parm(kherr_param p) {\r
     if(parm_type(p) == KEPT_STRINGT) {\r
-        wchar_t * d = wcsdup((wchar_t *)parm_data(p));\r
+        wchar_t * d = PWCSDUP((wchar_t *)parm_data(p));\r
         return kherr_val(KEPT_STRINGT, d);\r
     } else\r
         return p;\r
@@ -1154,7 +1179,7 @@ KHMEXP kherr_param kherr_dup_string(const wchar_t * s)
     else\r
         cb_s += sizeof(wchar_t);\r
 \r
-    dest = malloc(cb_s);\r
+    dest = PMALLOC(cb_s);\r
     assert(dest != NULL);\r
     dest[0] = L'\0';\r
 \r
index 7ccc6e56094fac62c18509a5de6ba742900f1703..973390f5eb5c7d68e5bd0ac12fc816f250d9031f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -261,13 +261,16 @@ enum kherr_event_flags {
                                   longer considered significant. */\r
 };\r
 \r
+/*! \brief Serial number for error contexts */\r
+typedef khm_ui_4 kherr_serial;\r
+\r
 /*! \brief An error context\r
 */\r
 typedef struct tag_kherr_context {\r
     khm_int32      magic;       /*!< Magic number. Always set to\r
                                   KHERR_CONTEXT_MAGIC */\r
 \r
-    khm_ui_4       serial;      /*!< Context instance serial number.\r
+    kherr_serial   serial;      /*!< Context instance serial number.\r
                                   Context objects themselves may be\r
                                   reused for different contexts as\r
                                   they are freed and reallocated.\r
@@ -383,7 +386,8 @@ enum kherr_ctx_event {
 \r
     \see kherr_add_ctx_handler()\r
  */\r
-typedef void (*kherr_ctx_handler)(enum kherr_ctx_event, kherr_context *);\r
+typedef void (KHMAPI * kherr_ctx_handler)(enum kherr_ctx_event, \r
+                                         kherr_context *);\r
 \r
 /*! \brief Add a context event handler\r
 \r
@@ -430,9 +434,14 @@ typedef void (*kherr_ctx_handler)(enum kherr_ctx_event, kherr_context *);
         indication which notifications should be sent to the handler.\r
         If a \a filter value of zero is provided, all of the events\r
         will be sent to the handler.\r
+\r
+    \param[in] serial The serial number of the error context that\r
+        should be tracked.  If this is zero, all error contexts can\r
+        trigger the handler.\r
  */\r
 KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h, \r
-                                         khm_int32 filter);\r
+                                         khm_int32 filter,\r
+                                         kherr_serial serial);\r
 \r
 /*! \brief Remove a context event handler\r
 \r
@@ -440,7 +449,8 @@ KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h,
 \r
     \see kherr_add_ctx_handler()\r
  */\r
-KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h);\r
+KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h,\r
+                                            kherr_serial serial);\r
 \r
 \r
 /*! \brief Report an error\r
@@ -962,4 +972,9 @@ KHMEXP void KHMAPI kherr_evaluate_last_event(void);
 \r
 /*@}*/\r
 \r
+/* In debug mode, outputs the formatted string to the debug console */\r
+#ifdef DEBUG\r
+KHMEXP void kherr_debug_printf(wchar_t * fmt, ...);\r
+#endif\r
+\r
 #endif\r
index e91cc3d018f1cf0f88504df5c80cc50f76fbc6e5..2b43fd7f4dc3308bb7c208973feaca8c13c0df6c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -29,6 +29,7 @@
 \r
 #include<windows.h>\r
 #include<kherr.h>\r
+#include<utils.h>\r
 #include<strsafe.h>\r
 \r
 typedef struct tag_kherr_thread {\r
@@ -40,8 +41,9 @@ typedef struct tag_kherr_thread {
 #define THREAD_STACK_SIZE 8\r
 \r
 typedef struct tag_kherr_handler_node {\r
-    khm_int32 filter;\r
+    khm_int32         filter;\r
     kherr_ctx_handler h;\r
+    kherr_serial      serial;\r
 } kherr_handler_node;\r
 \r
 #define CTX_ALLOC_INCR 4\r
index b108609db46de022418bd92306bd7695bb0aa279..0ae2292046194a9c78522b6c0c0d94c9e2d9d833 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index af8419fdaad9e80f17d0658951f747aab1db2b7c..5e955953dfcdd05a96d572a648d2e0b0268b4390 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 /* $Id$ */\r
 \r
 #include<kmminternal.h>\r
+#include<assert.h>\r
 \r
-khm_boolean kmm_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)\r
+khm_boolean kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)\r
 {\r
     HMODULE h;\r
 \r
     if(l->filename != NULL) {\r
-        h = LoadLibrary(l->filename);\r
+        wchar_t path[MAX_PATH];\r
+        DWORD dw;\r
+\r
+        /* construct the path name */\r
+        assert(m->h_module != NULL);\r
+\r
+        dw = PathIsFileSpec(l->filename);\r
+\r
+        assert(dw);\r
+        if (!dw)\r
+            return FALSE;\r
+\r
+        dw = GetModuleFileName(m->h_module, path, ARRAYLENGTH(path));\r
+        assert(dw != 0);\r
+        if (dw == 0)\r
+            return FALSE;\r
+\r
+        PathRemoveFileSpec(path);\r
+        dw = PathAppend(path, l->filename);\r
+        assert(dw);\r
+        if (!dw)\r
+            return FALSE;\r
+\r
+        h = LoadLibrary(path);\r
         if(!h)\r
             return FALSE;\r
 \r
@@ -41,6 +65,7 @@ khm_boolean kmm_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)
         LeaveCriticalSection(&cs_kmm);\r
 \r
         return TRUE;\r
+\r
     } else {\r
         /*  in this case, the language resources are assumed to be in the\r
             main module library itself. */\r
@@ -69,9 +94,9 @@ KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale
         return KHM_ERROR_INVALID_OPERATION;\r
 \r
     if(!locales || n_locales < 0)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
-    f = malloc(n_locales * sizeof(int));\r
+    f = PMALLOC(n_locales * sizeof(int));\r
     if(!f)\r
         return KHM_ERROR_UNKNOWN;\r
     ZeroMemory(f, sizeof(int) * n_locales);\r
@@ -82,7 +107,7 @@ KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale
     for(i=0; i<n_locales; i++) {\r
         if(locales[i].language == lcid) {\r
             f[i] = TRUE;\r
-            if(kmm_load_locale_lib(m, &locales[i]))\r
+            if(kmmint_load_locale_lib(m, &locales[i]))\r
                 break;\r
         }\r
     }\r
@@ -94,7 +119,7 @@ KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale
     for(i=0; i<n_locales; i++) {\r
         if(!f[i] && (PRIMARYLANGID(locales[i].language) == PRIMARYLANGID(lcid))) {\r
             f[i] = TRUE;\r
-            if(kmm_load_locale_lib(m,&locales[i]))\r
+            if(kmmint_load_locale_lib(m,&locales[i]))\r
                 break;\r
         }\r
     }\r
@@ -106,7 +131,7 @@ KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale
     for(i=0; i<n_locales; i++) {\r
         if(!f[i] && (locales[i].flags & KMM_MLOC_FLAG_DEFAULT)) {\r
             f[i] = TRUE;\r
-            if(kmm_load_locale_lib(m,&locales[i]))\r
+            if(kmmint_load_locale_lib(m,&locales[i]))\r
                 break;\r
         }\r
     }\r
@@ -118,7 +143,7 @@ KHMEXP khm_int32 KHMAPI kmm_set_locale_info(kmm_module module, kmm_module_locale
     rv = KHM_ERROR_NOT_FOUND;\r
 \r
 _exit:\r
-    free(f);\r
+    PFREE(f);\r
     return rv;\r
 }\r
 \r
index 8e487be73a41ad250204c49d8a4f680b4137d996..0dc7e4cea4dcc05d665e79c11a13fb22346c3307 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -54,7 +54,19 @@ typedef khm_handle kmm_plugin;
 #define KMM_MAXCCH_DESC 512\r
 \r
 /*! \brief Maximum number of bytes in a description in KMM including the terminating NULL */\r
-#define KMM_MAXCB_DESC (sizeof(wchar_t) * KMM_MAXCB_NAME)\r
+#define KMM_MAXCB_DESC (sizeof(wchar_t) * KMM_MAXCCH_NAME)\r
+\r
+/*! \brief Maximum number of characters in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCCH_VENDOR 256\r
+\r
+/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCB_VENDOR (sizeof(wchar_t) * KMM_MAXCCH_VENDOR)\r
+\r
+/*! \brief Maximum number of characters in a support URI in KMM including the terminating NULL */\r
+#define KMM_MAXCCH_SUPPORT 256\r
+\r
+/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCB_SUPPORT (sizeof(wchar_t) * KMM_MAXCCH_SUPPORT)\r
 \r
 /*! \brief Maximum number of dependencies per plugin\r
 */\r
@@ -62,7 +74,7 @@ typedef khm_handle kmm_plugin;
 \r
 /*! \brief Maximum number of dependants per plugin\r
  */\r
-#define KMM_MAX_DEPENDANTS      16\r
+#define KMM_MAX_DEPENDANTS      32\r
 \r
 /*! \brief Maximum number of characters a dependency string including trailing double NULL */\r
 #define KMM_MAXCCH_DEPS (KMM_MAXCCH_NAME * KMM_MAX_DEPENDENCIES + 1)\r
@@ -141,23 +153,27 @@ typedef struct tag_kmm_plugin_info {
 /*! \brief A credentials provider\r
 \r
     \see \ref pi_pt_cred for more information.\r
-*/\r
+ */\r
 #define KHM_PITYPE_CRED     1\r
 \r
+/*! \brief A identity provider \r
+\r
+    \see \ref pi_pt_cred for more information\r
+ */\r
+#define KHM_PITYPE_IDENT    2\r
+\r
 /*! \brief A configuration provider\r
 \r
     \see \ref pi_pt_conf for more information.\r
-*/\r
-#define KHM_PITYPE_CONFIG   2\r
+ */\r
+#define KHM_PITYPE_CONFIG   3\r
 \r
-/*@}*/\r
+/*! \brief Undefined plugin type\r
 \r
-/*! \name Plugin flags\r
-@{*/\r
+    The plugin doesn't provide any credential type.\r
+ */\r
+#define KHM_PITYPE_MISC     4\r
 \r
-/*! \brief The plugin is an identity provider\r
-*/\r
-#define KHM_PIFLAG_IDENTITY_PROVIDER 1\r
 /*@}*/\r
 \r
 /*! \brief Plugin states */\r
@@ -208,6 +224,8 @@ typedef struct tag_kmm_module_reg {
 \r
     wchar_t *   vendor;             /*!< Vendor/copyright string */\r
 \r
+    wchar_t *   support;            /*!< Support URL/contact */\r
+\r
     khm_int32   n_plugins;          /*!< Number of plugins that are\r
                                         active */\r
     kmm_plugin_reg * plugin_reg_info;  /*!< Array of kmm_plugin_reg\r
@@ -243,6 +261,12 @@ typedef struct tag_kmm_module_info {
 /*! \brief Module states\r
 */\r
 enum KMM_MODULE_STATES {\r
+    KMM_MODULE_STATE_FAIL_INCOMPAT=-12, /*!< The library containing\r
+                                          the module was not\r
+                                          compatible with this version\r
+                                          of NetIDMgr. */\r
+    KMM_MODULE_STATE_FAIL_INV_MODULE=-11, /*!< The library containing\r
+                                            the module was invalid. */\r
     KMM_MODULE_STATE_FAIL_UNKNOWN=-10,   /*!< Module could not be\r
                                           loaded due to unknown\r
                                           reasons. */\r
@@ -463,14 +487,14 @@ KHMEXP khm_boolean  KHMAPI
 kmm_load_pending(void);\r
 \r
 #ifdef _WIN32\r
-/*! \brief Returns the Windows module handle from a handle to a NetIDMgr module.\r
 \r
+/*! \brief Returns the Windows module handle from a handle to a NetIDMgr module.\r
     Although it is possible to obtain the Windows module handle and\r
     use it to call Windows API functions, it is not recommended to do\r
     so.  This is because that might cause the state of the module to\r
     change in ways which are inconsistent from the internal data\r
     structures that kmm maintains.\r
-*/\r
+ */\r
 KHMEXP HMODULE     KHMAPI \r
 kmm_get_hmodule(kmm_module m);\r
 #endif\r
@@ -526,7 +550,7 @@ kmm_release_plugin(kmm_plugin p);
     \retval KHM_ERROR_SUCCESS Succeeded.\r
     \retval KHM_ERROR_INVALID_OPERATION The function was not called\r
         during init_module()\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_DUPLICATE The plugin was already provided\r
 \r
     \note This can only be called when handing init_module()\r
@@ -661,7 +685,7 @@ kmm_get_modules_config(khm_int32 flags, khm_handle * result);
         copied.\r
 \r
     \retval KHM_ERROR_SUCCESS The requested information was copied\r
-    \retval KHM_ERROR_INVALID_PARM One of the parameters was invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One of the parameters was invalid\r
     \retval KHM_ERROR_TOO_LONG The buffer was not large enough or was\r
         NULL.  The number of bytes requied is in \a cb_buffer.\r
     \retval KHM_ERROR_NOT_FOUND The specified module is not a\r
@@ -720,7 +744,7 @@ kmm_release_module_info_i(kmm_module_info * info);
     \retval KHM_ERROR_TOO_LONG The buffer was either \a NULL or\r
         insufficient to hold the requested information.  The required\r
         size of the buffer was stored in \a cb_buffer\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
         invlaid.\r
     \retval KHM_ERROR_NOT_FOUND The specified plugin was not found\r
         among the registered plugins.\r
@@ -821,9 +845,9 @@ kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags);
     zero, in which case \a plugin_info can be \a NULL.  Plugins can be\r
     registered separately using kmm_register_plugin().\r
 \r
-    \param[in] module Information about the module.  All members are\r
-        required, however \a plugin_info can be \a NULL if \a\r
-        n_plugins is zero.\r
+    \param[in] module Information about the module.  The name and path\r
+        fields are required. The \a plugin_info field can only be \a\r
+        NULL if \a n_plugins is zero.\r
 \r
     \param[in] config_flags Flags used to call khc_open_space().  This\r
         can be used to choose the configuration store in which the\r
@@ -911,6 +935,10 @@ typedef struct tag_kmm_module_locale {
     kmm_get_resource_hmodule().  This function does not return until a\r
     matched library is loaded.\r
 \r
+    Note that the ::kmm_module_locale structure only specifies a\r
+    module name for the resource module.  This resource module must\r
+    exist in the same directory as the \a module.\r
+\r
     \param[in] module The module handle\r
     \param[in] locales An array of ::kmm_module_locale objects\r
     \param[in] n_locales The number of objects in the array pointed to by \a locales\r
index e1f5292ce8b0cb3df3afe8849f86481f9451f556..25da22345b72396760bb082355c3b07cad5f160b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 /* $Id$ */\r
 \r
 #include<kmminternal.h>\r
+#include<netidmgr_version.h>\r
+#include<assert.h>\r
 \r
-kmm_module_i * kmm_get_module_i(wchar_t * name)\r
+kmm_module_i * kmmint_get_module_i(wchar_t * name)\r
 {\r
     kmm_module_i * m;\r
     size_t sz;\r
@@ -39,11 +41,11 @@ kmm_module_i * kmm_get_module_i(wchar_t * name)
     m = (kmm_module_i *) hash_lookup(hash_modules, (void *) name);\r
 \r
     if(m == NULL) {\r
-        m = malloc(sizeof(kmm_module_i));\r
+        m = PMALLOC(sizeof(kmm_module_i));\r
         ZeroMemory(m, sizeof(kmm_module_i));\r
 \r
         m->magic = KMM_MODULE_MAGIC;\r
-        m->name = malloc(sz);\r
+        m->name = PMALLOC(sz);\r
         StringCbCopy(m->name, sz, name);\r
         m->state = KMM_MODULE_STATE_NONE;\r
 \r
@@ -55,7 +57,7 @@ kmm_module_i * kmm_get_module_i(wchar_t * name)
     return m;\r
 }\r
 \r
-kmm_module_i * kmm_find_module_i(wchar_t * name)\r
+kmm_module_i * kmmint_find_module_i(wchar_t * name)\r
 {\r
     kmm_module_i * m;\r
 \r
@@ -67,7 +69,7 @@ kmm_module_i * kmm_find_module_i(wchar_t * name)
 }\r
 \r
 /* called with cs_kmm held */\r
-void kmm_free_module(kmm_module_i * m)\r
+void kmmint_free_module(kmm_module_i * m)\r
 {\r
     m->magic = 0;\r
 \r
@@ -75,14 +77,24 @@ void kmm_free_module(kmm_module_i * m)
     LDELETE(&kmm_all_modules, m);\r
 \r
     if (m->name)\r
-        free(m->name);\r
+        PFREE(m->name);\r
+\r
+    if (m->description)\r
+        PFREE(m->description);\r
+\r
     if (m->path)\r
-        free(m->path);\r
+        PFREE(m->path);\r
+\r
     if (m->vendor)\r
-        free(m->vendor);\r
+        PFREE(m->vendor);\r
+\r
+    if (m->support)\r
+        PFREE(m->support);\r
+\r
     if (m->version_info)\r
-        free(m->version_info);\r
-    free(m);\r
+        PFREE(m->version_info);\r
+\r
+    PFREE(m);\r
 \r
     if (kmm_all_modules == NULL)\r
         SetEvent(evt_exit);\r
@@ -91,7 +103,7 @@ void kmm_free_module(kmm_module_i * m)
 KHMEXP khm_int32   KHMAPI kmm_hold_module(kmm_module module)\r
 {\r
     if(!kmm_is_module(module))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     EnterCriticalSection(&cs_kmm);\r
     kmm_module_from_handle(module)->refcount++;\r
     LeaveCriticalSection(&cs_kmm);\r
@@ -103,7 +115,7 @@ KHMEXP khm_int32   KHMAPI kmm_release_module(kmm_module vm)
 {\r
     kmm_module_i * m;\r
     if(!kmm_is_module(vm))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_kmm);\r
     m = kmm_module_from_handle(vm);\r
@@ -111,12 +123,313 @@ KHMEXP khm_int32   KHMAPI kmm_release_module(kmm_module vm)
     {\r
         /* note that a 0 ref count means that there are no active\r
            plugins */\r
-        kmm_free_module(m);\r
+        kmmint_free_module(m);\r
     }\r
     LeaveCriticalSection(&cs_kmm);\r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
+khm_int32\r
+kmmint_check_api_version(DWORD v) {\r
+    /* for now, we require an exact match.  In the future when we are\r
+       swamped with so much time that we don't know what to do with\r
+       it, we can actually parse the apiversion.txt file and create a\r
+       compatibility table which we can check against the functions\r
+       used by the module and decide whether or not it is\r
+       compatible. */\r
+\r
+    if (v != KH_VERSION_API)\r
+        return KHM_ERROR_INCOMPATIBLE;\r
+    else\r
+        return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+struct lang_code {\r
+    WORD language;\r
+    WORD codepage;\r
+};\r
+\r
+khm_int32\r
+kmmint_read_module_info(kmm_module_i * m) {\r
+    /* the only fields we can count on at this point are m->name and\r
+       m->path */\r
+    DWORD t;\r
+    size_t cb;\r
+    WORD lang;\r
+    khm_int32 rv = KHM_ERROR_SUCCESS;\r
+    struct lang_code *languages;\r
+    int n_languages;\r
+    int i;\r
+    wchar_t resname[256];       /* the resource names are a lot shorter */\r
+    wchar_t * r;\r
+    VS_FIXEDFILEINFO *vff;\r
+\r
+    assert(m->name);\r
+    assert(m->path);\r
+\r
+    t = TRUE;\r
+    cb = GetFileVersionInfoSize(m->path,\r
+                                &t);\r
+    /* if successful, cb gets the size in bytes of the version info\r
+       structure and sets t to zero */\r
+    if (t) {\r
+        return KHM_ERROR_NOT_FOUND;\r
+    } else if (cb == 0) {\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));\r
+        return KHM_ERROR_INVALID_PARAM;\r
+    }\r
+\r
+    if (m->version_info) {\r
+        PFREE(m->version_info);\r
+        m->version_info = NULL;\r
+    }\r
+\r
+    m->version_info = PMALLOC(cb);\r
+#ifdef DEBUG\r
+    assert(m->version_info);\r
+#endif\r
+\r
+    if(!GetFileVersionInfo(m->path,\r
+                           t, (DWORD) cb, m->version_info)) {\r
+        rv = KHM_ERROR_NOT_FOUND;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));\r
+        _location(L"GetFileVersionInfo");\r
+        goto _cleanup;\r
+    }\r
+\r
+    if(!VerQueryValue(m->version_info,\r
+                     L"\\VarFileInfo\\Translation",\r
+                     (LPVOID*) &languages,\r
+                     &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_NO_TRANS, _dupstr(m->path));\r
+        _location(L"VerQueryValue");\r
+        goto _cleanup;\r
+    }\r
+\r
+    n_languages = (int) (cb / sizeof(*languages));\r
+    lang = GetUserDefaultLangID();\r
+    for (i = 0; i < n_languages; i++) {\r
+        if(languages[i].language == lang)\r
+            break;\r
+    }\r
+\r
+    if (i >= n_languages) {\r
+        lang = GetSystemDefaultLangID();\r
+        for (i=0; i<n_languages; i++)\r
+            if (languages[i].language == lang)\r
+                break;\r
+    }\r
+\r
+    if (i >= n_languages) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr0(KHERR_WARNING, MSG_RMI_NO_LOCAL);\r
+        goto _cleanup;\r
+    }\r
+\r
+    /* check module name */\r
+    StringCbPrintf(resname, sizeof(resname),\r
+                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_MODULE),\r
+                   languages[i].language,\r
+                   languages[i].codepage);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       resname, (LPVOID *) &r, &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+                    _cstr(TEXT(NIMV_MODULE)));\r
+        goto _cleanup;\r
+    }\r
+\r
+    if (cb > KMM_MAXCB_NAME ||\r
+        FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+                    _cstr(TEXT(NIMV_MODULE)));\r
+        goto _cleanup;\r
+                    \r
+    }\r
+\r
+    if (wcscmp(r, m->name)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr2(KHERR_WARNING, MSG_RMI_MOD_MISMATCH,\r
+                    _dupstr(r), _dupstr(m->name));\r
+        goto _cleanup;\r
+    }\r
+\r
+    /* check API version */\r
+    StringCbPrintf(resname, sizeof(resname),\r
+                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_APIVER),\r
+                   languages[i].language,\r
+                   languages[i].codepage);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       resname, (LPVOID *) &r, &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+                    _cstr(TEXT(NIMV_APIVER)));\r
+        goto _cleanup;\r
+    }\r
+\r
+    if (cb > KMM_MAXCB_NAME ||\r
+        FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+                    _cstr(TEXT(NIMV_APIVER)));\r
+        goto _cleanup;\r
+    }\r
+\r
+    t = wcstol(r, NULL, 10);\r
+\r
+    rv = kmmint_check_api_version(t);\r
+\r
+    if (KHM_FAILED(rv)) {\r
+        _report_mr2(KHERR_WARNING, MSG_RMI_API_MISMATCH,\r
+                    _int32(t), _int32(KH_VERSION_API));\r
+        goto _cleanup;\r
+    }\r
+\r
+    /* Looks good.  Now load the description, copyright, support URI\r
+       and file versions */\r
+    if (m->description) {\r
+        PFREE(m->description);\r
+        m->description = NULL;\r
+    }\r
+\r
+    StringCbPrintf(resname, sizeof(resname),\r
+                   L"\\StringFileInfo\\%04x%04x\\FileDescription",\r
+                   languages[i].language,\r
+                   languages[i].codepage);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       resname, (LPVOID *) &r, &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+                    _cstr(L"FileDescription"));\r
+        goto _cleanup;\r
+    }\r
+\r
+    if (cb > KMM_MAXCB_DESC ||\r
+        FAILED(StringCbLength(r, KMM_MAXCB_DESC, &cb))) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+                    _cstr(L"FileDescription"));\r
+        goto _cleanup;\r
+    }\r
+\r
+    cb += sizeof(wchar_t);\r
+\r
+    m->description = PMALLOC(cb);\r
+#ifdef DEBUG\r
+    assert(m->description);\r
+#endif\r
+    StringCbCopy(m->description, cb, r);\r
+\r
+    /* on to the support URI */\r
+    if (m->support) {\r
+        PFREE(m->support);\r
+        m->support = NULL;\r
+    }\r
+\r
+    StringCbPrintf(resname, sizeof(resname),\r
+                   L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_SUPPORT),\r
+                   languages[i].language,\r
+                   languages[i].codepage);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       resname, (LPVOID *) &r, &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,\r
+                    _cstr(TEXT(NIMV_SUPPORT)));\r
+        goto _cleanup;\r
+    }\r
+\r
+    if (cb > KMM_MAXCB_SUPPORT ||\r
+        FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+                    _cstr(TEXT(NIMV_SUPPORT)));\r
+        goto _cleanup;\r
+    }\r
+\r
+    cb += sizeof(wchar_t);\r
+\r
+    m->support = PMALLOC(cb);\r
+#ifdef DEBUG\r
+    assert(m->support);\r
+#endif\r
+    StringCbCopy(m->support, cb, r);\r
+\r
+    /* the vendor/copyright */\r
+    if (m->vendor) {\r
+        PFREE(m->vendor);\r
+        m->vendor = NULL;\r
+    }\r
+\r
+    StringCbPrintf(resname, sizeof(resname),\r
+                   L"\\StringFileInfo\\%04x%04x\\LegalCopyright",\r
+                   languages[i].language,\r
+                   languages[i].codepage);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       resname, (LPVOID *) &r, &cb)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+                    _cstr(L"LegalCopyright"));\r
+        goto _cleanup;\r
+    }\r
+\r
+    if (cb > KMM_MAXCB_SUPPORT ||\r
+        FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+                    _cstr(L"LegalCopyright"));\r
+        goto _cleanup;\r
+    }\r
+\r
+    cb += sizeof(wchar_t);\r
+\r
+    m->vendor = PMALLOC(cb);\r
+#ifdef DEBUG\r
+    assert(m->vendor);\r
+#endif\r
+    StringCbCopy(m->vendor, cb, r);\r
+\r
+    if (!VerQueryValue(m->version_info,\r
+                       L"\\",\r
+                       (LPVOID *) &vff,\r
+                       &cb) ||\r
+        cb != sizeof(*vff)) {\r
+\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+        _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+                    _cstr(L"Fixed Version Info"));\r
+        goto _cleanup;\r
+    }\r
+\r
+    m->file_version.major = HIWORD(vff->dwFileVersionMS);\r
+    m->file_version.minor = LOWORD(vff->dwFileVersionMS);\r
+    m->file_version.patch = HIWORD(vff->dwFileVersionLS);\r
+    m->file_version.aux   = LOWORD(vff->dwFileVersionLS);\r
+\r
+    m->prod_version.major = HIWORD(vff->dwProductVersionMS);\r
+    m->prod_version.minor = LOWORD(vff->dwProductVersionMS);\r
+    m->prod_version.patch = HIWORD(vff->dwProductVersionLS);\r
+    m->prod_version.aux   = LOWORD(vff->dwProductVersionLS);\r
+\r
+    rv = KHM_ERROR_SUCCESS;\r
+\r
+ _cleanup:\r
+    if (KHM_FAILED(rv)) {\r
+        if (m->version_info) {\r
+            PFREE(m->version_info);\r
+            m->version_info = NULL;\r
+        }\r
+    }\r
+\r
+    return rv;\r
+}\r
+\r
 KHMEXP khm_int32   KHMAPI kmm_load_module(wchar_t * modname, \r
                                           khm_int32 flags, \r
                                           kmm_module * result)\r
@@ -127,11 +440,11 @@ KHMEXP khm_int32   KHMAPI kmm_load_module(wchar_t * modname,
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(FAILED(StringCbLength(modname, KMM_MAXCB_NAME, &cbsize)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     cbsize += sizeof(wchar_t);\r
 \r
     EnterCriticalSection(&cs_kmm);\r
-    mi = kmm_find_module_i(modname);\r
+    mi = kmmint_find_module_i(modname);\r
 \r
     if(mi != NULL) {\r
         kmm_hold_module(kmm_handle_from_module(mi));\r
@@ -158,7 +471,7 @@ KHMEXP khm_int32   KHMAPI kmm_load_module(wchar_t * modname,
     if(mi) {\r
         m = mi;\r
     } else {\r
-        m = kmm_get_module_i(modname);\r
+        m = kmmint_get_module_i(modname);\r
         m->state = KMM_MODULE_STATE_PREINIT;\r
         kmm_hold_module(kmm_handle_from_module(m));\r
     }\r
@@ -215,7 +528,8 @@ KHMEXP khm_int32   KHMAPI kmm_load_module(wchar_t * modname,
     return rv;\r
 }\r
 \r
-KHMEXP khm_int32   KHMAPI kmm_get_module_state(kmm_module m)\r
+KHMEXP khm_int32   KHMAPI \r
+kmm_get_module_state(kmm_module m)\r
 {\r
     if(!kmm_is_module(m))\r
         return KMM_MODULE_STATE_NONE;\r
@@ -230,7 +544,7 @@ kmm_get_module_info_i(kmm_module vm, kmm_module_info * info) {
 \r
     EnterCriticalSection(&cs_kmm);\r
     if (!kmm_is_module(vm) || !info)\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
     else {\r
         m = kmm_module_from_handle(vm);\r
 \r
@@ -265,10 +579,11 @@ kmm_release_module_info_i(kmm_module_info * info) {
 }\r
 \r
 \r
-KHMEXP khm_int32   KHMAPI kmm_unload_module(kmm_module module)\r
+KHMEXP khm_int32   KHMAPI \r
+kmm_unload_module(kmm_module module)\r
 {\r
     if(!kmm_is_module(module))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     kmm_hold_module(module);\r
     kmq_post_message(KMSG_KMM, \r
@@ -279,11 +594,11 @@ KHMEXP khm_int32   KHMAPI kmm_unload_module(kmm_module module)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32   KHMAPI kmm_load_default_modules(void) {\r
+KHMEXP khm_int32   KHMAPI \r
+kmm_load_default_modules(void) {\r
     khm_handle csm = NULL;\r
+    khm_handle cs_mod = NULL;\r
     khm_int32 rv;\r
-    wchar_t * ll = NULL;\r
-    wchar_t *str;\r
     wchar_t buf[KMM_MAXCCH_NAME];\r
     khm_size s;\r
 \r
@@ -291,44 +606,35 @@ KHMEXP khm_int32   KHMAPI kmm_load_default_modules(void) {
     if(KHM_FAILED(rv))\r
         return rv;\r
 \r
-    _begin_task(KHERR_CF_TRANSITIVE);\r
     _report_mr0(KHERR_NONE, MSG_LOAD_DEFAULT);\r
     _describe();\r
 \r
-    rv = khc_read_multi_string(csm, KMM_VALNAME_LOADLIST, NULL, &s);\r
-    if(rv != KHM_ERROR_TOO_LONG)\r
-        goto _exit;\r
+    kmmint_add_to_module_queue();\r
+\r
+    while(KHM_SUCCEEDED(khc_enum_subspaces(csm, cs_mod, &cs_mod))) {\r
 \r
-    ll = malloc(s);\r
-    rv = khc_read_multi_string(csm, KMM_VALNAME_LOADLIST, ll, &s);\r
-    if(KHM_FAILED(rv))\r
-        goto _exit;\r
+        s = sizeof(buf);\r
+        if (KHM_FAILED(khc_get_config_space_name(cs_mod, buf, &s)))\r
+            continue;\r
 \r
-    kmmint_add_to_module_queue();\r
+        /* check for schema subspace.  This is not an actual module. */\r
+        if (!wcscmp(buf, L"_Schema"))\r
+            continue;\r
 \r
-    str = ll;\r
-    while(str && *str) {\r
-        if(SUCCEEDED(StringCbCopy(buf, sizeof(buf), str))) {\r
-            kmm_load_module(buf, 0, NULL);\r
-        }\r
-        str = multi_string_next(str);\r
+        kmm_load_module(buf, 0, NULL);\r
     }\r
 \r
     kmmint_remove_from_module_queue();\r
 \r
-_exit:\r
-    if(ll)\r
-        free(ll);\r
     if(csm)\r
         khc_close_space(csm);\r
 \r
-    _end_task();\r
-\r
     return rv;\r
 }\r
 \r
 #ifdef _WIN32\r
-KHMEXP HMODULE     KHMAPI kmm_get_hmodule(kmm_module m)\r
+KHMEXP HMODULE     KHMAPI \r
+kmm_get_hmodule(kmm_module m)\r
 {\r
     if(!kmm_is_module(m))\r
         return NULL;\r
index f37eaa186c91f34b079199bddb3fae1fa44edc31..b8a90c9fe9e65159d196b5048f873cd42892ce79 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -32,7 +32,7 @@
 */\r
 \r
 kmm_plugin_i * \r
-kmm_get_plugin_i(wchar_t * name)\r
+kmmint_get_plugin_i(wchar_t * name)\r
 {\r
     kmm_plugin_i * p;\r
     size_t cb;\r
@@ -45,15 +45,15 @@ kmm_get_plugin_i(wchar_t * name)
     p = (kmm_plugin_i *) hash_lookup(hash_plugins, (void *) name);\r
 \r
     if(p == NULL) {\r
-        p = malloc(sizeof(kmm_plugin_i));\r
+        p = PMALLOC(sizeof(kmm_plugin_i));\r
         ZeroMemory(p, sizeof(kmm_plugin_i));\r
         p->magic = KMM_PLUGIN_MAGIC;\r
-        p->p.name = malloc(cb);\r
+        p->p.name = PMALLOC(cb);\r
         StringCbCopy(p->p.name, cb, name);\r
         p->state = KMM_PLUGIN_STATE_NONE;\r
 \r
         hash_add(hash_plugins, (void *) p->p.name, (void *) p);\r
-        kmm_list_plugin(p);\r
+        kmmint_list_plugin(p);\r
     }\r
     LeaveCriticalSection(&cs_kmm);\r
 \r
@@ -61,7 +61,7 @@ kmm_get_plugin_i(wchar_t * name)
 }\r
 \r
 kmm_plugin_i * \r
-kmm_find_plugin_i(wchar_t * name)\r
+kmmint_find_plugin_i(wchar_t * name)\r
 {\r
     kmm_plugin_i * p;\r
     size_t cb;\r
@@ -78,7 +78,7 @@ kmm_find_plugin_i(wchar_t * name)
 \r
 /* the plugin must be delisted before calling this */\r
 void \r
-kmm_list_plugin(kmm_plugin_i * p)\r
+kmmint_list_plugin(kmm_plugin_i * p)\r
 {\r
     EnterCriticalSection(&cs_kmm);\r
     if((p->flags & KMM_PLUGIN_FLAG_IN_MODLIST) ||\r
@@ -92,7 +92,7 @@ kmm_list_plugin(kmm_plugin_i * p)
 }\r
 \r
 void \r
-kmm_delist_plugin(kmm_plugin_i * p)\r
+kmmint_delist_plugin(kmm_plugin_i * p)\r
 {\r
     EnterCriticalSection(&cs_kmm);\r
     if(p->flags & KMM_PLUGIN_FLAG_IN_LIST) {\r
@@ -112,7 +112,7 @@ kmm_hold_plugin(kmm_plugin p)
     kmm_plugin_i * pi;\r
 \r
     if(!kmm_is_plugin(p))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_kmm);\r
     pi = kmm_plugin_from_handle(p);\r
@@ -124,14 +124,14 @@ kmm_hold_plugin(kmm_plugin p)
 \r
 /* called with cs_kmm held */\r
 void \r
-kmm_free_plugin(kmm_plugin_i * pi)\r
+kmmint_free_plugin(kmm_plugin_i * pi)\r
 {\r
     int i;\r
     pi->magic = 0;\r
 \r
     hash_del(hash_plugins, (void *) pi->p.name);\r
 \r
-    kmm_delist_plugin(pi);\r
+    kmmint_delist_plugin(pi);\r
 \r
     for(i=0; i<pi->n_dependants; i++) {\r
         kmm_release_plugin(kmm_handle_from_plugin(pi->dependants[i]));\r
@@ -146,18 +146,18 @@ kmm_free_plugin(kmm_plugin_i * pi)
     pi->p.module = NULL;\r
 \r
     if(pi->p.name)\r
-        free(pi->p.name);\r
+        PFREE(pi->p.name);\r
     pi->p.name = NULL;\r
 \r
     if(pi->p.description)\r
-        free(pi->p.description);\r
+        PFREE(pi->p.description);\r
     pi->p.description = NULL;\r
 \r
     if(pi->p.dependencies)\r
-        free(pi->p.dependencies);\r
+        PFREE(pi->p.dependencies);\r
     pi->p.dependencies = NULL;\r
 \r
-    free(pi);\r
+    PFREE(pi);\r
 }\r
 \r
 KHMEXP khm_int32   KHMAPI\r
@@ -167,11 +167,11 @@ kmm_get_plugin_info_i(kmm_plugin p, kmm_plugin_info * info) {
     khm_handle csp_plugin;\r
 \r
     if (!info)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_kmm);\r
     if (!kmm_is_plugin(p)) {\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
         goto _cleanup;\r
     }\r
 \r
@@ -217,7 +217,7 @@ kmm_release_plugin_info_i(kmm_plugin_info * info) {
     khm_int32 rv;\r
 \r
     if (!info || !info->h_plugin)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     rv = kmm_release_plugin(info->h_plugin);\r
 \r
@@ -285,13 +285,13 @@ kmm_release_plugin(kmm_plugin p)
     kmm_plugin_i * pi;\r
 \r
     if(!kmm_is_plugin(p))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_kmm);\r
     pi = kmm_plugin_from_handle(p);\r
     pi->refcount--;\r
     if(pi->refcount == 0) {\r
-        kmm_free_plugin(pi);\r
+        kmmint_free_plugin(pi);\r
     }\r
     LeaveCriticalSection(&cs_kmm);\r
 \r
@@ -314,20 +314,22 @@ kmm_provide_plugin(kmm_module module, kmm_plugin_reg * plugin)
         return KHM_ERROR_INVALID_OPERATION;\r
 \r
     if(!plugin || \r
-        FAILED(StringCbLength(plugin->name, KMM_MAXCB_NAME - sizeof(wchar_t), &cb_name)) ||\r
-          (plugin->description && \r
-             FAILED(StringCbLength(plugin->description, KMM_MAXCB_DESC - sizeof(wchar_t), &cb_desc))) ||\r
-          (plugin->dependencies && \r
-             KHM_FAILED(multi_string_length_cb(plugin->dependencies, KMM_MAXCB_DEPS, &cb_dep)))\r
-        )\r
-    {\r
-        return KHM_ERROR_INVALID_PARM;\r
+       FAILED(StringCbLength(plugin->name, KMM_MAXCB_NAME - sizeof(wchar_t), \r
+                             &cb_name)) ||\r
+       (plugin->description && \r
+        FAILED(StringCbLength(plugin->description, \r
+                              KMM_MAXCB_DESC - sizeof(wchar_t), \r
+                              &cb_desc))) ||\r
+       (plugin->dependencies && \r
+        KHM_FAILED(multi_string_length_cb(plugin->dependencies, \r
+                                          KMM_MAXCB_DEPS, &cb_dep)))) {\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     cb_name += sizeof(wchar_t);\r
     cb_desc += sizeof(wchar_t);\r
 \r
-    p = kmm_get_plugin_i(plugin->name);\r
+    p = kmmint_get_plugin_i(plugin->name);\r
 \r
     /* released below or in kmm_init_module() */\r
     kmm_hold_plugin(kmm_handle_from_plugin(p));\r
@@ -348,13 +350,13 @@ kmm_provide_plugin(kmm_module module, kmm_plugin_reg * plugin)
     p->p.type = plugin->type;\r
 \r
     if(plugin->description) {\r
-        p->p.description = malloc(cb_desc);\r
+        p->p.description = PMALLOC(cb_desc);\r
         StringCbCopy(p->p.description, cb_desc, plugin->description);\r
     } else\r
         p->p.description = NULL;\r
 \r
     if(plugin->dependencies) {\r
-        p->p.dependencies = malloc(cb_dep);\r
+        p->p.dependencies = PMALLOC(cb_dep);\r
         multi_string_copy_cb(p->p.dependencies, cb_dep, plugin->dependencies);\r
     } else\r
         p->p.dependencies = NULL;\r
@@ -365,7 +367,7 @@ kmm_provide_plugin(kmm_module module, kmm_plugin_reg * plugin)
 \r
     p->state = KMM_PLUGIN_STATE_REG;\r
 \r
-    kmm_delist_plugin(p);\r
+    kmmint_delist_plugin(p);\r
     EnterCriticalSection(&cs_kmm);\r
     LPUSH(&(m->plugins), p);\r
     p->flags |= KMM_PLUGIN_FLAG_IN_MODLIST;\r
index ea13fc19bd5979fdad3639d47c698724c3594724..131cb7514477cfa09edba764ebc2c8a0488fb264 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -96,7 +96,7 @@ kmm_get_plugin_config(wchar_t * plugin, khm_int32 flags, khm_handle * result)
     khm_int32 rv;\r
 \r
     if(!plugin || wcschr(plugin, L'/') || wcschr(plugin, L'\\'))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(KHM_FAILED(kmm_get_plugins_config(flags, &csplugins)))\r
         return KHM_ERROR_UNKNOWN;\r
@@ -118,7 +118,7 @@ kmm_get_module_config(wchar_t * module, khm_int32 flags, khm_handle * result)
     khm_int32 rv;\r
 \r
     if(!module || wcschr(module, L'/') || wcschr(module, L'\\'))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(KHM_FAILED(kmm_get_modules_config(flags, &csmodules)))\r
         return KHM_ERROR_UNKNOWN;\r
@@ -143,14 +143,16 @@ kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags)
     config_flags &= ~KHM_FLAG_CREATE;\r
 \r
     if((plugin == NULL) ||\r
-        (plugin->dependencies && \r
-         KHM_FAILED(multi_string_length_cch(plugin->dependencies, KMM_MAXCCH_DEPS, &cch))) ||\r
-       FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME - 1, &cch)) ||\r
-       (plugin->description && \r
-        FAILED(StringCchLength(plugin->description, KMM_MAXCCH_DESC - 1, &cch))) ||\r
-       FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME - 1, &cch)))\r
+       (plugin->dependencies && \r
+        KHM_FAILED(multi_string_length_cch(plugin->dependencies, \r
+                                           KMM_MAXCCH_DEPS, &cch))) ||\r
+       FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME, &cch)) ||\r
+       (plugin->description &&\r
+        FAILED(StringCchLength(plugin->description,\r
+                               KMM_MAXCCH_DESC, &cch))) ||\r
+       FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME, &cch)))\r
     {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     /* note that we are retaining the length of the plugin name in\r
@@ -177,10 +179,13 @@ kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags)
         rv = khc_write_string(csp_plugin, L"Description", plugin->description);\r
         CKRV;\r
     }\r
+\r
     if(plugin->dependencies) {\r
-        rv = khc_write_multi_string(csp_plugin, L"Dependencies", plugin->dependencies);\r
+        rv = khc_write_multi_string(csp_plugin, L"Dependencies", \r
+                                    plugin->dependencies);\r
         CKRV;\r
     }\r
+\r
     rv = khc_write_int32(csp_plugin, L"Type", plugin->type);\r
     CKRV;\r
     rv = khc_write_int32(csp_plugin, L"Flags", plugin->flags);\r
@@ -198,12 +203,12 @@ kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags)
         cb += cch * sizeof(wchar_t);\r
         scb = cb;\r
 \r
-        pl = malloc(cb);\r
+        pl = PMALLOC(cb);\r
 \r
-        rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);\r
+        rv = khc_read_multi_string(csp_module, L"PluginList", pl, &cb);\r
         if(KHM_FAILED(rv)) {\r
             if(pl)\r
-                free(pl);\r
+                PFREE(pl);\r
             goto _exit;\r
         }\r
 \r
@@ -212,7 +217,7 @@ kmm_register_plugin(kmm_plugin_reg * plugin, khm_int32 config_flags)
             rv = khc_write_multi_string(csp_module, L"PluginList", pl);\r
         }\r
 \r
-        free(pl);\r
+        PFREE(pl);\r
         CKRV;\r
     }\r
 \r
@@ -236,24 +241,21 @@ kmm_register_module(kmm_module_reg * module, khm_int32 config_flags)
     int i;\r
 \r
     if((module == NULL) ||\r
-        FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME - 1, &cch)) ||\r
+        FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME, &cch)) ||\r
         (module->description && \r
-            FAILED(StringCchLength(module->description, KMM_MAXCCH_DESC - 1, &cch))) ||\r
+            FAILED(StringCchLength(module->description, \r
+                                   KMM_MAXCCH_DESC, &cch))) ||\r
         FAILED(StringCchLength(module->path, MAX_PATH, &cch)) ||\r
-        (module->n_plugins > 0 && module->plugin_reg_info == NULL))\r
-    {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        (module->n_plugins > 0 && module->plugin_reg_info == NULL)) {\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
 #define CKRV if(KHM_FAILED(rv)) goto _exit\r
 \r
-    rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, &csp_module);\r
+    rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, \r
+                               &csp_module);\r
     CKRV;\r
 \r
-    if(module->description) {\r
-        rv = khc_write_string(csp_module, L"Description", module->description);\r
-        CKRV;\r
-    }\r
     rv = khc_write_string(csp_module, L"ImagePath", module->path);\r
     CKRV;\r
 \r
@@ -264,7 +266,7 @@ kmm_register_module(kmm_module_reg * module, khm_int32 config_flags)
        is loaded for the first time */\r
 \r
     for(i=0; i<module->n_plugins; i++) {\r
-        rv = kmm_register_plugin(module->plugin_reg_info + i, config_flags);\r
+        rv = kmm_register_plugin(&(module->plugin_reg_info[i]), config_flags);\r
         CKRV;\r
     }\r
 \r
index 3c690f36b6c8002c14711f00779453fef6fd6893..ae94a9ed314f2e2f229fc6e200c21d79b9ec236e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -38,6 +38,9 @@ kmmint_check_completion(void) {
         InterlockedIncrement(&startup_signal) == 1) {\r
 \r
         load_done = TRUE;\r
+\r
+        /* TODO: check for orphaned plugins */\r
+\r
         kmq_post_message(KMSG_KMM, KMSG_KMM_I_DONE, 0, 0);\r
     }\r
 }\r
@@ -148,31 +151,35 @@ DWORD WINAPI kmm_plugin_broker(LPVOID lpParameter)
 \r
     p->tid_thread = GetCurrentThreadId();\r
 \r
-    rv = (p->p.msg_proc(KMSG_SYSTEM, KMSG_SYSTEM_INIT, 0, (void *) &(p->p)));\r
+    if (IsBadCodePtr(p->p.msg_proc)) {\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
+    } else {\r
+        rv = (p->p.msg_proc(KMSG_SYSTEM, KMSG_SYSTEM_INIT, \r
+                            0, (void *) &(p->p)));\r
+    }\r
 \r
     /* if it fails to initialize, we exit the plugin */\r
     if(KHM_FAILED(rv)) {\r
-       kmmint_remove_from_plugin_queue();\r
+        kmmint_remove_from_plugin_queue();\r
         rv = 1;\r
         goto _exit;\r
     }\r
 \r
     /* subscribe to default message classes by plugin type */\r
-    if(p->p.type & KHM_PITYPE_CRED) {\r
+    if(p->p.type == KHM_PITYPE_CRED) {\r
         kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);\r
         kmq_subscribe(KMSG_KCDB, p->p.msg_proc);\r
         kmq_subscribe(KMSG_CRED, p->p.msg_proc);\r
-    }\r
-\r
-    if(p->p.flags & KHM_PIFLAG_IDENTITY_PROVIDER) {\r
+    } else if(p->p.type == KHM_PITYPE_IDENT) {\r
         khm_handle h = NULL;\r
 \r
+        kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);\r
+        kmq_subscribe(KMSG_KCDB, p->p.msg_proc);\r
+\r
         kmq_create_subscription(p->p.msg_proc, &h);\r
         kcdb_identity_set_provider(h);\r
         /* kcdb deletes the subscription when it's done with it */\r
-    }\r
-\r
-    if(p->p.type == KHM_PITYPE_CONFIG) {\r
+    } else if(p->p.type == KHM_PITYPE_CONFIG) {\r
         /*TODO: subscribe to configuration provider messages here */\r
     }\r
 \r
@@ -204,17 +211,15 @@ DWORD WINAPI kmm_plugin_broker(LPVOID lpParameter)
     while(KHM_SUCCEEDED(kmq_dispatch(INFINITE)));\r
 \r
     /* unsubscribe from default message classes by plugin type */\r
-    if(p->p.type & KHM_PITYPE_CRED) {\r
+    if(p->p.type == KHM_PITYPE_CRED) {\r
         kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);\r
         kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);\r
         kmq_unsubscribe(KMSG_CRED, p->p.msg_proc);\r
-    }\r
-\r
-    if(p->p.flags & KHM_PIFLAG_IDENTITY_PROVIDER) {\r
+    } else if (p->p.type == KHM_PITYPE_IDENT) {\r
+        kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);\r
+        kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);\r
         kcdb_identity_set_provider(NULL);\r
-    }\r
-\r
-    if(p->p.type == KHM_PITYPE_CONFIG) {\r
+    } else if(p->p.type == KHM_PITYPE_CONFIG) {\r
         /*TODO: unsubscribe from configuration provider messages here */\r
     }\r
 \r
@@ -224,7 +229,8 @@ _exit:
     p->state = KMM_PLUGIN_STATE_EXITED;\r
 \r
     /* the following call will automatically release the plugin */\r
-    kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_PLUGIN, (void *) p);\r
+    kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, \r
+                     KMM_REG_EXIT_PLUGIN, (void *) p);\r
 \r
     TlsSetValue(tls_kmm, (LPVOID) 0);\r
 \r
@@ -282,8 +288,7 @@ void kmm_init_plugin(kmm_plugin_i * p) {
     }\r
 \r
     if(KHM_FAILED(kmm_get_plugin_config(p->p.name, 0, &csp_plugin)) ||\r
-        KHM_FAILED(khc_read_int32(csp_plugin, L"Flags", &t)))\r
-    {\r
+        KHM_FAILED(khc_read_int32(csp_plugin, L"Flags", &t))) {\r
         if(KHM_FAILED(kmm_register_plugin(&(p->p), 0))) {\r
             _report_mr0(KHERR_ERROR, MSG_IP_NOT_REGISTERED);\r
 \r
@@ -329,13 +334,15 @@ void kmm_init_plugin(kmm_plugin_i * p) {
         wchar_t * d;\r
         khm_size sz = 0;\r
 \r
-        if(khc_read_multi_string(csp_plugin, L"Dependencies", NULL, &sz) != KHM_ERROR_TOO_LONG)\r
+        if(khc_read_multi_string(csp_plugin, L"Dependencies", \r
+                                 NULL, &sz) != KHM_ERROR_TOO_LONG)\r
             break;\r
 \r
-        deps = malloc(sz);\r
-        if(KHM_FAILED(khc_read_multi_string(csp_plugin, L"Dependencies", deps, &sz))) {\r
+        deps = PMALLOC(sz);\r
+        if(KHM_FAILED(khc_read_multi_string(csp_plugin, L"Dependencies", \r
+                                            deps, &sz))) {\r
             if(deps)\r
-                free(deps);\r
+                PFREE(deps);\r
             break;\r
         }\r
 \r
@@ -343,14 +350,14 @@ void kmm_init_plugin(kmm_plugin_i * p) {
             kmm_plugin_i * pd;\r
             int i;\r
 \r
-            pd = kmm_get_plugin_i(d);\r
+            pd = kmmint_get_plugin_i(d);\r
 \r
             if(pd->state == KMM_PLUGIN_STATE_NONE) {\r
                 /* the dependant was not previously known */\r
                 pd->state = KMM_PLUGIN_STATE_PLACEHOLDER;\r
             }\r
 \r
-            for(i=0; i<pd->n_dependants; i++) {\r
+            for(i=0; i < pd->n_dependants; i++) {\r
                 if(pd->dependants[i] == p)\r
                     break;\r
             }\r
@@ -361,7 +368,7 @@ void kmm_init_plugin(kmm_plugin_i * p) {
                     RaiseException(1, EXCEPTION_NONCONTINUABLE, 0, NULL);\r
                 }\r
 \r
-                /* released in kmm_free_plugin() */\r
+                /* released in kmmint_free_plugin() */\r
                 kmm_hold_plugin(kmm_handle_from_plugin(p));\r
                 pd->dependants[pd->n_dependants] = p;\r
                 pd->n_dependants++;\r
@@ -378,15 +385,15 @@ void kmm_init_plugin(kmm_plugin_i * p) {
             p->state = KMM_PLUGIN_STATE_HOLD;\r
         }\r
 \r
-        free(deps);\r
+        PFREE(deps);\r
 \r
     } while(FALSE);\r
     LeaveCriticalSection(&cs_kmm);\r
 \r
     EnterCriticalSection(&cs_kmm);\r
     p->module->plugin_count++;\r
-    kmm_delist_plugin(p);\r
-    kmm_list_plugin(p);\r
+    kmmint_delist_plugin(p);\r
+    kmmint_list_plugin(p);\r
     LeaveCriticalSection(&cs_kmm);\r
 \r
     if(p->state == KMM_PLUGIN_STATE_HOLD) {\r
@@ -397,13 +404,12 @@ void kmm_init_plugin(kmm_plugin_i * p) {
 \r
     kmmint_add_to_plugin_queue();\r
 \r
-    p->ht_thread = CreateThread(\r
-        NULL,\r
-        0,\r
-        kmm_plugin_broker,\r
-        (LPVOID) p,\r
-        CREATE_SUSPENDED,\r
-        &dummy);\r
+    p->ht_thread = CreateThread(NULL,\r
+                                0,\r
+                                kmm_plugin_broker,\r
+                                (LPVOID) p,\r
+                                CREATE_SUSPENDED,\r
+                                &dummy);\r
 \r
     p->state = KMM_PLUGIN_STATE_INIT;\r
 \r
@@ -549,18 +555,19 @@ void kmm_init_module(kmm_module_i * m) {
         goto _exit;\r
     }\r
 \r
-    if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"Flags", &i))) {\r
-        if(i & KMM_MODULE_FLAG_DISABLED) {\r
-            _report_mr0(KHERR_ERROR, MSG_IM_DISABLED);\r
+    if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"Flags", &i)) &&\r
+       (i & KMM_MODULE_FLAG_DISABLED)) {\r
 \r
-            m->state = KMM_MODULE_STATE_FAIL_DISABLED;\r
-            goto _exit;\r
-        }\r
+        _report_mr0(KHERR_ERROR, MSG_IM_DISABLED);\r
+\r
+        m->state = KMM_MODULE_STATE_FAIL_DISABLED;\r
+        goto _exit;\r
     }\r
 \r
     if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"FailureCount", &i))) {\r
         khm_int64 tm;\r
         khm_int64 ct;\r
+        khm_int32 last_reason = 0;\r
 \r
         /* reset the failure count if the failure count reset time\r
            period has elapsed */\r
@@ -578,7 +585,13 @@ void kmm_init_module(kmm_module_i * m) {
 \r
         }\r
 \r
-        if(i > max_fail_count) {\r
+        khc_read_int32(csp_mod, L"FailureReason", &last_reason);\r
+\r
+        /* did we exceed the max failure count?  However, we ignore\r
+           the max failure count if the reason why it didn't load the\r
+           last time was because the module wasn't found. */\r
+        if(i > max_fail_count && \r
+           last_reason != KMM_MODULE_STATE_FAIL_NOT_FOUND) {\r
             /* failed too many times */\r
             _report_mr0(KHERR_ERROR, MSG_IM_MAX_FAIL);\r
 \r
@@ -587,10 +600,11 @@ void kmm_init_module(kmm_module_i * m) {
         }\r
     }\r
 \r
-    if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) == KHM_ERROR_TOO_LONG) {\r
+    if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) == \r
+       KHM_ERROR_TOO_LONG) {\r
         if(m->path)\r
-            free(m->path);\r
-        m->path = malloc(sz);\r
+            PFREE(m->path);\r
+        m->path = PMALLOC(sz);\r
         khc_read_string(csp_mod, L"ImagePath", m->path, &sz);\r
     } else {\r
         _report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED);\r
@@ -599,11 +613,23 @@ void kmm_init_module(kmm_module_i * m) {
         goto _exit;\r
     }\r
 \r
-    if (khc_read_string(csp_mod, L"Vendor", NULL, &sz) == KHM_ERROR_TOO_LONG) {\r
-        if (m->vendor)\r
-            free(m->vendor);\r
-        m->vendor = malloc(sz);\r
-        khc_read_string(csp_mod, L"Vendor", m->vendor, &sz);\r
+    rv = kmmint_read_module_info(m);\r
+\r
+    if (KHM_FAILED(rv)) {\r
+        if (rv == KHM_ERROR_INCOMPATIBLE) {\r
+            _report_mr0(KHERR_ERROR, MSG_IM_INCOMPATIBLE);\r
+\r
+            m->state = KMM_MODULE_STATE_FAIL_INCOMPAT;\r
+        } else if (rv == KHM_ERROR_NOT_FOUND) {\r
+            _report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));\r
+\r
+            m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;\r
+        } else {\r
+            _report_mr0(KHERR_ERROR, MSG_IM_INVALID_MODULE);\r
+\r
+            m->state = KMM_MODULE_STATE_FAIL_INV_MODULE;\r
+        }\r
+        goto _exit;\r
     }\r
 \r
     /* check again */\r
@@ -613,11 +639,13 @@ void kmm_init_module(kmm_module_i * m) {
         goto _exit;\r
     }\r
 \r
+    /* from this point on, we must record any failure codes */\r
+    record_failure = TRUE;\r
+\r
     hm = LoadLibrary(m->path);\r
     if(!hm) {\r
         m->h_module = NULL;\r
         m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;\r
-        record_failure = TRUE;\r
 \r
         _report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));\r
 \r
@@ -628,12 +656,11 @@ void kmm_init_module(kmm_module_i * m) {
        exit_module */\r
     release_module = FALSE;\r
     exit_module = TRUE;\r
-    record_failure = TRUE;\r
 \r
     m->flags |= KMM_MODULE_FLAG_LOADED;\r
     m->h_module = hm;\r
 \r
-    /*TODO: check signatures */\r
+    /* TODO: check signatures */\r
 \r
     p_init_module = (init_module_t) GetProcAddress(hm, EXP_INIT_MODULE);\r
 \r
@@ -646,7 +673,6 @@ void kmm_init_module(kmm_module_i * m) {
 \r
     m->state = KMM_MODULE_STATE_INIT;\r
 \r
-\r
     /* call init_module() */\r
     rv = (*p_init_module)(kmm_handle_from_module(m));\r
 \r
@@ -695,7 +721,7 @@ void kmm_init_module(kmm_module_i * m) {
 \r
     ResetEvent(evt_exit);\r
 \r
-_exit:\r
+ _exit:\r
     if(csp_mod) {\r
         if(record_failure) {\r
             khm_int64 ct;\r
@@ -709,18 +735,18 @@ _exit:
                 GetSystemTimeAsFileTime((LPFILETIME) &ct);\r
                 khc_write_int64(csp_mod, L"FailureTime", ct);\r
             }\r
+\r
+            khc_write_int32(csp_mod, L"FailureReason", m->state);\r
         }\r
         khc_close_space(csp_mod);\r
     }\r
+\r
     if(csp_mods)\r
         khc_close_space(csp_mods);\r
 \r
     _report_mr2(KHERR_INFO, MSG_IM_MOD_STATE, \r
                 _dupstr(m->name), _int32(m->state));\r
 \r
-    if(release_module)\r
-        kmm_release_module(kmm_handle_from_module(m));\r
-\r
     kmmint_remove_from_module_queue();\r
 \r
     /* if something went wrong after init_module was called on the\r
@@ -728,6 +754,53 @@ _exit:
     if(exit_module)\r
         kmm_exit_module(m);\r
 \r
+    if(release_module)\r
+        kmm_release_module(kmm_handle_from_module(m));\r
+\r
+    if (kherr_is_error()) {\r
+        kherr_context * c;\r
+        kherr_event * err_e = NULL;\r
+        kherr_event * warn_e = NULL;\r
+        kherr_event * e;\r
+\r
+        c = kherr_peek_context();\r
+        err_e = kherr_get_err_event(c);\r
+        for(e = kherr_get_first_event(c);\r
+            e;\r
+            e = kherr_get_next_event(e)) {\r
+            if (e != err_e &&\r
+                e->severity == KHERR_WARNING) {\r
+                warn_e = e;\r
+                break;\r
+            }\r
+        }\r
+\r
+        kherr_evaluate_event(err_e);\r
+        if (warn_e)\r
+            kherr_evaluate_event(warn_e);\r
+\r
+        kherr_clear_error();\r
+\r
+        e = kherr_report(KHERR_ERROR,\r
+                         (wchar_t *) MSG_IMERR_TITLE,\r
+                         KHERR_FACILITY,\r
+                         NULL,\r
+                         err_e->long_desc,\r
+                         ((warn_e)? (wchar_t *)MSG_IMERR_SUGGEST: NULL),\r
+                         KHERR_FACILITY_ID,\r
+                         KHERR_SUGGEST_NONE,\r
+                         _cstr(m->name),\r
+                         ((warn_e)? _cstr(warn_e->long_desc):0),\r
+                         0,0,\r
+                         KHERR_RF_MSG_SHORT_DESC |\r
+                         ((warn_e)? KHERR_RF_MSG_SUGGEST: 0),\r
+                         KHERR_HMODULE);\r
+\r
+        kherr_evaluate_event(e);\r
+\r
+        kherr_release_context(c);\r
+    }\r
+\r
     _end_task();\r
 }\r
 \r
@@ -780,7 +853,8 @@ void kmm_exit_module(kmm_module_i * m) {
         while(p) {\r
             if(p->module == m) {\r
                 kmm_hold_plugin(kmm_handle_from_plugin(p));\r
-                kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_PLUGIN, (void *) p);\r
+                kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, \r
+                                 KMM_REG_EXIT_PLUGIN, (void *) p);\r
                 np++;\r
             }\r
 \r
index 93444bdf4b0cbe71e77455f9ae2640c8a83317f9..b22e9b205643c3306f97dac34a0bfd5143ea23ea 100644 (file)
@@ -9,7 +9,7 @@ PluginManager,KC_SPACE,0,Plugin Manager Configuration
       Description,KC_STRING,<Description>,Description of the plugin\r
       Dependencies,KC_STRING,<Dependencies>,Multi string of plugin names of plugins that this plugin depends on\r
       Type,KC_INT32,0,The type of the plugin\r
-      Flags,KC_INT32,0,Flags.  Currently unused\r
+      Flags,KC_INT32,0,Flags\r
       FailureCount,KC_INT32,0,Number of failed loads\r
       FailureTime,KC_INT64,0,FILETIME of first failure\r
       FailureReason,KC_INT32,0,Reason for first failure.  One of the plugin status values.\r
@@ -22,31 +22,24 @@ PluginManager,KC_SPACE,0,Plugin Manager Configuration
     ModuleMaxFailureCount,KC_INT32,3,Maximum number of failure counts before module is disabled\r
     ModuleFailureCountResetTime,KC_INT64,72000,Time after first failure at which the failure count is reset\r
     _Schema,KC_SPACE,0,Module schema\r
-      ImagePath,KC_STRING,<Path to the library binary>,Path to the DLL\r
-      Description,KC_STRING,<Description>,Description of the module\r
-      Vendor,KC_STRING,<Vendor string>,Vendor or copyright string\r
-      Flags,KC_INT32,0,Flags. Currently unused.\r
+      ImagePath,KC_STRING,<Path to the library binary>,Path to the DLL (including DLL name)\r
+      Flags,KC_INT32,0,Flags\r
       FailureCount,KC_INT32,0,Number of failed loads\r
       FailureTime,KC_INT64,0,FILETIME of first failure\r
-      FailureReason,KC_INT32,0,Reason for first failure.  One of the module status values.\r
-      FileVersion,KC_INT64,0,khm_version of file\r
-      ProductVersion,KC_INT64,0,khm_version of product\r
+      FailureReason,KC_INT32,0,Reason for last failure.  One of the module status values.\r
       PluginList,KC_STRING,<plugins>,List of plugins implemented in the module\r
     _Schema,KC_ENDSPACE,0,\r
     OpenAFS,KC_SPACE,0,OpenAFS Module\r
       ImagePath,KC_STRING,afscred.dll,\r
       PluginList,KC_STRING,AfsCred,\r
-      Vendor,KC_STRING,OpenAFS.org,\r
     OpenAFS,KC_ENDSPACE,0,\r
     MITKrb5,KC_SPACE,0,MIT Kerberos V\r
       ImagePath,KC_STRING,krb5cred.dll,\r
       PluginList,KC_STRING,Krb5Cred,\r
-      Vendor,KC_STRING,Massachusetts Institute of Technology,\r
     MITKrb5,KC_ENDSPACE,0,\r
     MITKrb4,KC_SPACE,0,MIT Kerberos IV\r
       ImagePath,KC_STRING,krb4cred.dll,\r
       PluginList,KC_STRING,Krb4Cred,\r
-      Vendor,KC_STRING,Massachusetts Institute of Technology,\r
     MITKrb4,KC_ENDSPACE,0,\r
   Modules,KC_ENDSPACE,0,\r
 PluginManager,KC_ENDSPACE,0,\r
index 662eff228fe5da914f3ce624121cdf9b4a30ea8e..3ef45198efdc7a274d5bee5471b26bc4b4e21605 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -28,6 +28,7 @@
 #define __KHIMAIRA_KMMINTERNAL_H\r
 \r
 #include<windows.h>\r
+#include<shlwapi.h>\r
 #include<strsafe.h>\r
 \r
 #define KHERR_FACILITY kmm_facility\r
@@ -44,7 +45,6 @@
 #include<kcreddb.h>\r
 #include<kmm_msgs.h>\r
 \r
-\r
 struct kmm_plugin_i_t; /* forward dcl */\r
 \r
 typedef struct kmm_module_i_t {\r
@@ -52,8 +52,12 @@ typedef struct kmm_module_i_t {
 \r
     wchar_t * name;\r
     wchar_t * path;\r
-\r
+    wchar_t * description;\r
     wchar_t * vendor;\r
+    wchar_t * support;\r
+\r
+    khm_version file_version;\r
+    khm_version prod_version;\r
 \r
     HMODULE h_module;\r
 \r
@@ -80,22 +84,23 @@ typedef struct kmm_module_i_t {
 #define kmm_module_from_handle(m) ((kmm_module_i *) m)\r
 #define kmm_handle_from_module(m) ((kmm_module) m)\r
 \r
-/* the resources have been loaded */\r
-#define KMM_MODULE_FLAG_RES_LOADED  8\r
-\r
-/* the signature has been verified */\r
-#define KMM_MODULE_FLAG_SIG         16\r
-\r
 /* LoadLibrary succeeded for module */\r
 #define KMM_MODULE_FLAG_LOADED      1\r
 \r
 /* init_module entry called */\r
 #define KMM_MODULE_FLAG_INITP       2\r
 \r
+/* the resources have been loaded */\r
+#define KMM_MODULE_FLAG_RES_LOADED  8\r
+\r
+/* the signature has been verified */\r
+#define KMM_MODULE_FLAG_SIG         16\r
+\r
 /* the module is disabled by the user\r
    (option specifed in configuration) */\r
 #define KMM_MODULE_FLAG_DISABLED    1024\r
 \r
+\r
 typedef struct kmm_plugin_i_t {\r
     kmm_plugin_reg p;\r
 \r
@@ -182,18 +187,36 @@ void kmm_init_module(kmm_module_i * m);
 void kmm_exit_module(kmm_module_i * m);\r
 \r
 /* Modules */\r
-kmm_module_i * kmm_get_module_i(wchar_t * name);\r
-kmm_module_i * kmm_find_module_i(wchar_t * name);\r
-void kmm_free_module(kmm_module_i * m);\r
+kmm_module_i * \r
+kmmint_get_module_i(wchar_t * name);\r
+\r
+kmm_module_i * \r
+kmmint_find_module_i(wchar_t * name);\r
+\r
+void \r
+kmmint_free_module(kmm_module_i * m);\r
+\r
+khm_int32\r
+kmmint_read_module_info(kmm_module_i * m);\r
 \r
 /* Plugins */\r
-kmm_plugin_i * kmm_get_plugin_i(wchar_t * name);\r
-kmm_plugin_i * kmm_find_plugin_i(wchar_t * name);\r
-void kmm_free_plugin(kmm_plugin_i * pi);\r
-void kmm_list_plugin(kmm_plugin_i * p);\r
-void kmm_delist_plugin(kmm_plugin_i * p);\r
+kmm_plugin_i * \r
+kmmint_get_plugin_i(wchar_t * name);\r
+\r
+kmm_plugin_i * \r
+kmmint_find_plugin_i(wchar_t * name);\r
+\r
+void \r
+kmmint_free_plugin(kmm_plugin_i * pi);\r
+\r
+void \r
+kmmint_list_plugin(kmm_plugin_i * p);\r
+\r
+void \r
+kmmint_delist_plugin(kmm_plugin_i * p);\r
 \r
-khm_boolean kmm_load_locale_lib(kmm_module_i * m, kmm_module_locale * l);\r
+khm_boolean \r
+kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l);\r
 \r
 #define KMM_CSNAME_ROOT L"PluginManager"\r
 #define KMM_CSNAME_PLUGINS L"Plugins"\r
index 8ec4bc0a3c96dd764de3e190e2d06838fe3ca402..6489313f80b96f419eadd97b8c79256115f8325f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -96,9 +96,11 @@ KHMEXP void KHMAPI kmm_exit(void)
         kmm_plugin_i * pn;\r
 \r
         pn = LNEXT(p);\r
-        /* plugins that were never resolved should be kicked off\r
-           the list.  Flipping the refcount will do that if no\r
-           other references exist for the plugin */\r
+        /* plugins that were never resolved should be kicked off the\r
+           list.  Flipping the refcount will do that if no other\r
+           references exist for the plugin.  The plugins that were\r
+           waiting for unresolved dependencies will automatically get\r
+           freed when the placeholders and other plugins get freed. */\r
         if(p->state == KMM_PLUGIN_STATE_PLACEHOLDER) {\r
             kmm_hold_plugin(kmm_handle_from_plugin(p));\r
             kmm_release_plugin(kmm_handle_from_plugin(p));\r
index f7489bf4c03e2a24c4a084579c89fb2da1157622..99f94f1f4a020a3e721fa3c66eeb3c658d195b63 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 5e88121d14d8e9733ab69937d65adc5ad17eba01..17bc6b80e9c82df6702436310766ca7c78085527 100644 (file)
@@ -73,6 +73,18 @@ Language=English
 Module has failed too many times\r
 .\r
 \r
+MessageId=\r
+SymbolicName=MSG_IM_INVALID_MODULE\r
+Language=English\r
+The DLL containing the module was not of the correct format.\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_IM_INCOMPATIBLE\r
+Language=English \r
+The DLL containing the module was not compatible with this version of NetIDMgr.\r
+.\r
+\r
 Messageid=\r
 SymbolicName=MSG_IM_NOT_FOUND\r
 Language=English\r
@@ -103,6 +115,20 @@ Language=English
 Module [%1] is in state [%2!d!]\r
 .\r
 \r
+MessageId=\r
+SymbolicName=MSG_IMERR_TITLE\r
+Language=English\r
+Failed to load module %1!s!\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_IMERR_SUGGEST\r
+Language=English\r
+The following information may help resolve this issue:\r
+\r
+%2!s!\r
+.\r
+\r
 MessageId=\r
 SymbolicName=MSG_IP_TASK_DESC\r
 Language=English\r
@@ -144,3 +170,45 @@ SymbolicName=MSG_IP_EXITING
 Language=English\r
 The plugin [%1] is in error state [%2!d!].  Exiting plugin.\r
 .\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NOT_FOUND\r
+Language=English\r
+Can't get file version information for path [%1!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NO_TRANS\r
+Language=English\r
+Can't get version resource tranlations list for path [%1!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NO_LOCAL\r
+Language=English\r
+The list of version translations were empty or did not contain a resource for the current user or system locale.\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_RES_MISSING\r
+Language=English\r
+Required resource %1!s! missing\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_MOD_MISMATCH\r
+Language=English\r
+The module name specified in the resource is [%1!s!] while the module name as registered is [%2!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_RES_TOO_LONG\r
+Language=English\r
+The resource %1!s! is malformed or too long\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_API_MISMATCH\r
+Language=English\r
+The module was compile for API version %1!d!.  However the current API version is %2!d!.\r
+.\r
index 32072cf63776910da0110933dc0a8b6e6229be00..03519bafd6bad6bf6b6a2ca36237e0fadee6aaa6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -44,7 +44,7 @@ kmq_message_ref * kmqint_get_message_ref(void) {
 \r
     LPOP(&kmq_msg_ref_free, &r);\r
     if(!r) {\r
-        r = malloc(sizeof(kmq_message_ref));\r
+        r = PMALLOC(sizeof(kmq_message_ref));\r
     }\r
     ZeroMemory(r, sizeof(kmq_message_ref));\r
 \r
@@ -134,11 +134,20 @@ void kmqint_post(kmq_msg_subscription * s, kmq_message * m, khm_boolean try_send
 \r
         if(try_send && q->thread == GetCurrentThreadId()) {\r
             khm_int32 rv;\r
-            /* we are sending a message from this thread to this thread.\r
-               just call the recipient directly, bypassing the message queue. */\r
+            /* we are sending a message from this thread to this\r
+               thread.  just call the recipient directly, bypassing\r
+               the message queue. */\r
             m->refcount++;\r
             m->nSent++;\r
-            rv = s->recipient.cb(m->type, m->subtype, m->uparam, m->vparam);\r
+            if (IsBadCodePtr(s->recipient.cb)) {\r
+                rv = KHM_ERROR_INVALID_OPERATION;\r
+            } else {\r
+                if (IsBadCodePtr(s->recipient.cb))\r
+                    rv = KHM_ERROR_INVALID_OPERATION;\r
+                else\r
+                    rv = s->recipient.cb(m->type, m->subtype, \r
+                                         m->uparam, m->vparam);\r
+            }\r
             m->refcount--;\r
             if(KHM_SUCCEEDED(rv))\r
                 m->nCompleted++;\r
@@ -166,26 +175,31 @@ void kmqint_post(kmq_msg_subscription * s, kmq_message * m, khm_boolean try_send
     else if(s->rcpt_type == KMQ_RCPTTYPE_HWND) {\r
         m->refcount++;\r
 \r
-        if(try_send && GetCurrentThreadId() == GetWindowThreadProcessId(s->recipient.hwnd, NULL)) {\r
-            /* kmqint_post does not know whether there are any other messages\r
-               waiting to be posted at this point.  Hence, simply sending the\r
-               message is not the right thing to do as the recipient may\r
-               incorrectly assume that the message has completed when\r
-               (m->nCompleted + m->nFailed == m->nSent).  Therefore, we only\r
-               increment nSent after the message is sent. */\r
-            SendMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, m->type, (LPARAM) m);\r
+        if(try_send && \r
+           GetCurrentThreadId() == GetWindowThreadProcessId(s->recipient.hwnd, \r
+                                                            NULL)) {\r
+            /* kmqint_post does not know whether there are any other\r
+               messages waiting to be posted at this point.  Hence,\r
+               simply sending the message is not the right thing to do\r
+               as the recipient may incorrectly assume that the\r
+               message has completed when (m->nCompleted + m->nFailed\r
+               == m->nSent).  Therefore, we only increment nSent after\r
+               the message is sent. */\r
+            SendMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, \r
+                        m->type, (LPARAM) m);\r
             m->nSent++;\r
         } else {\r
             m->nSent++;\r
-            PostMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, m->type, (LPARAM) m);\r
+            PostMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, \r
+                        m->type, (LPARAM) m);\r
         }\r
-    } \r
+    }\r
 #endif\r
 \r
     else {\r
-        /* This could either be because we were passed in an invalid subscription\r
-           or because we lost a race to a thread that deleted an ad-hoc\r
-           subscription. */\r
+        /* This could either be because we were passed in an invalid\r
+           subscription or because we lost a race to a thread that\r
+           deleted an ad-hoc subscription. */\r
 #ifdef DEBUG\r
         assert(FALSE);\r
 #else\r
@@ -201,7 +215,7 @@ void kmqint_post(kmq_msg_subscription * s, kmq_message * m, khm_boolean try_send
 KHMEXP khm_int32 KHMAPI kmq_subscribe_hwnd(khm_int32 type, HWND hwnd) {\r
     kmq_msg_subscription * s;\r
 \r
-    s = malloc(sizeof(kmq_msg_subscription));\r
+    s = PMALLOC(sizeof(kmq_msg_subscription));\r
     LINIT(s);\r
     s->queue = NULL;\r
     s->rcpt_type = KMQ_RCPTTYPE_HWND;\r
@@ -217,7 +231,7 @@ KHMEXP khm_int32 KHMAPI kmq_subscribe_hwnd(khm_int32 type, HWND hwnd) {
 KHMEXP khm_int32 KHMAPI kmq_subscribe(khm_int32 type, kmq_callback_t cb) {\r
     kmq_msg_subscription * s;\r
 \r
-    s = malloc(sizeof(kmq_msg_subscription));\r
+    s = PMALLOC(sizeof(kmq_msg_subscription));\r
     LINIT(s);\r
     s->queue = kmqint_get_thread_queue();\r
     s->rcpt_type = KMQ_RCPTTYPE_CB;\r
@@ -230,11 +244,12 @@ KHMEXP khm_int32 KHMAPI kmq_subscribe(khm_int32 type, kmq_callback_t cb) {
 /*! \internal\r
     \note Obtains ::cs_kmq_global\r
 */\r
-KHMEXP khm_int32 KHMAPI kmq_create_subscription(kmq_callback_t cb, khm_handle * result)\r
+KHMEXP khm_int32 KHMAPI kmq_create_subscription(kmq_callback_t cb, \r
+                                                khm_handle * result)\r
 {\r
     kmq_msg_subscription * s;\r
 \r
-    s = malloc(sizeof(kmq_msg_subscription));\r
+    s = PMALLOC(sizeof(kmq_msg_subscription));\r
     LINIT(s);\r
     s->queue = kmqint_get_thread_queue();\r
     s->rcpt_type = KMQ_RCPTTYPE_CB;\r
@@ -261,7 +276,7 @@ KHMEXP khm_int32 KHMAPI kmq_delete_subscription(khm_handle sub)
     LDELETE(&kmq_adhoc_subs, s);\r
     LeaveCriticalSection(&cs_kmq_global);\r
 \r
-    free(s);\r
+    PFREE(s);\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
@@ -275,7 +290,7 @@ KHMEXP khm_int32 KHMAPI kmq_unsubscribe_hwnd(khm_int32 type, HWND hwnd) {
 \r
     s = kmqint_msg_type_del_sub_hwnd(type, hwnd);\r
     if(s)\r
-        free(s);\r
+        PFREE(s);\r
     return (s)?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
 }\r
 \r
@@ -288,7 +303,7 @@ KHMEXP khm_int32 KHMAPI kmq_unsubscribe(khm_int32 type, kmq_callback_t cb) {
 \r
     s = kmqint_msg_type_del_sub_cb(type,cb);\r
     if(s)\r
-        free(s);\r
+        PFREE(s);\r
 \r
     return (s)?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
 }\r
@@ -357,6 +372,7 @@ KHMEXP LRESULT KHMAPI kmq_wm_dispatch(LPARAM lparm, kmq_callback_t cb) {
 }\r
 \r
 /*! \internal\r
+\r
     \note Obtains ::cs_kmq_global, kmq_queue::cs, ::cs_kmq_msg_ref, ::cs_kmq_msg, \r
 */\r
 KHMEXP khm_int32 KHMAPI kmq_dispatch(kmq_timer timeout) {\r
@@ -367,6 +383,8 @@ KHMEXP khm_int32 KHMAPI kmq_dispatch(kmq_timer timeout) {
 \r
     q = kmqint_get_thread_queue();\r
 \r
+    assert(q->wait_o);\r
+\r
     hr = WaitForSingleObject(q->wait_o, timeout);\r
     if(hr == WAIT_OBJECT_0) {\r
         /* signalled */\r
index cb50c5476133bceb4d7e134b07c2d0836c36debd..f157e6ab222df52ad1036225f8fd955d0bb31d15 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -81,7 +81,7 @@ void kmqint_attach_this_thread(void) {
     if(!q) {\r
         EnterCriticalSection(&cs_kmq_global);\r
 \r
-        q = malloc(sizeof(kmq_queue));\r
+        q = PMALLOC(sizeof(kmq_queue));\r
 \r
         InitializeCriticalSection(&q->cs);\r
         q->thread = GetCurrentThreadId();\r
index 3d596d79549a46149a9cb56a0efe59fe9007f2c3..4c8c610cd84ef38cd415e7694f502a0e7e3bd6d9 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -258,7 +258,7 @@ KHMEXP khm_int32 KHMAPI kmq_exit(void);
 \r
     \see kmq_find_type() and kmq_unregister_type()\r
 \r
-    \retval KHM_ERROR_INVALID_PARM The \a name parameter was invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM The \a name parameter was invalid.\r
     \retval KHM_ERROR_EXISTS A message type with that name already exists.\r
     \retval KHM_ERROR_NO_RESOURCES Can't register any more message types.\r
     \retval KHM_ERROR_SUCCESS The operation succeeded.\r
@@ -725,7 +725,7 @@ KHMEXP khm_boolean KHMAPI kmq_has_completed(kmq_call call);
 \r
     \retval KHM_ERROR_SUCCESS The call completed\r
     \retval KHM_ERROR_TIMEOUT The timeout period expired\r
-    \retval KHM_ERROR_INVALID_PARM One of the parameters were invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One of the parameters were invalid.\r
 */\r
 KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout);\r
 \r
index c82fb925d71747c27524b997a7ee12d3319d0230..aeaf3366ca0bef11048fd76122929c7448d354f5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -33,6 +33,7 @@
 #include<kherror.h>\r
 #include<khmsgtypes.h>\r
 #include<kconfig.h>\r
+#include<utils.h>\r
 #include<strsafe.h>\r
 \r
 #define KMQ_CONF_SPACE_NAME L"KMQ"\r
index d93403a57b3fc8a6d974f05cc7bd7ec941cc7e83..3e8176f1b3b3dad8605e9f64763f7d82b2b4b626 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index eb44eecf3acb5fb0bd549ec89e02b82a6e9b0afe..62a0133d206ee73aac82e787368702b51a5523f3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -97,7 +97,7 @@ void kmqint_msg_type_create(int t) {
     EnterCriticalSection(&cs_kmq_types);\r
     if(!msg_types[t]) {\r
         kmq_msg_type * mt;\r
-        mt = malloc(sizeof(kmq_msg_type));\r
+        mt = PMALLOC(sizeof(kmq_msg_type));\r
         ZeroMemory(mt, sizeof(kmq_msg_type));\r
         mt->id = t;\r
         LINIT(mt);\r
@@ -119,8 +119,8 @@ KHMEXP khm_int32 KHMAPI kmq_register_type(wchar_t * name,
     size_t sz;\r
 \r
     if(FAILED(StringCbLength(name, KMQ_MAXCB_TYPE_NAME, &sz)) ||\r
-        sz == 0)\r
-        return KHM_ERROR_INVALID_PARM;\r
+       sz == 0)\r
+        return KHM_ERROR_INVALID_PARAM;\r
     sz += sizeof(wchar_t);\r
 \r
     EnterCriticalSection(&cs_kmq_types);\r
@@ -128,10 +128,17 @@ KHMEXP khm_int32 KHMAPI kmq_register_type(wchar_t * name,
         if(msg_types[i] == NULL) {\r
             if(first_free == 0)\r
                 first_free = i;\r
+            /* continue searching since we might find that this type\r
+               is already registered. */\r
         } else {\r
             if(msg_types[i]->name != NULL && \r
-               !wcscmp(msg_types[i]->name, name))\r
+               !wcscmp(msg_types[i]->name, name)) {\r
+\r
                 registered = TRUE;\r
+                if (new_id)\r
+                    *new_id = i;\r
+                break;\r
+            }\r
         }\r
     }\r
 \r
@@ -141,7 +148,7 @@ KHMEXP khm_int32 KHMAPI kmq_register_type(wchar_t * name,
         rv = KHM_ERROR_NO_RESOURCES;\r
     } else {\r
         kmqint_msg_type_create(first_free);\r
-        msg_types[first_free]->name = malloc(sz);\r
+        msg_types[first_free]->name = PMALLOC(sz);\r
         StringCbCopy(msg_types[first_free]->name, sz, name);\r
 \r
         if(new_id != NULL)\r
@@ -172,7 +179,6 @@ KHMEXP khm_int32 KHMAPI kmq_find_type(wchar_t * name, khm_int32 * id)
     }\r
 \r
     return KHM_ERROR_NOT_FOUND;\r
-\r
 }\r
 \r
 KHMEXP khm_int32 KHMAPI kmq_unregister_type(khm_int32 id)\r
@@ -180,7 +186,7 @@ KHMEXP khm_int32 KHMAPI kmq_unregister_type(khm_int32 id)
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(id < KMSGBASE_USER || id > KMQ_MSG_TYPE_MAX)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_kmq_types);\r
     if(msg_types[id] != NULL) {\r
@@ -240,6 +246,7 @@ void kmqint_msg_type_del_sub(kmq_msg_subscription *s) {
     LeaveCriticalSection(&cs_kmq_types);\r
 }\r
 \r
+\r
 /*! \internal\r
     \brief Deletes a window subscription from a message type\r
     \note Obtains ::cs_kmq_types\r
@@ -288,7 +295,9 @@ kmq_msg_subscription * kmqint_msg_type_del_sub_cb(khm_int32 t, kmq_callback_t cb
     s = msg_types[t]->subs;\r
     while(s) {\r
         kmq_msg_subscription * n = LNEXT(s);\r
-        if(s->rcpt_type == KMQ_RCPTTYPE_CB && s->recipient.cb == cb && s->queue == q) {\r
+        if(s->rcpt_type == KMQ_RCPTTYPE_CB && \r
+           s->recipient.cb == cb && \r
+           s->queue == q) {\r
             /*TODO: do more here? */\r
             LDELETE(&msg_types[t]->subs, s);\r
             break;\r
@@ -306,6 +315,7 @@ kmq_msg_subscription * kmqint_msg_type_del_sub_cb(khm_int32 t, kmq_callback_t cb
     */\r
 khm_int32 kmqint_msg_publish(kmq_message * m, khm_boolean try_send) {\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
+\r
     if(msg_types[m->type]) {\r
         kmq_msg_type *t;\r
         kmq_msg_subscription * s;\r
@@ -341,7 +351,7 @@ khm_int32 kmqint_msg_publish(kmq_message * m, khm_boolean try_send) {
 khm_int32 kmqint_msg_type_set_handler(khm_int32 type, kmq_msg_completion_handler handler) {\r
 \r
     if (type == KMSG_SYSTEM)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(!msg_types[type])\r
         kmqint_msg_type_create(type);\r
index 5391844ac181dd67628178c5e8efae091b759332..af1f555667e04d7406bc2719c77fa02b1162acdf 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -33,13 +33,14 @@ kmq_message * msg_active = NULL;
 /*! \internal\r
     \brief Get a message object\r
     \note called with ::cs_kmq_msg held */\r
-kmq_message * kmqint_get_message(void) {\r
+kmq_message * \r
+kmqint_get_message(void) {\r
     kmq_message * m;\r
 \r
     LPOP(&msg_free,&m);\r
     if(!m) {\r
         /* allocate one */\r
-        m = malloc(sizeof(kmq_message));\r
+        m = PMALLOC(sizeof(kmq_message));\r
     }\r
     ZeroMemory((void*)m, sizeof(kmq_message));\r
 \r
@@ -52,7 +53,8 @@ kmq_message * kmqint_get_message(void) {
     \brief Frees a message object\r
     \note called with ::cs_kmq_msg held\r
     */\r
-void kmqint_put_message(kmq_message *m) {\r
+void \r
+kmqint_put_message(kmq_message *m) {\r
     int queued;\r
     /* we can only free a message if the refcount is zero.\r
        Otherwise we have to wait until the call is freed. */\r
@@ -80,7 +82,9 @@ void kmqint_put_message(kmq_message *m) {
 /*! \internal\r
     \note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs\r
     */\r
-KHMEXP khm_int32 KHMAPI kmq_send_message(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_message(khm_int32 type, khm_int32 subtype, \r
+                 khm_ui_4 uparam, void * blob) {\r
     kmq_call c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -100,7 +104,9 @@ KHMEXP khm_int32 KHMAPI kmq_send_message(khm_int32 type, khm_int32 subtype, khm_
 /*! \internal\r
     \note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs\r
     */\r
-KHMEXP khm_int32 KHMAPI kmq_post_message(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_message(khm_int32 type, khm_int32 subtype, \r
+                 khm_ui_4 uparam, void * blob) {\r
     return kmqint_post_message_ex(type, subtype, uparam, blob, NULL, FALSE);\r
 }\r
 \r
@@ -108,7 +114,8 @@ KHMEXP khm_int32 KHMAPI kmq_post_message(khm_int32 type, khm_int32 subtype, khm_
     \brief Frees a call\r
     \note Obtains ::cs_kmq_msg\r
     */\r
-KHMEXP khm_int32 KHMAPI kmq_free_call(kmq_call call) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_free_call(kmq_call call) {\r
     kmq_message * m;\r
 \r
     m = call;\r
@@ -126,13 +133,10 @@ KHMEXP khm_int32 KHMAPI kmq_free_call(kmq_call call) {
 /*! \internal\r
     \note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs \r
     */\r
-khm_int32 kmqint_post_message_ex(\r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * blob, \r
-    kmq_call * call,\r
-    khm_boolean try_send) {\r
+khm_int32 \r
+kmqint_post_message_ex(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, \r
+    void * blob, kmq_call * call, khm_boolean try_send) \r
+{\r
     kmq_message * m;\r
     kherr_context * ctx;\r
 \r
@@ -170,7 +174,9 @@ khm_int32 kmqint_post_message_ex(
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_post_message_ex(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob, kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_message_ex(khm_int32 type, khm_int32 subtype, \r
+                    khm_ui_4 uparam, void * blob, kmq_call * call)\r
 {\r
     return kmqint_post_message_ex(type, subtype, uparam, blob, call, FALSE);\r
 }\r
@@ -178,21 +184,19 @@ KHMEXP khm_int32 KHMAPI kmq_post_message_ex(khm_int32 type, khm_int32 subtype, k
 \r
 /*! \internal\r
 */\r
-KHMEXP khm_int32 KHMAPI kmq_post_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+                 khm_ui_4 uparam, void * vparam)\r
 {\r
     return kmq_post_sub_msg_ex(sub, type, subtype, uparam, vparam, NULL);\r
 }\r
 \r
 /*! \internal\r
 */\r
-khm_int32 kmqint_post_sub_msg_ex(\r
-    khm_handle sub, \r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * vparam, \r
-    kmq_call * call,\r
-    khm_boolean try_send)\r
+khm_int32 \r
+kmqint_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+                       khm_ui_4 uparam, void * vparam, \r
+                       kmq_call * call, khm_boolean try_send)\r
 {\r
     kmq_message * m;\r
     kherr_context * ctx;\r
@@ -237,20 +241,18 @@ khm_int32 kmqint_post_sub_msg_ex(
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam, kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+                    khm_ui_4 uparam, void * vparam, kmq_call * call)\r
 {\r
-    return kmqint_post_sub_msg_ex(sub, type, subtype, uparam, vparam, call, FALSE);\r
+    return kmqint_post_sub_msg_ex(sub, type, subtype, \r
+                                  uparam, vparam, call, FALSE);\r
 }\r
 \r
-khm_int32 kmqint_post_subs_msg_ex(\r
-    khm_handle * subs, \r
-    khm_size   n_subs, \r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * vparam, \r
-    kmq_call * call,\r
-    khm_boolean try_send)\r
+khm_int32 \r
+kmqint_post_subs_msg_ex(khm_handle * subs, khm_size   n_subs, khm_int32 type, \r
+                        khm_int32 subtype, khm_ui_4 uparam, void * vparam, \r
+                        kmq_call * call, khm_boolean try_send)\r
 {\r
     kmq_message * m;\r
     kherr_context * ctx;\r
@@ -301,49 +303,50 @@ khm_int32 kmqint_post_subs_msg_ex(
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_post_subs_msg(\r
-    khm_handle * subs, \r
-    khm_size   n_subs, \r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_subs_msg(khm_handle * subs, \r
+                  khm_size   n_subs, \r
+                  khm_int32 type, \r
+                  khm_int32 subtype, \r
+                  khm_ui_4 uparam, \r
+                  void * vparam)\r
 {\r
-    return kmqint_post_subs_msg_ex(\r
-        subs,\r
-        n_subs,\r
-        type,\r
-        subtype,\r
-        uparam,\r
-        vparam,\r
-        NULL,\r
-        FALSE);\r
+    return kmqint_post_subs_msg_ex(subs,\r
+                                   n_subs,\r
+                                   type,\r
+                                   subtype,\r
+                                   uparam,\r
+                                   vparam,\r
+                                   NULL,\r
+                                   FALSE);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_post_subs_msg_ex(\r
-    khm_handle * subs, \r
-    khm_int32 n_subs, \r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * vparam, \r
-    kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_subs_msg_ex(khm_handle * subs, \r
+                     khm_int32 n_subs, \r
+                     khm_int32 type, \r
+                     khm_int32 subtype, \r
+                     khm_ui_4 uparam, \r
+                     void * vparam, \r
+                     kmq_call * call)\r
 {\r
-    return kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, uparam, vparam, call, FALSE);\r
+    return kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, \r
+                                   uparam, vparam, call, FALSE);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_send_subs_msg(\r
-    khm_handle *subs, \r
-    khm_int32 n_subs,\r
-    khm_int32 type, \r
-    khm_int32 subtype, \r
-    khm_ui_4 uparam, \r
-    void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_subs_msg(khm_handle *subs, \r
+                  khm_int32 n_subs,\r
+                  khm_int32 type, \r
+                  khm_int32 subtype, \r
+                  khm_ui_4 uparam, \r
+                  void * vparam)\r
 {\r
     kmq_call c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
-    rv = kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, uparam, vparam, &c, TRUE);\r
+    rv = kmqint_post_subs_msg_ex(subs, n_subs, type, subtype,\r
+                                 uparam, vparam, &c, TRUE);\r
     if(KHM_FAILED(rv))\r
         return rv;\r
 \r
@@ -358,7 +361,9 @@ KHMEXP khm_int32 KHMAPI kmq_send_subs_msg(
 \r
 /*! \internal\r
 */\r
-KHMEXP khm_int32 KHMAPI kmq_send_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+                 khm_ui_4 uparam, void * vparam)\r
 {\r
     kmq_call c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -379,7 +384,8 @@ KHMEXP khm_int32 KHMAPI kmq_send_sub_msg(khm_handle sub, khm_int32 type, khm_int
 /*! \internal\r
     \note Obtains ::cs_kmq_global, ::cs_kmq_msg, ::cs_kmq_msg_ref, kmq_queue::cs\r
     */\r
-KHMEXP khm_int32 KHMAPI kmq_send_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam) {\r
     kmq_call c;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
@@ -397,7 +403,9 @@ KHMEXP khm_int32 KHMAPI kmq_send_thread_quit_message(kmq_thread_id thread, khm_u
 /*! \internal\r
     \note Obtains ::cs_kmq_global, ::cs_kmq_msg, ::cs_kmq_msg_ref, kmq_queue::cs\r
     */ \r
-KHMEXP khm_int32 KHMAPI kmq_post_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam, kmq_call * call) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_thread_quit_message(kmq_thread_id thread, \r
+                             khm_ui_4 uparam, kmq_call * call) {\r
     kmq_message * m;\r
     kmq_queue * q;\r
 \r
@@ -438,15 +446,18 @@ KHMEXP khm_int32 KHMAPI kmq_post_thread_quit_message(kmq_thread_id thread, khm_u
 }\r
 \r
 /* TODO:Implement these */\r
-KHMEXP khm_int32 KHMAPI kmq_get_next_response(kmq_call call, void ** resp) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_get_next_response(kmq_call call, void ** resp) {\r
     return 0;\r
 }\r
 \r
-KHMEXP khm_boolean KHMAPI kmq_has_completed(kmq_call call) {\r
+KHMEXP khm_boolean KHMAPI \r
+kmq_has_completed(kmq_call call) {\r
     return (call->nCompleted + call->nFailed == call->nSent);\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_wait(kmq_call call, kmq_timer timeout) {\r
     kmq_message * m = call;\r
     DWORD rv;\r
     /*TODO: check for call free */\r
@@ -458,13 +469,15 @@ KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout) {
         else\r
             return KHM_ERROR_TIMEOUT;\r
     } else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 /*! \internal\r
     \note Obtains ::cs_kmq_types\r
     */\r
-KHMEXP khm_int32 KHMAPI kmq_set_completion_handler(khm_int32 type, kmq_msg_completion_handler handler) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_set_completion_handler(khm_int32 type, \r
+                           kmq_msg_completion_handler handler) {\r
     return kmqint_msg_type_set_handler(type, handler);\r
 }\r
 \r
index 5d48c2d12df45d50941178480c74282c49f08841..fc2887cc1bf2ac190b30a26971883493240038e5 100644 (file)
@@ -48,6 +48,7 @@ OBJFILES= \
        $(UTILDIR)\hashtable.obj        \\r
        $(UTILDIR)\sync.obj             \\r
        $(UTILDIR)\mstring.obj          \\r
+       $(UTILDIR)\perfstat.obj         \\r
        $(KHERRDIR)\kherrmain.obj       \\r
        $(KHERRDIR)\kherr.obj           \\r
        $(KCONFIGDIR)\kconfigmain.obj   \\r
@@ -95,7 +96,9 @@ RESFILES= \
 SDKLIBFILES= \\r
        advapi32.lib                    \\r
        strsafe.lib                     \\r
-       comctl32.lib\r
+       comctl32.lib                    \\r
+       shlwapi.lib                     \\r
+       version.lib\r
 \r
 $(DLLFILE): $(OBJFILES) $(RESFILES)\r
        $(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
index f54d4ef72cd72989c631155cf6b8884a72a7f96e..e54e2813742012bbd0de88d7ae7142afd23277c5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 10870e8c393f99c9a423ff66fa160c332e9755a2..26aeaa691124c3f8edcab068ff1a4f2237d736c4 100644 (file)
@@ -25,7 +25,7 @@
 /* $Id$ */\r
 \r
 #include<afxres.h>\r
-#include<khimaira_version.h>\r
+#include<netidmgr_intver.h>\r
 \r
 #ifdef _WIN32\r
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
index cd33813f7846f787076bcb30ff7021c3782bc2a8..ed5110e6674e551d2ace9644bb59e0cf43de8a3e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -134,6 +134,7 @@ DECL_FUNC_PTR(krb5_get_renewed_creds);
 DECL_FUNC_PTR(krb5_get_default_config_files);\r
 DECL_FUNC_PTR(krb5_free_config_files);\r
 DECL_FUNC_PTR(krb5_get_default_realm);\r
+DECL_FUNC_PTR(krb5_set_default_realm);\r
 DECL_FUNC_PTR(krb5_free_ticket);\r
 DECL_FUNC_PTR(krb5_decode_ticket);\r
 DECL_FUNC_PTR(krb5_get_host_realm);\r
@@ -152,10 +153,16 @@ DECL_FUNC_PTR(error_message);
 \r
 // Profile functions\r
 DECL_FUNC_PTR(profile_init);    \r
+DECL_FUNC_PTR(profile_flush);\r
 DECL_FUNC_PTR(profile_release); \r
 DECL_FUNC_PTR(profile_get_subsection_names);\r
 DECL_FUNC_PTR(profile_free_list);\r
 DECL_FUNC_PTR(profile_get_string);\r
+DECL_FUNC_PTR(profile_get_values);\r
+DECL_FUNC_PTR(profile_get_relation_names);\r
+DECL_FUNC_PTR(profile_clear_relation);\r
+DECL_FUNC_PTR(profile_add_relation);\r
+DECL_FUNC_PTR(profile_update_relation);\r
 DECL_FUNC_PTR(profile_release_string);\r
 \r
 // Service functions\r
@@ -217,67 +224,68 @@ FUNC_INFO k4_fi[] = {
 \r
 FUNC_INFO k5_fi[] = {\r
     MAKE_FUNC_INFO(krb5_change_password),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_init),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_tkt_life),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_renew_life),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_forwardable),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_proxiable),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_address_list),\r
-        MAKE_FUNC_INFO(krb5_get_init_creds_password),\r
-        MAKE_FUNC_INFO(krb5_get_prompt_types),\r
-        MAKE_FUNC_INFO(krb5_build_principal_ext),\r
-        MAKE_FUNC_INFO(krb5_cc_get_name),\r
-        MAKE_FUNC_INFO(krb5_cc_resolve),\r
-        MAKE_FUNC_INFO(krb5_cc_default),\r
-        MAKE_FUNC_INFO(krb5_cc_default_name),\r
-        MAKE_FUNC_INFO(krb5_cc_set_default_name),\r
-        MAKE_FUNC_INFO(krb5_cc_initialize),\r
-        MAKE_FUNC_INFO(krb5_cc_destroy),\r
-        MAKE_FUNC_INFO(krb5_cc_close),\r
-        MAKE_FUNC_INFO(krb5_cc_copy_creds),\r
-        MAKE_FUNC_INFO(krb5_cc_store_cred),\r
-        MAKE_FUNC_INFO(krb5_cc_retrieve_cred),\r
-        MAKE_FUNC_INFO(krb5_cc_get_principal),\r
-        MAKE_FUNC_INFO(krb5_cc_start_seq_get),\r
-        MAKE_FUNC_INFO(krb5_cc_next_cred),\r
-        MAKE_FUNC_INFO(krb5_cc_end_seq_get),\r
-        MAKE_FUNC_INFO(krb5_cc_remove_cred),\r
-        MAKE_FUNC_INFO(krb5_cc_set_flags),\r
-        // MAKE_FUNC_INFO(krb5_cc_get_type),\r
-        MAKE_FUNC_INFO(krb5_free_context),\r
-        MAKE_FUNC_INFO(krb5_free_cred_contents),\r
-        MAKE_FUNC_INFO(krb5_free_principal),\r
-        MAKE_FUNC_INFO(krb5_get_in_tkt_with_password),\r
-        MAKE_FUNC_INFO(krb5_init_context),\r
-        MAKE_FUNC_INFO(krb5_parse_name),\r
-        MAKE_FUNC_INFO(krb5_timeofday),\r
-        MAKE_FUNC_INFO(krb5_timestamp_to_sfstring),\r
-        MAKE_FUNC_INFO(krb5_unparse_name),\r
-        MAKE_FUNC_INFO(krb5_get_credentials),\r
-        MAKE_FUNC_INFO(krb5_mk_req),\r
-        MAKE_FUNC_INFO(krb5_sname_to_principal),\r
-        MAKE_FUNC_INFO(krb5_get_credentials_renew),\r
-        MAKE_FUNC_INFO(krb5_free_data),\r
-        MAKE_FUNC_INFO(krb5_free_data_contents),\r
-        //  MAKE_FUNC_INFO(krb5_get_realm_domain),\r
-        MAKE_FUNC_INFO(krb5_free_unparsed_name),\r
-        MAKE_FUNC_INFO(krb5_os_localaddr),\r
-        MAKE_FUNC_INFO(krb5_copy_keyblock_contents),\r
-        MAKE_FUNC_INFO(krb5_copy_data),\r
-        MAKE_FUNC_INFO(krb5_free_creds),\r
-        MAKE_FUNC_INFO(krb5_build_principal),\r
-        MAKE_FUNC_INFO(krb5_get_renewed_creds),\r
-        MAKE_FUNC_INFO(krb5_free_addresses),\r
-        MAKE_FUNC_INFO(krb5_get_default_config_files),\r
-        MAKE_FUNC_INFO(krb5_free_config_files),\r
-        MAKE_FUNC_INFO(krb5_get_default_realm),\r
-        MAKE_FUNC_INFO(krb5_free_ticket),\r
-        MAKE_FUNC_INFO(krb5_decode_ticket),\r
-        MAKE_FUNC_INFO(krb5_get_host_realm),\r
-        MAKE_FUNC_INFO(krb5_free_host_realm),\r
-        MAKE_FUNC_INFO(krb5_c_random_make_octets),\r
-        MAKE_FUNC_INFO(krb5_free_default_realm),\r
-        END_FUNC_INFO\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_init),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_tkt_life),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_renew_life),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_forwardable),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_proxiable),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_address_list),\r
+    MAKE_FUNC_INFO(krb5_get_init_creds_password),\r
+    MAKE_FUNC_INFO(krb5_get_prompt_types),\r
+    MAKE_FUNC_INFO(krb5_build_principal_ext),\r
+    MAKE_FUNC_INFO(krb5_cc_get_name),\r
+    MAKE_FUNC_INFO(krb5_cc_resolve),\r
+    MAKE_FUNC_INFO(krb5_cc_default),\r
+    MAKE_FUNC_INFO(krb5_cc_default_name),\r
+    MAKE_FUNC_INFO(krb5_cc_set_default_name),\r
+    MAKE_FUNC_INFO(krb5_cc_initialize),\r
+    MAKE_FUNC_INFO(krb5_cc_destroy),\r
+    MAKE_FUNC_INFO(krb5_cc_close),\r
+    MAKE_FUNC_INFO(krb5_cc_copy_creds),\r
+    MAKE_FUNC_INFO(krb5_cc_store_cred),\r
+    MAKE_FUNC_INFO(krb5_cc_retrieve_cred),\r
+    MAKE_FUNC_INFO(krb5_cc_get_principal),\r
+    MAKE_FUNC_INFO(krb5_cc_start_seq_get),\r
+    MAKE_FUNC_INFO(krb5_cc_next_cred),\r
+    MAKE_FUNC_INFO(krb5_cc_end_seq_get),\r
+    MAKE_FUNC_INFO(krb5_cc_remove_cred),\r
+    MAKE_FUNC_INFO(krb5_cc_set_flags),\r
+    // MAKE_FUNC_INFO(krb5_cc_get_type),\r
+    MAKE_FUNC_INFO(krb5_free_context),\r
+    MAKE_FUNC_INFO(krb5_free_cred_contents),\r
+    MAKE_FUNC_INFO(krb5_free_principal),\r
+    MAKE_FUNC_INFO(krb5_get_in_tkt_with_password),\r
+    MAKE_FUNC_INFO(krb5_init_context),\r
+    MAKE_FUNC_INFO(krb5_parse_name),\r
+    MAKE_FUNC_INFO(krb5_timeofday),\r
+    MAKE_FUNC_INFO(krb5_timestamp_to_sfstring),\r
+    MAKE_FUNC_INFO(krb5_unparse_name),\r
+    MAKE_FUNC_INFO(krb5_get_credentials),\r
+    MAKE_FUNC_INFO(krb5_mk_req),\r
+    MAKE_FUNC_INFO(krb5_sname_to_principal),\r
+    MAKE_FUNC_INFO(krb5_get_credentials_renew),\r
+    MAKE_FUNC_INFO(krb5_free_data),\r
+    MAKE_FUNC_INFO(krb5_free_data_contents),\r
+    //  MAKE_FUNC_INFO(krb5_get_realm_domain),\r
+    MAKE_FUNC_INFO(krb5_free_unparsed_name),\r
+    MAKE_FUNC_INFO(krb5_os_localaddr),\r
+    MAKE_FUNC_INFO(krb5_copy_keyblock_contents),\r
+    MAKE_FUNC_INFO(krb5_copy_data),\r
+    MAKE_FUNC_INFO(krb5_free_creds),\r
+    MAKE_FUNC_INFO(krb5_build_principal),\r
+    MAKE_FUNC_INFO(krb5_get_renewed_creds),\r
+    MAKE_FUNC_INFO(krb5_free_addresses),\r
+    MAKE_FUNC_INFO(krb5_get_default_config_files),\r
+    MAKE_FUNC_INFO(krb5_free_config_files),\r
+    MAKE_FUNC_INFO(krb5_get_default_realm),\r
+    MAKE_FUNC_INFO(krb5_set_default_realm),\r
+    MAKE_FUNC_INFO(krb5_free_ticket),\r
+    MAKE_FUNC_INFO(krb5_decode_ticket),\r
+    MAKE_FUNC_INFO(krb5_get_host_realm),\r
+    MAKE_FUNC_INFO(krb5_free_host_realm),\r
+    MAKE_FUNC_INFO(krb5_c_random_make_octets),\r
+    MAKE_FUNC_INFO(krb5_free_default_realm),\r
+    END_FUNC_INFO\r
 };\r
 \r
 FUNC_INFO k524_fi[] = {\r
@@ -288,12 +296,18 @@ FUNC_INFO k524_fi[] = {
 \r
 FUNC_INFO profile_fi[] = {\r
     MAKE_FUNC_INFO(profile_init),\r
-        MAKE_FUNC_INFO(profile_release), \r
-        MAKE_FUNC_INFO(profile_get_subsection_names),\r
-        MAKE_FUNC_INFO(profile_free_list),\r
-        MAKE_FUNC_INFO(profile_get_string),\r
-        MAKE_FUNC_INFO(profile_release_string),\r
-        END_FUNC_INFO\r
+    MAKE_FUNC_INFO(profile_flush),\r
+    MAKE_FUNC_INFO(profile_release), \r
+    MAKE_FUNC_INFO(profile_get_subsection_names),\r
+    MAKE_FUNC_INFO(profile_free_list),\r
+    MAKE_FUNC_INFO(profile_get_string),\r
+    MAKE_FUNC_INFO(profile_get_values),\r
+    MAKE_FUNC_INFO(profile_get_relation_names),\r
+    MAKE_FUNC_INFO(profile_clear_relation),\r
+    MAKE_FUNC_INFO(profile_add_relation),\r
+    MAKE_FUNC_INFO(profile_update_relation),\r
+    MAKE_FUNC_INFO(profile_release_string),\r
+    END_FUNC_INFO\r
 };\r
 \r
 FUNC_INFO ce_fi[] = {\r
index b3ba225a66d7301ff41278429fc3e0017c7dc28a..99aad9aedcbef6e7da63096c70bf8d3b2d80b6ce 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -247,6 +247,7 @@ extern DECL_FUNC_PTR(krb5_free_addresses);
 extern DECL_FUNC_PTR(krb5_get_default_config_files);\r
 extern DECL_FUNC_PTR(krb5_free_config_files);\r
 extern DECL_FUNC_PTR(krb5_get_default_realm);\r
+extern DECL_FUNC_PTR(krb5_set_default_realm);\r
 extern DECL_FUNC_PTR(krb5_free_ticket);\r
 extern DECL_FUNC_PTR(krb5_decode_ticket);\r
 extern DECL_FUNC_PTR(krb5_get_host_realm);\r
@@ -264,10 +265,16 @@ extern DECL_FUNC_PTR(error_message);
 \r
 // Profile functions\r
 extern DECL_FUNC_PTR(profile_init);\r
+extern DECL_FUNC_PTR(profile_flush);\r
 extern DECL_FUNC_PTR(profile_release);\r
 extern DECL_FUNC_PTR(profile_get_subsection_names);\r
 extern DECL_FUNC_PTR(profile_free_list);\r
 extern DECL_FUNC_PTR(profile_get_string);\r
+extern DECL_FUNC_PTR(profile_get_values);\r
+extern DECL_FUNC_PTR(profile_get_relation_names);\r
+extern DECL_FUNC_PTR(profile_clear_relation);\r
+extern DECL_FUNC_PTR(profile_add_relation);\r
+extern DECL_FUNC_PTR(profile_update_relation);\r
 extern DECL_FUNC_PTR(profile_release_string);\r
 \r
 // Service functions\r
index 5501a120686d4fd80b55e9183cc42f0a2d094f4f..6019c928ef8f4402966d89524f2ee7b03ead29a8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 /* $Id$ */\r
 \r
 #include<windows.h>\r
-#include<kcreddb.h>\r
-#include<kherror.h>\r
+#include<netidmgr.h>\r
 #include<dynimport.h>\r
+#include<krb5common.h>\r
+#ifdef DEBUG\r
+#include<assert.h>\r
+#endif\r
 \r
 /**************************************/\r
 /* khm_krb5_error():           */\r
@@ -94,15 +97,14 @@ khm_krb5_initialize(khm_handle ident,
     if (pkrb5_init_context == NULL)\r
         return 1;\r
 \r
-    if (*ctx == 0 && (rc = (*pkrb5_init_context)(ctx)))\r
-    {\r
+    if (*ctx == 0 && (rc = (*pkrb5_init_context)(ctx))) {\r
         functionName = "krb5_init_context()";\r
         freeContextFlag = 0;\r
         goto on_error;\r
     }\r
 \r
     if(*cache == 0) {\r
-        wchar_t wccname[256];\r
+        wchar_t wccname[MAX_PATH];\r
         khm_size cbwccname;\r
 \r
         if(ident != NULL) {\r
@@ -110,8 +112,21 @@ khm_krb5_initialize(khm_handle ident,
             do {\r
                 char ccname[256];\r
 \r
-                if(KHM_FAILED(kcdb_identity_get_attrib(ident, L"Krb5CCName", NULL, wccname, &cbwccname)))\r
-                    break;\r
+                if(KHM_FAILED(kcdb_identity_get_attrib(ident, L"Krb5CCName",\r
+                                                       NULL, wccname,\r
+                                                       &cbwccname))) {\r
+                    cbwccname = sizeof(wccname);\r
+                    if (KHM_FAILED\r
+                        (khm_krb5_find_ccache_for_identity(ident,\r
+                                                           ctx,\r
+                                                           wccname,\r
+                                                           &cbwccname))) {\r
+#ifdef DEBUG_LIKE_A_MADMAN\r
+                        assert(FALSE);\r
+#endif\r
+                        break;\r
+                    }\r
+                }\r
 \r
                 if(UnicodeStrToAnsi(ccname, sizeof(ccname), wccname) == 0)\r
                     break;\r
@@ -124,8 +139,11 @@ khm_krb5_initialize(khm_handle ident,
             } while(FALSE);\r
         }\r
 \r
-        if (*cache == 0 && (rc = (*pkrb5_cc_default)(*ctx, cache)))\r
-        {\r
+        if (*cache == 0\r
+#ifdef FAILOVER_TO_DEFAULT_CCACHE\r
+            && (rc = (*pkrb5_cc_default)(*ctx, cache))\r
+#endif\r
+            ) {\r
             functionName = "krb5_cc_default()";\r
             freeContextFlag = 1;\r
             goto on_error;\r
@@ -141,8 +159,7 @@ khm_krb5_initialize(khm_handle ident,
         if (rc != KRB5_FCC_NOFILE && rc != KRB5_CC_NOTFOUND)\r
             khm_krb5_error(rc, "krb5_cc_set_flags()", 0, ctx, \r
             cache);\r
-        else if ((rc == KRB5_FCC_NOFILE || rc == KRB5_CC_NOTFOUND) && *ctx != NULL)\r
-        {\r
+        else if ((rc == KRB5_FCC_NOFILE || rc == KRB5_CC_NOTFOUND) && *ctx != NULL) {\r
             if (*cache != NULL)\r
                 (*pkrb5_cc_close)(*ctx, *cache);\r
         }\r
@@ -154,3 +171,267 @@ on_error:
     return khm_krb5_error(rc, functionName, freeContextFlag, ctx, cache);\r
 #endif //!NO_KRB5\r
 }\r
+\r
+#define TIMET_TOLERANCE (60*5)\r
+\r
+khm_int32 KHMAPI\r
+khm_get_identity_expiration_time(krb5_context ctx, krb5_ccache cc, \r
+                                 khm_handle ident, \r
+                                 krb5_timestamp * pexpiration)\r
+{\r
+    krb5_principal principal = 0;\r
+    char * princ_name = NULL;\r
+    krb5_creds creds;\r
+    krb5_error_code code;\r
+    krb5_error_code cc_code;\r
+    krb5_cc_cursor cur;\r
+    krb5_timestamp now, expiration = 0;\r
+\r
+    wchar_t w_ident_name[KCDB_IDENT_MAXCCH_NAME];\r
+    char    ident_name[KCDB_IDENT_MAXCCH_NAME];\r
+    khm_size cb;\r
+\r
+    khm_int32 rv = KHM_ERROR_NOT_FOUND;\r
+\r
+    if (!ctx || !cc || !ident || !pexpiration)\r
+        return KHM_ERROR_GENERAL;\r
+\r
+    code = pkrb5_cc_get_principal(ctx, cc, &principal);\r
+\r
+    if ( code )\r
+        return KHM_ERROR_INVALID_PARAM;\r
+\r
+    cb = sizeof(w_ident_name);\r
+    kcdb_identity_get_name(ident, w_ident_name, &cb);\r
+    UnicodeStrToAnsi(ident_name, sizeof(ident_name), w_ident_name);\r
+\r
+    code = pkrb5_unparse_name(ctx, principal, &princ_name);\r
+\r
+    /* compare principal to ident. */\r
+\r
+    if ( code || !princ_name ||\r
+         strcmp(princ_name, ident_name) ) {\r
+        if (princ_name)\r
+            pkrb5_free_unparsed_name(ctx, princ_name);\r
+        pkrb5_free_principal(ctx, principal);\r
+        return KHM_ERROR_UNKNOWN;\r
+    }\r
+\r
+    pkrb5_free_unparsed_name(ctx, princ_name);\r
+    pkrb5_free_principal(ctx, principal);\r
+\r
+    code = pkrb5_timeofday(ctx, &now);\r
+\r
+    if (code)\r
+        return KHM_ERROR_UNKNOWN;\r
+\r
+    cc_code = pkrb5_cc_start_seq_get(ctx, cc, &cur);\r
+\r
+    while (!(cc_code = pkrb5_cc_next_cred(ctx, cc, &cur, &creds))) {\r
+        krb5_data * c0 = krb5_princ_name(ctx, creds.server);\r
+        krb5_data * c1  = krb5_princ_component(ctx, creds.server, 1);\r
+        krb5_data * r = krb5_princ_realm(ctx, creds.server);\r
+\r
+        if ( c0 && c1 && r && c1->length == r->length && \r
+             !strncmp(c1->data,r->data,r->length) &&\r
+             !strncmp("krbtgt",c0->data,c0->length) ) {\r
+\r
+            /* we have a TGT, check for the expiration time.\r
+             * if it is valid and renewable, use the renew time \r
+             */\r
+\r
+            if (!(creds.ticket_flags & TKT_FLG_INVALID) &&\r
+                creds.times.starttime < (now + TIMET_TOLERANCE) && \r
+                (creds.times.endtime + TIMET_TOLERANCE) > now) {\r
+                expiration = creds.times.endtime;\r
+\r
+                if ((creds.ticket_flags & TKT_FLG_RENEWABLE) && \r
+                    (creds.times.renew_till > creds.times.endtime)) {\r
+                    expiration = creds.times.renew_till;\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    if (cc_code == KRB5_CC_END) {\r
+        cc_code = pkrb5_cc_end_seq_get(ctx, cc, &cur);\r
+        rv = KHM_ERROR_SUCCESS;\r
+        *pexpiration = expiration;\r
+    }\r
+\r
+    return rv;\r
+}\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_find_ccache_for_identity(khm_handle ident, krb5_context *pctx,\r
+                                  void * buffer, khm_size * pcbbuf)\r
+{\r
+    krb5_context        ctx = 0;\r
+    krb5_ccache         cache = 0;\r
+    krb5_error_code     code;\r
+    apiCB *             cc_ctx = 0;\r
+    struct _infoNC **   pNCi = NULL;\r
+    int                 i;\r
+    khm_int32           t;\r
+    wchar_t *           ms = NULL;\r
+    khm_size            cb;\r
+    krb5_timestamp      expiration = 0;\r
+    krb5_timestamp      best_match_expiration = 0;\r
+    char                best_match_ccname[256] = "";\r
+    khm_handle          csp_params = NULL;\r
+    khm_handle          csp_plugins = NULL;\r
+\r
+    if (!buffer || !pcbbuf)\r
+    return KHM_ERROR_GENERAL;\r
+\r
+    ctx = *pctx;\r
+\r
+    code = pcc_initialize(&cc_ctx, CC_API_VER_2, NULL, NULL);\r
+    if (code)\r
+        goto _exit;\r
+\r
+    code = pcc_get_NC_info(cc_ctx, &pNCi);\r
+\r
+    if (code) \r
+        goto _exit;\r
+\r
+    for(i=0; pNCi[i]; i++) {\r
+        if (pNCi[i]->vers != CC_CRED_V5)\r
+            continue;\r
+\r
+        code = (*pkrb5_cc_resolve)(ctx, pNCi[i]->name, &cache);\r
+        if (code)\r
+            continue;\r
+\r
+        /* need a function to check the cache for the identity\r
+         * and determine if it has valid tickets.  If it has \r
+         * the right identity and valid tickets, store the \r
+         * expiration time and the cache name.  If it has the\r
+         * right identity but no valid tickets, store the ccache\r
+         * name and an expiration time of zero.  if it does not\r
+         * have the right identity don't save the name.\r
+         * \r
+         * Keep searching to find the best cache available.\r
+         */\r
+\r
+        if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+                                                           ident, \r
+                                                           &expiration))) {\r
+            if ( expiration > best_match_expiration ) {\r
+                best_match_expiration = expiration;\r
+                StringCbCopyA(best_match_ccname, \r
+                              sizeof(best_match_ccname),\r
+                              "API:");\r
+                StringCbCatA(best_match_ccname,\r
+                             sizeof(best_match_ccname),\r
+                             pNCi[i]->name);\r
+                expiration = 0;\r
+            }\r
+        }\r
+\r
+        if(ctx != NULL && cache != NULL)\r
+            (*pkrb5_cc_close)(ctx, cache);\r
+        cache = 0;\r
+    }\r
+\r
+    if (KHM_SUCCEEDED(kmm_get_plugins_config(0, &csp_plugins))) {\r
+        khc_open_space(csp_plugins, L"Krb5Cred\\Parameters",  0, &csp_params);\r
+        khc_close_space(csp_plugins);\r
+        csp_plugins = NULL;\r
+    }\r
+\r
+#ifdef DEBUG\r
+    if (csp_params == NULL) {\r
+        assert(FALSE);\r
+    }\r
+#endif\r
+\r
+    if (csp_params &&\r
+        KHM_SUCCEEDED(khc_read_int32(csp_params, L"MsLsaList", &t)) && t) {\r
+        code = (*pkrb5_cc_resolve)(ctx, "MSLSA:", &cache);\r
+        if (code == 0 && cache) {\r
+            if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+                                                               ident, \r
+                                                               &expiration))) {\r
+                if ( expiration > best_match_expiration ) {\r
+                    best_match_expiration = expiration;\r
+                    StringCbCopyA(best_match_ccname, sizeof(best_match_ccname),\r
+                                  "MSLSA:");\r
+                    expiration = 0;\r
+                }\r
+            }\r
+        }\r
+\r
+        if (ctx != NULL && cache != NULL)\r
+            (*pkrb5_cc_close)(ctx, cache);\r
+\r
+        cache = 0;\r
+    }\r
+\r
+    if (csp_params &&\r
+        khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+        == KHM_ERROR_TOO_LONG &&\r
+        cb > sizeof(wchar_t) * 2) {\r
+\r
+        wchar_t * t;\r
+        char ccname[MAX_PATH + 6];\r
+\r
+        ms = PMALLOC(cb);\r
+\r
+#ifdef DEBUG\r
+        assert(ms);\r
+#endif\r
+\r
+        khc_read_multi_string(csp_params, L"FileCCList", ms, &cb);\r
+        for(t = ms; t && *t; t = multi_string_next(t)) {\r
+            StringCchPrintfA(ccname, ARRAYLENGTH(ccname),\r
+                             "FILE:%S", t);\r
+\r
+            code = (*pkrb5_cc_resolve)(ctx, ccname, &cache);\r
+            if (code)\r
+                continue;\r
+\r
+            if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+                                                               ident, \r
+                                                               &expiration))) {\r
+                if ( expiration > best_match_expiration ) {\r
+                    best_match_expiration = expiration;\r
+                    StringCbCopyA(best_match_ccname,\r
+                                  sizeof(best_match_ccname),\r
+                                  ccname);\r
+                    expiration = 0;\r
+                }\r
+            }\r
+\r
+            if (ctx != NULL && cache != NULL)\r
+                (*pkrb5_cc_close)(ctx, cache);\r
+            cache = 0;\r
+        }\r
+\r
+        PFREE(ms);\r
+    }\r
+ _exit:\r
+    if (csp_params)\r
+        khc_close_space(csp_params);\r
+\r
+    if (pNCi)\r
+        (*pcc_free_NC_info)(cc_ctx, &pNCi);\r
+\r
+    if (cc_ctx)\r
+        (*pcc_shutdown)(&cc_ctx);\r
+\r
+    if (best_match_ccname[0]) {\r
+        \r
+        if (*pcbbuf = AnsiStrToUnicode((wchar_t *)buffer, \r
+                                       *pcbbuf,\r
+                                       best_match_ccname)) {\r
+\r
+            *pcbbuf = (*pcbbuf + 1) * sizeof(wchar_t);\r
+\r
+            return KHM_ERROR_SUCCESS;\r
+        }\r
+\r
+    }\r
+\r
+    return KHM_ERROR_GENERAL;\r
+}\r
index 7d998215a50434f4120bcb8f149c7fce27193dc6..bd6337192a77481b03955cf9660b0a50541a81e4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -38,6 +38,15 @@ int khm_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName,
 \r
 \r
 int khm_krb5_initialize(khm_handle ident, krb5_context *, krb5_ccache *);\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_find_ccache_for_identity(khm_handle ident, krb5_context *pctx,\r
+                                  void * buffer, khm_size * pcbbuf);\r
+\r
+khm_int32 KHMAPI\r
+khm_get_identity_expiration_time(krb5_context ctx, krb5_ccache cc, \r
+                                 khm_handle ident, \r
+                                 krb5_timestamp * pexpiration);\r
 #endif /* NO_KRB5 */\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index d6b749192d1b8767e8e0e2094baff3aafb005451..2385e617937751e63abad7009058ecef90c040c9 100644 (file)
@@ -32,12 +32,13 @@ LIBFILE=$(LIBDIR)\krb4cred.lib
 OBJFILES=                              \\r
        $(LIBDIR)\dynimport.obj         \\r
        $(LIBDIR)\krb5common.obj        \\r
-       $(OBJ)\main.obj                 \\r
+       $(OBJ)\krb4main.obj             \\r
        $(OBJ)\krb4plugin.obj           \\r
        $(OBJ)\krb4funcs.obj            \\r
        $(OBJ)\errorfuncs.obj           \\r
        $(OBJ)\krb4config.obj           \\r
-       $(OBJ)\krb4configdlg.obj\r
+       $(OBJ)\krb4configdlg.obj        \\r
+       $(OBJ)\krb4newcreds.obj\r
 \r
 LIBFILES=                              \\r
        $(LIBDIR)\nidmgr32.lib          \\r
@@ -45,10 +46,12 @@ LIBFILES=                           \
 \r
 SDKLIBFILES=\r
 \r
+VERRESFILE=$(OBJ)\version.res\r
+\r
 $(OBJ)\krb4config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg\r
        $(CCSV) $** $@\r
 \r
-$(DLLFILE): $(OBJFILES)\r
+$(DLLFILE): $(OBJFILES) $(VERRESFILE)\r
        $(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
 \r
 all: mkdirs $(DLLFILE) lang\r
index 9feaad2a70bf712a2d87a274cdc41291e3615e67..dba9f5dc6cb6d0494e04345c044ecefa335c1811 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -72,7 +72,7 @@ HWND GetRootParent (HWND Child)
 }\r
 \r
 \r
-LPSTR err_describe(LPSTR buf, long code)\r
+LPSTR err_describe(LPSTR buf, size_t len, long code)\r
 {\r
     LPSTR cp, com_err_msg;\r
     int offset;\r
@@ -89,7 +89,8 @@ LPSTR err_describe(LPSTR buf, long code)
     case kadm_err_base:\r
        break;\r
     default:\r
-       strcpy(buf, com_err_msg);\r
+       strncpy(buf, com_err_msg, len);\r
+       buf[len-1] = '\0';\r
        return buf;\r
     }\r
 \r
@@ -192,8 +193,10 @@ LPSTR err_describe(LPSTR buf, long code)
             /* no extra error msg */\r
             break;\r
         }\r
-    if(com_err_msg != buf)\r
-        strcpy(buf, com_err_msg);\r
+    if(com_err_msg != buf) {\r
+        strncpy(buf, com_err_msg, len);\r
+       buf[len-1] = '\0';\r
+    }\r
     cp = buf + strlen(buf);\r
     *cp++ = '\n';\r
     switch(table_num) {\r
@@ -207,7 +210,7 @@ LPSTR err_describe(LPSTR buf, long code)
         etype = Lerror_table_name(table_num);\r
         break;\r
     }\r
-    wsprintfA((LPSTR) cp, (LPSTR) "(%s error %d"\r
+    StringCbPrintfA((LPSTR) cp, len - (cp-buf), (LPSTR) "(%s error %d"\r
 #ifdef DEBUG_COM_ERR\r
              " (absolute error %ld)"\r
 #endif\r
@@ -221,44 +224,3 @@ LPSTR err_describe(LPSTR buf, long code)
     return (LPSTR)buf;\r
 }\r
 \r
-int lsh_com_err_proc (LPSTR whoami, long code,\r
-                              LPSTR fmt, va_list args)\r
-{\r
-    int retval;\r
-    HWND hOldFocus;\r
-    char buf[1024], *cp; /* changed to 512 by jms 8/23/93 */\r
-    WORD mbformat = MB_OK | MB_ICONEXCLAMATION;\r
-  \r
-    cp = buf;\r
-    memset(buf, '\0', sizeof(buf));\r
-    cp[0] = '\0';\r
-  \r
-    if (code)\r
-    {\r
-        err_describe(buf, code);\r
-        while (*cp)\r
-            cp++;\r
-    }\r
-  \r
-    if (fmt)\r
-    {\r
-        if (fmt[0] == '%' && fmt[1] == 'b')\r
-       {\r
-            fmt += 2;\r
-            mbformat = va_arg(args, WORD);\r
-            /* if the first arg is a %b, we use it for the message\r
-               box MB_??? flags. */\r
-       }\r
-        if (code)\r
-       {\r
-            *cp++ = '\n';\r
-            *cp++ = '\n';\r
-       }\r
-        wvsprintfA((LPSTR)cp, fmt, args);\r
-    }\r
-    hOldFocus = GetFocus();\r
-    retval = MessageBoxA(/*GetRootParent(hOldFocus)*/NULL, buf, whoami, \r
-                        mbformat | MB_ICONHAND | MB_TASKMODAL);\r
-    SetFocus(hOldFocus);\r
-    return retval;\r
-}\r
index be8f4e7c5787e17b1372cbaaa5618d9efcc010a9..e339eca4f749d77b88558daa963fac9af38bb536 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -43,32 +43,17 @@ typedef LPSTR (*err_func)(int, long);
 #endif\r
 \r
 #include <krberr.h>\r
-extern void Leash_initialize_krb_error_func(err_func func,struct et_list **);\r
-#undef init_krb_err_func\r
-#define init_krb_err_func(erf) Leash_initialize_krb_error_func(erf,&_et_list)\r
-\r
 #include <kadm_err.h>\r
 \r
-extern void Leash_initialize_kadm_error_table(struct et_list **);\r
-#undef init_kadm_err_tbl\r
-#define init_kadm_err_tbl() Leash_initialize_kadm_error_table(&_et_list)\r
 #define kadm_err_base ERROR_TABLE_BASE_kadm\r
 \r
-#define krb_err_func Leash_krb_err_func\r
-\r
 #include <stdarg.h>\r
-int lsh_com_err_proc (LPSTR whoami, long code,\r
-                     LPSTR fmt, va_list args);\r
-void FAR Leash_load_com_err_callback(FARPROC,FARPROC,FARPROC);\r
 \r
 #ifndef KRBERR\r
 #define KRBERR(code) (code + krb_err_base)\r
 #endif\r
 \r
-int lsh_com_err_proc (LPSTR whoami, long code, LPSTR fmt, va_list args);\r
-int DoNiftyErrorReport(long errnum, LPSTR what);\r
-\r
-LPSTR err_describe(LPSTR buf, long code);\r
+LPSTR err_describe(LPSTR buf, size_t len, long code);\r
 \r
 \r
 /* */\r
diff --git a/src/windows/identity/plugins/krb4/images/plugin.ico b/src/windows/identity/plugins/krb4/images/plugin.ico
new file mode 100644 (file)
index 0000000..791b359
Binary files /dev/null and b/src/windows/identity/plugins/krb4/images/plugin.ico differ
index 9ad3406980b01c4fe4a62080d9c926968cd16ad7..e6eb890df3c5c86059ca594cfa1f1dcc67071ea2 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 #include<kherror.h>\r
 #include<khuidefs.h>\r
 #include<strsafe.h>\r
+#include<assert.h>\r
+\r
+typedef struct tag_k4_ids_data {\r
+    khui_config_init_data cfg;\r
+\r
+    khm_int32 get_tix;\r
+} k4_ids_data;\r
+\r
+static void\r
+k4_ids_read_params(k4_ids_data * d) {\r
+    khm_int32 t;\r
+#ifdef DEBUG\r
+    assert(csp_params);\r
+#endif\r
+\r
+    t = 1;\r
+    khc_read_int32(csp_params, L"Krb4NewCreds", &t);\r
+    d->get_tix = !!t;\r
+}\r
+\r
+static void\r
+k4_ids_write_params(HWND hw, k4_ids_data * d) {\r
+    khm_int32 nv;\r
+    khm_boolean applied = FALSE;\r
+\r
+    if (IsDlgButtonChecked(hw, IDC_CFG_GETTIX) == BST_CHECKED)\r
+        nv = TRUE;\r
+    else\r
+        nv = FALSE;\r
+\r
+    if (!!nv != !!d->get_tix) {\r
+        d->get_tix = !!nv;\r
+        khc_write_int32(csp_params, L"Krb4NewCreds", d->get_tix);\r
+        applied = TRUE;\r
+    }\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            (applied)?KHUI_CNFLAG_APPLIED:0,\r
+                            KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k4_ids_check_mod(HWND hw, k4_ids_data * d) {\r
+    khm_int32 nv;\r
+\r
+    if (IsDlgButtonChecked(hw, IDC_CFG_GETTIX) == BST_CHECKED)\r
+        nv = TRUE;\r
+    else\r
+        nv = FALSE;\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            (!!nv != !!d->get_tix)? KHUI_CNFLAG_MODIFIED: 0,\r
+                            KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+INT_PTR CALLBACK\r
+krb4_ids_config_proc(HWND hwnd,\r
+                     UINT uMsg,\r
+                     WPARAM wParam,\r
+                     LPARAM lParam) {\r
+    k4_ids_data * d;\r
+\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        d = PMALLOC(sizeof(*d));\r
+        ZeroMemory(d, sizeof(*d));\r
+\r
+        d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+        k4_ids_read_params(d);\r
+\r
+        CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+                       (d->get_tix)? BST_CHECKED: BST_UNCHECKED);\r
+\r
+        break;\r
+\r
+    case WM_COMMAND:\r
+        d = (k4_ids_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        if (HIWORD(wParam) == BN_CLICKED) {\r
+            k4_ids_check_mod(hwnd, d);\r
+        }\r
+        break;\r
+\r
+    case KHUI_WM_CFG_NOTIFY:\r
+        d = (k4_ids_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        if (HIWORD(wParam) == WMCFG_APPLY) {\r
+            k4_ids_write_params(hwnd, d);\r
+        }\r
+        break;\r
+\r
+    case WM_DESTROY:\r
+        d = (k4_ids_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        PFREE(d);\r
+        break;\r
+    }\r
+\r
+    return FALSE;\r
+}\r
+\r
+INT_PTR CALLBACK\r
+krb4_id_config_proc(HWND hwnd,\r
+                    UINT uMsg,\r
+                    WPARAM wParam,\r
+                    LPARAM lParam) {\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        {\r
+            wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+            khm_size cb;\r
+            khui_config_init_data * d;\r
+            khm_handle ident = NULL;\r
+            khm_int32 gettix = 0;\r
+            khm_int32 flags = 0;\r
+\r
+            d = (khui_config_init_data *) lParam;\r
+\r
+            khc_read_int32(csp_params, L"Krb4NewCreds", &gettix);\r
+            if (gettix == 0)\r
+                goto set_ui;\r
+\r
+            *idname = 0;\r
+            cb = sizeof(idname);\r
+            khui_cfg_get_name(d->ctx_node, idname, &cb);\r
+\r
+            kcdb_identity_create(idname, 0, &ident);\r
+\r
+            if (ident == NULL) {\r
+                gettix = 0;\r
+                goto set_ui;\r
+            }\r
+\r
+            kcdb_identity_get_flags(ident, &flags);\r
+\r
+            kcdb_identity_release(ident);\r
+\r
+            if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
+                gettix = 0;\r
+\r
+        set_ui:\r
+            CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+                           (gettix)?BST_CHECKED: BST_UNCHECKED);\r
+        }\r
+        break;\r
+    }\r
+\r
+    return FALSE;\r
+}\r
+\r
 \r
 INT_PTR CALLBACK\r
 krb4_confg_proc(HWND hwnd,\r
index 8fda720b3acec3d4a2a99ca475cbb3edb4d81703..7798e5c9ede962701ae36c6573795da33479496e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -78,11 +78,12 @@ int com_addr(void)
 long \r
 khm_krb4_list_tickets(void) \r
 {\r
+    char    ptktname[MAX_PATH + 5];\r
     char    pname[ANAME_SZ];\r
     char    pinst[INST_SZ];\r
     char    prealm[REALM_SZ];\r
     wchar_t wbuf[256];\r
-    int     k_errno;\r
+    int     k_errno = 0;\r
     CREDENTIALS c;\r
     int newtickets = 0;\r
     int open = 0;\r
@@ -91,6 +92,8 @@ khm_krb4_list_tickets(void)
     time_t tt;\r
     FILETIME ft;\r
 \r
+    kcdb_credset_flush(krb4_credset);\r
+\r
     // Since krb_get_tf_realm will return a ticket_file error,\r
     // we will call tf_init and tf_close first to filter out\r
     // things like no ticket file.  Otherwise, the error that\r
@@ -98,7 +101,7 @@ khm_krb4_list_tickets(void)
     // klist: can't find realm of ticket file: No ticket file (tf_util)\r
     // instead of klist: No ticket file (tf_util)\r
     if (ptf_init == NULL)\r
-        return(KSUCCESS);\r
+        goto collect;\r
 \r
     com_addr();\r
     \r
@@ -126,6 +129,8 @@ khm_krb4_list_tickets(void)
         goto cleanup;\r
     }\r
 \r
+    StringCchCopyA(ptktname, ARRAYLENGTH(ptktname), (*ptkt_string)());\r
+\r
     open = 1;\r
 \r
     // Get principal name and instance \r
@@ -147,8 +152,6 @@ khm_krb4_list_tickets(void)
         goto cleanup;\r
     }\r
 \r
-    kcdb_credset_flush(krb4_credset);\r
-\r
     // Get KRB4 tickets\r
     while ((k_errno = (*ptf_get_cred)(&c)) == KSUCCESS)\r
     {\r
@@ -174,12 +177,13 @@ khm_krb4_list_tickets(void)
         TimetToFileTimeInterval(tt, &ft);\r
         kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &ft, sizeof(ft));\r
 \r
+        AnsiStrToUnicode(wbuf, sizeof(wbuf), ptktname);\r
+        kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wbuf, KCDB_CBSIZE_AUTO);\r
+\r
         kcdb_credset_add_cred(krb4_credset, cred, -1);\r
 \r
     } // while\r
 \r
-    kcdb_credset_collect(NULL, krb4_credset, ident, credtype_id_krb4, NULL);\r
-\r
 cleanup:\r
     if (ptf_close == NULL)\r
         return(KSUCCESS);\r
@@ -219,6 +223,10 @@ cleanup:
                    MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND);\r
     }\r
 #endif\r
+\r
+ collect:\r
+    kcdb_credset_collect(NULL, krb4_credset, ident, credtype_id_krb4, NULL);\r
+\r
     return k_errno;\r
 }\r
 \r
@@ -227,7 +235,7 @@ cleanup:
 #define KRB5_FILE               "KRB5.INI"\r
 \r
 BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname)\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)\r
 {\r
     char **configFile = NULL;\r
     if (pkrb5_get_default_config_files(&configFile)) \r
@@ -271,7 +279,7 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname)
             LPSTR pFind;\r
 \r
            //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);\r
-            if (khm_get_profile_file(krbConFile, sizeof(krbConFile)))  \r
+            if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile)))     \r
                 {\r
                    GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));\r
                     krbConFile[MAX_PATH-1] = '\0';\r
@@ -368,7 +376,7 @@ wchar_t * khm_krb5_get_realm_list(void)
 \r
         char krb5_conf[MAX_PATH+1];\r
 \r
-        if (!khm_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
+        if (!khm_krb5_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
             profile_t profile;\r
             long retval;\r
             const char *filenames[2];\r
@@ -392,7 +400,7 @@ wchar_t * khm_krb5_get_realm_list(void)
                     }\r
                     cbsize += sizeof(wchar_t); /* double null terminated */\r
 \r
-                    rlist = malloc(cbsize);\r
+                    rlist = PMALLOC(cbsize);\r
                     d = rlist;\r
                     for (cpp = sections; *cpp; cpp++)\r
                     {\r
@@ -430,7 +438,7 @@ wchar_t * khm_krb5_get_realm_list(void)
 \r
             /*TODO: compute the actual required buffer size instead of hardcoding */\r
             cbsize = 16384; // arbitrary\r
-            rlist = malloc(cbsize);\r
+            rlist = PMALLOC(cbsize);\r
             d = rlist;\r
 \r
             // Skip the default realm\r
@@ -493,7 +501,7 @@ wchar_t * khm_krb5_get_default_realm(void)
     \r
     if (def) {\r
         cch = strlen(def) + 1;\r
-        realm = malloc(sizeof(wchar_t) * cch);\r
+        realm = PMALLOC(sizeof(wchar_t) * cch);\r
         AnsiStrToUnicode(realm, sizeof(wchar_t) * cch, def);\r
         pkrb5_free_default_realm(ctx, def);\r
     } else\r
@@ -503,3 +511,291 @@ wchar_t * khm_krb5_get_default_realm(void)
 \r
     return realm;\r
 }\r
+\r
+static\r
+char *\r
+make_postfix(const char * base,\r
+             const char * postfix,\r
+             char ** rcopy)\r
+{\r
+    int base_size;\r
+    int ret_size;\r
+    char * copy = 0;\r
+    char * ret = 0;\r
+\r
+    base_size = (int) strlen(base) + 1;\r
+    ret_size = base_size + (int) strlen(postfix) + 1;\r
+    copy = malloc(base_size);\r
+    ret = malloc(ret_size);\r
+\r
+    if (!copy || !ret)\r
+        goto cleanup;\r
+\r
+    strncpy(copy, base, base_size);\r
+    copy[base_size - 1] = 0;\r
+\r
+    strncpy(ret, base, base_size);\r
+    strncpy(ret + (base_size - 1), postfix, ret_size - (base_size - 1));\r
+    ret[ret_size - 1] = 0;\r
+\r
+ cleanup:\r
+    if (!copy || !ret) {\r
+        if (copy)\r
+            free(copy);\r
+        if (ret)\r
+            free(ret);\r
+        copy = ret = 0;\r
+    }\r
+    // INVARIANT: (ret ==> copy) && (copy ==> ret)\r
+    *rcopy = copy;\r
+    return ret;\r
+}\r
+\r
+\r
+static\r
+long\r
+make_temp_cache_v4(const char * postfix)\r
+{\r
+    static char * old_cache = 0;\r
+\r
+    if (!pkrb_set_tkt_string || !ptkt_string || !pdest_tkt)\r
+        return 0; // XXX - is this appropriate?\r
+\r
+    if (old_cache) {\r
+        pdest_tkt();\r
+        pkrb_set_tkt_string(old_cache);\r
+        free(old_cache);\r
+        old_cache = 0;\r
+    }\r
+\r
+    if (postfix)\r
+    {\r
+        char * tmp_cache = make_postfix(ptkt_string(), postfix, &old_cache);\r
+\r
+        if (!tmp_cache)\r
+            return KFAILURE;\r
+\r
+        pkrb_set_tkt_string(tmp_cache);\r
+        free(tmp_cache);\r
+    }\r
+    return 0;\r
+}\r
+\r
+long\r
+khm_krb4_changepwd(char * principal,\r
+                   char * password,\r
+                   char * newpassword,\r
+                   char** error_str)\r
+{\r
+    long k_errno;\r
+\r
+    if (!pkrb_set_tkt_string || !ptkt_string || !pkadm_change_your_password ||\r
+        !pdest_tkt)\r
+        return KFAILURE;\r
+\r
+    k_errno = make_temp_cache_v4("_chgpwd");\r
+    if (k_errno) return k_errno;\r
+    k_errno = pkadm_change_your_password(principal, password, newpassword, \r
+                                         error_str);\r
+    make_temp_cache_v4(0);\r
+    return k_errno;\r
+}\r
+\r
+long\r
+khm_convert524(khm_handle identity)\r
+{\r
+#ifdef NO_KRB5\r
+    return(0);\r
+#else\r
+    krb5_context ctx = 0;\r
+    krb5_error_code code = 0;\r
+    int icode = 0;\r
+    krb5_principal me = 0;\r
+    krb5_principal server = 0;\r
+    krb5_creds *v5creds = 0;\r
+    krb5_creds increds;\r
+    krb5_ccache cc = 0;\r
+    CREDENTIALS * v4creds = NULL;\r
+    static int init_ets = 1;\r
+\r
+    if (!pkrb5_init_context ||\r
+        !pkrb_in_tkt ||\r
+        !pkrb524_init_ets ||\r
+        !pkrb524_convert_creds_kdc)\r
+        return 0;\r
+\r
+    v4creds = (CREDENTIALS *) malloc(sizeof(CREDENTIALS));\r
+    memset((char *) v4creds, 0, sizeof(CREDENTIALS));\r
+\r
+    memset((char *) &increds, 0, sizeof(increds));\r
+    /*\r
+      From this point on, we can goto cleanup because increds is\r
+      initialized.\r
+    */\r
+\r
+    code = khm_krb5_initialize(identity, &ctx, &cc);\r
+    if (code)\r
+        goto cleanup;\r
+\r
+    if ( init_ets ) {\r
+        pkrb524_init_ets(ctx);\r
+        init_ets = 0;\r
+    }\r
+\r
+    if (code = pkrb5_cc_get_principal(ctx, cc, &me))\r
+        goto cleanup;\r
+\r
+    if ((code = pkrb5_build_principal(ctx,\r
+                                      &server,\r
+                                      krb5_princ_realm(ctx, me)->length,\r
+                                      krb5_princ_realm(ctx, me)->data,\r
+                                      "krbtgt",\r
+                                      krb5_princ_realm(ctx, me)->data,\r
+                                      NULL))) {\r
+        goto cleanup;\r
+    }\r
+    \r
+    increds.client = me;\r
+    increds.server = server;\r
+    increds.times.endtime = 0;\r
+    increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC;\r
+    if ((code = pkrb5_get_credentials(ctx, 0,\r
+                                      cc,\r
+                                      &increds,\r
+                                      &v5creds))) {\r
+        goto cleanup;\r
+    }\r
+\r
+    if ((icode = pkrb524_convert_creds_kdc(ctx,\r
+                                           v5creds,\r
+                                           v4creds))) {\r
+        goto cleanup;\r
+    }\r
+\r
+    /* initialize ticket cache */\r
+    if ((icode = pkrb_in_tkt(v4creds->pname, v4creds->pinst, v4creds->realm)\r
+         != KSUCCESS)) {\r
+        goto cleanup;\r
+    }\r
+    /* stash ticket, session key, etc. for future use */\r
+    if ((icode = pkrb_save_credentials(v4creds->service,\r
+                                       v4creds->instance,\r
+                                       v4creds->realm,\r
+                                       v4creds->session,\r
+                                       v4creds->lifetime,\r
+                                       v4creds->kvno,\r
+                                       &(v4creds->ticket_st),\r
+                                       v4creds->issue_date))) {\r
+        goto cleanup;\r
+    }\r
+\r
+ cleanup:\r
+    memset(v4creds, 0, sizeof(v4creds));\r
+    free(v4creds);\r
+\r
+    if (v5creds) {\r
+        pkrb5_free_creds(ctx, v5creds);\r
+    }\r
+    if (increds.client == me)\r
+        me = 0;\r
+    if (increds.server == server)\r
+        server = 0;\r
+\r
+    if (ctx)\r
+        pkrb5_free_cred_contents(ctx, &increds);\r
+\r
+    if (server) {\r
+        pkrb5_free_principal(ctx, server);\r
+    }\r
+\r
+    if (me) {\r
+        pkrb5_free_principal(ctx, me);\r
+    }\r
+\r
+    if (ctx && cc)\r
+        pkrb5_cc_close(ctx, cc);\r
+\r
+    if (ctx) {\r
+        pkrb5_free_context(ctx);\r
+    }\r
+\r
+    return (code || icode);\r
+#endif /* NO_KRB5 */    \r
+}\r
+\r
+long\r
+khm_krb4_kinit(char * aname,\r
+               char * inst,\r
+               char * realm,\r
+               long lifetime,\r
+               char * password) {\r
+\r
+    wchar_t * functionName = NULL;\r
+    wchar_t * err_context = NULL;\r
+    int rc4 = 0;\r
+    int msg = 0;\r
+\r
+    if (pkname_parse == NULL) {\r
+        goto cleanup;\r
+    }\r
+\r
+    err_context = L"getting realm";\r
+    if (!*realm && (rc4  = (int)(*pkrb_get_lrealm)(realm, 1))) {\r
+        functionName = L"krb_get_lrealm()";\r
+        msg = IDS_ERR_REALM;\r
+        goto cleanup;\r
+    }\r
+\r
+    err_context = L"checking principal";\r
+    if ((!*aname) || (!(rc4  = (int)(*pk_isname)(aname)))) {\r
+        functionName = L"krb_get_lrealm()";\r
+        msg = IDS_ERR_PRINCIPAL;\r
+        goto cleanup;\r
+    }\r
+\r
+    /* optional instance */\r
+    if (!(rc4 = (int)(*pk_isinst)(inst))) {\r
+        functionName = L"k_isinst()";\r
+        msg = IDS_ERR_INVINST;\r
+        goto cleanup;\r
+    }\r
+\r
+    if (!(rc4 = (int)(*pk_isrealm)(realm))) {\r
+        functionName = L"k_isrealm()";\r
+        msg = IDS_ERR_REALM;\r
+        goto cleanup;\r
+    }\r
+\r
+    err_context = L"fetching ticket";  \r
+    rc4 = (*pkrb_get_pw_in_tkt)(aname, inst, realm, "krbtgt", realm, \r
+                                lifetime, password);\r
+\r
+    if (rc4) /* XXX: do we want: && (rc != NO_TKT_FIL) as well? */ { \r
+        functionName = L"krb_get_pw_in_tkt()";\r
+        msg = IDS_ERR_PWINTKT;\r
+        goto cleanup;\r
+    }\r
+\r
+    return 0;\r
+\r
+ cleanup:\r
+    {\r
+        _report_sr0(KHERR_ERROR, msg);\r
+        _location(functionName);\r
+    }\r
+    return rc4;\r
+}\r
+\r
+\r
+int khm_krb4_kdestroy(void) {\r
+    int k_errno = 0;\r
+\r
+    if (pdest_tkt != NULL)\r
+    {\r
+        k_errno = (*pdest_tkt)();\r
+        if (k_errno && (k_errno != RET_TKFIL))\r
+            return KRBERR(k_errno);\r
+    }\r
+\r
+    return k_errno;\r
+}\r
index ea97358b9f8f9689bbc9d259edcb6bbf7ceb85b5..742036878fc7f27f2eaa843ceb72d5fb76b047d3 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 #define KRB5_DEFAULT_LIFE            60*60*10 /* 10 hours */\r
 \r
-// Function Prototypes.\r
-BOOL khm_krb5_ms2mit(BOOL);\r
-\r
-int\r
-khm_krb5_kinit(krb5_context       alt_ctx,\r
-               char *             principal_name,\r
-               char *             password,\r
-               krb5_deltat        lifetime,\r
-               DWORD              forwardable,\r
-               DWORD              proxiable,\r
-               krb5_deltat        renew_life,\r
-               DWORD              addressless,\r
-               DWORD              publicIP,\r
-               krb5_prompter_fct  prompter,\r
-               void *             p_data\r
-               );\r
-\r
-long\r
-Leash_int_kinit_ex(\r
-    krb5_context ctx,\r
-    HWND hParent,\r
-    char * principal, \r
-    char * password, \r
-    int lifetime,\r
-    int forwardable,\r
-    int proxiable,\r
-    int renew_life,\r
-    int addressless,\r
-    unsigned long publicIP,\r
-    int displayErrors\r
-    );\r
 \r
 long\r
-Leash_int_checkpwd(\r
-    char * principal,\r
-    char * password,\r
-    int    displayErrors\r
-    );\r
-\r
-long\r
-Leash_int_changepwd(\r
-    char * principal, \r
-    char * password, \r
-    char * newpassword,\r
-    char** result_string,\r
-    int    displayErrors\r
-    );\r
-\r
-int\r
-Leash_krb5_kdestroy(\r
-    void\r
-    );\r
-\r
-int\r
-Leash_krb5_kinit(\r
-    krb5_context,\r
-    HWND hParent,\r
-    char * principal_name, \r
-    char * password,\r
-    krb5_deltat lifetime,\r
-    DWORD       forwardable,\r
-    DWORD       proxiable,\r
-    krb5_deltat renew_life,\r
-    DWORD       addressless,\r
-    DWORD       publicIP\r
-    );\r
+khm_convert524(khm_handle identity);\r
 \r
 long\r
-khm_convert524(\r
-    krb5_context ctx\r
-    );\r
-    \r
-int\r
-Leash_afs_unlog(\r
-    void\r
-    );\r
+khm_krb4_kinit(char * aname,\r
+               char * inst,\r
+               char * realm,\r
+               long lifetime,\r
+               char * password);    \r
 \r
-int\r
-Leash_afs_klog(\r
-    char *, \r
-    char *, \r
-    char *, \r
-    int\r
-    );\r
+long \r
+khm_krb4_list_tickets(void);\r
 \r
-int \r
-LeashKRB5_renew(void);\r
+int khm_krb4_kdestroy(void);\r
 \r
 LONG\r
 write_registry_setting(\r
@@ -180,11 +108,7 @@ config_boolean_to_int(
     const char *s\r
     );\r
 \r
-\r
 wchar_t * khm_krb5_get_default_realm(void);\r
 wchar_t * khm_krb5_get_realm_list(void);\r
-long khm_krb5_list_tickets(krb5_context *krbv5Context);\r
-long khm_krb4_list_tickets(void);\r
-\r
 \r
 #endif\r
similarity index 75%
rename from src/windows/identity/plugins/krb4/main.c
rename to src/windows/identity/plugins/krb4/krb4main.c
index 60ceb7f83c7727aaa47b54aaf3f4a247dd410ebb..b83cd5eb42fae01f3ae3583968c4796e80c690ea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -39,8 +39,6 @@ khm_int32 attr_id_key_enctype   = -1;
 khm_int32 attr_id_tkt_enctype   = -1;\r
 khm_int32 attr_id_addr_list     = -1;\r
 khm_int32 attr_id_krb5_flags    = -1;\r
-khm_int32 attr_id_renew_till    = -1;\r
-khm_int32 attr_id_renew_for     = -1;\r
 \r
 khm_handle csp_plugins          = NULL;\r
 khm_handle csp_krbcred          = NULL;\r
@@ -91,44 +89,6 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
     if(KHM_FAILED(rv = init_error_funcs()))\r
         goto _exit;\r
 \r
-    /* Lookup common data types */\r
-    if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ENCTYPE, &type_id_enctype))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ADDR_LIST, &type_id_addr_list))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_FLAGS, &type_id_krb5_flags))) {\r
-            goto _exit;\r
-    }\r
-\r
-    /* Lookup common attributes */\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, &attr_id_key_enctype))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_TKT_ENCTYPE, &attr_id_tkt_enctype))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_ADDR_LIST, &attr_id_addr_list))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KRB5_FLAGS, &attr_id_krb5_flags))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_RENEW_TILL, &attr_id_renew_till))) {\r
-            goto _exit;\r
-    }\r
-\r
-    if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_RENEW_FOR, &attr_id_renew_for))) {\r
-            goto _exit;\r
-    }\r
-\r
     rv = kmm_get_plugins_config(0, &csp_plugins);\r
     if(KHM_FAILED(rv)) goto _exit;\r
 \r
diff --git a/src/windows/identity/plugins/krb4/krb4newcreds.c b/src/windows/identity/plugins/krb4/krb4newcreds.c
new file mode 100644 (file)
index 0000000..fdbe304
--- /dev/null
@@ -0,0 +1,657 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<kherror.h>\r
+#include<khmsgtypes.h>\r
+#include<khuidefs.h>\r
+#include<utils.h>\r
+#include<commctrl.h>\r
+#include<strsafe.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+\r
+#define K4_METHOD_AUTO     0\r
+#define K4_METHOD_PASSWORD 1\r
+#define K4_METHOD_K524     2\r
+\r
+int method_to_id[] = {\r
+    IDC_NCK4_AUTO,\r
+    IDC_NCK4_PWD,\r
+    IDC_NCK4_K524\r
+};\r
+\r
+typedef struct tag_k4_dlg_data {\r
+    HWND hwnd;\r
+    khui_new_creds * nc;\r
+    khui_new_creds_by_type * nct;\r
+\r
+    khm_boolean      k4_enabled;\r
+    khm_int32        method;\r
+    time_t           lifetime;\r
+} k4_dlg_data;\r
+\r
+void k4_update_display(k4_dlg_data * d) {\r
+    CheckDlgButton(d->hwnd, IDC_NCK4_OBTAIN,\r
+                   (d->k4_enabled)?BST_CHECKED: BST_UNCHECKED);\r
+\r
+    if (d->k4_enabled) {\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), TRUE);\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), TRUE);\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), TRUE);\r
+    } else {\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), FALSE);\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), FALSE);\r
+        EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), FALSE);\r
+    }\r
+\r
+    CheckRadioButton(d->hwnd, IDC_NCK4_AUTO, IDC_NCK4_K524,\r
+                     method_to_id[d->method]);\r
+}\r
+\r
+void k4_update_data(k4_dlg_data * d) {\r
+    int i;\r
+    khm_boolean oldstate;\r
+\r
+    oldstate = d->k4_enabled;\r
+\r
+    if (IsDlgButtonChecked(d->hwnd, IDC_NCK4_OBTAIN) == BST_CHECKED)\r
+        d->k4_enabled = TRUE;\r
+    else\r
+        d->k4_enabled = FALSE;\r
+\r
+    if ((oldstate && !d->k4_enabled) ||\r
+        (!oldstate && d->k4_enabled)) {\r
+\r
+        khui_cw_enable_type(d->nc, credtype_id_krb4, d->k4_enabled);\r
+    }\r
+\r
+    d->method = 0;\r
+\r
+    for (i=K4_METHOD_AUTO; i<=K4_METHOD_K524; i++) {\r
+        if (IsDlgButtonChecked(d->hwnd, method_to_id[i]) == BST_CHECKED) {\r
+            d->method = i;\r
+            break;\r
+        }\r
+    }\r
+}\r
+\r
+void k4_read_identity_data(k4_dlg_data * d) {\r
+    khm_handle csp_ident = NULL;\r
+    khm_handle csp_k4 = NULL;\r
+\r
+    khm_int32 idflags = 0;\r
+    khm_int32 t;\r
+\r
+    if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4NewCreds", &t)))\r
+        d->k4_enabled = !!t;\r
+    else\r
+        d->k4_enabled = TRUE;\r
+\r
+    if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4Method", &t)))\r
+        d->method = t;\r
+    else\r
+        d->method = K4_METHOD_AUTO;\r
+\r
+    if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"DefaultLifetime", &t)))\r
+        d->lifetime = t;\r
+    else\r
+        d->lifetime = 10 * 60 * 60; /* 10 hours */\r
+\r
+    if (d->nc->n_identities > 0 &&\r
+        d->nc->identities[0]) {\r
+\r
+        if (KHM_SUCCEEDED(kcdb_identity_get_config(d->nc->identities[0],\r
+                                                   0,\r
+                                                   &csp_ident))) {\r
+\r
+            khc_open_space(csp_ident, CSNAME_KRB4CRED, 0, &csp_k4);\r
+            \r
+            if (csp_k4) {\r
+                if (KHM_SUCCEEDED(khc_read_int32(csp_k4, L"Krb4NewCreds", &t)))\r
+                    d->k4_enabled = !!t;\r
+                if (KHM_SUCCEEDED(khc_read_int32(csp_k4, L"Krb4Method", &t)))\r
+                    d->method = t;\r
+                khc_close_space(csp_k4);\r
+            }\r
+\r
+            khc_close_space(csp_ident);\r
+\r
+            kcdb_identity_get_flags(d->nc->identities[0], &idflags);\r
+        }\r
+\r
+        if (!(idflags & KCDB_IDENT_FLAG_DEFAULT)) {\r
+            /* we only support k4 for one identity, and that is the\r
+               default identity.  If we are trying to get tickets for\r
+               a non-default identity, then we start off as\r
+               disabled. */\r
+\r
+            khm_handle defident = NULL;\r
+\r
+            if (KHM_SUCCEEDED(kcdb_identity_get_default(&defident))) {\r
+                kcdb_identity_release(defident);\r
+\r
+                d->k4_enabled = FALSE;\r
+            }\r
+        }\r
+    } else {\r
+        d->k4_enabled = FALSE;\r
+    }\r
+\r
+    if (d->method < 0 || d->method > K4_METHOD_K524)\r
+        d->method = K4_METHOD_AUTO;\r
+}\r
+\r
+void k4_write_identity_data(k4_dlg_data * d) {\r
+    khm_handle csp_ident = NULL;\r
+    khm_handle csp_k4 = NULL;\r
+\r
+    if (d->nc->n_identities > 0 &&\r
+        d->nc->identities[0] &&\r
+        KHM_SUCCEEDED(kcdb_identity_get_config(d->nc->identities[0],\r
+                                               KHM_FLAG_CREATE,\r
+                                               &csp_ident))) {\r
+        khc_open_space(csp_ident, CSNAME_KRB4CRED, KHM_FLAG_CREATE, &csp_k4);\r
+\r
+        if (csp_k4) {\r
+            khc_write_int32(csp_k4, L"Krb4NewCreds", !!d->k4_enabled);\r
+            khc_write_int32(csp_k4, L"Krb4Method", d->method);\r
+\r
+            khc_close_space(csp_k4);\r
+        }\r
+\r
+        khc_close_space(csp_ident);\r
+    }\r
+}\r
+\r
+void k4_handle_wmnc_notify(k4_dlg_data * d,\r
+                           WPARAM wParam,\r
+                           LPARAM lParam) {\r
+    switch(HIWORD(wParam)) {\r
+    case WMNC_UPDATE_CREDTEXT:\r
+        {\r
+            if (d->nct->credtext) {\r
+                PFREE(d->nct->credtext);\r
+                d->nct->credtext = NULL;\r
+            }\r
+\r
+            if (d->nc->n_identities > 0 &&\r
+                d->nc->identities[0]) {\r
+\r
+                khm_int32 flags = 0;\r
+                wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+                wchar_t * atsign;\r
+                wchar_t * realm;\r
+                khm_size cb;\r
+\r
+                kcdb_identity_get_flags(d->nc->identities[0], &flags);\r
+\r
+                if (flags & KCDB_IDENT_FLAG_INVALID)\r
+                    break;\r
+\r
+                cb = sizeof(idname);\r
+                kcdb_identity_get_name(d->nc->identities[0], idname,\r
+                                       &cb);\r
+\r
+                atsign = wcsrchr(idname, L'@');\r
+\r
+                if (atsign == NULL || !atsign[1])\r
+                    break;\r
+\r
+                realm = ++atsign;\r
+\r
+                if (d->k4_enabled) {\r
+                    wchar_t wmethod[128];\r
+                    wchar_t wfmt[128];\r
+                    wchar_t wct[512];\r
+\r
+                    LoadString(hResModule, IDS_CT_TGTFOR,\r
+                               wfmt, ARRAYLENGTH(wfmt));\r
+\r
+                    if (d->method == K4_METHOD_AUTO)\r
+                        LoadString(hResModule, IDS_METHOD_AUTO, wmethod,\r
+                                   ARRAYLENGTH(wmethod));\r
+                    else if (d->method == K4_METHOD_PASSWORD)\r
+                        LoadString(hResModule, IDS_METHOD_PWD, wmethod,\r
+                                   ARRAYLENGTH(wmethod));\r
+                    else if (d->method == K4_METHOD_K524)\r
+                        LoadString(hResModule, IDS_METHOD_K524, wmethod,\r
+                                   ARRAYLENGTH(wmethod));\r
+                    else {\r
+                        assert(FALSE);\r
+                    }\r
+\r
+                    StringCbPrintf(wct, sizeof(wct), wfmt, realm, wmethod);\r
+\r
+                    StringCbLength(wct, sizeof(wct), &cb);\r
+                    cb += sizeof(wchar_t);\r
+\r
+                    d->nct->credtext = PMALLOC(cb);\r
+\r
+                    StringCbCopy(d->nct->credtext, cb, wct);\r
+                } else {\r
+                    wchar_t wct[256];\r
+\r
+                    LoadString(hResModule, IDS_CT_DISABLED,\r
+                               wct, ARRAYLENGTH(wct));\r
+\r
+                    StringCbLength(wct, sizeof(wct), &cb);\r
+                    cb += sizeof(wchar_t);\r
+\r
+                    d->nct->credtext = PMALLOC(cb);\r
+\r
+                    StringCbCopy(d->nct->credtext, cb, wct);\r
+                }\r
+            }\r
+            /* no identities were selected.  it is not the\r
+               responsibility of krb4 to complain about this. */\r
+        }\r
+        break;\r
+\r
+    case WMNC_IDENTITY_CHANGE:\r
+        k4_read_identity_data(d);\r
+        k4_update_display(d);\r
+        break;\r
+\r
+    case WMNC_CREDTEXT_LINK:\r
+        {\r
+            wchar_t wid[KHUI_MAXCCH_HTLINK_FIELD];\r
+            wchar_t * wids;\r
+            khui_htwnd_link * l;\r
+\r
+            l = (khui_htwnd_link *) lParam;\r
+\r
+            wcsncpy(wid, l->id, l->id_len);\r
+            wid[l->id_len] = 0;\r
+            wids = wcschr(wid, L':');\r
+\r
+            if (!wids)\r
+                break;\r
+            else\r
+                wids++;\r
+\r
+            if (!wcscmp(wids, L"Enable")) {\r
+                d->k4_enabled = TRUE;\r
+\r
+                k4_update_display(d);\r
+                khui_cw_enable_type(d->nc, credtype_id_krb4, TRUE);\r
+            }\r
+        }\r
+        break;\r
+    }\r
+}\r
+\r
+INT_PTR CALLBACK k4_nc_dlg_proc(HWND hwnd,\r
+                                UINT uMsg,\r
+                                WPARAM wParam,\r
+                                LPARAM lParam) {\r
+\r
+    k4_dlg_data * d;\r
+\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        {\r
+            d = PMALLOC(sizeof(*d));\r
+            ZeroMemory(d, sizeof(*d));\r
+\r
+            d->nc = (khui_new_creds *) lParam;\r
+            khui_cw_find_type(d->nc, credtype_id_krb4, &d->nct);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+            SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) d);\r
+#pragma warning(pop)\r
+\r
+            d->nct->aux = (LPARAM) d;\r
+            d->hwnd = hwnd;\r
+\r
+            d->k4_enabled = TRUE;\r
+            d->method = K4_METHOD_AUTO;\r
+\r
+            k4_update_display(d);\r
+        }\r
+        break;\r
+\r
+    case WM_COMMAND:\r
+        {\r
+            d = (k4_dlg_data *) (LONG_PTR)\r
+                GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+            k4_update_data(d);\r
+            k4_update_display(d);\r
+        }\r
+        break;\r
+\r
+    case KHUI_WM_NC_NOTIFY:\r
+        {\r
+            d = (k4_dlg_data *) (LONG_PTR)\r
+                GetWindowLongPtr(hwnd, DWLP_USER);\r
+            k4_handle_wmnc_notify(d, wParam, lParam);\r
+        }\r
+        break;\r
+\r
+    case WM_DESTROY:\r
+        {\r
+            d = (k4_dlg_data *) (LONG_PTR)\r
+                GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+            d->nct->aux = 0;\r
+\r
+            PFREE(d);\r
+        }\r
+        break;\r
+    }\r
+\r
+    return FALSE;\r
+}\r
+\r
+khm_int32\r
+krb4_msg_newcred(khm_int32 msg_type, khm_int32 msg_subtype,\r
+                 khm_ui_4 uparam, void * vparam) {\r
+\r
+    switch(msg_subtype) {\r
+    case KMSG_CRED_NEW_CREDS:\r
+        {\r
+            khui_new_creds * nc;\r
+            khui_new_creds_by_type * nct;\r
+            khm_size cbsize;\r
+            wchar_t wbuf[256];\r
+\r
+            nc = (khui_new_creds *) vparam;\r
+\r
+            nct = PMALLOC(sizeof(*nct));\r
+#ifdef DEBUG\r
+            assert(nct);\r
+#endif\r
+            ZeroMemory(nct, sizeof(*nct));\r
+\r
+            nct->type = credtype_id_krb4;\r
+            nct->ordinal = 3;\r
+            LoadString(hResModule, IDS_NC_K4_SHORT,\r
+                       wbuf, ARRAYLENGTH(wbuf));\r
+            StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
+            cbsize += sizeof(wchar_t);\r
+\r
+            nct->name = PMALLOC(cbsize);\r
+            StringCbCopy(nct->name, cbsize, wbuf);\r
+\r
+            nct->type_deps[nct->n_type_deps++] = credtype_id_krb5;\r
+\r
+            nct->h_module = hResModule;\r
+            nct->dlg_proc = k4_nc_dlg_proc;\r
+            nct->dlg_template = MAKEINTRESOURCE(IDD_NC_KRB4);\r
+\r
+            khui_cw_add_type(nc, nct);\r
+        }\r
+        break;\r
+\r
+    case KMSG_CRED_RENEW_CREDS:\r
+        {\r
+            khui_new_creds * nc;\r
+            khui_new_creds_by_type * nct;\r
+            khm_size cbsize;\r
+            wchar_t wbuf[256];\r
+\r
+            nc = (khui_new_creds *) vparam;\r
+\r
+            nct = PMALLOC(sizeof(*nct));\r
+#ifdef DEBUG\r
+            assert(nct);\r
+#endif\r
+\r
+            ZeroMemory(nct, sizeof(*nct));\r
+\r
+            nct->type = credtype_id_krb4;\r
+            nct->ordinal = 3;\r
+            LoadString(hResModule, IDS_NC_K4_SHORT,\r
+                       wbuf, ARRAYLENGTH(wbuf));\r
+            StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
+            cbsize += sizeof(wchar_t);\r
+\r
+            nct->name = PMALLOC(cbsize);\r
+            StringCbCopy(nct->name, cbsize, wbuf);\r
+\r
+            nct->type_deps[nct->n_type_deps++] = credtype_id_krb5;\r
+\r
+            khui_cw_add_type(nc, nct);\r
+        }\r
+        break;\r
+\r
+    case KMSG_CRED_DIALOG_SETUP:\r
+        break;\r
+\r
+    case KMSG_CRED_PROCESS:\r
+        {\r
+            khui_new_creds * nc;\r
+            khui_new_creds_by_type * nct = NULL;\r
+            khm_handle ident = NULL;\r
+            k4_dlg_data * d = NULL;\r
+            long code = 0;\r
+\r
+            nc = (khui_new_creds *) vparam;\r
+            if (KHM_FAILED(khui_cw_find_type(nc, credtype_id_krb4, &nct)))\r
+                break;\r
+\r
+            if (nc->subtype == KMSG_CRED_NEW_CREDS ||\r
+                nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
+                khm_int32 method;\r
+\r
+                if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+\r
+                    d = (k4_dlg_data *) nct->aux;\r
+                    if (!d ||\r
+                        nc->n_identities == 0 ||\r
+                        nc->identities[0] == NULL ||\r
+                        nc->result != KHUI_NC_RESULT_GET_CREDS)\r
+                        break;\r
+\r
+                    if (!d->k4_enabled) {\r
+                        k4_write_identity_data(d);\r
+                        break;\r
+                    }\r
+\r
+                    method = d->method;\r
+                    ident = nc->identities[0];\r
+\r
+                } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
+\r
+                    if ((nc->ctx.scope == KHUI_SCOPE_IDENT &&\r
+                         nc->ctx.identity != NULL) ||\r
+\r
+                        (nc->ctx.scope == KHUI_SCOPE_CREDTYPE &&\r
+                         nc->ctx.cred_type == credtype_id_krb4 &&\r
+                         nc->ctx.identity != NULL) ||\r
+\r
+                        (nc->ctx.scope == KHUI_SCOPE_CRED &&\r
+                         nc->ctx.cred_type == credtype_id_krb4 &&\r
+                         nc->ctx.identity != NULL &&\r
+                         nc->ctx.cred != NULL)) {\r
+\r
+                        ident = nc->ctx.identity;\r
+\r
+                    } else {\r
+                        break;\r
+                    }\r
+\r
+                    method = K4_METHOD_K524; /* only k524 is supported\r
+                                                for renewals */\r
+                } else {\r
+                    assert(FALSE);\r
+                }\r
+\r
+                if ((method == K4_METHOD_AUTO ||\r
+                     method == K4_METHOD_K524) &&\r
+                    khui_cw_type_succeeded(nc, credtype_id_krb5)) {\r
+\r
+                    code = khm_convert524(ident);\r
+\r
+                    if (code == 0) {\r
+                        khui_cw_set_response(nc, credtype_id_krb4,\r
+                                             KHUI_NC_RESPONSE_SUCCESS |\r
+                                             KHUI_NC_RESPONSE_EXIT);\r
+\r
+                        if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+                            assert(d != NULL);\r
+\r
+                            k4_write_identity_data(d);\r
+                        }\r
+                        break;\r
+                    } else if (method == K4_METHOD_K524) {\r
+                        khui_cw_set_response(nc, credtype_id_krb4,\r
+                                             KHUI_NC_RESPONSE_FAILED |\r
+                                             KHUI_NC_RESPONSE_EXIT);\r
+                        break;\r
+                    }\r
+                }\r
+\r
+                /* only supported for new credentials */\r
+                if (method == K4_METHOD_AUTO ||\r
+                    method == K4_METHOD_PASSWORD) {\r
+                    \r
+                    khm_size n_prompts = 0;\r
+                    khm_size idx;\r
+                    khm_size cb;\r
+                    wchar_t wpwd[KHUI_MAXCCH_PROMPT_VALUE];\r
+                    char pwd[KHUI_MAXCCH_PROMPT_VALUE];\r
+                    wchar_t widname[KCDB_IDENT_MAXCCH_NAME];\r
+                    char idname[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+                    char * aname = NULL;\r
+                    char * inst = NULL;\r
+                    char * realm = NULL;\r
+\r
+                    assert(nc->subtype == KMSG_CRED_NEW_CREDS);\r
+\r
+                    code = TRUE; /* just has to be non-zero */\r
+\r
+                    khui_cw_get_prompt_count(nc, &n_prompts);\r
+\r
+                    if (n_prompts == 0)\r
+                        goto _skip_pwd;\r
+\r
+                    for (idx = 0; idx < n_prompts; idx++) {\r
+                        khui_new_creds_prompt * p;\r
+\r
+                        if (KHM_FAILED(khui_cw_get_prompt(nc, idx, &p)))\r
+                            continue;\r
+\r
+                        if (p->type == KHUI_NCPROMPT_TYPE_PASSWORD)\r
+                            break;\r
+                    }\r
+\r
+                    if (idx >= n_prompts)\r
+                        goto _skip_pwd;\r
+\r
+                    khui_cw_sync_prompt_values(nc);\r
+\r
+                    cb = sizeof(wpwd);\r
+                    if (KHM_FAILED(khui_cw_get_prompt_value(nc, idx,\r
+                                                            wpwd,\r
+                                                            &cb)))\r
+                        goto _skip_pwd;\r
+\r
+                    UnicodeStrToAnsi(pwd, sizeof(pwd), wpwd);\r
+\r
+                    cb = sizeof(widname);\r
+                    kcdb_identity_get_name(ident,\r
+                                           widname,\r
+                                           &cb);\r
+\r
+                    UnicodeStrToAnsi(idname, sizeof(idname), widname);\r
+\r
+                    {\r
+                        char * atsign;\r
+\r
+                        atsign = strchr(idname, '@');\r
+                        if (atsign == NULL)\r
+                            goto _skip_pwd;\r
+\r
+                        *atsign++ = 0;\r
+\r
+                        realm = atsign;\r
+                    }\r
+\r
+                    {\r
+                        char * slash;\r
+\r
+                        slash = strchr(idname, '/');\r
+                        if (slash != NULL) {\r
+                            *slash++ = 0;\r
+                            inst = slash;\r
+                        } else {\r
+                            inst = "";\r
+                        }\r
+                    }\r
+\r
+                    aname = idname;\r
+\r
+                    code = khm_krb4_kinit(aname, inst, realm,\r
+                                          (long) d->lifetime, pwd);\r
+                _skip_pwd:\r
+\r
+                    if (code) {\r
+                        khui_cw_set_response(nc, credtype_id_krb4,\r
+                                             KHUI_NC_RESPONSE_EXIT |\r
+                                             KHUI_NC_RESPONSE_FAILED);\r
+\r
+                    } else {\r
+                        khui_cw_set_response(nc, credtype_id_krb4,\r
+                                             KHUI_NC_RESPONSE_EXIT |\r
+                                             KHUI_NC_RESPONSE_SUCCESS);\r
+\r
+                        if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+\r
+                            assert(d != NULL);\r
+                            k4_write_identity_data(d);\r
+\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        break;\r
+\r
+    case KMSG_CRED_END:\r
+        {\r
+            khui_new_creds * nc;\r
+            khui_new_creds_by_type * nct = NULL;\r
+\r
+            nc = (khui_new_creds *) vparam;\r
+            if (KHM_FAILED(khui_cw_find_type(nc, credtype_id_krb4, &nct)))\r
+                break;\r
+\r
+            khui_cw_del_type(nc, credtype_id_krb4);\r
+\r
+            if (nct->name)\r
+                PFREE(nct->name);\r
+\r
+            PFREE(nct);\r
+        }\r
+        break;\r
+    }\r
+\r
+    return KHM_ERROR_SUCCESS;\r
+}\r
index 106febac00831108637b007dbb1975884c36125b..23f913bd9b53018a7c47932a54ca9ac117824d8e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 #include<kherror.h>\r
 #include<khmsgtypes.h>\r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 #include<commctrl.h>\r
 #include<strsafe.h>\r
 #include<krb5.h>\r
 \r
 khm_int32 credtype_id_krb4 = KCDB_CREDTYPE_INVALID;\r
+khm_int32 credtype_id_krb5 = KCDB_CREDTYPE_INVALID;\r
+\r
 khm_boolean krb4_initialized = FALSE;\r
 khm_handle krb4_credset = NULL;\r
 \r
@@ -64,7 +67,7 @@ krb4_msg_system(khm_int32 msg_type, khm_int32 msg_subtype,
                 {\r
                     StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
                     cbsize += sizeof(wchar_t);\r
-                    ct.short_desc = malloc(cbsize);\r
+                    ct.short_desc = PMALLOC(cbsize);\r
                     StringCbCopy(ct.short_desc, cbsize, buf);\r
                 }\r
 \r
@@ -76,7 +79,7 @@ krb4_msg_system(khm_int32 msg_type, khm_int32 msg_subtype,
                 {\r
                     StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
                     cbsize += sizeof(wchar_t);\r
-                    ct.long_desc = malloc(cbsize);\r
+                    ct.long_desc = PMALLOC(cbsize);\r
                     StringCbCopy(ct.long_desc, cbsize, buf);\r
                 }\r
 \r
@@ -88,34 +91,116 @@ krb4_msg_system(khm_int32 msg_type, khm_int32 msg_subtype,
             if(KHM_SUCCEEDED(rv))\r
                 rv = kcdb_credset_create(&krb4_credset);\r
 \r
+            if (KHM_SUCCEEDED(rv))\r
+                rv = kcdb_credtype_get_id(KRB5_CREDTYPE_NAME, \r
+                                          &credtype_id_krb5);\r
+\r
             if(ct.short_desc)\r
-                free(ct.short_desc);\r
+                PFREE(ct.short_desc);\r
 \r
             if(ct.long_desc)\r
-                free(ct.long_desc);\r
+                PFREE(ct.long_desc);\r
+\r
+            if (KHM_SUCCEEDED(rv)) {\r
+                khui_config_node idents;\r
+\r
+                ZeroMemory(&reg, sizeof(reg));\r
+\r
+                reg.name = KRB4_CONFIG_NODE_NAME;\r
+                reg.short_desc = wshort_desc;\r
+                reg.long_desc = wlong_desc;\r
+                reg.h_module = hResModule;\r
+                reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_KRB4);\r
+                reg.dlg_proc = krb4_confg_proc;\r
+                reg.flags = 0;\r
+\r
+                LoadString(hResModule, IDS_CFG_KRB4_LONG,\r
+                           wlong_desc, ARRAYLENGTH(wlong_desc));\r
+                LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+                           wshort_desc, ARRAYLENGTH(wshort_desc));\r
+\r
+                khui_cfg_register(NULL, &reg);\r
+\r
+                khui_cfg_open(NULL, L"KhmIdentities", &idents);\r
+\r
+                ZeroMemory(&reg, sizeof(reg));\r
+\r
+                reg.name = KRB4_IDS_CONFIG_NODE_NAME;\r
+                reg.short_desc = wshort_desc;\r
+                reg.long_desc = wlong_desc;\r
+                reg.h_module = hResModule;\r
+                reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_IDS_KRB4);\r
+                reg.dlg_proc = krb4_ids_config_proc;\r
+                reg.flags = KHUI_CNFLAG_SUBPANEL;\r
+\r
+                LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+                           wlong_desc, ARRAYLENGTH(wlong_desc));\r
+                LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+                           wshort_desc, ARRAYLENGTH(wshort_desc));\r
+\r
+                khui_cfg_register(idents, &reg);\r
 \r
-            ZeroMemory(&reg, sizeof(reg));\r
+                ZeroMemory(&reg, sizeof(reg));\r
 \r
-            reg.name = KRB4_CONFIG_NODE_NAME;\r
-            reg.short_desc = wshort_desc;\r
-            reg.long_desc = wlong_desc;\r
-            reg.h_module = hResModule;\r
-            reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_KRB4);\r
-            reg.dlg_proc = krb4_confg_proc;\r
-            reg.flags = 0;\r
+                reg.name = KRB4_ID_CONFIG_NODE_NAME;\r
+                reg.short_desc = wshort_desc;\r
+                reg.long_desc = wlong_desc;\r
+                reg.h_module = hResModule;\r
+                reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_ID_KRB4);\r
+                reg.dlg_proc = krb4_id_config_proc;\r
+                reg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_PLURAL;\r
 \r
-            LoadString(hResModule, IDS_CFG_KRB4_LONG,\r
-                       wlong_desc, ARRAYLENGTH(wlong_desc));\r
-            LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
-                       wshort_desc, ARRAYLENGTH(wshort_desc));\r
+                LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+                           wlong_desc, ARRAYLENGTH(wlong_desc));\r
+                LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+                           wshort_desc, ARRAYLENGTH(wshort_desc));\r
 \r
-            khui_cfg_register(NULL, &reg);\r
+                khui_cfg_register(idents, &reg);\r
+\r
+                khui_cfg_release(idents);\r
 \r
-            if(KHM_SUCCEEDED(rv)) {\r
                 krb4_initialized = TRUE;\r
 \r
                 khm_krb4_list_tickets();\r
             }\r
+\r
+            /* Lookup common data types */\r
+            if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ENCTYPE, \r
+                                           &type_id_enctype))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ADDR_LIST, \r
+                                           &type_id_addr_list))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            if(KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_FLAGS, \r
+                                           &type_id_krb5_flags))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            /* Lookup common attributes */\r
+            if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, \r
+                                             &attr_id_key_enctype))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_TKT_ENCTYPE, \r
+                                             &attr_id_tkt_enctype))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_ADDR_LIST, \r
+                                             &attr_id_addr_list))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
+            if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KRB5_FLAGS, \r
+                                             &attr_id_krb5_flags))) {\r
+                rv = KHM_ERROR_UNKNOWN;\r
+            }\r
+\r
         }\r
         break;\r
 \r
@@ -140,11 +225,47 @@ krb4_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype,
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     switch(msg_subtype) {\r
-        case KMSG_CRED_REFRESH:\r
-            {\r
-                khm_krb4_list_tickets();\r
+    case KMSG_CRED_REFRESH:\r
+        {\r
+            khm_krb4_list_tickets();\r
+        }\r
+        break;\r
+\r
+    case KMSG_CRED_DESTROY_CREDS:\r
+        {\r
+            khui_action_context * ctx;\r
+            khm_handle credset;\r
+            khm_size nc_root = 0;\r
+            khm_size nc_sel = 0;\r
+\r
+            ctx = (khui_action_context *) vparam;\r
+\r
+            /* if all krb4 tickets are selected, then we destroy all\r
+               of them.  Otherwise, we do nothing. */\r
+\r
+            kcdb_credset_create(&credset);\r
+\r
+            kcdb_credset_extract(credset, ctx->credset,\r
+                                 NULL, credtype_id_krb4);\r
+            kcdb_credset_get_size(credset, &nc_sel);\r
+\r
+            kcdb_credset_flush(credset);\r
+\r
+            kcdb_credset_extract(credset, NULL,\r
+                                 NULL, credtype_id_krb4);\r
+            kcdb_credset_get_size(credset, &nc_root);\r
+\r
+            kcdb_credset_delete(credset);\r
+\r
+            if (nc_root == nc_sel) {\r
+                khm_krb4_kdestroy();\r
             }\r
-            break;\r
+        }\r
+        break;\r
+\r
+    default:\r
+        if (IS_CRED_ACQ_MSG(msg_subtype))\r
+            return krb4_msg_newcred(msg_type, msg_subtype, uparam, vparam);\r
     }\r
 \r
     return rv;\r
index bed0d1ccb9bd5fe42c8c9388866a2eb64a736c57..9aa7cd944edd75330104459f59f126e2b83c2557 100644 (file)
@@ -6,18 +6,11 @@ Krb4Cred,KC_SPACE,0,"Kerberos IV Credentials Provider"
   Type,KC_INT32,1,\r
   Flags,KC_INT32,0,\r
   Parameters,KC_SPACE,0,Parameters for KrbCred\r
+    Krb4NewCreds,KC_INT32,1,Obtain Kerberos 4 tickets\r
+    Krb4Method,KC_INT32,0,Method for acquiring K4 tix. 0-Auto;1-Password;2-K524\r
     CreateMissingConfig,KC_INT32,0,Create missing configuration files\r
-    MsLsaImport,KC_INT32,2,Automatically import MSLSA credentials\r
-    AutoRenewTickets,KC_INT32,1,Automatically renew expiring tickets\r
     DefaultLifetime,KC_INT32,36000,Default ticket lifetime\r
     MaxLifetime,KC_INT32,86400,Maximum lifetime\r
     MinLifetime,KC_INT32,60,Minimum lifetime\r
-    Forwardable,KC_INT32,1,Obtain forwardable tickets (boolean)\r
-    Proxiable,KC_INT32,0,Obtain proxiable tickets (boolean)\r
-    Addressless,KC_INT32,1,Obtain addressless tickets (boolean)\r
-    Renewable,KC_INT32,1,Obtain renewable tickets (boolean)\r
-    DefaultRenewLifetime,KC_INT32,604800,Default renewable lifetime\r
-    MaxRenewLifetime,KC_INT32,2592000,Maximum renewable lifetime\r
-    MinRenewLifetime,KC_INT32,60,Maximum renewable lifetime\r
   Parameters,KC_ENDSPACE,0,\r
 Krb4Cred,KC_ENDSPACE,0,\r
index e56d114ee905a39884282966724a45444c834a55..9f5d3c932ee2e5a665d32478b28470d215dd2a54 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 #include<windows.h>\r
 \r
-#include<khdefs.h>\r
-#include<kcreddb.h>\r
-#include<kmm.h>\r
-#include<kconfig.h>\r
+#define KHERR_FACILITY L"Kerberos4"\r
+#define KHERR_FACILITY_ID 65\r
+#define KHERR_HMODULE hResModule\r
 \r
+#include<netidmgr.h>\r
 \r
 #include<krb4funcs.h>\r
 #include<krb5common.h>\r
@@ -41,7 +41,6 @@
 #include<dynimport.h>\r
 \r
 #include<langres.h>\r
-#include<datarep.h>\r
 \r
 #define TYPENAME_ENCTYPE        L"EncType"\r
 #define TYPENAME_ADDR_LIST      L"AddrList"\r
@@ -86,8 +85,13 @@ extern khm_int32 attr_id_renew_for;
 \r
 #define KRB4_CREDTYPE_NAME  L"Krb4Cred"\r
 \r
+#define KRB5_CREDTYPE_NAME  L"Krb5Cred"\r
+\r
 #define KRB4_CONFIG_NODE_NAME L"Krb4Config"\r
 \r
+#define KRB4_ID_CONFIG_NODE_NAME L"Krb4IdentConfig"\r
+#define KRB4_IDS_CONFIG_NODE_NAME L"Krb4IdentsConfig"\r
+\r
 extern khm_handle csp_plugins;\r
 extern khm_handle csp_krbcred;\r
 extern khm_handle csp_params;\r
@@ -96,6 +100,7 @@ extern kconf_schema schema_krbconfig[];
 \r
 /* other globals */\r
 extern khm_int32 credtype_id_krb4;\r
+extern khm_int32 credtype_id_krb5;\r
 \r
 extern khm_boolean krb4_initialized;\r
 \r
@@ -111,4 +116,20 @@ krb4_confg_proc(HWND hwnd,
                 UINT uMsg,\r
                 WPARAM wParam,\r
                 LPARAM lParam);\r
+\r
+INT_PTR CALLBACK\r
+krb4_ids_config_proc(HWND hwnd,\r
+                     UINT uMsg,\r
+                     WPARAM wParam,\r
+                     LPARAM lParam);\r
+\r
+INT_PTR CALLBACK\r
+krb4_id_config_proc(HWND hwnd,\r
+                    UINT uMsg,\r
+                    WPARAM wParam,\r
+                    LPARAM lParam);\r
+\r
+khm_int32\r
+krb4_msg_newcred(khm_int32 msg_type, khm_int32 msg_subtype,\r
+                 khm_ui_4 uparam, void * vparam);\r
 #endif\r
index a5d62a26a402c9b691186304743caf3606c84872..042da77b7acb789f9091eba9232f36e1d650f304 100644 (file)
@@ -57,7 +57,18 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
 EXSTYLE WS_EX_CONTROLPARENT\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
-    LTEXT           "kRB4",IDC_STATIC,38,43,71,24\r
+    CONTROL         "Kerberos 4 Ticket Options",IDC_STATIC,"Static",\r
+                    SS_LEFTNOWORDWRAP | SS_SUNKEN | WS_GROUP,7,7,286,11\r
+    CONTROL         "Obtain Kerberos 4 tickets",IDC_NCK4_OBTAIN,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,7,26,97,10\r
+    CONTROL         "Automatically determine method",IDC_NCK4_AUTO,"Button",\r
+                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,23,58,119,10\r
+    CONTROL         "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON | \r
+                    WS_TABSTOP,23,75,47,10\r
+    CONTROL         "Kerberos 5 to 4 translation",IDC_NCK4_K524,"Button",\r
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,23,92,101,10\r
+    GROUPBOX        "Obtain Kerberos 4 tickets using",IDC_STATIC,7,43,286,72,\r
+                    WS_GROUP\r
 END\r
 \r
 IDD_CFG_KRB4 DIALOGEX 0, 0, 255, 182\r
@@ -75,6 +86,27 @@ BEGIN
     PUSHBUTTON      "Browse...",IDC_CFG_RLMBROW,200,47,48,14\r
 END\r
 \r
+IDD_CFG_IDS_KRB4 DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+    CONTROL         "Obtain Kerberos 4 tickets",IDC_CFG_GETTIX,"Button",\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,7,7,221,17\r
+    LTEXT           "Note that, if enabled, Kerberos 4 tickets will be acquired during initial credential acquisition and during credential renewals.\n\nHowever, currently Kerberos 4 tickets can only be obtained for the default identity.",\r
+                    IDC_STATIC,7,91,221,53,SS_SUNKEN\r
+END\r
+\r
+IDD_CFG_ID_KRB4 DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+    CONTROL         "Obtain Kerberos 4 tickets for this identity",\r
+                    IDC_CFG_GETTIX,"Button",BS_AUTOCHECKBOX | WS_DISABLED | \r
+                    WS_TABSTOP,7,7,147,10\r
+END\r
+\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -102,6 +134,22 @@ BEGIN
         TOPMARGIN, 7\r
         BOTTOMMARGIN, 175\r
     END\r
+\r
+    IDD_CFG_IDS_KRB4, DIALOG\r
+    BEGIN\r
+        LEFTMARGIN, 7\r
+        RIGHTMARGIN, 228\r
+        TOPMARGIN, 7\r
+        BOTTOMMARGIN, 144\r
+    END\r
+\r
+    IDD_CFG_ID_KRB4, DIALOG\r
+    BEGIN\r
+        LEFTMARGIN, 7\r
+        RIGHTMARGIN, 228\r
+        TOPMARGIN, 7\r
+        BOTTOMMARGIN, 144\r
+    END\r
 END\r
 #endif    // APSTUDIO_INVOKED\r
 \r
@@ -114,6 +162,14 @@ END
 STRINGTABLE \r
 BEGIN\r
     IDS_PLUGIN_DESC         "Kerberos 4 Credentials Provider"\r
+    IDS_NC_K4_SHORT         "Kerberos 4"\r
+    IDS_ERR_REALM           "Could not resolve realm"\r
+    IDS_ERR_PRINCIPAL       "Invalid principal"\r
+    IDS_ERR_INVINST         "Invalid instance"\r
+    IDS_ERR_PWINTKT         "Could not get Kerberos 4 tickets"\r
+    IDS_CT_DISABLED         "<p><a id=""SwitchPanel"" param=""Krb4Cred""><b>Krb4</b></a><tab>: Disabled  (click <a id=""Krb4Cred:Enable"">here</a> to enable)</p>"\r
+    IDS_CT_TGTFOR           "<p><a id=""SwitchPanel"" param=""Krb4Cred""><b>Krb4</b></a><tab>: Tickets for realm %s</p>"\r
+    IDS_METHOD_AUTO         "Automatically determined method"\r
 END\r
 \r
 STRINGTABLE \r
@@ -124,6 +180,13 @@ BEGIN
     IDS_CFG_KRB4_SHORT      "Kerberos 4"\r
 END\r
 \r
+STRINGTABLE \r
+BEGIN\r
+    IDS_METHOD_PWD          "Password"\r
+    IDS_METHOD_K524         "Kerberos 5 to 4 translation"\r
+    IDS_CFG_IDS_KRB4_SHORT  "Kerberos 4"\r
+END\r
+\r
 #endif    // English (U.S.) resources\r
 /////////////////////////////////////////////////////////////////////////////\r
 \r
index 2096adec3b6811dbf9732eb4ef36e1f6f71db6a7..ceb2360075492665b0bc0d6b919de6e8faa39d56 100644 (file)
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}\r
 // Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\plugins\krb4\lang\en_us\langres.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\plugins\krb4\lang\en_us\langres.rc\r
 //\r
 #define IDS_UNK_ADDR_FMT                101\r
 #define IDS_KRB5_CREDTEXT_0             102\r
@@ -8,16 +8,29 @@
 #define IDS_PLUGIN_DESC                 103\r
 #define IDS_KEY_ENCTYPE_SHORT_DESC      104\r
 #define IDD_CFG_KRB4                    104\r
+#define IDS_NC_K4_SHORT                 104\r
 #define IDS_TKT_ENCTYPE_SHORT_DESC      105\r
+#define IDS_ERR_REALM                   105\r
+#define IDD_CFG_IDS_KRB4                105\r
 #define IDS_KEY_ENCTYPE_LONG_DESC       106\r
+#define IDS_ERR_PRINCIPAL               106\r
+#define IDD_CFG_ID_KRB4                 106\r
 #define IDS_TKT_ENCTYPE_LONG_DESC       107\r
+#define IDS_ERR_INVINST                 107\r
 #define IDS_ADDR_LIST_SHORT_DESC        108\r
+#define IDS_ERR_PWINTKT                 108\r
 #define IDS_ADDR_LIST_LONG_DESC         109\r
+#define IDS_CT_DISABLED                 109\r
 #define IDS_ETYPE_NULL                  110\r
+#define IDS_CT_TGTFOR                   110\r
 #define IDS_ETYPE_DES_CBC_CRC           111\r
+#define IDS_METHOD_AUTO                 111\r
 #define IDS_ETYPE_DES_CBC_MD4           112\r
+#define IDS_METHOD_PWD                  112\r
 #define IDS_ETYPE_DES_CBC_MD5           113\r
+#define IDS_METHOD_K524                 113\r
 #define IDS_ETYPE_DES_CBC_RAW           114\r
+#define IDS_CFG_IDS_KRB4_SHORT          114\r
 #define IDS_ETYPE_DES3_CBC_SHA          115\r
 #define IDS_ETYPE_DES3_CBC_RAW          116\r
 #define IDS_ETYPE_DES_HMAC_SHA1         117\r
 #define IDC_CFG_RLMPATH                 1030\r
 #define IDC_CFG_CFGBROW                 1031\r
 #define IDC_CFG_RLMBROW                 1032\r
+#define IDC_NCK4_OBTAIN                 1033\r
+#define IDC_NCK4_PWD                    1034\r
+#define IDC_NCK4_K524                   1035\r
+#define IDC_NCK4_AUTO                   1036\r
+#define IDC_CFG_GETTIX                  1037\r
+#define IDC_CHECK1                      1038\r
 \r
 // Next default values for new objects\r
 // \r
 #ifdef APSTUDIO_INVOKED\r
 #ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE        105\r
+#define _APS_NEXT_RESOURCE_VALUE        107\r
 #define _APS_NEXT_COMMAND_VALUE         40001\r
-#define _APS_NEXT_CONTROL_VALUE         1033\r
+#define _APS_NEXT_CONTROL_VALUE         1039\r
 #define _APS_NEXT_SYMED_VALUE           101\r
 #endif\r
 #endif\r
diff --git a/src/windows/identity/plugins/krb4/version.rc b/src/windows/identity/plugins/krb4/version.rc
new file mode 100644 (file)
index 0000000..3ca6b1c
--- /dev/null
@@ -0,0 +1,66 @@
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<netidmgr_intver.h>\r
+\r
+1 VERSIONINFO \r
+        FILEVERSION     KH_VERSION_LIST\r
+        PRODUCTVERSION  KH_VERSION_LIST\r
+        FILEFLAGSMASK   KH_VER_FILEFLAGMASK\r
+        FILEFLAGS       KH_VER_FILEFLAGS\r
+        FILEOS          KH_VER_FILEOS\r
+        FILETYPE        KH_VER_FILETYPEDLL\r
+        FILESUBTYPE     0\r
+  {\r
+\r
+    BLOCK "StringFileInfo"\r
+    {\r
+      BLOCK "040904b0"\r
+      {\r
+        VALUE "CompanyName",     KH_VERSTR_COMPANY_1033\r
+        VALUE "FileDescription", "Kerberos 4 plugin for NetIDMgr"\r
+        VALUE "FileVersion",     KH_VERSTR_VERSION_1033\r
+        VALUE "InternalName",    "krb4cred"\r
+        VALUE "LegalCopyright",  KH_VERSTR_COPYRIGHT_1033\r
+        VALUE "OriginalFilename", "krb4cred.dll"\r
+        VALUE "ProductName",     "NetIDMgr"\r
+        VALUE "ProductVersion",  KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+        VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+        VALUE NIMV_MODULE,       "MITKrb4"\r
+        VALUE NIMV_PLUGINS,      "Krb4Cred"\r
+        VALUE NIMV_APIVER,       KH_VERSION_STRINGAPI\r
+        VALUE NIMV_SUPPORT,      "http://web.mit.edu/kerberos"\r
+      }\r
+    }\r
+\r
+    BLOCK "VarFileInfo"\r
+    {\r
+        VALUE "Translation", 0x409, 1200\r
+    }\r
+\r
+  }\r
index 9bf9ef020e34dcb7faa80fc73e90bc21ee8c80ab..e0553d8461721ea3735aa0beeb0908ef3e83ba7c 100644 (file)
@@ -32,7 +32,7 @@ LIBFILE=$(LIBDIR)\krb5cred.lib
 OBJFILES= \\r
        $(LIBDIR)\dynimport.obj         \\r
        $(LIBDIR)\krb5common.obj        \\r
-       $(OBJ)\main.obj                 \\r
+       $(OBJ)\krb5main.obj             \\r
        $(OBJ)\datarep.obj              \\r
        $(OBJ)\errorfuncs.obj           \\r
        $(OBJ)\krb5plugin.obj           \\r
@@ -41,21 +41,28 @@ OBJFILES= \
        $(OBJ)\krb5funcs.obj            \\r
        $(OBJ)\krb5config.obj           \\r
        $(OBJ)\krb5identpro.obj         \\r
-       $(OBJ)\krb5configdlg.obj\r
+       $(OBJ)\krb5configdlg.obj        \\r
+       $(OBJ)\krb5configcc.obj         \\r
+       $(OBJ)\krb5configid.obj         \\r
+       $(OBJ)\krb5configids.obj\r
 \r
 LIBFILES= \\r
        $(LIBDIR)\nidmgr32.lib          \\r
        $(KFWLIBDIR)\loadfuncs.lib\r
 \r
 SDKLIBFILES=   \\r
-       netapi32.lib\r
+       netapi32.lib    \\r
+       shlwapi.lib     \\r
+       comctl32.lib\r
 \r
 MSGRESFILE=$(OBJ)\krb5_msgs.res\r
 \r
+VERRESFILE=$(OBJ)\version.res\r
+\r
 $(OBJ)\krb5config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg\r
        $(CCSV) $** $@\r
 \r
-$(DLLFILE): $(MSGRESFILE) $(OBJFILES)\r
+$(DLLFILE): $(MSGRESFILE) $(VERRESFILE) $(OBJFILES)\r
        $(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
 \r
 $(MSGRESFILE): $(OBJ)\krb5_msgs.rc\r
index f8cc4cc484c9d74bff9299948df18d67d9f513f1..2c4036083340ea17fad423a4a57575953178c63f 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -39,7 +39,7 @@ khm_int32 KHMAPI enctype_toString(const void * data, khm_size cbdata, wchar_t *d
     size_t cblength;\r
 \r
     if(cbdata != sizeof(khm_int32))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     etype = *((khm_int32 *) data);\r
 \r
index e5388f01dbbc6e6a68f0593d18b13a11c3ac8b8c..ac6771cb9c639d5c222769549001ef5f8db6ce10 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -34,4 +34,4 @@ khm_int32 KHMAPI krb5flags_toString(const void *, khm_size, wchar_t *, khm_size
 khm_int32 KHMAPI renew_for_cb(khm_handle cred, khm_int32 id, void * buffer, khm_size * pcbsize);\r
 \r
 \r
-#endif
\ No newline at end of file
+#endif\r
index ab64889cb70306d8edf5dcb61ffe68ef46ec1642..28016d3cb8e9c05348eb180ae7379c732ea3303c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 46d68f9fc0ece119670423e647c932cd727c4daa..86fc5b44046a2ab3e5ea47c9bde7244efc1b8571 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
similarity index 77%
rename from src/windows/identity/ui/images/wgt_arrow_expand.ico
rename to src/windows/identity/plugins/krb5/images/deleted.ico
index 485b537b03ce7758cc82dd275e16d3b2cc921898..a8063f9ee72d8b209717fad18acb3384f8309e44 100644 (file)
Binary files a/src/windows/identity/ui/images/wgt_arrow_expand.ico and b/src/windows/identity/plugins/krb5/images/deleted.ico differ
diff --git a/src/windows/identity/plugins/krb5/images/krb5plugin.ico b/src/windows/identity/plugins/krb5/images/krb5plugin.ico
new file mode 100644 (file)
index 0000000..791b359
Binary files /dev/null and b/src/windows/identity/plugins/krb5/images/krb5plugin.ico differ
similarity index 72%
rename from src/windows/identity/ui/images/wgt_arrow_collapse.ico
rename to src/windows/identity/plugins/krb5/images/modified.ico
index b248bd9d6c71a961ba093afb4c8fce91b3bba4e3..733d9d5348bd94acdca867d77c36a83c42efcc92 100644 (file)
Binary files a/src/windows/identity/ui/images/wgt_arrow_collapse.ico and b/src/windows/identity/plugins/krb5/images/modified.ico differ
diff --git a/src/windows/identity/plugins/krb5/images/new.ico b/src/windows/identity/plugins/krb5/images/new.ico
new file mode 100644 (file)
index 0000000..1049eb2
Binary files /dev/null and b/src/windows/identity/plugins/krb5/images/new.ico differ
diff --git a/src/windows/identity/plugins/krb5/images/normal.ico b/src/windows/identity/plugins/krb5/images/normal.ico
new file mode 100644 (file)
index 0000000..56a702f
Binary files /dev/null and b/src/windows/identity/plugins/krb5/images/normal.ico differ
diff --git a/src/windows/identity/plugins/krb5/krb5configcc.c b/src/windows/identity/plugins/krb5/krb5configcc.c
new file mode 100644 (file)
index 0000000..256f6b7
--- /dev/null
@@ -0,0 +1,547 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_file_cc {\r
+    wchar_t path[MAX_PATH];\r
+    khm_int32 flags;\r
+} k5_file_cc;\r
+\r
+#define K5_FCC_ALLOC_INCR  8\r
+\r
+#define K5_FCC_FLAG_EXISTS 1\r
+\r
+typedef struct tag_k5_ccc_data {\r
+    khm_boolean   inc_api;\r
+    khm_boolean   inc_mslsa;\r
+    k5_file_cc *  file_ccs;\r
+    khm_size      n_file_ccs;\r
+    khm_size      nc_file_ccs;\r
+} k5_ccc_data;\r
+\r
+typedef struct tag_k5_ccc_dlg_data {\r
+    khui_config_node node;\r
+    k5_ccc_data save;\r
+    k5_ccc_data work;\r
+} k5_ccc_dlg_data;\r
+\r
+void k5_free_file_ccs(k5_ccc_data * d) {\r
+    if (d->file_ccs)\r
+        PFREE(d->file_ccs);\r
+    d->n_file_ccs = 0;\r
+    d->nc_file_ccs = 0;\r
+}\r
+\r
+void k5_flush_file_ccs(k5_ccc_data * d) {\r
+    d->n_file_ccs = 0;\r
+}\r
+\r
+void k5_del_file_cc(k5_ccc_data * d, khm_size idx) {\r
+    if (idx > d->n_file_ccs)\r
+        return;\r
+\r
+    if (idx < d->n_file_ccs - 1) {\r
+        MoveMemory(&d->file_ccs[idx],\r
+                   &d->file_ccs[idx + 1],\r
+                   sizeof(d->file_ccs[0]) * (d->n_file_ccs - (idx + 1)));\r
+    }\r
+\r
+    d->n_file_ccs--;\r
+}\r
+\r
+void k5_add_file_cc(k5_ccc_data * d, wchar_t * path) {\r
+    khm_size i;\r
+    khm_size cch;\r
+\r
+    if (FAILED(StringCchLength(path, MAX_PATH, &cch)) ||\r
+        cch == 0)\r
+        return;\r
+\r
+    /* see if it's there first */\r
+    for (i=0; i < d->n_file_ccs; i++) {\r
+        if(!wcsicmp(d->file_ccs[i].path, path))\r
+            return;\r
+    }\r
+\r
+    if (d->n_file_ccs == d->nc_file_ccs) {\r
+        k5_file_cc * f;\r
+\r
+        d->nc_file_ccs = UBOUNDSS(d->n_file_ccs + 1,\r
+                                  K5_FCC_ALLOC_INCR,\r
+                                  K5_FCC_ALLOC_INCR);\r
+#ifdef DEBUG\r
+        assert(d->nc_file_ccs > d->n_file_ccs);\r
+#endif\r
+        f = PMALLOC(sizeof(*f) * d->nc_file_ccs);\r
+        ZeroMemory(f, sizeof(*f) * d->nc_file_ccs);\r
+\r
+        if (d->n_file_ccs > 0) {\r
+#ifdef DEBUG\r
+            assert(d->file_ccs != NULL);\r
+#endif\r
+            memcpy(f, d->file_ccs, sizeof(*f) * d->n_file_ccs);\r
+        }\r
+        if (d->file_ccs)\r
+            PFREE(d->file_ccs);\r
+        d->file_ccs = f;\r
+    }\r
+\r
+    StringCbCopy(d->file_ccs[d->n_file_ccs].path,\r
+                 sizeof(d->file_ccs[0].path),\r
+                 path);\r
+    if(PathFileExists(path))\r
+        d->file_ccs[d->n_file_ccs].flags = K5_FCC_FLAG_EXISTS;\r
+    else\r
+        d->file_ccs[d->n_file_ccs].flags = 0;\r
+\r
+    d->n_file_ccs++;\r
+}\r
+\r
+void k5_read_file_cc_data(k5_ccc_data * d) {\r
+    khm_int32 t;\r
+    wchar_t * fclist = NULL;\r
+    wchar_t * fc;\r
+    khm_size cb;\r
+\r
+#ifdef DEBUG\r
+    assert(csp_params);\r
+#endif\r
+\r
+    d->inc_api = TRUE;\r
+    t = TRUE;\r
+    khc_read_int32(csp_params, L"MsLsaList", &t);\r
+    d->inc_mslsa = t;\r
+\r
+    if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+        != KHM_ERROR_TOO_LONG ||\r
+        cb <= sizeof(wchar_t) * 2) {\r
+\r
+        k5_flush_file_ccs(d);\r
+    } else {\r
+        fclist = PMALLOC(cb);\r
+#ifdef DEBUG\r
+        assert(fclist);\r
+#endif\r
+        khc_read_multi_string(csp_params, L"FileCCList", fclist, &cb);\r
+\r
+        for(fc = fclist; fc && *fc; fc = multi_string_next(fc)) {\r
+            k5_add_file_cc(d, fc);\r
+        }\r
+\r
+        PFREE(fclist);\r
+    }\r
+}\r
+\r
+void k5_write_file_cc_data(k5_ccc_data * d) {\r
+    wchar_t * ms;\r
+    khm_size cb;\r
+    khm_size cbt;\r
+    khm_int32 t;\r
+    khm_size i;\r
+\r
+#ifdef DEBUG\r
+    assert(csp_params);\r
+#endif\r
+    if (KHM_FAILED(khc_read_int32(csp_params, L"MsLsaList", &t)) ||\r
+        !!t != !!d->inc_mslsa) {\r
+        khc_write_int32(csp_params, L"MsLsaList", !!d->inc_mslsa);\r
+    }\r
+\r
+    if (d->n_file_ccs > 0) {\r
+        cb = d->n_file_ccs * MAX_PATH * sizeof(wchar_t);\r
+        ms = PMALLOC(cb);\r
+#ifdef DEBUG\r
+        assert(ms);\r
+#endif\r
+        multi_string_init(ms, cb);\r
+\r
+        for(i=0; i<d->n_file_ccs; i++) {\r
+            cbt = cb;\r
+            multi_string_append(ms, &cbt, d->file_ccs[i].path);\r
+        }\r
+\r
+        khc_write_multi_string(csp_params, L"FileCCList", ms);\r
+\r
+        PFREE(ms);\r
+    } else {\r
+        if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+            != KHM_ERROR_TOO_LONG ||\r
+            cb != sizeof(wchar_t) * 2)\r
+\r
+            khc_write_multi_string(csp_params, L"FileCCList", L"\0\0");\r
+    }\r
+}\r
+\r
+void k5_copy_file_cc_data(k5_ccc_data * dest, const k5_ccc_data * src) {\r
+    khm_size i;\r
+\r
+    k5_flush_file_ccs(dest);\r
+    dest->inc_mslsa = src->inc_mslsa;\r
+    dest->inc_api = src->inc_api;\r
+\r
+    for (i=0; i < src->n_file_ccs; i++) {\r
+        k5_add_file_cc(dest, src->file_ccs[i].path);\r
+    }\r
+}\r
+\r
+BOOL k5_ccc_get_mod(k5_ccc_dlg_data * d) {\r
+    khm_size i, j;\r
+\r
+    if (!!d->work.inc_mslsa != !!d->save.inc_mslsa ||\r
+        !!d->work.inc_api != !!d->save.inc_api ||\r
+        d->work.n_file_ccs != d->save.n_file_ccs)\r
+        return TRUE;\r
+\r
+    for (i=0; i < d->work.n_file_ccs; i++) {\r
+        for (j=0; j < d->save.n_file_ccs; j++) {\r
+            if (!wcsicmp(d->work.file_ccs[i].path,\r
+                         d->save.file_ccs[j].path))\r
+                break;\r
+        }\r
+        if (j >= d->save.n_file_ccs)\r
+            return TRUE;\r
+    }\r
+\r
+    return FALSE;\r
+}\r
+\r
+void k5_ccc_update_ui(HWND hwnd, k5_ccc_dlg_data * d) {\r
+    khm_size i;\r
+    HWND lv;\r
+\r
+    if (d->work.inc_api)\r
+        CheckDlgButton(hwnd, IDC_CFG_INCAPI, BST_CHECKED);\r
+    else\r
+        CheckDlgButton(hwnd, IDC_CFG_INCAPI, BST_UNCHECKED);\r
+    if (d->work.inc_mslsa)\r
+        CheckDlgButton(hwnd, IDC_CFG_INCMSLSA, BST_CHECKED);\r
+    else\r
+        CheckDlgButton(hwnd, IDC_CFG_INCMSLSA, BST_UNCHECKED);\r
+\r
+    lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+    assert(lv);\r
+#endif\r
+    ListView_DeleteAllItems(lv);\r
+\r
+    for (i=0; i<d->work.n_file_ccs; i++) {\r
+        LVITEM lvi;\r
+\r
+        ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+        lvi.mask = LVIF_PARAM | LVIF_TEXT;\r
+        lvi.lParam = (LPARAM) i;\r
+        lvi.pszText = d->work.file_ccs[i].path;\r
+\r
+        ListView_InsertItem(lv, &lvi);\r
+    }\r
+\r
+    if (k5_ccc_get_mod(d)) {\r
+        khui_cfg_set_flags(d->node,\r
+                           KHUI_CNFLAG_MODIFIED,\r
+                           KHUI_CNFLAG_MODIFIED);\r
+    } else {\r
+        khui_cfg_set_flags(d->node,\r
+                           0,\r
+                           KHUI_CNFLAG_MODIFIED);\r
+    }\r
+}\r
+\r
+void k5_ccc_update_data(HWND hwnd, k5_ccc_data * d) {\r
+    if (IsDlgButtonChecked(hwnd, IDC_CFG_INCAPI) == BST_CHECKED)\r
+        d->inc_api = TRUE;\r
+    else\r
+        d->inc_api = FALSE;\r
+\r
+    if (IsDlgButtonChecked(hwnd, IDC_CFG_INCMSLSA) == BST_CHECKED)\r
+        d->inc_mslsa = TRUE;\r
+    else\r
+        d->inc_mslsa = FALSE;\r
+    /* everything else is controlled by buttons */\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_ccconfig_dlgproc(HWND hwnd,\r
+                    UINT uMsg,\r
+                    WPARAM wParam,\r
+                    LPARAM lParam) {\r
+\r
+    k5_ccc_dlg_data * d;\r
+\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+        assert(d);\r
+#endif\r
+        ZeroMemory(d, sizeof(*d));\r
+        k5_read_file_cc_data(&d->save);\r
+        k5_copy_file_cc_data(&d->work, &d->save);\r
+\r
+        d->node = (khui_config_node) lParam;\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+        {\r
+            LVCOLUMN lvc;\r
+            HWND lv;\r
+            wchar_t buf[256];\r
+            RECT r;\r
+\r
+            lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+            assert(lv);\r
+#endif\r
+            ZeroMemory(&lvc, sizeof(lvc));\r
+            lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+\r
+            LoadString(hResModule, IDS_CFG_FCTITLE,\r
+                       buf, ARRAYLENGTH(buf));\r
+\r
+            GetWindowRect(lv, &r);\r
+\r
+            lvc.pszText = buf;\r
+            lvc.cx = (r.right - r.left) * 9 / 10;\r
+\r
+            ListView_InsertColumn(lv, 0, &lvc);\r
+        }\r
+\r
+        SendDlgItemMessage(hwnd, IDC_CFG_FCNAME, EM_SETLIMITTEXT, \r
+                           MAX_PATH - 1, 0);\r
+\r
+        k5_ccc_update_ui(hwnd, d);\r
+        break;\r
+\r
+    case WM_COMMAND:\r
+        d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+        switch(wParam) {\r
+        case MAKEWPARAM(IDC_CFG_ADD, BN_CLICKED):\r
+            {\r
+                wchar_t path[MAX_PATH];\r
+                wchar_t cpath[MAX_PATH];\r
+                khm_size i;\r
+\r
+                GetDlgItemText(hwnd, IDC_CFG_FCNAME, \r
+                               cpath, ARRAYLENGTH(cpath));\r
+\r
+                PathCanonicalize(path, cpath);\r
+\r
+                if (!*path)\r
+                    return TRUE; /* nothing to add */\r
+\r
+                for (i=0; i < d->work.n_file_ccs; i++) {\r
+                    if (!wcsicmp(path, d->work.file_ccs[i].path)) {\r
+\r
+                        /* allow the user to correct case, as appropriate */\r
+                        StringCbCopy(d->work.file_ccs[i].path,\r
+                                     sizeof(d->work.file_ccs[i].path),\r
+                                     path);\r
+                        k5_ccc_update_ui(hwnd, d);\r
+                        return TRUE;\r
+                    }\r
+                }\r
+\r
+                /* not there.  we need to add.  but check a few things\r
+                   first */\r
+                if (!PathFileExists(path)) {\r
+                    EDITBALLOONTIP bt;\r
+                    wchar_t title[64];\r
+                    wchar_t text[128];\r
+\r
+                    bt.cbStruct = sizeof(bt);\r
+                    bt.pszTitle = title;\r
+                    LoadString(hResModule, IDS_CFG_FCN_WARNING,\r
+                               title, ARRAYLENGTH(title));\r
+                    bt.pszText = text;\r
+                    LoadString(hResModule, IDS_CFG_FCN_W_NOTFOUND,\r
+                               text, ARRAYLENGTH(text));\r
+                    bt.ttiIcon = TTI_WARNING;\r
+\r
+                    SendDlgItemMessage(hwnd, IDC_CFG_FCNAME,\r
+                                       EM_SHOWBALLOONTIP,\r
+                                       0,\r
+                                       (LPARAM) &bt);\r
+\r
+                } else if (PathIsRelative(path)) {\r
+                    EDITBALLOONTIP bt;\r
+                    wchar_t title[64];\r
+                    wchar_t text[128];\r
+\r
+                    bt.cbStruct = sizeof(bt);\r
+                    bt.pszTitle = title;\r
+                    LoadString(hResModule, IDS_CFG_FCN_WARNING,\r
+                               title, ARRAYLENGTH(title));\r
+                    bt.pszText = text;\r
+                    LoadString(hResModule, IDS_CFG_FCN_W_RELATIVE,\r
+                               text, ARRAYLENGTH(text));\r
+                    bt.ttiIcon = TTI_WARNING;\r
+\r
+                    SendDlgItemMessage(hwnd, IDC_CFG_FCNAME,\r
+                                       EM_SHOWBALLOONTIP,\r
+                                       0,\r
+                                       (LPARAM) &bt);\r
+                }\r
+\r
+                k5_add_file_cc(&d->work, path);\r
+\r
+                k5_ccc_update_ui(hwnd, d);\r
+            }\r
+            return TRUE;\r
+\r
+        case MAKEWPARAM(IDC_CFG_BROWSE, BN_CLICKED):\r
+            {\r
+                OPENFILENAME ofn;\r
+                wchar_t path[MAX_PATH * 8];\r
+                wchar_t title[128];\r
+\r
+                ZeroMemory(&ofn, sizeof(ofn));\r
+                ZeroMemory(path, sizeof(path));\r
+\r
+                GetDlgItemText(hwnd, IDC_CFG_FCNAME,\r
+                               path, ARRAYLENGTH(path));\r
+\r
+                /* don't pass in invalid paths */\r
+                if (!PathFileExists(path))\r
+                    *path = 0;\r
+\r
+                ofn.lStructSize = sizeof(ofn);\r
+                ofn.hwndOwner = hwnd;\r
+                ofn.lpstrFilter = L"All files\0*.*\0\0";\r
+                ofn.nFilterIndex = 1;\r
+                ofn.lpstrFile = path;\r
+                ofn.nMaxFile = ARRAYLENGTH(path);\r
+                ofn.lpstrTitle = title;\r
+\r
+                LoadString(hResModule, IDS_CFG_FCOPENTITLE,\r
+                           title, ARRAYLENGTH(title));\r
+\r
+                ofn.Flags = OFN_ALLOWMULTISELECT |\r
+                    OFN_DONTADDTORECENT |\r
+                    OFN_FORCESHOWHIDDEN |\r
+                    OFN_EXPLORER;\r
+\r
+                if (GetOpenFileName(&ofn)) {\r
+                    wchar_t * p;\r
+                    wchar_t spath[MAX_PATH];\r
+\r
+                    p = multi_string_next(path);\r
+                    if (p) {\r
+                        /* multi select */\r
+                        for(;p && *p; p = multi_string_next(p)) {\r
+                            StringCbCopy(spath, sizeof(spath), path);\r
+                            PathAppend(spath, p);\r
+\r
+                            k5_add_file_cc(&d->work, spath);\r
+                        }\r
+                    } else {\r
+                        /* single select */\r
+                        k5_add_file_cc(&d->work, path);\r
+                    }\r
+                    k5_ccc_update_ui(hwnd, d);\r
+                }\r
+            }\r
+            return TRUE;\r
+\r
+        case MAKEWPARAM(IDC_CFG_REMOVE, BN_CLICKED):\r
+            {\r
+                khm_size i;\r
+                int lv_idx;\r
+                HWND lv;\r
+                wchar_t buf[MAX_PATH];\r
+\r
+                lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+                assert(lv);\r
+#endif\r
+\r
+                lv_idx = -1;\r
+                while((lv_idx = ListView_GetNextItem(lv, lv_idx, \r
+                                                     LVNI_SELECTED)) != -1) {\r
+                    ListView_GetItemText(lv, lv_idx, 0, buf, ARRAYLENGTH(buf));\r
+                    for (i=0; i < d->work.n_file_ccs; i++) {\r
+                        if (!wcsicmp(buf, d->work.file_ccs[i].path)) {\r
+                            k5_del_file_cc(&d->work, i);\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
+\r
+                k5_ccc_update_ui(hwnd, d);\r
+            }\r
+            return TRUE;\r
+\r
+        case MAKEWPARAM(IDC_CFG_INCAPI, BN_CLICKED):\r
+        case MAKEWPARAM(IDC_CFG_INCMSLSA, BN_CLICKED):\r
+            k5_ccc_update_data(hwnd, &d->work);\r
+            k5_ccc_update_ui(hwnd, d);\r
+            return TRUE;\r
+        }\r
+        break;\r
+\r
+    case WM_DESTROY:\r
+        d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        k5_free_file_ccs(&d->work);\r
+        k5_free_file_ccs(&d->save);\r
+        PFREE(d);\r
+        return TRUE;\r
+\r
+    case KHUI_WM_CFG_NOTIFY:\r
+        d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        switch(HIWORD(wParam)) {\r
+        case WMCFG_APPLY:\r
+            if (k5_ccc_get_mod(d)) {\r
+                k5_write_file_cc_data(&d->work);\r
+                k5_copy_file_cc_data(&d->save, &d->work);\r
+                khui_cfg_set_flags(d->node,\r
+                                   KHUI_CNFLAG_APPLIED,\r
+                                   KHUI_CNFLAG_APPLIED);\r
+                k5_ccc_update_ui(hwnd, d);\r
+\r
+                kmq_post_sub_msg(k5_sub, KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);\r
+            }\r
+            break;\r
+        }\r
+    }\r
+    return FALSE;\r
+}\r
index c3b00e16123eef54c278a51b75121052055301f7..63fdc32b633393fb142e8983d975156c51342115 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 #include<krb5.h>\r
 #include<assert.h>\r
 #include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+\r
+typedef struct tag_k5_realm_kdc {\r
+    wchar_t       name[K5_MAXCCH_HOST];\r
+    khm_boolean   admin;        /* admin server? */\r
+    khm_boolean   master;       /* master kdc? */\r
+    khm_int32     flags;\r
+} k5_realm_kdc;\r
+\r
+#define K5_RKFLAG_DELETED    1\r
+#define K5_RKFLAG_NEW        2\r
+#define K5_RKFLAG_MOD_ADMIN  4\r
+#define K5_RKFLAG_MOD_MASTER 8\r
+\r
+typedef struct tag_k5_domain_map {\r
+    wchar_t       name[K5_MAXCCH_HOST]; /* name of host that maps to a\r
+                                           realm */\r
+    khm_int32     flags;\r
+} k5_domain_map;\r
+\r
+#define K5_DMFLAG_DELETED 1\r
+#define K5_DMFLAG_NEW     2\r
+\r
+typedef struct tag_k5_realm_data {\r
+    wchar_t       realm[K5_MAXCCH_REALM];\r
+    k5_realm_kdc  kdcs[K5_MAX_KDC];\r
+    khm_size      n_kdcs;\r
+    k5_domain_map domain_maps[K5_MAX_DOMAIN_MAPPINGS];\r
+    khm_size      n_domain_maps;\r
+\r
+    khm_int32     flags;\r
+} k5_realm_data;\r
+\r
+#define K5_RDFLAG_DELETED 1\r
+#define K5_RDFLAG_NEW     2\r
+#define K5_RDFLAG_MODIFED 4\r
+\r
+#define K5_REALMS_ALLOC_INCR 8\r
+\r
+typedef struct tag_k5_config_data {\r
+    wchar_t       def_realm[K5_MAXCCH_REALM];    /* default realm */\r
+\r
+    wchar_t       config_file[MAX_PATH]; /* path to configuration file */\r
+    khm_boolean   create_config_file; /* create config_file if missing? */\r
+\r
+    /* [libdefaults] */\r
+    khm_boolean   dns_lookup_kdc;\r
+    khm_boolean   dns_lookup_realm;\r
+    khm_boolean   dns_fallback;\r
+\r
+    khm_boolean   noaddresses;\r
+\r
+    k5_lsa_import lsa_import;   /* import mslsa creds? */\r
+\r
+    /* [realms] */\r
+    k5_realm_data *realms;\r
+    khm_size      n_realms;\r
+    khm_size      nc_realms;\r
+    khm_size      c_realm;\r
+\r
+    khui_config_node node_main;\r
+    khui_config_node node_realm;\r
+\r
+    khm_int32     flags;\r
+} k5_config_data;\r
+\r
+#define K5_CDFLAG_MOD_DEF_REALM      1\r
+#define K5_CDFLAG_MOD_CONF_FILE      2\r
+#define K5_CDFLAG_MOD_DNS_LOOKUP_KDC 4\r
+#define K5_CDFLAG_MOD_DNS_LOOKUP_RLM 8\r
+#define K5_CDFLAG_MOD_DNS_FALLBACK   0x10\r
+#define K5_CDFLAG_MOD_NOADDRESSES    0x20\r
+#define K5_CDFLAG_MOD_LSA_IMPORT     0x40\r
+#define K5_CDFLAG_MOD_CREATE_CONF    0x80\r
+#define K5_CDFLAG_MOD_REALMS         0x1000\r
+\r
+static const char *const conf_yes[] = {\r
+    "y", "yes", "true", "t", "1", "on",\r
+    0,\r
+};\r
+\r
+static const char *const conf_no[] = {\r
+    "n", "no", "false", "nil", "0", "off",\r
+    0,\r
+};\r
+\r
+int\r
+k5_parse_boolean(const char *s)\r
+{\r
+    const char *const *p;\r
+\r
+    for(p=conf_yes; *p; p++) {\r
+        if (!stricmp(*p,s))\r
+            return 1;\r
+    }\r
+\r
+    for(p=conf_no; *p; p++) {\r
+        if (!stricmp(*p,s))\r
+            return 0;\r
+    }\r
+\r
+    /* Default to "no" */\r
+    return 0;\r
+}\r
+\r
+void\r
+k5_init_config_data(k5_config_data * d) {\r
+    ZeroMemory(d, sizeof(*d));\r
+}\r
+\r
+void\r
+k5_free_config_data(k5_config_data * d) {\r
+    if (d->realms)\r
+        PFREE(d->realms);\r
+\r
+    k5_init_config_data(d);\r
+}\r
+\r
+static void\r
+k5_assert_n_realms(k5_config_data * d, khm_size n) {\r
+    khm_size nc_realms;\r
+\r
+    if (n <= d->nc_realms)\r
+        return;\r
+\r
+    nc_realms = UBOUNDSS(n, K5_REALMS_ALLOC_INCR, K5_REALMS_ALLOC_INCR);\r
+    assert(nc_realms > d->nc_realms);\r
+\r
+    d->realms = PREALLOC(d->realms, nc_realms * sizeof(*(d->realms)));\r
+    d->nc_realms = nc_realms;\r
+\r
+    ZeroMemory(&d->realms[d->n_realms],\r
+               (d->nc_realms - d->n_realms) * sizeof(*(d->realms)));\r
+}\r
+\r
+void\r
+k5_purge_config_data(k5_config_data * d,\r
+                     khm_boolean purge_realms,\r
+                     khm_boolean purge_kdcs,\r
+                     khm_boolean purge_dmap) {\r
+    khm_size r;\r
+    khm_size k;\r
+    khm_size m;\r
+\r
+    for (r=0; r < d->n_realms; r++) {\r
+        if (purge_realms &&\r
+            (d->realms[r].flags & K5_RDFLAG_NEW) &&\r
+            (d->realms[r].flags & K5_RDFLAG_DELETED)) {\r
+\r
+            if (d->n_realms > r+1)\r
+                MoveMemory(&d->realms[r], &d->realms[r+1],\r
+                           sizeof(d->realms[0]) * (d->n_realms - (r+1)));\r
+            r--;\r
+            d->n_realms--;\r
+            continue;\r
+        }\r
+\r
+        for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+            if (purge_kdcs &&\r
+                (d->realms[r].kdcs[k].flags & K5_RKFLAG_NEW) &&\r
+                (d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED)) {\r
+                if (d->realms[r].n_kdcs > k + 1)\r
+                    MoveMemory(&d->realms[r].kdcs[k],\r
+                               &d->realms[r].kdcs[k+1],\r
+                               sizeof(d->realms[0].kdcs[0]) *\r
+                               (d->realms[r].n_kdcs - (k+1)));\r
+                k--;\r
+                d->realms[r].n_kdcs--;\r
+                continue;\r
+            }\r
+        }\r
+\r
+        if (K5_MAX_KDC > k+1)\r
+            ZeroMemory(&d->realms[r].kdcs[k],\r
+                       sizeof(d->realms[0].kdcs[0]) *\r
+                       (K5_MAX_KDC - (k + 1)));\r
+\r
+        for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+            if (purge_dmap &&\r
+                (d->realms[r].domain_maps[m].flags & K5_DMFLAG_NEW) &&\r
+                (d->realms[r].domain_maps[m].flags & K5_DMFLAG_DELETED)) {\r
+                if (d->realms[r].n_domain_maps > m + 1)\r
+                    MoveMemory(&d->realms[r].domain_maps[m],\r
+                               &d->realms[r].domain_maps[m+1],\r
+                               sizeof(d->realms[0].domain_maps[0]) *\r
+                               (d->realms[r].n_domain_maps - (m+1)));\r
+                m--;\r
+                d->realms[r].n_domain_maps--;\r
+                continue;\r
+            }\r
+        }\r
+\r
+        if (K5_MAX_DOMAIN_MAPPINGS > m+1)\r
+            ZeroMemory(&d->realms[r].domain_maps[m],\r
+                       sizeof(d->realms[0].domain_maps[0]) *\r
+                       (K5_MAX_DOMAIN_MAPPINGS - (m+1)));\r
+    }\r
+\r
+    if (d->nc_realms > r + 1)\r
+        ZeroMemory(&d->realms[r],\r
+                   sizeof(d->realms[0]) *\r
+                   (d->nc_realms - (r + 1)));\r
+}\r
+\r
+static khm_boolean\r
+k5_is_profile_loaded(void) {\r
+#ifdef DEBUG\r
+    assert(pprofile_init);\r
+    assert(pprofile_get_subsection_names);\r
+    assert(pprofile_get_values);\r
+    assert(pprofile_get_string);\r
+    assert(pprofile_get_relation_names);\r
+    assert(pprofile_free_list);\r
+    assert(pprofile_release_string);\r
+    assert(pprofile_release);\r
+    assert(pprofile_clear_relation);\r
+    assert(pprofile_add_relation);\r
+    assert(pprofile_update_relation);\r
+    assert(pprofile_flush);\r
+#endif\r
+\r
+    if (!pprofile_init ||\r
+        !pprofile_get_subsection_names ||\r
+        !pprofile_get_values ||\r
+        !pprofile_get_string ||\r
+        !pprofile_get_relation_names ||\r
+        !pprofile_free_list ||\r
+        !pprofile_release_string ||\r
+        !pprofile_release ||\r
+        !pprofile_clear_relation ||\r
+        !pprofile_add_relation ||\r
+        !pprofile_update_relation ||\r
+        !pprofile_flush)\r
+\r
+        return FALSE;\r
+\r
+    return TRUE;\r
+}\r
+\r
+void\r
+k5_read_config_data(k5_config_data * d) {\r
+    wchar_t * defrealm;\r
+    char config_file[MAX_PATH];\r
+    profile_t profile = NULL;\r
+    const char *filenames[2];\r
+    long rv;\r
+    khm_size s;\r
+\r
+    if (!k5_is_profile_loaded())\r
+        return;\r
+\r
+    defrealm = khm_krb5_get_default_realm();\r
+\r
+    if (defrealm) {\r
+        StringCbCopy(d->def_realm, sizeof(d->def_realm), defrealm);\r
+        PFREE(defrealm);\r
+    } else {\r
+        StringCbCopy(d->def_realm, sizeof(d->def_realm), L"");\r
+    }\r
+\r
+    khm_krb5_get_profile_file(config_file, ARRAYLENGTH(config_file));\r
+\r
+    AnsiStrToUnicode(d->config_file, sizeof(d->config_file), config_file);\r
+\r
+    filenames[0] = config_file;\r
+    filenames[1] = NULL;\r
+\r
+    rv = pprofile_init(filenames, &profile);\r
+\r
+    if (!rv) {\r
+        const char * sec_realms[] = { "realms", NULL };\r
+        const char * sec_domain_realm[] = { "domain_realm", NULL };\r
+        char ** sections;\r
+        char ** dr_from;\r
+        char * boolv;\r
+\r
+        /* first fish out a few values from [libdefaults] */\r
+\r
+        rv = pprofile_get_string(profile, "libdefaults", "dns_lookup_kdc",\r
+                                 NULL, NULL, &boolv);\r
+        if (!rv && boolv) {\r
+            d->dns_lookup_kdc = k5_parse_boolean(boolv);\r
+            pprofile_release_string(boolv);\r
+        } else\r
+            d->dns_lookup_kdc = FALSE;\r
+\r
+        rv = pprofile_get_string(profile, "libdefaults", "dns_lookup_realm",\r
+                                 NULL, NULL, &boolv);\r
+        if (!rv && boolv) {\r
+            d->dns_lookup_realm = k5_parse_boolean(boolv);\r
+            pprofile_release_string(boolv);\r
+        } else\r
+            d->dns_lookup_realm = FALSE;\r
+\r
+        rv = pprofile_get_string(profile, "libdefaults", "dns_fallback",\r
+                                 NULL, NULL, &boolv);\r
+        if (!rv && boolv) {\r
+            d->dns_fallback = k5_parse_boolean(boolv);\r
+            pprofile_release_string(boolv);\r
+        } else\r
+            d->dns_fallback = FALSE;\r
+\r
+        rv = pprofile_get_string(profile, "libdefaults", "noaddresses",\r
+                                 NULL, NULL, &boolv);\r
+        if (!rv && boolv) {\r
+            d->noaddresses = k5_parse_boolean(boolv);\r
+            pprofile_release_string(boolv);\r
+        } else\r
+            d->noaddresses = TRUE;\r
+\r
+        /* now we look at the [realms] section */\r
+        rv = pprofile_get_subsection_names(profile, sec_realms, &sections);\r
+\r
+        /* what? no realms? whatever */\r
+        if (rv) goto _skip_realms;\r
+\r
+        /* get a count first */\r
+        for (s=0; sections[s] && sections[s][0]; s++);\r
+\r
+        k5_assert_n_realms(d, s);\r
+        d->n_realms = s;\r
+\r
+        /* now go through each and fish out the kdcs, admin_server\r
+           and master_kdc. */\r
+        for (s=0; sections[s] && sections[s][0]; s++) {\r
+            const char * sec_kdcs[] = \r
+                { "realms", sections[s], "kdc", NULL };\r
+\r
+            const char * sec_admin[] =\r
+                { "realms", sections[s], "admin_server", NULL };\r
+\r
+            const char * sec_master[] =\r
+                { "realms", sections[s], "master_kdc", NULL };\r
+\r
+            char ** values;\r
+\r
+            AnsiStrToUnicode(d->realms[s].realm, sizeof(d->realms[s].realm),\r
+                             sections[s]);\r
+            d->realms[s].n_kdcs = 0;\r
+            d->realms[s].n_domain_maps = 0;\r
+\r
+            rv = pprofile_get_values(profile, sec_kdcs, &values);\r
+            if (!rv) {\r
+                khm_size i;\r
+\r
+                for (i=0 ; values[i] && values[i][0] && i < K5_MAX_KDC; i++) {\r
+                    AnsiStrToUnicode(d->realms[s].kdcs[i].name,\r
+                                     sizeof(d->realms[s].kdcs[i].name),\r
+                                     values[i]);\r
+\r
+                }\r
+                d->realms[s].n_kdcs = i;\r
+\r
+                pprofile_free_list(values);\r
+            }\r
+\r
+            rv = pprofile_get_values(profile, sec_admin, &values);\r
+            if (!rv) {\r
+                khm_size i;\r
+                khm_size j;\r
+                wchar_t kdc_name[K5_MAXCCH_HOST];\r
+\r
+                for (i=0; values[i] && values[i][0]; i++) {\r
+                    AnsiStrToUnicode(kdc_name,\r
+                                     sizeof(kdc_name), values[i]);\r
+\r
+                    for (j=0; j < d->realms[s].n_kdcs; j++)\r
+                        if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))\r
+                            break;\r
+\r
+                    if (j < d->realms[s].n_kdcs) {\r
+                        d->realms[s].kdcs[j].admin = TRUE;\r
+                    } else if (d->realms[s].n_kdcs < K5_MAX_KDC) {\r
+                        j = d->realms[s].n_kdcs;\r
+                        StringCbCopy(d->realms[s].kdcs[j].name,\r
+                                     sizeof(d->realms[s].kdcs[j].name),\r
+                                     kdc_name);\r
+                        d->realms[s].kdcs[j].admin = TRUE;\r
+                        d->realms[s].n_kdcs ++;\r
+                    }\r
+                }\r
+                pprofile_free_list(values);\r
+            }\r
+\r
+            rv = pprofile_get_values(profile, sec_master, &values);\r
+            if (!rv) {\r
+                khm_size i;\r
+                khm_size j;\r
+                wchar_t kdc_name[K5_MAXCCH_HOST];\r
+\r
+                for (i=0; values[i] && values[i][0]; i++) {\r
+                    AnsiStrToUnicode(kdc_name, sizeof(kdc_name), values[i]);\r
+\r
+                    for (j=0; j < d->realms[s].n_kdcs; j++)\r
+                        if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))\r
+                            break;\r
+\r
+                    if (j < d->realms[s].n_kdcs) {\r
+                        d->realms[s].kdcs[j].master = TRUE;\r
+                    } else if (d->realms[s].n_kdcs < K5_MAX_KDC) {\r
+                        j = d->realms[s].n_kdcs;\r
+                        StringCbCopy(d->realms[s].kdcs[j].name,\r
+                                     sizeof(d->realms[s].kdcs[j].name),\r
+                                     kdc_name);\r
+                        d->realms[s].kdcs[j].master = TRUE;\r
+                        d->realms[s].n_kdcs ++;\r
+                    }\r
+                }\r
+\r
+                pprofile_free_list(values);\r
+            }\r
+        }\r
+        pprofile_free_list(sections);\r
+\r
+    _skip_realms:\r
+\r
+        rv = pprofile_get_relation_names(profile, sec_domain_realm, &dr_from);\r
+        if (!rv) {\r
+            khm_size i;\r
+            khm_size j;\r
+            char * dr_to;\r
+            wchar_t wdr_from[K5_MAXCCH_HOST];\r
+            wchar_t wdr_to[K5_MAXCCH_HOST];\r
+\r
+            for (i=0; dr_from[i] && dr_from[i][0]; i++) {\r
+                AnsiStrToUnicode(wdr_from, sizeof(wdr_from), dr_from[i]);\r
+\r
+                rv = pprofile_get_string(profile, "domain_realm", dr_from[i],\r
+                                         NULL, NULL, &dr_to);\r
+\r
+                if (rv || !dr_to)\r
+                    continue;\r
+\r
+                AnsiStrToUnicode(wdr_to, sizeof(wdr_to), dr_to);\r
+\r
+                for (j=0; j < d->n_realms; j++) {\r
+                    if (!wcsicmp(wdr_to, d->realms[j].realm))\r
+                        break;\r
+                }\r
+\r
+                if (j >= d->n_realms) {\r
+                    j = d->n_realms;\r
+                    k5_assert_n_realms(d, j + 1);\r
+\r
+                    StringCbCopy(d->realms[j].realm,\r
+                                 sizeof(d->realms[j].realm),\r
+                                 wdr_to);\r
+                    d->realms[j].n_kdcs = 0;\r
+                    d->realms[j].n_domain_maps = 0;\r
+\r
+                    d->n_realms++;\r
+                }\r
+\r
+                if (d->realms[j].n_domain_maps < K5_MAX_DOMAIN_MAPPINGS) {\r
+                    khm_size k;\r
+\r
+                    k = d->realms[j].n_domain_maps;\r
+\r
+                    StringCbCopy(d->realms[j].domain_maps[k].name,\r
+                                 sizeof(d->realms[j].domain_maps[k].name),\r
+                                 wdr_from);\r
+\r
+                    d->realms[j].n_domain_maps++;\r
+                }\r
+\r
+                pprofile_release_string(dr_to);\r
+            }\r
+            pprofile_free_list(dr_from);\r
+        }\r
+        pprofile_release(profile);\r
+    }\r
+\r
+    /* last, read the MSLSA import setting */\r
+    {\r
+        khm_int32 t;\r
+\r
+        if (KHM_SUCCEEDED(khc_read_int32(csp_params,\r
+                                         L"MsLsaImport", &t))) {\r
+            d->lsa_import = t;\r
+        } else {\r
+            d->lsa_import = K5_LSAIMPORT_ALWAYS;\r
+        }\r
+    }\r
+\r
+    d->flags = 0;\r
+}\r
+\r
+void\r
+k5_write_config_data(k5_config_data * d) {\r
+    char astr[MAX_PATH * 2];\r
+    char config_file[MAX_PATH];\r
+    profile_t profile = NULL;\r
+    const char *filenames[2];\r
+    long rv;\r
+    khm_size s;\r
+\r
+    if (d->flags == 0)\r
+        return;\r
+\r
+    if (!k5_is_profile_loaded())\r
+        return;\r
+\r
+    if (d->flags & K5_CDFLAG_MOD_DEF_REALM) {\r
+        if (SUCCEEDED(StringCbLength(d->def_realm,\r
+                                     sizeof(d->def_realm), &s)) &&\r
+            s > 0) {\r
+            khm_krb5_set_default_realm(d->def_realm);\r
+        }\r
+    }\r
+\r
+    /* write the MSLSA import setting */\r
+    if (d->flags & K5_CDFLAG_MOD_LSA_IMPORT) {\r
+\r
+        khc_write_int32(csp_params, L"MsLsaImport", d->lsa_import);\r
+\r
+    }\r
+\r
+    if (!(d->flags & \r
+          (K5_CDFLAG_MOD_CONF_FILE |\r
+           K5_CDFLAG_MOD_DNS_FALLBACK |\r
+           K5_CDFLAG_MOD_DNS_LOOKUP_RLM |\r
+           K5_CDFLAG_MOD_DNS_LOOKUP_KDC |\r
+           K5_CDFLAG_MOD_NOADDRESSES |\r
+           K5_CDFLAG_MOD_CREATE_CONF |\r
+           K5_CDFLAG_MOD_REALMS))) {\r
+\r
+        d->flags = 0;\r
+        return;\r
+\r
+    }\r
+\r
+    khm_krb5_get_profile_file(config_file, ARRAYLENGTH(config_file));\r
+\r
+    UnicodeStrToAnsi(astr, sizeof(astr), d->config_file);\r
+\r
+    if (stricmp(config_file, astr)) {\r
+        assert(FALSE);\r
+    }\r
+\r
+    filenames[0] = config_file;\r
+    filenames[1] = NULL;\r
+\r
+    rv = pprofile_init(filenames, &profile);\r
+\r
+#if FAILOVER_TO_TEMPORARY_FILE\r
+    if (rv) {\r
+        char temp_file[MAX_PATH];\r
+\r
+        khm_krb5_get_temp_profile_file(temp_file,\r
+                                       ARRAYLENGTH(temp_file));\r
+\r
+        filenames[0] = temp_file;\r
+\r
+        rv = pprofile_init(filenames, &profile);\r
+\r
+            ?? TODO: Also warn if we are doing this\r
+    }\r
+#endif\r
+\r
+\r
+    if (!rv) {\r
+        const char * sec_realms[] = { "realms", NULL };\r
+        const char * sec_domain_realm[] = { "domain_realm", NULL };\r
+        const char * sec_libdefaults[] = { "libdefaults", NULL, NULL };\r
+        khm_size r;\r
+\r
+        if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_KDC) {\r
+\r
+            sec_libdefaults[1] = "dns_lookup_kdc";\r
+\r
+            pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+            rv = pprofile_add_relation(profile, sec_libdefaults,\r
+                                       (d->dns_lookup_kdc)?\r
+                                       conf_yes[0]:\r
+                                       conf_no[0]);\r
+        }\r
+\r
+\r
+        if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_RLM) {\r
+\r
+            sec_libdefaults[1] = "dns_lookup_realm";\r
+\r
+            pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+            rv = pprofile_add_relation(profile, sec_libdefaults,\r
+                                       (d->dns_lookup_realm)?\r
+                                       conf_yes[0]:\r
+                                       conf_no[0]);\r
+\r
+        }\r
+\r
+        if (d->flags & K5_CDFLAG_MOD_DNS_FALLBACK) {\r
+\r
+            sec_libdefaults[1] = "dns_fallback";\r
+\r
+            pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+            rv = pprofile_add_relation(profile, sec_libdefaults,\r
+                                       (d->dns_fallback)?\r
+                                       conf_yes[0]:\r
+                                       conf_no[0]);\r
+        }\r
+\r
+        if (d->flags & K5_CDFLAG_MOD_NOADDRESSES) {\r
+\r
+            sec_libdefaults[1] = "noaddresses";\r
+\r
+            pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+            rv = pprofile_add_relation(profile, sec_libdefaults,\r
+                                       (d->noaddresses)?\r
+                                       conf_yes[0]:\r
+                                       conf_no[0]);\r
+        }\r
+\r
+        /* now we look at the [realms] section */\r
+\r
+        for (r=0; r < d->n_realms; r++) {\r
+            char realm[K5_MAXCCH_REALM];\r
+            char host[K5_MAXCCH_HOST];\r
+\r
+            const char * sec_kdcs[] = \r
+                { "realms", realm, "kdc", NULL };\r
+\r
+            const char * sec_admin[] =\r
+                { "realms", realm, "admin_server", NULL };\r
+\r
+            const char * sec_master[] =\r
+                { "realms", realm, "master_kdc", NULL };\r
+\r
+            const char * sec_domain_map[] =\r
+                { "domain_realm", host, NULL };\r
+\r
+            char ** values;\r
+\r
+            UnicodeStrToAnsi(realm, sizeof(realm),\r
+                             d->realms[r].realm);\r
+\r
+            if (!(d->realms[r].flags & K5_RDFLAG_DELETED) &&\r
+                (d->realms[r].flags & K5_RDFLAG_NEW)) {\r
+\r
+                khm_size k;\r
+                khm_size m;\r
+\r
+                /* this is a new realm */\r
+\r
+                for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+                    if (!(d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED)) {\r
+                        UnicodeStrToAnsi(host, sizeof(host),\r
+                                         d->realms[r].kdcs[k].name);\r
+\r
+                        if (d->realms[r].kdcs[k].master)\r
+                            pprofile_add_relation(profile, sec_master,\r
+                                                  host);\r
+                        else\r
+                            pprofile_add_relation(profile, sec_kdcs,\r
+                                                  host);\r
+\r
+                        if (d->realms[r].kdcs[k].admin)\r
+                            pprofile_add_relation(profile, sec_admin,\r
+                                                  host);\r
+                    }\r
+                }\r
+\r
+                for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+\r
+                    UnicodeStrToAnsi(host, sizeof(host),\r
+                                     d->realms[r].domain_maps[m].name);\r
+\r
+                    if ((d->realms[r].domain_maps[m].flags &\r
+                         K5_DMFLAG_DELETED) &&\r
+                        !(d->realms[r].domain_maps[m].flags &\r
+                          K5_DMFLAG_NEW))\r
+                        pprofile_clear_relation(profile, sec_domain_map);\r
+                    else if (!(d->realms[r].domain_maps[m].flags &\r
+                               K5_DMFLAG_DELETED) &&\r
+                             (d->realms[r].domain_maps[m].flags &\r
+                              K5_DMFLAG_NEW))\r
+                        pprofile_add_relation(profile, sec_domain_map,\r
+                                              realm);\r
+                }\r
+            } else if ((d->realms[r].flags & K5_RDFLAG_DELETED) &&\r
+                       !(d->realms[r].flags & K5_RDFLAG_NEW)) {\r
+\r
+                const char * sec_all[] =\r
+                    { "realms", realm, NULL, NULL };\r
+                khm_size v;\r
+\r
+                /* this realm should be deleted */\r
+\r
+                rv = pprofile_get_relation_names(profile, sec_all,\r
+                                                 &values);\r
+                if (!rv) {\r
+                    for (v=0; values[v] && values[v][0]; v++) {\r
+                        sec_all[2] = values[v];\r
+                        pprofile_clear_relation(profile, sec_all);\r
+                    }\r
+                    pprofile_free_list(values);\r
+                }\r
+\r
+                rv = pprofile_get_relation_names(profile, sec_domain_realm,\r
+                                                 &values);\r
+                if (!rv) {\r
+                    char * maprealm;\r
+\r
+                    for (v=0; values[v] && values[v][0]; v++) {\r
+\r
+                        rv = pprofile_get_string(profile, "domain_realm",\r
+                                                 values[v], NULL, NULL,\r
+                                                 &maprealm);\r
+\r
+                        if (!rv) {\r
+                            if (!strcmp(maprealm, realm)) {\r
+                                StringCbCopyA(host, sizeof(host), \r
+                                              values[v]);\r
+                                pprofile_clear_relation(profile, \r
+                                                        sec_domain_map);\r
+                            }\r
+                            pprofile_release_string(maprealm);\r
+                        }\r
+                    }\r
+\r
+                    pprofile_free_list(values);\r
+                }\r
+            } else if (!(d->realms[r].flags & K5_RDFLAG_DELETED)) {\r
+                khm_size k;\r
+                khm_size m;\r
+\r
+                /* same as before.  check if we have to update the kdc\r
+                   list or the domain_realm mappings */\r
+\r
+                for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+                    UnicodeStrToAnsi(host, sizeof(host),\r
+                                     d->realms[r].kdcs[k].name);\r
+                    if (d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED) {\r
+                        pprofile_update_relation(profile, sec_kdcs,\r
+                                                 host, NULL);\r
+                        pprofile_update_relation(profile, sec_admin,\r
+                                                 host, NULL);\r
+                        pprofile_update_relation(profile, sec_master,\r
+                                                 host, NULL);\r
+\r
+                        continue;\r
+                    }\r
+\r
+                    if (d->realms[r].kdcs[k].flags & K5_RKFLAG_NEW) {\r
+                        if (d->realms[r].kdcs[k].master)\r
+                            pprofile_add_relation(profile, sec_master,\r
+                                                  host);\r
+                        else\r
+                            pprofile_add_relation(profile, sec_kdcs,\r
+                                                  host);\r
+\r
+                        if (d->realms[r].kdcs[k].admin)\r
+                            pprofile_add_relation(profile, sec_admin,\r
+                                                  host);\r
+                        continue;\r
+                    }\r
+\r
+                    if (d->realms[r].kdcs[k].flags & K5_RKFLAG_MOD_MASTER) {\r
+                        if (!d->realms[r].kdcs[k].master) {\r
+                            pprofile_add_relation(profile, sec_kdcs,\r
+                                                  host);\r
+                            pprofile_update_relation(profile, sec_master,\r
+                                                     host, NULL);\r
+                        } else {\r
+                            pprofile_add_relation(profile, sec_master,\r
+                                                  host);\r
+                            pprofile_update_relation(profile, sec_kdcs,\r
+                                                     host, NULL);\r
+                        }\r
+                    }\r
+\r
+                    if (d->realms[r].kdcs[k].flags & K5_RKFLAG_MOD_ADMIN) {\r
+                        if (d->realms[r].kdcs[k].admin)\r
+                            pprofile_add_relation(profile, sec_admin,\r
+                                                  host);\r
+                        else\r
+                            pprofile_update_relation(profile, sec_admin,\r
+                                                     host, NULL);\r
+                    }\r
+                }\r
+\r
+                for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+\r
+                    UnicodeStrToAnsi(host, sizeof(host),\r
+                                     d->realms[r].domain_maps[m].name);\r
+\r
+                    if ((d->realms[r].domain_maps[m].flags &\r
+                         K5_DMFLAG_DELETED) &&\r
+                        !(d->realms[r].domain_maps[m].flags &\r
+                          K5_DMFLAG_NEW))\r
+                        pprofile_clear_relation(profile, sec_domain_map);\r
+                    else if (!(d->realms[r].domain_maps[m].flags &\r
+                               K5_DMFLAG_DELETED) &&\r
+                             (d->realms[r].domain_maps[m].flags &\r
+                              K5_DMFLAG_NEW))\r
+                        pprofile_add_relation(profile, sec_domain_map,\r
+                                              realm);\r
+                }\r
+            }\r
+        }\r
+\r
+        rv = pprofile_flush(profile);\r
+\r
+        pprofile_release(profile);\r
+    }\r
+\r
+    if (rv) {\r
+        khui_alert * alert;\r
+        wchar_t title[KHUI_MAXCCH_TITLE];\r
+        wchar_t fmsg[KHUI_MAXCCH_MESSAGE];\r
+        wchar_t msg[KHUI_MAXCCH_MESSAGE];\r
+        wchar_t sugg[KHUI_MAXCCH_SUGGESTION];\r
+\r
+        LoadString(hResModule, IDS_K5ERR_CANTWRITEPROFILE,\r
+                   title, ARRAYLENGTH(title));\r
+        if (rv)\r
+            LoadString(hResModule, IDS_K5ERR_PROFNOWRITE,\r
+                       fmsg, ARRAYLENGTH(fmsg));\r
+\r
+        LoadString(hResModule, IDS_K5ERR_PROFSUGGEST,\r
+                   sugg, ARRAYLENGTH(sugg));\r
+\r
+        StringCbPrintf(msg, sizeof(msg), fmsg, config_file);\r
+\r
+        khui_alert_create_empty(&alert);\r
+        khui_alert_set_severity(alert, (rv)?KHERR_ERROR:KHERR_WARNING);\r
+        khui_alert_set_title(alert, title);\r
+        khui_alert_set_message(alert, msg);\r
+        khui_alert_set_suggestion(alert, sugg);\r
+        \r
+        khui_alert_show(alert);\r
+    }\r
+\r
+    d->flags = 0;\r
+}\r
+\r
+/* actual dialog stuff */\r
+\r
+#define IDX_NORMAL   1\r
+#define IDX_MODIFIED 2\r
+#define IDX_NEW      3\r
+#define IDX_DELETED  4\r
+\r
+static k5_config_data k5_config_dlg_data;\r
+static khm_boolean    k5_dlg_data_valid = FALSE;\r
 \r
 INT_PTR CALLBACK \r
 k5_config_dlgproc(HWND hwnd,\r
@@ -38,41 +892,42 @@ k5_config_dlgproc(HWND hwnd,
     case WM_INITDIALOG:\r
         {\r
             HWND hw;\r
-            wchar_t * realms;\r
-            wchar_t * defrealm;\r
+            khm_size i;\r
+            k5_config_data * d;\r
+\r
             wchar_t * t;\r
-            char conffile[MAX_PATH];\r
-            wchar_t wconffile[MAX_PATH];\r
             wchar_t importopts[256];\r
             WKSTA_INFO_100 * winfo100;\r
 \r
-            hw = GetDlgItem(hwnd, IDC_CFG_DEFREALM);\r
 #ifdef DEBUG\r
-            assert(hw);\r
+            assert(!k5_dlg_data_valid);\r
 #endif\r
-            realms = khm_krb5_get_realm_list();\r
-            defrealm = khm_krb5_get_default_realm();\r
+\r
+            k5_init_config_data(&k5_config_dlg_data);\r
+            k5_read_config_data(&k5_config_dlg_data);\r
+\r
+            k5_dlg_data_valid = TRUE;\r
+\r
+            d = &k5_config_dlg_data;\r
+\r
+            d->node_main = (khui_config_node) lParam;\r
+\r
+            hw = GetDlgItem(hwnd, IDC_CFG_DEFREALM);\r
 #ifdef DEBUG\r
-            assert(realms);\r
-            assert(defrealm);\r
+            assert(hw);\r
 #endif\r
 \r
             SendMessage(hw, CB_RESETCONTENT, 0, 0);\r
 \r
-            for(t = realms; t && *t; t = multi_string_next(t)) {\r
-                SendMessage(hw, CB_ADDSTRING, 0, (LPARAM) t);\r
+            for (i=0; i < d->n_realms; i++) {\r
+                SendMessage(hw, CB_ADDSTRING, 0,\r
+                            (LPARAM) d->realms[i].realm);\r
             }\r
 \r
-            SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) defrealm);\r
-\r
-            free(defrealm);\r
-            free(realms);\r
-\r
-            khm_get_profile_file(conffile, sizeof(conffile));\r
+            SendMessage(hw, CB_SELECTSTRING, -1,\r
+                        (LPARAM) d->def_realm);\r
 \r
-            AnsiStrToUnicode(wconffile, sizeof(wconffile), conffile);\r
-\r
-            SetDlgItemText(hwnd, IDC_CFG_CFGFILE, wconffile);\r
+            SetDlgItemText(hwnd, IDC_CFG_CFGFILE, d->config_file);\r
 \r
             /* hostname/domain */\r
             if (NetWkstaGetInfo(NULL, 100, (LPBYTE *) &winfo100) == NERR_Success) {\r
@@ -99,175 +954,692 @@ k5_config_dlgproc(HWND hwnd,
                 SendMessage(hw, CB_ADDSTRING, 0, (LPARAM) t);\r
             }\r
 \r
-            SendMessage(hw, CB_SETCURSEL, 0, 0);\r
-            \r
+            SendMessage(hw, CB_SETCURSEL, 0, d->lsa_import);\r
+            t = importopts;\r
+            SendMessage(hw, CB_GETLBTEXT, d->lsa_import,(LPARAM) t);\r
+            SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) t);\r
         }\r
         break;\r
 \r
-    case WM_DESTROY:\r
+    case WM_COMMAND:\r
+        {\r
+            k5_config_data * d;\r
+\r
+            d = &k5_config_dlg_data;\r
+\r
+            if (wParam == MAKEWPARAM(IDC_CFG_IMPORT, CBN_SELCHANGE)) {\r
+                int idx;\r
+                int modified = FALSE;\r
+\r
+                idx = (int) SendDlgItemMessage(hwnd, IDC_CFG_IMPORT,\r
+                                               CB_GETCURSEL, 0, 0);\r
+                if (idx != CB_ERR && idx != d->lsa_import) {\r
+                    d->lsa_import = idx;\r
+                    d->flags |= K5_CDFLAG_MOD_LSA_IMPORT;\r
+                    modified = TRUE;\r
+                }\r
+\r
+                khui_cfg_set_flags(d->node_main,\r
+                                   (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+                                   KHUI_CNFLAG_MODIFIED);\r
+                return TRUE;\r
+            }\r
+        }\r
         break;\r
-    }\r
-    return FALSE;\r
-}\r
 \r
-INT_PTR CALLBACK \r
-k5_realms_dlgproc(HWND hwndDlg,\r
-                  UINT uMsg,\r
-                  WPARAM wParam,\r
-                  LPARAM lParam) {\r
-    switch(uMsg) {\r
-    case WM_INITDIALOG:\r
+    case KHUI_WM_CFG_NOTIFY:\r
+        {\r
+            k5_config_data * d;\r
+\r
+            d = &k5_config_dlg_data;\r
+\r
+            if (HIWORD(wParam) == WMCFG_APPLY) {\r
+                khm_int32 oflags;\r
+\r
+                oflags = d->flags;\r
+                k5_write_config_data(d);\r
+\r
+                if (d->flags != oflags) {\r
+                    khui_cfg_set_flags(d->node_main,\r
+                                       KHUI_CNFLAG_APPLIED,\r
+                                       KHUI_CNFLAG_APPLIED |\r
+                                       KHUI_CNFLAG_MODIFIED);\r
+                }\r
+                return TRUE;\r
+            }\r
+        }\r
         break;\r
 \r
     case WM_DESTROY:\r
+        {\r
+            k5_free_config_data(&k5_config_dlg_data);\r
+            k5_dlg_data_valid = FALSE;\r
+        }\r
         break;\r
     }\r
     return FALSE;\r
 }\r
 \r
-typedef struct tag_k5_ids_dlg_data {\r
-    khui_tracker tc_life;\r
-    khui_tracker tc_renew;\r
-    khui_tracker tc_life_min;\r
-    khui_tracker tc_life_max;\r
-    khui_tracker tc_renew_min;\r
-    khui_tracker tc_renew_max;\r
-\r
-    time_t life;\r
-    time_t renew_life;\r
-    time_t life_min;\r
-    time_t life_max;\r
-    time_t renew_min;\r
-    time_t renew_max;\r
-} k5_ids_dlg_data;\r
+static HIMAGELIST\r
+k5_get_state_image_list(void) {\r
+    HIMAGELIST hil;\r
+    HICON hicon;\r
+\r
+    hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON),\r
+                           GetSystemMetrics(SM_CYSMICON),\r
+                           ILC_COLOR | ILC_MASK,\r
+                           4,\r
+                           2);\r
+\r
+    hicon = LoadImage(hResModule,\r
+                      MAKEINTRESOURCE(IDI_NORMAL),\r
+                      IMAGE_ICON,\r
+                      GetSystemMetrics(SM_CXSMICON),\r
+                      GetSystemMetrics(SM_CYSMICON),\r
+                      LR_DEFAULTCOLOR);\r
+\r
+    ImageList_AddIcon(hil, hicon);\r
+\r
+    DestroyIcon(hicon);\r
+\r
+    hicon = LoadImage(hResModule,\r
+                      MAKEINTRESOURCE(IDI_MODIFIED),\r
+                      IMAGE_ICON,\r
+                      GetSystemMetrics(SM_CXSMICON),\r
+                      GetSystemMetrics(SM_CYSMICON),\r
+                      LR_DEFAULTCOLOR);\r
+\r
+    ImageList_AddIcon(hil, hicon);\r
+\r
+    DestroyIcon(hicon);\r
+\r
+    hicon = LoadImage(hResModule,\r
+                      MAKEINTRESOURCE(IDI_NEW),\r
+                      IMAGE_ICON,\r
+                      GetSystemMetrics(SM_CXSMICON),\r
+                      GetSystemMetrics(SM_CYSMICON),\r
+                      LR_DEFAULTCOLOR);\r
+\r
+    ImageList_AddIcon(hil, hicon);\r
+\r
+    DestroyIcon(hicon);\r
+\r
+    hicon = LoadImage(hResModule,\r
+                      MAKEINTRESOURCE(IDI_DELETED),\r
+                      IMAGE_ICON,\r
+                      GetSystemMetrics(SM_CXSMICON),\r
+                      GetSystemMetrics(SM_CYSMICON),\r
+                      LR_DEFAULTCOLOR);\r
+\r
+    ImageList_AddIcon(hil, hicon);\r
+\r
+    DestroyIcon(hicon);\r
+\r
+    return hil;\r
+}\r
+\r
+static void\r
+k5_update_realms_display(HWND hw_list, k5_config_data * d) {\r
+    khm_size i;\r
+    LVITEM lvi;\r
+    wchar_t buf[64];\r
+\r
+    ListView_DeleteAllItems(hw_list);\r
+\r
+    for (i=0; i < d->n_realms; i++) {\r
+        if ((d->realms[i].flags & K5_RDFLAG_DELETED) &&\r
+            (d->realms[i].flags & K5_RDFLAG_NEW))\r
+            continue;\r
+\r
+        ZeroMemory(&lvi, sizeof(lvi));\r
+        lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+        lvi.iItem = 0;\r
+        lvi.iSubItem = 0;\r
+        lvi.pszText = d->realms[i].realm;\r
+        lvi.lParam = i;\r
+\r
+        if (d->realms[i].flags & K5_RDFLAG_DELETED) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+        } else if (d->realms[i].flags & K5_RDFLAG_NEW) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+        } else if (d->realms[i].flags & K5_RDFLAG_MODIFED) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_MODIFIED);\r
+        } else {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+        }\r
+        lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+        ListView_InsertItem(hw_list, &lvi);\r
+    }\r
+\r
+    ZeroMemory(&lvi, sizeof(lvi));\r
+    lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+    lvi.iItem = 0;\r
+    lvi.iSubItem = 0;\r
+    lvi.pszText = buf;\r
+    lvi.lParam = (LPARAM) -1;\r
+\r
+    LoadString(hResModule, IDS_CFG_RE_NEWREALM,\r
+               buf, ARRAYLENGTH(buf));\r
+\r
+    lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+    lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+    ListView_InsertItem(hw_list, &lvi);\r
+\r
+    if (d->flags & K5_CDFLAG_MOD_REALMS) {\r
+        khui_cfg_set_flags(d->node_realm, KHUI_CNFLAG_MODIFIED,\r
+                           KHUI_CNFLAG_MODIFIED);\r
+    } else {\r
+        khui_cfg_set_flags(d->node_realm, 0,\r
+                           KHUI_CNFLAG_MODIFIED);\r
+    }\r
+}\r
 \r
 static void\r
-k5_ids_read_params(k5_ids_dlg_data * d) {\r
-    khm_int32 t;\r
-    khm_int32 rv;\r
+k5_update_kdcs_display(HWND hw_kdc, k5_config_data * d, khm_size idx_rlm) {\r
+    khm_size k;\r
+    LVITEM lvi;\r
+    int idx_item;\r
+    k5_realm_kdc * pkdc;\r
+    wchar_t wyes[8];\r
+    wchar_t wno[8];\r
+    wchar_t wbuf[64];\r
+\r
+    ListView_DeleteAllItems(hw_kdc);\r
+\r
+    if (d == NULL)\r
+        return;\r
 \r
 #ifdef DEBUG\r
-    assert(csp_params);\r
+    assert(idx_rlm < d->n_realms);\r
 #endif\r
+    LoadString(hResModule, IDS_YES, wyes, ARRAYLENGTH(wyes));\r
+    LoadString(hResModule, IDS_NO, wno, ARRAYLENGTH(wno));\r
+\r
+    for (k=0; k < d->realms[idx_rlm].n_kdcs; k++) {\r
+        if ((d->realms[idx_rlm].kdcs[k].flags & K5_RKFLAG_DELETED) &&\r
+            (d->realms[idx_rlm].kdcs[k].flags & K5_RKFLAG_NEW))\r
+            continue;\r
+\r
+        pkdc = &(d->realms[idx_rlm].kdcs[k]);\r
+\r
+        ZeroMemory(&lvi, sizeof(lvi));\r
+        lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+        lvi.iItem = K5_MAX_KDC;\r
+        lvi.iSubItem = 0;\r
+        lvi.lParam = k;\r
+        lvi.pszText = pkdc->name;\r
+        if (pkdc->flags & K5_RKFLAG_DELETED) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+        } else if (pkdc->flags & K5_RKFLAG_NEW) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+        } else if ((pkdc->flags & K5_RKFLAG_MOD_ADMIN) ||\r
+                   (pkdc->flags & K5_RKFLAG_MOD_MASTER)) {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_MODIFIED);\r
+        } else {\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+        }\r
+        lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+        idx_item = ListView_InsertItem(hw_kdc, &lvi);\r
+\r
+        lvi.mask = LVIF_TEXT;\r
+        lvi.iItem = idx_item;\r
+        lvi.iSubItem = 1;\r
+        if (pkdc->admin)\r
+            lvi.pszText = wyes;\r
+        else\r
+            lvi.pszText = wno;\r
+        ListView_SetItem(hw_kdc, &lvi);\r
+\r
+        lvi.iSubItem = 2;\r
+        if (pkdc->master)\r
+            lvi.pszText = wyes;\r
+        else\r
+            lvi.pszText = wno;\r
+        ListView_SetItem(hw_kdc, &lvi);\r
+    }\r
+\r
+    ZeroMemory(&lvi, sizeof(lvi));\r
+    lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;\r
+    lvi.iItem = 0;\r
+    lvi.iSubItem = 0;\r
+    lvi.pszText = wbuf;\r
+    lvi.lParam = (LPARAM) -1;\r
+    lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+    lvi.stateMask = LVIS_STATEIMAGEMASK;\r
 \r
-    rv = khc_read_int32(csp_params, L"DefaultLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->life = t;\r
-\r
-    rv = khc_read_int32(csp_params, L"DefaultRenewLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->renew_life = t;\r
-\r
-    rv = khc_read_int32(csp_params, L"MaxLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->life_max = t;\r
-\r
-    rv = khc_read_int32(csp_params, L"MinLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->life_min = t;\r
-\r
-    rv = khc_read_int32(csp_params, L"MaxRenewLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->renew_max = t;\r
-\r
-    rv = khc_read_int32(csp_params, L"MinRenewLifetime", &t);\r
-    assert(KHM_SUCCEEDED(rv));\r
-    d->renew_min = t;\r
-\r
-    khui_tracker_initialize(&d->tc_life);\r
-    d->tc_life.current = d->life;\r
-    d->tc_life.min = 0;\r
-    d->tc_life.max = 3600 * 24 * 7;\r
-\r
-    khui_tracker_initialize(&d->tc_renew);\r
-    d->tc_renew.current = d->renew_life;\r
-    d->tc_renew.min = 0;\r
-    d->tc_renew.max = 3600 * 24 * 30;\r
-\r
-    khui_tracker_initialize(&d->tc_life_min);\r
-    d->tc_life_min.current = d->life_min;\r
-    d->tc_life_min.min = d->tc_life.min;\r
-    d->tc_life_min.max = d->tc_life.max;\r
-\r
-    khui_tracker_initialize(&d->tc_life_max);\r
-    d->tc_life_max.current = d->life_max;\r
-    d->tc_life_max.min = d->tc_life.min;\r
-    d->tc_life_max.max = d->tc_life.max;\r
-\r
-    khui_tracker_initialize(&d->tc_renew_min);\r
-    d->tc_renew_min.current = d->renew_min;\r
-    d->tc_renew_min.min = d->tc_renew.min;\r
-    d->tc_renew_min.max = d->tc_renew.max;\r
-\r
-    khui_tracker_initialize(&d->tc_renew_max);\r
-    d->tc_renew_max.current = d->renew_max;\r
-    d->tc_renew_max.min = d->tc_renew.min;\r
-    d->tc_renew_max.max = d->tc_renew.max;\r
+    LoadString(hResModule, IDS_CFG_RE_NEWSERVER,\r
+               wbuf, ARRAYLENGTH(wbuf));\r
+\r
+    ListView_InsertItem(hw_kdc, &lvi);\r
 }\r
 \r
-INT_PTR CALLBACK \r
-k5_ids_tab_dlgproc(HWND hwnd,\r
-                  UINT uMsg,\r
-                  WPARAM wParam,\r
-                  LPARAM lParam) {\r
-    k5_ids_dlg_data * d;\r
+static void\r
+k5_update_dmap_display(HWND hw_dm, k5_config_data * d, khm_size idx_rlm) {\r
+    khm_size m;\r
+    LVITEM lvi;\r
+    k5_domain_map * map;\r
+    wchar_t wbuf[64];\r
+\r
+    ListView_DeleteAllItems(hw_dm);\r
+\r
+    if (d == NULL)\r
+        return;\r
 \r
-    switch(uMsg) {\r
-    case WM_INITDIALOG:\r
-        d = malloc(sizeof(*d));\r
 #ifdef DEBUG\r
-        assert(d);\r
+    assert(idx_rlm < d->n_realms);\r
 #endif\r
-        ZeroMemory(d, sizeof(*d));\r
-#pragma warning(push)\r
-#pragma warning(disable: 4244)\r
-        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
-#pragma warning(pop)\r
 \r
-        k5_ids_read_params(d);\r
-\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
-                             &d->tc_life);\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
-                             &d->tc_renew);\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MIN),\r
-                             &d->tc_life_min);\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MAX),\r
-                             &d->tc_life_max);\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MIN),\r
-                             &d->tc_renew_min);\r
-        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MAX),\r
-                             &d->tc_renew_max);\r
-        khui_tracker_refresh(&d->tc_life);\r
-        khui_tracker_refresh(&d->tc_life_min);\r
-        khui_tracker_refresh(&d->tc_life_max);\r
-        khui_tracker_refresh(&d->tc_renew);\r
-        khui_tracker_refresh(&d->tc_renew_min);\r
-        khui_tracker_refresh(&d->tc_renew_max);\r
-        break;\r
+    for (m=0; m < d->realms[idx_rlm].n_domain_maps; m++) {\r
+        map = &(d->realms[idx_rlm].domain_maps[m]);\r
 \r
-    case WM_DESTROY:\r
-        d = (k5_ids_dlg_data *) (LONG_PTR)\r
-            GetWindowLongPtr(hwnd, DWLP_USER);\r
-\r
-        khui_tracker_kill_controls(&d->tc_life);\r
-        khui_tracker_kill_controls(&d->tc_renew);\r
-        khui_tracker_kill_controls(&d->tc_life_min);\r
-        khui_tracker_kill_controls(&d->tc_life_max);\r
-        khui_tracker_kill_controls(&d->tc_renew_min);\r
-        khui_tracker_kill_controls(&d->tc_renew_max);\r
-        break;\r
+        if ((map->flags & K5_DMFLAG_NEW) &&\r
+            (map->flags & K5_DMFLAG_DELETED))\r
+            continue;\r
+\r
+        ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+        lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;\r
+        lvi.pszText = map->name;\r
+        if (map->flags & K5_DMFLAG_DELETED)\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+        else if (map->flags & K5_DMFLAG_NEW)\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+        else\r
+            lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+        lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+        lvi.lParam = m;\r
+\r
+        lvi.iItem = K5_MAX_DOMAIN_MAPPINGS;\r
+        lvi.iSubItem = 0;\r
+\r
+        ListView_InsertItem(hw_dm, &lvi);\r
     }\r
-    return FALSE;\r
+\r
+    ZeroMemory(&lvi, sizeof(lvi));\r
+    lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_STATE;\r
+    lvi.pszText = wbuf;\r
+    lvi.lParam = (LPARAM) -1;\r
+    lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+    lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+    lvi.iItem = 0;\r
+    lvi.iSubItem = 0;\r
+\r
+    LoadString(hResModule, IDS_CFG_RE_NEWDMAP,\r
+               wbuf, ARRAYLENGTH(wbuf));\r
+\r
+    ListView_InsertItem(hw_dm, &lvi);\r
 }\r
 \r
 INT_PTR CALLBACK \r
-k5_id_tab_dlgproc(HWND hwndDlg,\r
+k5_realms_dlgproc(HWND hwnd,\r
                   UINT uMsg,\r
                   WPARAM wParam,\r
                   LPARAM lParam) {\r
+    k5_config_data * d;\r
+\r
+    d = &k5_config_dlg_data;\r
+\r
     switch(uMsg) {\r
     case WM_INITDIALOG:\r
+        {\r
+            LVCOLUMN lvc;\r
+            HWND hw;\r
+            RECT r;\r
+            wchar_t buf[256];\r
+\r
+            assert(k5_dlg_data_valid);\r
+\r
+            d->node_realm = (khui_config_node) lParam;\r
+\r
+            /* set up columns for the Realms list */\r
+            hw = GetDlgItem(hwnd, IDC_CFG_REALMS);\r
+#ifdef DEBUG\r
+            assert(hw);\r
+#endif\r
+            GetWindowRect(hw, &r);\r
+            r.right -= 5;       /* shave a few pixels off the width */\r
+            ZeroMemory(&lvc, sizeof(lvc));\r
+            lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+            lvc.pszText = buf;\r
+            lvc.cx = (r.right - r.left);\r
+            LoadString(hResModule, IDS_CFG_RE_REALMS,\r
+                       buf, ARRAYLENGTH(buf));\r
+\r
+            ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+            ListView_SetImageList(hw,\r
+                                  k5_get_state_image_list(),\r
+                                  LVSIL_STATE);\r
+\r
+            k5_update_realms_display(hw, d);\r
+\r
+            /* set up columns for the servers list */\r
+            hw = GetDlgItem(hwnd, IDC_CFG_KDC);\r
+#ifdef DEBUG\r
+            assert(hw);\r
+#endif\r
+            GetWindowRect(hw, &r);\r
+            r.right -= 5;\r
+            ZeroMemory(&lvc, sizeof(lvc));\r
+            lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+            lvc.pszText = buf;\r
+            lvc.cx = (r.right - r.left) * 2 / 4;\r
+            LoadString(hResModule, IDS_CFG_RE_HEAD_SVR,\r
+                       buf, ARRAYLENGTH(buf));\r
+\r
+            ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+            lvc.cx = (r.right - r.left) * 1 / 4;\r
+            LoadString(hResModule, IDS_CFG_RE_HEAD_ADMIN,\r
+                       buf, ARRAYLENGTH(buf));\r
+            ListView_InsertColumn(hw, 1, &lvc);\r
+\r
+            LoadString(hResModule, IDS_CFG_RE_HEAD_MASTER,\r
+                       buf, ARRAYLENGTH(buf));\r
+            ListView_InsertColumn(hw, 2, &lvc);\r
+\r
+            ListView_SetImageList(hw,\r
+                                  k5_get_state_image_list(),\r
+                                  LVSIL_STATE);\r
+\r
+            /* set up columns for the domain/host mapping list */\r
+            hw = GetDlgItem(hwnd, IDC_CFG_DMAP);\r
+#ifdef DEBUG\r
+            assert(hw);\r
+#endif\r
+            GetWindowRect(hw, &r);\r
+            r.right -= 5;\r
+            ZeroMemory(&lvc, sizeof(lvc));\r
+            lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+            lvc.pszText = buf;\r
+            lvc.cx = (r.right - r.left);\r
+            LoadString(hResModule, IDS_CFG_RE_HEAD_DOMAIN,\r
+                       buf, ARRAYLENGTH(buf));\r
+\r
+            ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+\r
+            ListView_SetImageList(hw,\r
+                                  k5_get_state_image_list(),\r
+                                  LVSIL_STATE);\r
+        }\r
+        break;\r
+\r
+    case WM_NOTIFY:\r
+        {\r
+            LPNMHDR pnmh;\r
+            HWND hw_rlm = NULL;\r
+            HWND hw_kdc = NULL;\r
+            HWND hw_dmp = NULL;\r
+            int i;\r
+\r
+            pnmh = (LPNMHDR) lParam;\r
+\r
+            if (pnmh->idFrom == IDC_CFG_REALMS) {\r
+\r
+                hw_rlm = pnmh->hwndFrom;\r
+\r
+                switch(pnmh->code) {\r
+                case LVN_ITEMCHANGED:\r
+                    i = ListView_GetSelectedCount(hw_rlm);\r
+                    hw_kdc = GetDlgItem(hwnd, IDC_CFG_KDC);\r
+                    hw_dmp = GetDlgItem(hwnd, IDC_CFG_DMAP);\r
+\r
+                    d->c_realm = (khm_size) -1;\r
+                    \r
+                    if (i == 1) {\r
+                        LVITEM lvi;\r
+\r
+                        i = ListView_GetNextItem(hw_rlm, -1,\r
+                                                 LVNI_SELECTED);\r
+                        if (i == -1)\r
+                            goto _no_selection;\r
+\r
+                        ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+                        lvi.iItem = i;\r
+                        lvi.iSubItem = 0;\r
+                        lvi.mask = LVIF_PARAM;\r
+\r
+                        ListView_GetItem(hw_rlm, &lvi);\r
+\r
+                        if (lvi.lParam == -1)\r
+                            goto _no_selection;\r
+\r
+                        d->c_realm = lvi.lParam;\r
+\r
+                        k5_update_kdcs_display(hw_kdc, d, lvi.lParam);\r
+                        k5_update_dmap_display(hw_dmp, d, lvi.lParam);\r
+                        return TRUE;\r
+                    }\r
+\r
+                _no_selection:\r
+                    ListView_DeleteAllItems(hw_kdc);\r
+                    ListView_DeleteAllItems(hw_dmp);\r
+                    break;\r
+\r
+                case LVN_BEGINLABELEDIT:\r
+                    {\r
+                        NMLVDISPINFO * pdisp;\r
+                        LVITEM lvi;\r
+\r
+                        pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+                        ZeroMemory(&lvi, sizeof(lvi));\r
+                        lvi.iItem = pdisp->item.iItem;\r
+                        lvi.mask = LVIF_PARAM;\r
+\r
+                        ListView_GetItem(hw_rlm, &lvi);\r
+\r
+                        if (pdisp->item.iItem == -1 ||\r
+                            lvi.lParam != -1) {\r
+                            SetWindowLongPtr(hwnd, DWL_MSGRESULT, TRUE);\r
+                        } else {\r
+                            /* allow editing */\r
+                            HWND hw_edit;\r
+\r
+                            hw_edit = ListView_GetEditControl(hw_rlm);\r
+                            if (hw_edit != NULL) {\r
+                                SendMessage(hw_edit,\r
+                                            EM_SETLIMITTEXT,\r
+                                            K5_MAXCCH_REALM - 1,\r
+                                            0);\r
+                            }\r
+                            SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+                        }\r
+\r
+                        return TRUE;\r
+                    }\r
+                    break;\r
+\r
+                case LVN_ENDLABELEDIT:\r
+                    {\r
+                        NMLVDISPINFO * pdisp;\r
+                        khm_size n;\r
+\r
+                        pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+                        if (pdisp->item.pszText) {\r
+                            n = d->n_realms;\r
+                            k5_assert_n_realms(d, n+1);\r
+                            StringCbCopy(d->realms[n].realm,\r
+                                         sizeof(d->realms[n].realm),\r
+                                         pdisp->item.pszText);\r
+                            d->realms[n].flags = K5_RDFLAG_NEW;\r
+                            d->n_realms++;\r
+\r
+                            d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+                            k5_update_realms_display(hw_rlm, d);\r
+                        }\r
+\r
+                        return TRUE;\r
+                    }\r
+                    break;\r
+\r
+                case LVN_KEYDOWN:\r
+                    {\r
+                        NMLVKEYDOWN * pnmk;\r
+                        LVITEM lvi;\r
+                        khm_size r;\r
+                        int idx;\r
+                        BOOL modified = FALSE;\r
+\r
+                        pnmk = (NMLVKEYDOWN *) lParam;\r
+\r
+                        if (pnmk->wVKey == VK_DELETE) {\r
+                            idx = -1;\r
+                            while((idx = ListView_GetNextItem(hw_rlm, idx,\r
+                                                              LVNI_SELECTED))\r
+                                  != -1) {\r
+                                ZeroMemory(&lvi, sizeof(lvi));\r
+                                lvi.iItem = idx;\r
+                                lvi.iSubItem = 0;\r
+                                lvi.mask = LVIF_PARAM;\r
+\r
+                                ListView_GetItem(hw_rlm, &lvi);\r
+\r
+                                if (lvi.lParam != -1 &&\r
+                                    (r = lvi.lParam) < d->n_realms) {\r
+                                    d->realms[r].flags ^= K5_RDFLAG_DELETED;\r
+                                    modified = TRUE;\r
+                                }\r
+                            }\r
+\r
+                            if (modified) {\r
+                                d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+                                k5_purge_config_data(d, TRUE, TRUE, TRUE);\r
+                                k5_update_realms_display(hw_rlm, d);\r
+                                k5_update_dmap_display(GetDlgItem(hwnd, IDC_CFG_DMAP), NULL, 0);\r
+                                k5_update_kdcs_display(GetDlgItem(hwnd, IDC_CFG_KDC), NULL, 0);\r
+                            }\r
+                            return TRUE;\r
+                        }\r
+                    }\r
+                    break;\r
+                }\r
+            } else if (pnmh->idFrom == IDC_CFG_KDC) {\r
+                hw_kdc = pnmh->hwndFrom;\r
+\r
+                switch (pnmh->code) {\r
+                case LVN_BEGINLABELEDIT:\r
+                    {\r
+                        NMLVDISPINFO * pdisp;\r
+                        LVITEM lvi;\r
+\r
+                        pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+                        ZeroMemory(&lvi, sizeof(lvi));\r
+                        lvi.iItem = pdisp->item.iItem;\r
+                        lvi.mask = LVIF_PARAM;\r
+\r
+                        ListView_GetItem(hw_kdc, &lvi);\r
+\r
+                        if (pdisp->item.iItem == -1 ||\r
+                            lvi.lParam != -1) {\r
+                            SetWindowLongPtr(hwnd, DWL_MSGRESULT, TRUE);\r
+                        } else {\r
+                            /* allow editing */\r
+                            HWND hw_edit;\r
+\r
+                            hw_edit = ListView_GetEditControl(hw_kdc);\r
+                            if (hw_edit != NULL) {\r
+                                SendMessage(hw_edit,\r
+                                            EM_SETLIMITTEXT,\r
+                                            K5_MAXCCH_HOST - 1,\r
+                                            0);\r
+                            }\r
+                            SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+                        }\r
+                        return TRUE;\r
+                    }\r
+                    break;\r
+\r
+                case LVN_ENDLABELEDIT:\r
+                    {\r
+                        NMLVDISPINFO * pdisp;\r
+                        khm_size r;\r
+                        khm_size k;\r
+\r
+                        r = d->c_realm;\r
+\r
+                        pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+                        if (pdisp->item.pszText) {\r
+                            k = d->realms[r].n_kdcs;\r
+\r
+                            if (k >= K5_MAX_KDC) {\r
+                                SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+                                /* TODO: show a message box saying\r
+                                   there are too many KDC's\r
+                                   already. */\r
+                                return TRUE;\r
+                            }\r
+\r
+                            StringCbCopy(d->realms[r].kdcs[k].name,\r
+                                         sizeof(d->realms[0].kdcs[0].name),\r
+                                         pdisp->item.pszText);\r
+                            d->realms[r].kdcs[k].flags = K5_RKFLAG_NEW;\r
+                            d->realms[r].n_kdcs++;\r
+\r
+                            d->realms[r].flags |= K5_RDFLAG_MODIFED;\r
+\r
+                            k5_update_kdcs_display(hw_kdc, d, d->c_realm);\r
+                        }\r
+                        return TRUE;\r
+                    }\r
+                    break;\r
+\r
+                case LVN_KEYDOWN:\r
+                    {\r
+#if 0\r
+                        NMLVKEYDOWN * pnmk;\r
+                        LVITEM lvi;\r
+                        khm_size r;\r
+                        int idx;\r
+                        BOOL modified = FALSE;\r
+\r
+                        pnmk = (NMLVKEYDOWN *) lParam;\r
+\r
+                        if (pnmk->wVKey == VK_DELETE) {\r
+                            idx = -1;\r
+                            while((idx = ListView_GetNextItem(hw_rlm, idx,\r
+                                                              LVNI_SELECTED))\r
+                                  != -1) {\r
+                                ZeroMemory(&lvi, sizeof(lvi));\r
+                                lvi.iItem = idx;\r
+                                lvi.iSubItem = 0;\r
+                                lvi.mask = LVIF_PARAM;\r
+\r
+                                ListView_GetItem(hw_rlm, &lvi);\r
+\r
+                                if (lvi.lParam != -1 &&\r
+                                    (r = lvi.lParam) < d->n_realms) {\r
+                                    d->realms[r].flags ^= K5_RDFLAG_DELETED;\r
+                                    modified = TRUE;\r
+                                }\r
+                            }\r
+\r
+                            if (modified) {\r
+                                d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+                                k5_purge_config_data(d, TRUE, TRUE, TRUE);\r
+                                k5_update_realms_display(hw_rlm, d);\r
+                                k5_update_dmap_display(GetDlgItem(hwnd, IDC_CFG_DMAP), NULL, 0);\r
+                                k5_update_kdcs_display(GetDlgItem(hwnd, IDC_CFG_KDC), NULL, 0);\r
+                            }\r
+                            return TRUE;\r
+                        }\r
+#endif\r
+                    }\r
+                    break;\r
+                }\r
+            }\r
+        }\r
         break;\r
 \r
     case WM_DESTROY:\r
@@ -276,7 +1648,6 @@ k5_id_tab_dlgproc(HWND hwndDlg,
     return FALSE;\r
 }\r
 \r
-\r
 void\r
 k5_register_config_panels(void) {\r
     khui_config_node node;\r
@@ -308,6 +1679,7 @@ k5_register_config_panels(void) {
 #endif\r
     }\r
 \r
+#ifdef REALM_EDITOR\r
     ZeroMemory(&reg, sizeof(reg));\r
 \r
     LoadString(hResModule, IDS_K5RLM_SHORT_DESC,\r
@@ -324,6 +1696,24 @@ k5_register_config_panels(void) {
     reg.flags = 0;\r
 \r
     khui_cfg_register(node, &reg);\r
+#endif\r
+\r
+    ZeroMemory(&reg, sizeof(reg));\r
+\r
+    LoadString(hResModule, IDS_K5CCC_SHORT_DESC,\r
+               wshort, ARRAYLENGTH(wshort));\r
+    LoadString(hResModule, IDS_K5CCC_LONG_DESC,\r
+               wlong, ARRAYLENGTH(wlong));\r
+\r
+    reg.name = L"KerberosCCaches";\r
+    reg.short_desc = wshort;\r
+    reg.long_desc = wlong;\r
+    reg.h_module = hResModule;\r
+    reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_CACHES);\r
+    reg.dlg_proc = k5_ccconfig_dlgproc;\r
+    reg.flags = 0;\r
+\r
+    khui_cfg_register(node, &reg);\r
 \r
     khui_cfg_release(node);\r
 \r
@@ -374,9 +1764,12 @@ k5_register_config_panels(void) {
 void\r
 k5_unregister_config_panels(void) {\r
     khui_config_node node_main;\r
+#ifdef REALM_EDITOR\r
     khui_config_node node_realms;\r
+#endif\r
     khui_config_node node_ids;\r
     khui_config_node node_tab;\r
+    khui_config_node node_ccaches;\r
 \r
     if (KHM_FAILED(khui_cfg_open(NULL, L"Kerberos5", &node_main))) {\r
         node_main = NULL;\r
@@ -385,6 +1778,7 @@ k5_unregister_config_panels(void) {
 #endif\r
     }\r
 \r
+#ifdef REALM_EDITOR\r
     if (KHM_SUCCEEDED(khui_cfg_open(node_main, L"KerberosRealms", \r
                                     &node_realms))) {\r
         khui_cfg_remove(node_realms);\r
@@ -394,6 +1788,17 @@ k5_unregister_config_panels(void) {
     else\r
         assert(FALSE);\r
 #endif\r
+#endif\r
+\r
+    if (KHM_SUCCEEDED(khui_cfg_open(node_main, L"KerberosCCaches",\r
+                                    &node_ccaches))) {\r
+        khui_cfg_remove(node_ccaches);\r
+        khui_cfg_release(node_ccaches);\r
+    }\r
+#ifdef DEBUG\r
+    else\r
+        assert(FALSE);\r
+#endif\r
 \r
     if (node_main) {\r
         khui_cfg_remove(node_main);\r
diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c
new file mode 100644 (file)
index 0000000..17ab409
--- /dev/null
@@ -0,0 +1,254 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_id_dlg_data {\r
+    khui_config_init_data cfg;\r
+\r
+    khm_handle   ident;\r
+\r
+    khui_tracker tc_life;\r
+    khui_tracker tc_renew;\r
+\r
+    wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+\r
+    time_t life;\r
+    time_t renew_life;\r
+} k5_id_dlg_data;\r
+\r
+static void\r
+k5_id_read_params(k5_id_dlg_data * d) {\r
+\r
+    wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+    khm_size cb;\r
+    khm_int32 rv;\r
+    khm_int32 t;\r
+    khm_handle csp_ident;\r
+    khm_handle csp_idroot = NULL;\r
+\r
+    cb = sizeof(idname);\r
+    khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);\r
+\r
+    rv = kcdb_identity_create(idname, 0, &d->ident);\r
+#ifdef DEBUG\r
+    assert(KHM_SUCCEEDED(rv));\r
+#endif\r
+\r
+    rv = kcdb_identity_get_config(d->ident, 0, &csp_idroot);\r
+    if (KHM_SUCCEEDED(rv) &&\r
+        KHM_SUCCEEDED(khc_open_space(csp_idroot, CSNAME_KRB5CRED, 0,\r
+                                     &csp_ident))) {\r
+        khc_shadow_space(csp_ident, csp_params);\r
+    } else {\r
+        csp_ident = csp_params;\r
+    }\r
+\r
+    if (csp_idroot)\r
+        khc_close_space(csp_idroot);\r
+\r
+    rv = khc_read_int32(csp_ident, L"DefaultLifetime",  &t);\r
+    if (KHM_SUCCEEDED(rv))\r
+        d->life = t;\r
+    else\r
+        d->life = 36000;\r
+\r
+    rv = khc_read_int32(csp_ident, L"DefaultRenewLifetime", &t);\r
+    if (KHM_SUCCEEDED(rv))\r
+        d->renew_life = t;\r
+    else\r
+        d->renew_life = 604800;\r
+\r
+    cb = sizeof(d->ccache);\r
+    rv = khc_read_string(csp_ident, L"DefaultCCName", d->ccache, &cb);\r
+    if (KHM_FAILED(rv))\r
+        ZeroMemory(d->ccache, sizeof(d->ccache));\r
+\r
+    khui_tracker_initialize(&d->tc_life);\r
+    d->tc_life.current = d->life;\r
+    d->tc_life.min = 0;\r
+    d->tc_life.max = 3600 * 24 * 7;\r
+\r
+    khui_tracker_initialize(&d->tc_renew);\r
+    d->tc_renew.current = d->renew_life;\r
+    d->tc_renew.min = 0;\r
+    d->tc_renew.max = 3600 * 24 * 30;\r
+\r
+    if (csp_ident != csp_params)\r
+        khc_close_space(csp_ident);\r
+}\r
+\r
+static khm_boolean\r
+k5_id_is_mod(HWND hw, k5_id_dlg_data * d) {\r
+    wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+\r
+    GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));\r
+\r
+    if (wcsicmp(ccache, d->ccache) ||\r
+        d->tc_renew.current != d->renew_life ||\r
+        d->tc_life.current != d->life)\r
+        return TRUE;\r
+    return FALSE;\r
+}\r
+\r
+static void\r
+k5_id_check_mod(HWND hw, k5_id_dlg_data * d) {\r
+    BOOL modified = k5_id_is_mod(hw, d);\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+                            KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_id_write_params(HWND hw, k5_id_dlg_data * d) {\r
+\r
+    khm_handle csp_idroot = NULL;\r
+    khm_handle csp_ident = NULL;\r
+    wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+    khm_size cb;\r
+    khm_int32 rv;\r
+\r
+    if (!k5_id_is_mod(hw, d))\r
+        return;\r
+\r
+    rv = kcdb_identity_get_config(d->ident, KHM_FLAG_CREATE, &csp_idroot);\r
+    if (KHM_SUCCEEDED(rv)) {\r
+        khc_open_space(csp_idroot, CSNAME_KRB5CRED,\r
+                       KHM_FLAG_CREATE,\r
+                       &csp_ident);\r
+    }\r
+\r
+    if (csp_idroot)\r
+        khc_close_space(csp_idroot);\r
+\r
+    if (!csp_ident)\r
+        return;\r
+\r
+    if (d->life != d->tc_life.current) {\r
+        d->life = d->tc_life.current;\r
+        khc_write_int32(csp_ident, L"DefaultLifetime", (khm_int32) d->life);\r
+    }\r
+\r
+    if (d->renew_life != d->tc_renew.current) {\r
+        d->renew_life = d->tc_renew.current;\r
+        khc_write_int32(csp_ident, L"DefaultRenewLifetime", (khm_int32) d->renew_life);\r
+    }\r
+\r
+    GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));\r
+\r
+    if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) &&\r
+        wcsicmp(ccache, d->ccache)) {\r
+        khc_write_string(csp_ident, L"DefaultCCName", ccache);\r
+        StringCbCopy(d->ccache, sizeof(d->ccache), ccache);\r
+    } else {\r
+        khc_remove_value(csp_ident, L"DefaultCCName", KCONF_FLAG_USER);\r
+    }\r
+\r
+    if (csp_ident)\r
+        khc_close_space(csp_ident);\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            KHUI_CNFLAG_APPLIED,\r
+                            KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_id_tab_dlgproc(HWND hwnd,\r
+                  UINT uMsg,\r
+                  WPARAM wParam,\r
+                  LPARAM lParam) {\r
+\r
+    k5_id_dlg_data * d;\r
+\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+        assert(d);\r
+#endif\r
+        ZeroMemory(d, sizeof(*d));\r
+\r
+        d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+        k5_id_read_params(d);\r
+\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
+                             &d->tc_life);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
+                             &d->tc_renew);\r
+        khui_tracker_refresh(&d->tc_life);\r
+        khui_tracker_refresh(&d->tc_renew);\r
+\r
+        SetDlgItemText(hwnd, IDC_CFG_CCACHE, d->ccache);\r
+        break;\r
+\r
+    case WM_COMMAND:\r
+        d = (k5_id_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        if (HIWORD(wParam) == EN_CHANGE)\r
+            k5_id_check_mod(hwnd, d);\r
+        break;\r
+\r
+    case KHUI_WM_CFG_NOTIFY:\r
+        d = (k5_id_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        if (HIWORD(wParam) == WMCFG_APPLY) {\r
+            k5_id_write_params(hwnd, d);\r
+        }\r
+        break;\r
+\r
+    case WM_DESTROY:\r
+        d = (k5_id_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        khui_tracker_kill_controls(&d->tc_life);\r
+        khui_tracker_kill_controls(&d->tc_renew);\r
+\r
+        if (d->ident)\r
+            kcdb_identity_release(d->ident);\r
+\r
+        PFREE(d);\r
+        break;\r
+    }\r
+    return FALSE;\r
+}\r
diff --git a/src/windows/identity/plugins/krb5/krb5configids.c b/src/windows/identity/plugins/krb5/krb5configids.c
new file mode 100644 (file)
index 0000000..4eebb9c
--- /dev/null
@@ -0,0 +1,250 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_ids_dlg_data {\r
+    khui_config_init_data cfg;\r
+\r
+    khui_tracker tc_life;\r
+    khui_tracker tc_renew;\r
+    khui_tracker tc_life_min;\r
+    khui_tracker tc_life_max;\r
+    khui_tracker tc_renew_min;\r
+    khui_tracker tc_renew_max;\r
+\r
+    time_t life;\r
+    time_t renew_life;\r
+    time_t life_min;\r
+    time_t life_max;\r
+    time_t renew_min;\r
+    time_t renew_max;\r
+} k5_ids_dlg_data;\r
+\r
+static khm_boolean\r
+k5_ids_is_mod(k5_ids_dlg_data * d) {\r
+    if (d->life != d->tc_life.current ||\r
+        d->renew_life != d->tc_renew.current ||\r
+        d->life_max != d->tc_life_max.current ||\r
+        d->life_min != d->tc_life_min.current ||\r
+        d->renew_max != d->tc_renew_max.current ||\r
+        d->renew_min != d->tc_renew_min.current)\r
+        return TRUE;\r
+    return FALSE;\r
+}\r
+\r
+static void\r
+k5_ids_check_mod(k5_ids_dlg_data * d) {\r
+    BOOL modified = k5_ids_is_mod(d);\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+                            KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_ids_write_params(k5_ids_dlg_data * d) {\r
+\r
+    khm_int32 rv;\r
+\r
+#ifdef DEBUG\r
+    assert(csp_params);\r
+#endif\r
+\r
+    if (!k5_ids_is_mod(d))\r
+        return;\r
+\r
+#define WRITEPARAM(po,pn,vn) \\r
+  if (po != pn) {            \\r
+   po = pn;                  \\r
+   rv = khc_write_int32(csp_params, vn, (khm_int32) po); \\r
+   assert(KHM_SUCCEEDED(rv));       \\r
+  }\r
+    \r
+    WRITEPARAM(d->life,d->tc_life.current, L"DefaultLifetime");\r
+    WRITEPARAM(d->renew_life,d->tc_renew.current, L"DefaultRenewLifetime");\r
+    WRITEPARAM(d->life_max,d->tc_life_max.current, L"MaxLifetime");\r
+    WRITEPARAM(d->life_min,d->tc_life_min.current, L"MinLifetime");\r
+    WRITEPARAM(d->renew_max,d->tc_renew_max.current, L"MaxRenewLifetime");\r
+    WRITEPARAM(d->renew_min,d->tc_renew_min.current, L"MinRenewLifetime");\r
+\r
+#undef WRITEPARAM\r
+\r
+    khui_cfg_set_flags_inst(&d->cfg,\r
+                            KHUI_CNFLAG_APPLIED,\r
+                            KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_ids_read_params(k5_ids_dlg_data * d) {\r
+    khm_int32 t;\r
+    khm_int32 rv;\r
+\r
+#ifdef DEBUG\r
+    assert(csp_params);\r
+#endif\r
+\r
+    rv = khc_read_int32(csp_params, L"DefaultLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->life = t;\r
+\r
+    rv = khc_read_int32(csp_params, L"DefaultRenewLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->renew_life = t;\r
+\r
+    rv = khc_read_int32(csp_params, L"MaxLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->life_max = t;\r
+\r
+    rv = khc_read_int32(csp_params, L"MinLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->life_min = t;\r
+\r
+    rv = khc_read_int32(csp_params, L"MaxRenewLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->renew_max = t;\r
+\r
+    rv = khc_read_int32(csp_params, L"MinRenewLifetime", &t);\r
+    assert(KHM_SUCCEEDED(rv));\r
+    d->renew_min = t;\r
+\r
+    khui_tracker_initialize(&d->tc_life);\r
+    d->tc_life.current = d->life;\r
+    d->tc_life.min = 0;\r
+    d->tc_life.max = 3600 * 24 * 7;\r
+\r
+    khui_tracker_initialize(&d->tc_renew);\r
+    d->tc_renew.current = d->renew_life;\r
+    d->tc_renew.min = 0;\r
+    d->tc_renew.max = 3600 * 24 * 30;\r
+\r
+    khui_tracker_initialize(&d->tc_life_min);\r
+    d->tc_life_min.current = d->life_min;\r
+    d->tc_life_min.min = d->tc_life.min;\r
+    d->tc_life_min.max = d->tc_life.max;\r
+\r
+    khui_tracker_initialize(&d->tc_life_max);\r
+    d->tc_life_max.current = d->life_max;\r
+    d->tc_life_max.min = d->tc_life.min;\r
+    d->tc_life_max.max = d->tc_life.max;\r
+\r
+    khui_tracker_initialize(&d->tc_renew_min);\r
+    d->tc_renew_min.current = d->renew_min;\r
+    d->tc_renew_min.min = d->tc_renew.min;\r
+    d->tc_renew_min.max = d->tc_renew.max;\r
+\r
+    khui_tracker_initialize(&d->tc_renew_max);\r
+    d->tc_renew_max.current = d->renew_max;\r
+    d->tc_renew_max.min = d->tc_renew.min;\r
+    d->tc_renew_max.max = d->tc_renew.max;\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_ids_tab_dlgproc(HWND hwnd,\r
+                  UINT uMsg,\r
+                  WPARAM wParam,\r
+                  LPARAM lParam) {\r
+    k5_ids_dlg_data * d;\r
+\r
+    switch(uMsg) {\r
+    case WM_INITDIALOG:\r
+        d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+        assert(d);\r
+#endif\r
+        ZeroMemory(d, sizeof(*d));\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+        SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+        d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+        k5_ids_read_params(d);\r
+\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
+                             &d->tc_life);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
+                             &d->tc_renew);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MIN),\r
+                             &d->tc_life_min);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MAX),\r
+                             &d->tc_life_max);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MIN),\r
+                             &d->tc_renew_min);\r
+        khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MAX),\r
+                             &d->tc_renew_max);\r
+        khui_tracker_refresh(&d->tc_life);\r
+        khui_tracker_refresh(&d->tc_life_min);\r
+        khui_tracker_refresh(&d->tc_life_max);\r
+        khui_tracker_refresh(&d->tc_renew);\r
+        khui_tracker_refresh(&d->tc_renew_min);\r
+        khui_tracker_refresh(&d->tc_renew_max);\r
+        break;\r
+\r
+    case WM_COMMAND:\r
+        d = (k5_ids_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        if (HIWORD(wParam) == EN_CHANGE) {\r
+            k5_ids_check_mod(d);\r
+        }\r
+        break;\r
+\r
+    case KHUI_WM_CFG_NOTIFY:\r
+        d = (k5_ids_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+        if (HIWORD(wParam) == WMCFG_APPLY) {\r
+            k5_ids_write_params(d);\r
+        }\r
+        break;\r
+\r
+    case WM_DESTROY:\r
+        d = (k5_ids_dlg_data *) (LONG_PTR)\r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        khui_tracker_kill_controls(&d->tc_life);\r
+        khui_tracker_kill_controls(&d->tc_renew);\r
+        khui_tracker_kill_controls(&d->tc_life_min);\r
+        khui_tracker_kill_controls(&d->tc_life_max);\r
+        khui_tracker_kill_controls(&d->tc_renew_min);\r
+        khui_tracker_kill_controls(&d->tc_renew_max);\r
+\r
+        PFREE(d);\r
+        break;\r
+    }\r
+    return FALSE;\r
+}\r
+\r
index d3c97fff2f1f0f178ffc3b83c299015211963ebc..d1a897d63117ce7f36cffc7261d04d9476c00c1c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -59,7 +59,7 @@ khm_convert524(krb5_context alt_ctx)
         !pkrb524_convert_creds_kdc)\r
         return 0;\r
 \r
-    v4creds = (CREDENTIALS *) malloc(sizeof(CREDENTIALS));\r
+    v4creds = (CREDENTIALS *) PMALLOC(sizeof(CREDENTIALS));\r
     memset((char *) v4creds, 0, sizeof(CREDENTIALS));\r
 \r
     memset((char *) &increds, 0, sizeof(increds));\r
@@ -140,7 +140,7 @@ khm_convert524(krb5_context alt_ctx)
 \r
 cleanup:\r
     memset(v4creds, 0, sizeof(v4creds));\r
-    free(v4creds);\r
+    PFREE(v4creds);\r
 \r
     if (v5creds) {\r
         pkrb5_free_creds(ctx, v5creds);\r
@@ -237,10 +237,10 @@ static long get_tickets_from_cache(krb5_context ctx,
         cc_name = (*pkrb5_cc_get_name)(ctx, cache);\r
         if(cc_name) {\r
             namelen = strlen(cc_name);\r
-            namelen = (namelen + 1 + 4) * sizeof(wchar_t);\r
-            /* the +4 is for the possible addtion of API: during the\r
-               cannonicalization process */\r
-            wcc_name = malloc(namelen);\r
+            namelen = (namelen + 1 + 5) * sizeof(wchar_t);\r
+            /* the +5 is for the possible addtion of API: or FILE:\r
+               during the cannonicalization process */\r
+            wcc_name = PMALLOC(namelen);\r
             AnsiStrToUnicode(wcc_name, namelen, cc_name);\r
             khm_krb5_canon_cc_name(wcc_name, namelen);\r
         }\r
@@ -311,6 +311,7 @@ static long get_tickets_from_cache(krb5_context ctx,
                                        &KRBv5Credentials))) \r
     {\r
         khm_handle tident = NULL;\r
+        khm_int32 cred_flags = 0;\r
 \r
         if(ClientName != NULL)\r
             (*pkrb5_free_unparsed_name)(ctx, ClientName);\r
@@ -371,7 +372,7 @@ static long get_tickets_from_cache(krb5_context ctx,
         eft -= ft;\r
         kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &eft, sizeof(eft));\r
 \r
-        if (KRBv5Credentials.times.renew_till >= 0) {\r
+        if (KRBv5Credentials.times.renew_till > 0) {\r
             tt = KRBv5Credentials.times.renew_till;\r
             TimetToFileTime(tt, (LPFILETIME) &eft);\r
             kcdb_cred_set_attr(cred, KCDB_ATTR_RENEW_EXPIRE, &eft, \r
@@ -387,18 +388,29 @@ static long get_tickets_from_cache(krb5_context ctx,
 \r
         /* special flags understood by NetIDMgr */\r
         {\r
-            khm_int32 oflags, nflags;\r
-\r
-            kcdb_cred_get_flags(cred, &oflags);\r
-            nflags = oflags;\r
+            khm_int32 nflags = 0;\r
 \r
             if (ti & TKT_FLG_RENEWABLE)\r
                 nflags |= KCDB_CRED_FLAG_RENEWABLE;\r
             if (ti & TKT_FLG_INITIAL)\r
                 nflags |= KCDB_CRED_FLAG_INITIAL;\r
+           else {\r
+               krb5_data * c0, *c1, *r;\r
+\r
+               /* these are macros that do not allocate any memory */\r
+               c0 = krb5_princ_component(ctx,KRBv5Credentials.server,0);\r
+               c1 = krb5_princ_component(ctx,KRBv5Credentials.server,1);\r
+               r  = krb5_princ_realm(ctx,KRBv5Credentials.server);\r
+\r
+               if ( c0 && c1 && r && c1->length == r->length && \r
+                    !strncmp(c1->data,r->data,r->length) &&\r
+                    !strncmp("krbtgt",c0->data,c0->length) )\r
+                   nflags |= KCDB_CRED_FLAG_INITIAL;\r
+           }\r
+\r
+            kcdb_cred_set_flags(cred, nflags, KCDB_CRED_FLAGMASK_EXT);\r
 \r
-            if (oflags != nflags)\r
-                kcdb_cred_set_flags(cred, nflags, KCDB_CRED_FLAGMASK_ALL);\r
+            cred_flags = nflags;\r
         }\r
 \r
         if ( !pkrb5_decode_ticket(&KRBv5Credentials.ticket, &tkt)) {\r
@@ -410,8 +422,8 @@ static long get_tickets_from_cache(krb5_context ctx,
 \r
         ti = KRBv5Credentials.keyblock.enctype;\r
         kcdb_cred_set_attr(cred, attr_id_key_enctype, &ti, sizeof(ti));\r
-\r
-        kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name, KCDB_CBSIZE_AUTO);\r
+        kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name, \r
+                           KCDB_CBSIZE_AUTO);\r
 \r
         /*TODO: going here */\r
 #if 0\r
@@ -438,7 +450,8 @@ static long get_tickets_from_cache(krb5_context ctx,
         }\r
 #endif\r
 \r
-        if(KRBv5Credentials.ticket_flags & TKT_FLG_INITIAL) {\r
+        if(cred_flags & KCDB_CRED_FLAG_INITIAL) {\r
+            __int64 t_issue_new;\r
             __int64 t_expire_old;\r
             __int64 t_expire_new;\r
             khm_size cb;\r
@@ -451,6 +464,9 @@ static long get_tickets_from_cache(krb5_context ctx,
             tt = KRBv5Credentials.times.endtime;\r
             TimetToFileTime(tt, (LPFILETIME) &t_expire_new);\r
 \r
+            tt = KRBv5Credentials.times.starttime;\r
+            TimetToFileTime(tt, (LPFILETIME) &t_issue_new);\r
+\r
             cb = sizeof(t_expire_old);\r
             if(KHM_FAILED(kcdb_identity_get_attr(tident, \r
                                                  KCDB_ATTR_EXPIRE, \r
@@ -463,8 +479,11 @@ static long get_tickets_from_cache(krb5_context ctx,
                 kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, \r
                                        &t_expire_new, \r
                                        sizeof(t_expire_new));\r
+                kcdb_identity_set_attr(tident, KCDB_ATTR_ISSUE,\r
+                                       &t_issue_new,\r
+                                       sizeof(t_issue_new));\r
 \r
-                if (KRBv5Credentials.times.renew_till >= 0) {\r
+                if (KRBv5Credentials.times.renew_till > 0) {\r
                     tt = KRBv5Credentials.times.renew_till;\r
                     TimetToFileTime(tt, (LPFILETIME) &ft);\r
                     kcdb_identity_set_attr(tident, \r
@@ -525,7 +544,7 @@ static long get_tickets_from_cache(krb5_context ctx,
 \r
 _exit:\r
     if(wcc_name)\r
-        free(wcc_name);\r
+        PFREE(wcc_name);\r
 \r
     return code;\r
 }\r
@@ -534,11 +553,14 @@ long
 khm_krb5_list_tickets(krb5_context *krbv5Context)\r
 {\r
     krb5_context       ctx;\r
-    krb5_ccache                cache;\r
+    krb5_ccache                cache = 0;\r
     krb5_error_code    code;\r
-    apiCB *         cc_ctx = 0;\r
-    struct _infoNC ** pNCi = NULL;\r
-    int             i;\r
+    apiCB *             cc_ctx = 0;\r
+    struct _infoNC **   pNCi = NULL;\r
+    int                 i;\r
+    khm_int32           t;\r
+    wchar_t *           ms = NULL;\r
+    khm_size            cb;\r
 \r
     ctx = NULL;\r
     cache = NULL;\r
@@ -576,6 +598,49 @@ khm_krb5_list_tickets(krb5_context *krbv5Context)
         cache = 0;\r
     }\r
 \r
+    if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"MsLsaList", &t)) && t) {\r
+        code = (*pkrb5_cc_resolve)(ctx, "MSLSA:", &cache);\r
+\r
+        if (code == 0 && cache) {\r
+            code = get_tickets_from_cache(ctx, cache);\r
+        }\r
+\r
+        if (ctx != NULL && cache != NULL)\r
+            (*pkrb5_cc_close)(ctx, cache);\r
+        cache = 0;\r
+    }\r
+\r
+    if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+        == KHM_ERROR_TOO_LONG &&\r
+        cb > sizeof(wchar_t) * 2) {\r
+        wchar_t * t;\r
+        char ccname[MAX_PATH + 6];\r
+\r
+        ms = PMALLOC(cb);\r
+#ifdef DEBUG\r
+        assert(ms);\r
+#endif\r
+        khc_read_multi_string(csp_params, L"FileCCList", ms, &cb);\r
+\r
+        for(t = ms; t && *t; t = multi_string_next(t)) {\r
+            StringCchPrintfA(ccname, ARRAYLENGTH(ccname),\r
+                             "FILE:%S", t);\r
+\r
+            code = (*pkrb5_cc_resolve)(ctx, ccname, &cache);\r
+\r
+            if (code)\r
+                continue;\r
+\r
+            code = get_tickets_from_cache(ctx, cache);\r
+\r
+            if (ctx != NULL && cache != NULL)\r
+                (*pkrb5_cc_close)(ctx, cache);\r
+            cache = 0;\r
+        }\r
+\r
+        PFREE(ms);\r
+    }\r
+\r
 _exit:\r
     if (pNCi)\r
         (*pcc_free_NC_info)(cc_ctx, &pNCi);\r
@@ -585,7 +650,6 @@ _exit:
     kcdb_credset_collect(NULL, krb5_credset, NULL, credtype_id_krb5, NULL);\r
 \r
     return(code);\r
-\r
 }\r
 \r
 int\r
@@ -615,10 +679,10 @@ khm_krb5_renew(khm_handle identity)
     realm = krb5_princ_realm(ctx, me);\r
 \r
     code = pkrb5_build_principal_ext(ctx, &server,\r
-        realm->length,realm->data,\r
-        KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,\r
-        realm->length,realm->data,\r
-        0);\r
+                                     realm->length,realm->data,\r
+                                     KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,\r
+                                     realm->length,realm->data,\r
+                                     0);\r
 \r
     if (code) \r
         goto cleanup;\r
@@ -744,7 +808,7 @@ khm_krb5_kinit(krb5_context       alt_ctx,
             while ( local_addrs[i++] );\r
             addr_count = i + 1;\r
 \r
-            addrs = (krb5_address **) malloc((addr_count+1) * sizeof(krb5_address *));\r
+            addrs = (krb5_address **) PMALLOC((addr_count+1) * sizeof(krb5_address *));\r
             if ( !addrs ) {\r
                 pkrb5_free_addresses(ctx, local_addrs);\r
                 assert(0);\r
@@ -752,7 +816,7 @@ khm_krb5_kinit(krb5_context       alt_ctx,
             memset(addrs, 0, sizeof(krb5_address *) * (addr_count+1));\r
             i = 0;\r
             while ( local_addrs[i] ) {\r
-                addrs[i] = (krb5_address *)malloc(sizeof(krb5_address));\r
+                addrs[i] = (krb5_address *)PMALLOC(sizeof(krb5_address));\r
                 if (addrs[i] == NULL) {\r
                     pkrb5_free_addresses(ctx, local_addrs);\r
                     assert(0);\r
@@ -761,7 +825,7 @@ khm_krb5_kinit(krb5_context       alt_ctx,
                 addrs[i]->magic = local_addrs[i]->magic;\r
                 addrs[i]->addrtype = local_addrs[i]->addrtype;\r
                 addrs[i]->length = local_addrs[i]->length;\r
-                addrs[i]->contents = (unsigned char *)malloc(addrs[i]->length);\r
+                addrs[i]->contents = (unsigned char *)PMALLOC(addrs[i]->length);\r
                 if (!addrs[i]->contents) {\r
                     pkrb5_free_addresses(ctx, local_addrs);\r
                     assert(0);\r
@@ -773,14 +837,14 @@ khm_krb5_kinit(krb5_context       alt_ctx,
             }\r
             pkrb5_free_addresses(ctx, local_addrs);\r
 \r
-            addrs[i] = (krb5_address *)malloc(sizeof(krb5_address));\r
+            addrs[i] = (krb5_address *)PMALLOC(sizeof(krb5_address));\r
             if (addrs[i] == NULL)\r
                 assert(0);\r
 \r
             addrs[i]->magic = KV5M_ADDRESS;\r
             addrs[i]->addrtype = AF_INET;\r
             addrs[i]->length = 4;\r
-            addrs[i]->contents = (unsigned char *)malloc(addrs[i]->length);\r
+            addrs[i]->contents = (unsigned char *)PMALLOC(addrs[i]->length);\r
             if (!addrs[i]->contents)\r
                 assert(0);\r
 \r
@@ -814,8 +878,8 @@ cleanup:
         for ( i=0;i<addr_count;i++ ) {\r
             if ( addrs[i] ) {\r
                 if ( addrs[i]->contents )\r
-                    free(addrs[i]->contents);\r
-                free(addrs[i]);\r
+                    PFREE(addrs[i]->contents);\r
+                PFREE(addrs[i]);\r
             }\r
         }\r
     }\r
@@ -921,8 +985,19 @@ khm_krb5_canon_cc_name(wchar_t * wcc_name,
 \r
     colon = wcschr(wcc_name, L':');\r
 \r
-    if (colon)\r
+    if (colon) {\r
+        /* if the colon is just 1 character away from the beginning,\r
+           it's a FILE: cc */\r
+        if (colon - wcc_name == 1) {\r
+            if (cb_len + 5 * sizeof(wchar_t) > cb_cc_name)\r
+                return KHM_ERROR_TOO_LONG;\r
+\r
+            memmove(&wcc_name[5], &wcc_name[0], cb_len);\r
+            memmove(&wcc_name[0], L"FILE:", sizeof(wchar_t) * 5);\r
+        }\r
+\r
         return 0;\r
+    }\r
 \r
     if (cb_len + 4 * sizeof(wchar_t) > cb_cc_name)\r
         return KHM_ERROR_TOO_LONG;\r
@@ -1495,18 +1570,29 @@ cleanup:
 #define KRB_FILE                "KRB.CON"\r
 #define KRBREALM_FILE           "KRBREALM.CON"\r
 #define KRB5_FILE               "KRB5.INI"\r
+#define KRB5_TMP_FILE           "KRB5.INI.TMP"\r
+\r
+BOOL \r
+khm_krb5_get_temp_profile_file(LPSTR confname, UINT szConfname)\r
+{\r
+    GetTempPathA(szConfname, confname);\r
+    confname[szConfname-1] = '\0';\r
+    StringCchCatA(confname, szConfname, KRB5_TMP_FILE);\r
+    confname[szConfname-1] = '\0';\r
+    return FALSE;\r
+}\r
 \r
 BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname)\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)\r
 {\r
     char **configFile = NULL;\r
     if (pkrb5_get_default_config_files(&configFile)) \r
     {\r
         GetWindowsDirectoryA(confname,szConfname);\r
         confname[szConfname-1] = '\0';\r
-               strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
+        strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
         confname[szConfname-1] = '\0';\r
-               strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
+        strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
         confname[szConfname-1] = '\0';\r
         return FALSE;\r
     }\r
@@ -1523,9 +1609,9 @@ khm_get_profile_file(LPSTR confname, UINT szConfname)
     {\r
         GetWindowsDirectoryA(confname,szConfname);\r
         confname[szConfname-1] = '\0';\r
-               strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
+        strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
         confname[szConfname-1] = '\0';\r
-               strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
+        strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
         confname[szConfname-1] = '\0';\r
     }\r
     \r
@@ -1540,7 +1626,7 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname)
         LPSTR pFind;\r
 \r
         //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);\r
-        if (khm_get_profile_file(krbConFile, sizeof(krbConFile))) {\r
+        if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) {\r
             GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));\r
             krbConFile[MAX_PATH-1] = '\0';\r
             strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));\r
@@ -1634,7 +1720,7 @@ wchar_t * khm_krb5_get_realm_list(void)
 \r
         char krb5_conf[MAX_PATH+1];\r
 \r
-        if (!khm_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
+        if (!khm_krb5_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
             profile_t profile;\r
             long retval;\r
             const char *filenames[2];\r
@@ -1659,7 +1745,7 @@ wchar_t * khm_krb5_get_realm_list(void)
                     }\r
                     cbsize += sizeof(wchar_t); /* double null terminated */\r
 \r
-                    rlist = malloc(cbsize);\r
+                    rlist = PMALLOC(cbsize);\r
                     d = rlist;\r
                     for (cpp = sections; *cpp; cpp++)\r
                     {\r
@@ -1697,7 +1783,7 @@ wchar_t * khm_krb5_get_realm_list(void)
 \r
             /*TODO: compute the actual required buffer size instead of hardcoding */\r
             cbsize = 16384; // arbitrary\r
-            rlist = malloc(cbsize);\r
+            rlist = PMALLOC(cbsize);\r
             d = rlist;\r
 \r
             // Skip the default realm\r
@@ -1760,7 +1846,7 @@ wchar_t * khm_krb5_get_default_realm(void)
     \r
     if (def) {\r
         cch = strlen(def) + 1;\r
-        realm = malloc(sizeof(wchar_t) * cch);\r
+        realm = PMALLOC(sizeof(wchar_t) * cch);\r
         AnsiStrToUnicode(realm, sizeof(wchar_t) * cch, def);\r
         pkrb5_free_default_realm(ctx, def);\r
     } else\r
@@ -1771,6 +1857,32 @@ wchar_t * khm_krb5_get_default_realm(void)
     return realm;\r
 }\r
 \r
+long\r
+khm_krb5_set_default_realm(wchar_t * realm) {\r
+    krb5_context ctx=0;\r
+    char * def = 0;\r
+    long rv = 0;\r
+    char astr[K5_MAXCCH_REALM];\r
+\r
+    UnicodeStrToAnsi(astr, sizeof(astr), realm);\r
+\r
+    pkrb5_init_context(&ctx);\r
+    pkrb5_get_default_realm(ctx,&def);\r
+\r
+    if ((def && strcmp(def, astr)) ||\r
+        !def) {\r
+        rv = pkrb5_set_default_realm(ctx, astr);\r
+    }\r
+\r
+    if (def) {\r
+        pkrb5_free_default_realm(ctx, def);\r
+    }\r
+\r
+    pkrb5_free_context(ctx);\r
+\r
+    return rv;\r
+}\r
+\r
 wchar_t * khm_get_realm_from_princ(wchar_t * princ) {\r
     wchar_t * t;\r
 \r
@@ -1858,7 +1970,7 @@ khm_krb5_changepwd(char * principal,
            (result_string.length ? (sizeof(": ") - 1) : 0) +\r
            result_string.length;\r
        if (len && error_str) {\r
-           *error_str = malloc(len + 1);\r
+           *error_str = PMALLOC(len + 1);\r
            if (*error_str)\r
                StringCchPrintfA(*error_str, len+1,\r
                                 "%.*s%s%.*s",\r
@@ -1887,3 +1999,13 @@ khm_krb5_changepwd(char * principal,
 \r
    return rc;\r
 }\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy) {\r
+    if (kcdb_creds_comp_attr(vcred1, vcred2, KCDB_ATTR_LOCATION) ||\r
+        kcdb_creds_comp_attr(vcred1, vcred2, attr_id_key_enctype) ||\r
+        kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype))\r
+        return 1;\r
+    else\r
+        return 0;\r
+}\r
index 79ca95646ad9df14c108123767562fe9ed2ffe36..6c2c3eb6b935dcc67288e017e4e156ae759d10ea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -90,6 +90,9 @@ khm_krb5_renew(khm_handle identity);
 wchar_t * \r
 khm_krb5_get_default_realm(void);\r
 \r
+long\r
+khm_krb5_set_default_realm(wchar_t * realm);\r
+\r
 wchar_t * \r
 khm_krb5_get_realm_list(void);\r
 \r
@@ -116,6 +119,12 @@ khm_krb5_cc_name_cmp(const wchar_t * cc_name_1,
                      const wchar_t * cc_name_2);\r
 \r
 BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname);\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname);\r
+\r
+BOOL \r
+khm_krb5_get_temp_profile_file(LPSTR confname, UINT szConfname);\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy);\r
 \r
 #endif\r
index c568e49d0365ec6fd96748c93de258f9814740b8..dd4782e6f34e18a17202f8e8162f15e7f2a19d85 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -49,6 +49,7 @@ typedef struct tag_k5_new_cred_data {
     HWND hw_realm;\r
 } k5_new_cred_data;\r
 \r
+/* Runs in the UI thread */\r
 int \r
 k5_get_realm_from_nc(khui_new_creds * nc, \r
                      wchar_t * buf, \r
@@ -118,6 +119,7 @@ set_identity_from_ui(khui_new_creds * nc,
     return;\r
 }\r
 \r
+/* runs in the UI thread */\r
 static BOOL\r
 update_crossfeed(khui_new_creds * nc,\r
                  k5_new_cred_data * d,\r
@@ -127,6 +129,7 @@ update_crossfeed(khui_new_creds * nc,
     wchar_t realm[KCDB_IDENT_MAXCCH_NAME];\r
     khm_size cch;\r
     khm_size cch_left;\r
+    int idx;\r
 \r
     cch = (khm_size) GetWindowTextLength(d->hw_username);\r
 #ifdef DEBUG\r
@@ -145,6 +148,38 @@ update_crossfeed(khui_new_creds * nc,
         return FALSE;\r
 \r
     if (ctrl_id_src == K5_NCID_UN) {\r
+\r
+        idx = (int)SendMessage(d->hw_realm,\r
+                               CB_FINDSTRINGEXACT,\r
+                               (WPARAM) -1,\r
+                               (LPARAM) un_realm);\r
+\r
+        if (idx != CB_ERR) {\r
+            wchar_t srealm[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+            cch = SendMessage(d->hw_realm,\r
+                              CB_GETLBTEXTLEN,\r
+                              (WPARAM) idx,\r
+                              0);\r
+\r
+#ifdef DEBUG\r
+            assert(cch < ARRAYLENGTH(srealm) - 1);\r
+#endif\r
+            SendMessage(d->hw_realm,\r
+                        CB_GETLBTEXT,\r
+                        (WPARAM) idx,\r
+                        (LPARAM) srealm);\r
+\r
+            if (!wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) {\r
+                /* differ only by case */\r
+\r
+                StringCchCopy(un_realm, ARRAYLENGTH(un) - (un_realm - un),\r
+                              srealm);\r
+\r
+                SetWindowText(d->hw_username, un);\r
+            }\r
+        }\r
+\r
         SendMessage(d->hw_realm,\r
                     CB_SELECTSTRING,\r
                     (WPARAM) -1,\r
@@ -170,6 +205,26 @@ update_crossfeed(khui_new_creds * nc,
     GetWindowText(d->hw_realm, realm,\r
                   ARRAYLENGTH(realm));\r
 \r
+    idx = (int)SendMessage(d->hw_realm,\r
+                           CB_FINDSTRINGEXACT,\r
+                           (WPARAM) -1,\r
+                           (LPARAM) realm);\r
+\r
+    if (idx != CB_ERR) {\r
+        wchar_t srealm[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+        SendMessage(d->hw_realm,\r
+                    CB_GETLBTEXT,\r
+                    (WPARAM) idx,\r
+                    (LPARAM) srealm);\r
+\r
+        if (!wcsicmp(srealm, realm) && wcscmp(srealm, realm)) {\r
+            StringCbCopy(realm, sizeof(realm), srealm);\r
+\r
+            SetWindowText(d->hw_realm, srealm);\r
+        }\r
+    }\r
+\r
     StringCchCopy(un_realm, cch_left, realm);\r
 \r
     SendMessage(d->hw_username,\r
@@ -258,6 +313,7 @@ ui_cb(khui_new_creds * nc,
       UINT uMsg,\r
       WPARAM wParam,\r
       LPARAM lParam) {\r
+\r
     k5_new_cred_data * d;\r
 \r
     d = (k5_new_cred_data *) nc->ident_aux;\r
@@ -285,7 +341,7 @@ ui_cb(khui_new_creds * nc,
             assert(hw_parent != NULL);\r
 #endif\r
 \r
-            d = malloc(sizeof(*d));\r
+            d = PMALLOC(sizeof(*d));\r
             assert(d);\r
             ZeroMemory(d, sizeof(*d));\r
 \r
@@ -385,7 +441,7 @@ ui_cb(khui_new_creds * nc,
             if (rv != KHM_ERROR_TOO_LONG)\r
                 goto _add_lru_realms;\r
 \r
-            ms = malloc(cb_ms);\r
+            ms = PMALLOC(cb_ms);\r
             assert(ms != NULL);\r
 \r
             cb = cb_ms;\r
@@ -430,13 +486,13 @@ ui_cb(khui_new_creds * nc,
 \r
             if (ms != NULL) {\r
                 if (cb_ms < cb) {\r
-                    free(ms);\r
-                    ms = malloc(cb);\r
+                    PFREE(ms);\r
+                    ms = PMALLOC(cb);\r
                     assert(ms);\r
                     cb_ms = cb;\r
                 }\r
             } else {\r
-                ms = malloc(cb);\r
+                ms = PMALLOC(cb);\r
                 cb_ms = cb;\r
             }\r
 \r
@@ -476,10 +532,10 @@ ui_cb(khui_new_creds * nc,
             }\r
 \r
             if (defrealm)\r
-                free(defrealm);\r
+                PFREE(defrealm);\r
 \r
             if (ms)\r
-                free(ms);\r
+                PFREE(ms);\r
 \r
             /* now see about that default identity */\r
             if (nc->ctx.identity) {\r
@@ -553,7 +609,7 @@ ui_cb(khui_new_creds * nc,
             /* since we created all the windows as child windows of\r
                the new creds window, they will be destroyed when that\r
                window is destroyed. */\r
-            free(d);\r
+            PFREE(d);\r
         }\r
         return TRUE;\r
     }\r
@@ -598,6 +654,20 @@ k5_ident_valiate_name(khm_int32 msg_type,
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
+static void\r
+k5_update_last_default_identity(khm_handle ident) {\r
+    wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+    khm_size cb;\r
+\r
+    cb = sizeof(idname);\r
+    if (KHM_FAILED(kcdb_identity_get_name(ident, idname, &cb)))\r
+        return;\r
+\r
+    assert(csp_params);\r
+\r
+    khc_write_string(csp_params, L"LastDefaultIdent", idname);\r
+}\r
+\r
 static khm_int32\r
 k5_ident_set_default(khm_int32 msg_type,\r
                      khm_int32 msg_subtype,\r
@@ -702,9 +772,10 @@ k5_ident_set_default(khm_int32 msg_type,
 \r
             RegCloseKey(hk_ccname);\r
 \r
-            if (l == ERROR_SUCCESS)\r
+            if (l == ERROR_SUCCESS) {\r
+                k5_update_last_default_identity(def_ident);\r
                 return KHM_ERROR_SUCCESS;\r
-            else\r
+            else\r
                 return KHM_ERROR_UNKNOWN;\r
 \r
         } else if (dw > ARRAYLENGTH(env_ccname)) {\r
@@ -721,8 +792,10 @@ k5_ident_set_default(khm_int32 msg_type,
 \r
             /* if the %KRB5CCNAME is the same as the identity\r
                ccache, then it is already the default. */\r
-            if (!khm_krb5_cc_name_cmp(id_ccname, env_ccname))\r
+            if (!khm_krb5_cc_name_cmp(id_ccname, env_ccname)) {\r
+                k5_update_last_default_identity(def_ident);\r
                 return KHM_ERROR_SUCCESS;\r
+            }\r
 \r
             /* if not, we have to copy the contents of id_ccname\r
                to env_ccname */\r
@@ -734,8 +807,10 @@ k5_ident_set_default(khm_int32 msg_type,
                                                 env_ccname, \r
                                                 id_ccname);\r
 \r
-            if (code == 0)\r
+            if (code == 0) {\r
+                k5_update_last_default_identity(def_ident);\r
                 khm_krb5_list_tickets(&ctx);\r
+            }\r
 \r
             if (ctx)\r
                 pkrb5_free_context(ctx);\r
@@ -784,6 +859,17 @@ k5_ident_notify_create(khm_int32 msg_type,
     khm_size cb;\r
     khm_handle ident;\r
 \r
+    /* if there is a default identity already, we assume we don't need\r
+       to check this one. */\r
+\r
+    khm_handle def_ident;\r
+\r
+    if (KHM_SUCCEEDED(kcdb_identity_get_default(&def_ident))) {\r
+        kcdb_identity_release(def_ident);\r
+\r
+        return KHM_ERROR_SUCCESS;\r
+    }\r
+\r
     ident = (khm_handle) vparam;\r
 \r
     assert(k5_identpro_ctx != NULL);\r
@@ -829,7 +915,6 @@ k5_ident_notify_create(khm_int32 msg_type,
     if (cc)\r
         pkrb5_cc_close(k5_identpro_ctx, cc);\r
 \r
-\r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
@@ -842,6 +927,7 @@ k5_ident_update_apply_proc(khm_handle cred,
     khm_int32 t;\r
     khm_int32 flags;\r
     __int64 t_expire;\r
+       __int64 t_cexpire;\r
     __int64 t_rexpire;\r
     khm_size cb;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
@@ -851,32 +937,34 @@ k5_ident_update_apply_proc(khm_handle cred,
         KHM_FAILED(kcdb_cred_get_identity(cred, &ident)))\r
         return KHM_ERROR_SUCCESS;\r
 \r
-    if (ident != tident)\r
+    if (!kcdb_identity_is_equal(ident,tident))\r
         goto _cleanup;\r
 \r
     if (KHM_FAILED(kcdb_cred_get_flags(cred, &flags)))\r
         flags = 0;\r
 \r
-    cb = sizeof(t_expire);\r
-    if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
-                                         KCDB_ATTR_EXPIRE,\r
-                                         NULL,\r
-                                         &t_expire,\r
-                                         &cb))) {\r
-        __int64 t_cexpire;\r
-\r
+    if (flags & KCDB_CRED_FLAG_INITIAL) {\r
         cb = sizeof(t_cexpire);\r
-        if ((flags & KCDB_CRED_FLAG_INITIAL) ||\r
-            KHM_FAILED(kcdb_identity_get_attr(tident,\r
-                                              KCDB_ATTR_EXPIRE,\r
-                                              NULL,\r
-                                              &t_cexpire,\r
-                                              &cb)) ||\r
-            t_cexpire > t_expire)\r
-            kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE,\r
-                                   &t_expire, sizeof(t_expire));\r
-    } else if (flags & KCDB_CRED_FLAG_INITIAL) {\r
-        kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, NULL, 0);\r
+        if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
+                                             KCDB_ATTR_EXPIRE,\r
+                                             NULL,\r
+                                             &t_cexpire,\r
+                                             &cb))) {                                                                           \r
+                t_expire = 0;\r
+                cb = sizeof(t_expire);\r
+                if (KHM_FAILED(kcdb_identity_get_attr(tident,\r
+                                                      KCDB_ATTR_EXPIRE,\r
+                                                      NULL,\r
+                                                      &t_expire,\r
+                                                      &cb)) ||\r
+                    (t_cexpire > t_expire))\r
+                    kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE,\r
+                                           &t_cexpire, sizeof(t_cexpire));\r
+        } else {\r
+            kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, NULL, 0);\r
+        }\r
+    } else {\r
+        goto _cleanup;\r
     }\r
 \r
     cb = sizeof(ccname);\r
@@ -890,16 +978,14 @@ k5_ident_update_apply_proc(khm_handle cred,
         kcdb_identity_set_attr(tident, attr_id_krb5_ccname,\r
                                NULL, 0);\r
     }\r
-\r
-    if (!(flags & KCDB_CRED_FLAG_INITIAL))\r
-        goto _cleanup;\r
-\r
+                \r
     cb = sizeof(t);\r
     if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
                                          attr_id_krb5_flags,\r
                                          NULL,\r
                                          &t,\r
                                          &cb))) {\r
+\r
         kcdb_identity_set_attr(tident, attr_id_krb5_flags, \r
                                &t, sizeof(t));\r
 \r
@@ -939,6 +1025,13 @@ k5_ident_update(khm_int32 msg_type,
                 void * vparam) {\r
 \r
     khm_handle ident;\r
+    khm_handle tident;\r
+    krb5_ccache cc = NULL;\r
+    char * ccname;\r
+    krb5_error_code code;\r
+    khm_size cb;\r
+    wchar_t wid_ccname[MAX_PATH];\r
+    wchar_t w_ccname[MAX_PATH];\r
 \r
     ident = (khm_handle) vparam;\r
     if (ident == NULL)\r
@@ -948,6 +1041,42 @@ k5_ident_update(khm_int32 msg_type,
                        k5_ident_update_apply_proc,\r
                        (void *) ident);\r
 \r
+    if (KHM_SUCCEEDED(kcdb_identity_get_default(&tident))) {\r
+        kcdb_identity_release(tident);\r
+        goto _iu_cleanup;\r
+    }\r
+\r
+    cb = sizeof(wid_ccname);\r
+    if (KHM_FAILED(kcdb_identity_get_attr(ident,\r
+                                          attr_id_krb5_ccname,\r
+                                          NULL,\r
+                                          wid_ccname,\r
+                                          &cb)))\r
+        goto _iu_cleanup;\r
+\r
+    if(k5_identpro_ctx == NULL)\r
+        goto _iu_cleanup;\r
+\r
+    code = pkrb5_cc_default(k5_identpro_ctx, &cc);\r
+    if (code)\r
+        goto _iu_cleanup;\r
+\r
+    ccname = pkrb5_cc_get_name(k5_identpro_ctx, cc);\r
+    if (ccname == NULL)\r
+        goto _iu_cleanup;\r
+\r
+    AnsiStrToUnicode(w_ccname, sizeof(w_ccname), ccname);\r
+\r
+    khm_krb5_canon_cc_name(w_ccname, sizeof(w_ccname));\r
+    khm_krb5_canon_cc_name(wid_ccname, sizeof(wid_ccname));\r
+\r
+    if (!wcsicmp(w_ccname, wid_ccname))\r
+        kcdb_identity_set_default_int(ident);\r
+\r
+ _iu_cleanup:\r
+    if (cc && k5_identpro_ctx)\r
+        pkrb5_cc_close(k5_identpro_ctx, cc);\r
+\r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
@@ -965,6 +1094,7 @@ k5_ident_init(khm_int32 msg_type,
     char * princ_nameA = NULL;\r
     wchar_t princ_nameW[KCDB_IDENT_MAXCCH_NAME];\r
     khm_handle ident = NULL;\r
+    khm_boolean found_default = FALSE;\r
 \r
     assert(k5_identpro_ctx != NULL);\r
 \r
@@ -995,6 +1125,8 @@ k5_ident_init(khm_int32 msg_type,
 \r
     kcdb_identity_set_default_int(ident);\r
 \r
+    found_default = TRUE;\r
+\r
  _nc_cleanup:\r
     if (princ_nameA)\r
         pkrb5_free_unparsed_name(k5_identpro_ctx,\r
@@ -1008,6 +1140,25 @@ k5_ident_init(khm_int32 msg_type,
     if (ident)\r
         kcdb_identity_release(ident);\r
 \r
+    if (!found_default) {\r
+        wchar_t widname[KCDB_IDENT_MAXCCH_NAME];\r
+        khm_size cb;\r
+\r
+        cb = sizeof(widname);\r
+\r
+        assert(csp_params);\r
+\r
+        if (KHM_SUCCEEDED(khc_read_string(csp_params, L"LastDefaultIdent",\r
+                                          widname, &cb))) {\r
+            ident = NULL;\r
+            kcdb_identity_create(widname, KCDB_IDENT_FLAG_CREATE, &ident);\r
+            if (ident) {\r
+                kcdb_identity_set_default_int(ident);\r
+                kcdb_identity_release(ident);\r
+            }\r
+        }\r
+    }\r
+\r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
@@ -1106,3 +1257,121 @@ k5_msg_ident(khm_int32 msg_type,
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
+\r
+khm_int32 KHMAPI\r
+k5_ident_name_comp_func(const void * dl, khm_size cb_dl,\r
+                        const void * dr, khm_size cb_dr) {\r
+    wchar_t * idl = (wchar_t *) dl;\r
+    wchar_t * idr = (wchar_t *) dr;\r
+    wchar_t * rl;\r
+    wchar_t * rr;\r
+    khm_int32 r;\r
+\r
+    rl = khm_get_realm_from_princ(idl);\r
+    rr = khm_get_realm_from_princ(idr);\r
+\r
+    if (rl == NULL && rr == NULL)\r
+        return wcscmp(idl, idr);\r
+    else if (rl == NULL)\r
+        return 1;\r
+    else if (rr == NULL)\r
+        return -1;\r
+\r
+    r = wcscmp(rl, rr);\r
+    if (r == 0)\r
+        return wcscmp(idl, idr);\r
+    else\r
+        return r;\r
+}\r
+\r
+khm_int32\r
+k5_msg_system_idpro(khm_int32 msg_type, khm_int32 msg_subtype,\r
+                    khm_ui_4 uparam, void * vparam) {\r
+\r
+    switch(msg_subtype) {\r
+    case KMSG_SYSTEM_INIT:\r
+        {\r
+\r
+            pkrb5_init_context(&k5_identpro_ctx);\r
+            kcdb_identity_set_type(credtype_id_krb5);\r
+\r
+            if (KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_PRINC, \r
+                                            &type_id_krb5_princ))) {\r
+                kcdb_type dt;\r
+                kcdb_type * pstr;\r
+\r
+                kcdb_type_get_info(KCDB_TYPE_STRING, &pstr);\r
+\r
+                ZeroMemory(&dt, sizeof(dt));\r
+                dt.name = TYPENAME_KRB5_PRINC;\r
+                dt.id = KCDB_TYPE_INVALID;\r
+                dt.flags = KCDB_TYPE_FLAG_CB_AUTO;\r
+                dt.cb_min = pstr->cb_min;\r
+                dt.cb_max = pstr->cb_max;\r
+                dt.toString = pstr->toString;\r
+                dt.isValid = pstr->isValid;\r
+                dt.comp = k5_ident_name_comp_func;\r
+                dt.dup = pstr->dup;\r
+\r
+                kcdb_type_register(&dt, &type_id_krb5_princ);\r
+\r
+                type_regd_krb5_princ = TRUE;\r
+\r
+                kcdb_type_release_info(pstr);\r
+            }\r
+\r
+            if (type_id_krb5_princ != -1) {\r
+                kcdb_attrib * attr;\r
+\r
+                kcdb_attrib_get_info(KCDB_ATTR_ID_NAME, &attr);\r
+\r
+                attr->type = type_id_krb5_princ;\r
+\r
+                kcdb_attrib_release_info(attr);\r
+            }\r
+        }\r
+        break;\r
+\r
+    case KMSG_SYSTEM_EXIT:\r
+        {\r
+            if (k5_identpro_ctx) {\r
+                pkrb5_free_context(k5_identpro_ctx);\r
+                k5_identpro_ctx = NULL;\r
+            }\r
+\r
+            if (type_id_krb5_princ != -1) {\r
+                kcdb_attrib * attr;\r
+\r
+                kcdb_attrib_get_info(KCDB_ATTR_ID_NAME, &attr);\r
+\r
+                attr->type = KCDB_TYPE_STRING;\r
+\r
+                kcdb_attrib_release_info(attr);\r
+            }\r
+\r
+            /* allow a brief moment for any stale references to die */\r
+            Sleep(100);\r
+\r
+            if (type_regd_krb5_princ) {\r
+                kcdb_type_unregister(type_id_krb5_princ);\r
+            }\r
+        }\r
+        break;\r
+    }\r
+\r
+    return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+khm_int32 KHMAPI\r
+k5_ident_callback(khm_int32 msg_type, khm_int32 msg_subtype,\r
+                  khm_ui_4 uparam, void * vparam) {\r
+    switch(msg_type) {\r
+    case KMSG_SYSTEM:\r
+        return k5_msg_system_idpro(msg_type, msg_subtype, uparam, vparam);\r
+\r
+    case KMSG_IDENT:\r
+        return k5_msg_ident(msg_type, msg_subtype, uparam, vparam);\r
+    }\r
+\r
+    return KHM_ERROR_SUCCESS;\r
+}\r
similarity index 92%
rename from src/windows/identity/plugins/krb5/main.c
rename to src/windows/identity/plugins/krb5/krb5main.c
index db996d951bafa822d17fa48c25bbd50edcd7e65f..7bf121dd0c7ab33a63cdc10f4146ccafa2d61fac 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -35,10 +35,12 @@ const wchar_t * k5_facility = L"Krb5";
 khm_int32 type_id_enctype       = -1;\r
 khm_int32 type_id_addr_list     = -1;\r
 khm_int32 type_id_krb5_flags    = -1;\r
+khm_int32 type_id_krb5_princ    = -1;\r
 \r
 BOOL type_regd_enctype      = FALSE;\r
 BOOL type_regd_addr_list    = FALSE;\r
 BOOL type_regd_krb5_flags   = FALSE;\r
+BOOL type_regd_krb5_princ   = FALSE;\r
 \r
 khm_int32 attr_id_key_enctype   = -1;\r
 khm_int32 attr_id_tkt_enctype   = -1;\r
@@ -89,13 +91,25 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
     pi.name = KRB5_PLUGIN_NAME;\r
     pi.type = KHM_PITYPE_CRED;\r
     pi.icon = NULL; /*TODO: Assign icon */\r
-    pi.flags = KHM_PIFLAG_IDENTITY_PROVIDER;\r
+    pi.flags = 0;\r
     pi.msg_proc = k5_msg_callback;\r
     pi.description = buf;\r
     LoadString(hResModule, IDS_PLUGIN_DESC,\r
                buf, ARRAYLENGTH(buf));\r
     kmm_provide_plugin(h_module, &pi);\r
 \r
+    ZeroMemory(&pi, sizeof(pi));\r
+    pi.name = KRB5_IDENTPRO_NAME;\r
+    pi.type = KHM_PITYPE_IDENT;\r
+    pi.icon = NULL;             /* ignored */\r
+    pi.flags = 0;\r
+    pi.msg_proc = k5_ident_callback;\r
+    pi.description = buf;\r
+    pi.dependencies = KRB5_PLUGIN_NAME L"\0";\r
+    LoadString(hResModule, IDS_IDENTPRO_DESC,\r
+               buf, ARRAYLENGTH(buf));\r
+    kmm_provide_plugin(h_module, &pi);\r
+\r
     if(KHM_FAILED(rv = init_imports()))\r
         goto _exit;\r
 \r
index 968e0e2903f27b0b2f424333d7ac106412fd8964..fc36d2c20e2999891a05a1788253daef5dbb18dc 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -63,7 +63,7 @@ k5_handle_wm_initdialog(HWND hwnd,
     k5_dlg_data * d;\r
     khui_new_creds_by_type * nct;\r
     \r
-    d = malloc(sizeof(*d));\r
+    d = PMALLOC(sizeof(*d));\r
     ZeroMemory(d, sizeof(*d));\r
     /* lParam is a pointer to a khui_new_creds structure */\r
     d->nc = (khui_new_creds *) lParam;\r
@@ -116,7 +116,7 @@ k5_handle_wm_destroy(HWND hwnd,
         khui_tracker_kill_controls(&d->tc_lifetime);\r
     }\r
 \r
-    free(d);\r
+    PFREE(d);\r
 \r
     return TRUE;\r
 }\r
@@ -200,7 +200,7 @@ k5_handle_wmnc_notify(HWND hwnd,
                 break;\r
 \r
             if(nct->credtext)\r
-                free(nct->credtext);\r
+                PFREE(nct->credtext);\r
             nct->credtext = NULL;\r
 \r
             tbuf[0] = L'\0';\r
@@ -227,7 +227,7 @@ k5_handle_wmnc_notify(HWND hwnd,
                 StringCbLength(sbuf, sizeof(sbuf), &cbsize);\r
                 cbsize += sizeof(wchar_t);\r
 \r
-                nct->credtext = malloc(cbsize);\r
+                nct->credtext = PMALLOC(cbsize);\r
 \r
                 StringCbCopy(nct->credtext, cbsize, sbuf);\r
             } else if (nc->n_identities > 0 &&\r
@@ -242,7 +242,7 @@ k5_handle_wmnc_notify(HWND hwnd,
                 StringCbLength(sbuf, sizeof(sbuf), &cbsize);\r
                 cbsize += sizeof(wchar_t);\r
 \r
-                nct->credtext = malloc(cbsize);\r
+                nct->credtext = PMALLOC(cbsize);\r
 \r
                 StringCbCopy(nct->credtext, cbsize, sbuf);\r
             } else {\r
@@ -251,7 +251,7 @@ k5_handle_wmnc_notify(HWND hwnd,
                                    &cbsize);\r
                     cbsize += sizeof(wchar_t);\r
 \r
-                    nct->credtext = malloc(cbsize);\r
+                    nct->credtext = PMALLOC(cbsize);\r
 \r
                     StringCbCopy(nct->credtext, cbsize, d->cred_message);\r
                 }\r
@@ -1131,7 +1131,7 @@ k5_prep_kinit_job(khui_new_creds * nc)
     g_fjob.nc = nc;\r
     g_fjob.nct = nct;\r
     g_fjob.dialog = nct->hwnd_panel;\r
-    g_fjob.principal = malloc(size);\r
+    g_fjob.principal = PMALLOC(size);\r
     UnicodeStrToAnsi(g_fjob.principal, size, idname);\r
     g_fjob.password = NULL;\r
     g_fjob.lifetime = (krb5_deltat) d->tc_lifetime.current;\r
@@ -1155,7 +1155,7 @@ k5_prep_kinit_job(khui_new_creds * nc)
             SUCCEEDED(StringCchLength(pdlginfo->in.ccache,\r
                                       NETID_CCACHE_NAME_SZ,\r
                                       &size))) {\r
-            g_fjob.ccache = malloc(sizeof(char) * (size + 1));\r
+            g_fjob.ccache = PMALLOC(sizeof(char) * (size + 1));\r
 #ifdef DEBUG\r
             assert(g_fjob.ccache);\r
 #endif\r
@@ -1210,16 +1210,16 @@ void
 k5_free_kinit_job(void)\r
 {\r
     if (g_fjob.principal)\r
-        free(g_fjob.principal);\r
+        PFREE(g_fjob.principal);\r
 \r
     if (g_fjob.password)\r
-        free(g_fjob.password);\r
+        PFREE(g_fjob.password);\r
 \r
     if (g_fjob.identity)\r
         kcdb_identity_release(g_fjob.identity);\r
 \r
     if (g_fjob.ccache)\r
-        free(g_fjob.ccache);\r
+        PFREE(g_fjob.ccache);\r
 \r
     ZeroMemory(&g_fjob, sizeof(g_fjob));\r
 }\r
@@ -1272,7 +1272,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
 \r
             nc = (khui_new_creds *) vparam;\r
 \r
-            nct = malloc(sizeof(*nct));\r
+            nct = PMALLOC(sizeof(*nct));\r
             ZeroMemory(nct, sizeof(*nct));\r
 \r
             nct->type = credtype_id_krb5;\r
@@ -1283,7 +1283,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
             StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
             cbsize += sizeof(wchar_t);\r
 \r
-            nct->name = malloc(cbsize);\r
+            nct->name = PMALLOC(cbsize);\r
             StringCbCopy(nct->name, cbsize, wbuf);\r
 \r
             nct->h_module = hResModule;\r
@@ -1304,7 +1304,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
 \r
             nc = (khui_new_creds *) vparam;\r
 \r
-            nct = malloc(sizeof(*nct));\r
+            nct = PMALLOC(sizeof(*nct));\r
             ZeroMemory(nct, sizeof(*nct));\r
 \r
             nct->type = credtype_id_krb5;\r
@@ -1350,7 +1350,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                                            0, (LPARAM) t);\r
                         t = multi_string_next(t);\r
                     }\r
-                    free(realms);\r
+                    PFREE(realms);\r
                 }\r
 \r
                 /* and set the default realm */\r
@@ -1364,7 +1364,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                     SendDlgItemMessage(hwnd, IDC_NCK5_REALM, \r
                                        WM_SETTEXT, \r
                                        0, (LPARAM) defrealm);\r
-                    free(defrealm);\r
+                    PFREE(defrealm);\r
                 }\r
             } else {            /* if krb5 is the identity provider */\r
                 HWND hw_realms;\r
@@ -1526,14 +1526,15 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                        password */\r
                     if(g_fjob.code) {\r
                         if (is_k5_identpro)\r
-                            kcdb_identity_set_flags(ident, \r
+                            kcdb_identity_set_flags(ident,\r
+                                                    KCDB_IDENT_FLAG_INVALID,\r
                                                     KCDB_IDENT_FLAG_INVALID);\r
 \r
                         khui_cw_clear_prompts(nc);\r
                     }\r
 \r
                     if (d->cred_message) {\r
-                        free(d->cred_message);\r
+                        PFREE(d->cred_message);\r
                         d->cred_message = NULL;\r
                     }\r
 \r
@@ -1576,7 +1577,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                         StringCbLength(msg, sizeof(msg), &cb);\r
                         cb += sizeof(wchar_t);\r
 \r
-                        d->cred_message = malloc(cb);\r
+                        d->cred_message = PMALLOC(cb);\r
                         StringCbCopy(d->cred_message, cb, msg);\r
                     }\r
 \r
@@ -1587,6 +1588,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
 \r
                     if(is_k5_identpro)\r
                         kcdb_identity_set_flags(ident, \r
+                                                KCDB_IDENT_FLAG_VALID,\r
                                                 KCDB_IDENT_FLAG_VALID);\r
                 } else {\r
                     /* huh?? */\r
@@ -1688,12 +1690,12 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                     (nc->n_identities == 0 ||\r
                      nc->identities[0] == NULL ||\r
                      KHM_SUCCEEDED(kcdb_credset_find_filtered\r
-                                 (NULL,\r
-                                  -1,\r
-                                  k5_find_tgt_filter,\r
-                                  nc->identities[0],\r
-                                  NULL,\r
-                                  NULL))))\r
+                                   (NULL,\r
+                                    -1,\r
+                                    k5_find_tgt_filter,\r
+                                    nc->identities[0],\r
+                                    NULL,\r
+                                    NULL))))\r
                     g_fjob.code = 0;\r
 \r
 \r
@@ -1776,7 +1778,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                                                 &cb);\r
                     assert(rv == KHM_ERROR_TOO_LONG);\r
 \r
-                    idname = malloc(cb);\r
+                    idname = PMALLOC(cb);\r
                     assert(idname);\r
 \r
                     rv = kcdb_identity_get_name(nc->identities[0],\r
@@ -1793,7 +1795,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                     else\r
                         cb_ms += cb + sizeof(wchar_t);\r
 \r
-                    wbuf = malloc(cb_ms);\r
+                    wbuf = PMALLOC(cb_ms);\r
                     assert(wbuf);\r
 \r
                     cb = cb_ms;\r
@@ -1838,8 +1840,8 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                                                &cb);\r
 \r
                     if (rv == KHM_ERROR_TOO_LONG) {\r
-                        free(wbuf);\r
-                        wbuf = malloc(cb);\r
+                        PFREE(wbuf);\r
+                        wbuf = PMALLOC(cb);\r
                         assert(wbuf);\r
 \r
                         cb_ms = cb;\r
@@ -1886,10 +1888,10 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                         pkrb5_free_context(ctx);\r
 \r
                     if (idname)\r
-                        free(idname);\r
+                        PFREE(idname);\r
 \r
                     if (wbuf)\r
-                        free(wbuf);\r
+                        PFREE(wbuf);\r
                 } else if (g_fjob.state == FIBER_STATE_NONE) {\r
                     /* the user cancelled the operation */\r
                     r = KHUI_NC_RESPONSE_EXIT | \r
@@ -1921,6 +1923,12 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                 _end_task();\r
             } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
 \r
+                __int64 ftidexp = 0;\r
+                __int64 ftcurrent;\r
+                khm_size cb;\r
+\r
+                GetSystemTimeAsFileTime((LPFILETIME) &ftcurrent);\r
+\r
                 _begin_task(0);\r
                 _report_mr0(KHERR_NONE, MSG_CTX_RENEW_CREDS);\r
                 _describe();\r
@@ -1930,10 +1938,20 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                      nc->ctx.cred_type == credtype_id_krb5)) {\r
                     int code;\r
 \r
-                    if (nc->ctx.identity != 0)\r
+                    if (nc->ctx.identity != 0) {\r
+                        /* get the current identity expiration time */\r
+                        cb = sizeof(ftidexp);\r
+\r
+                        kcdb_identity_get_attr(nc->ctx.identity,\r
+                                               KCDB_ATTR_EXPIRE,\r
+                                               NULL,\r
+                                               &ftidexp,\r
+                                               &cb);\r
+\r
                         code = khm_krb5_renew(nc->ctx.identity);\r
-                    else\r
+                    } else {\r
                         code = 1; /* it just has to be non-zero */\r
+                    }\r
 \r
                     if (code == 0) {\r
                         khui_cw_set_response(nc, credtype_id_krb5, \r
@@ -1946,6 +1964,29 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                         khui_cw_set_response(nc, credtype_id_krb5, \r
                                              KHUI_NC_RESPONSE_EXIT | \r
                                              KHUI_NC_RESPONSE_FAILED);\r
+                    } else if (ftcurrent < ftidexp) {\r
+                        wchar_t tbuf[1024];\r
+                        DWORD suggestion;\r
+                        kherr_suggestion sug_id;\r
+\r
+                        /* if we failed to get new tickets, but the\r
+                           identity isstill valid, then we assume that\r
+                           the current tickets are still good enough\r
+                           for other credential types to obtain their\r
+                           credentials. */\r
+\r
+                        khm_err_describe(code, tbuf, sizeof(tbuf),\r
+                                         &suggestion, &sug_id);\r
+\r
+                        _report_cs0(KHERR_WARNING, tbuf);\r
+                        if (suggestion)\r
+                            _suggest_mr(suggestion, sug_id);\r
+\r
+                        _resolve();\r
+\r
+                        khui_cw_set_response(nc, credtype_id_krb5, \r
+                                             KHUI_NC_RESPONSE_EXIT |\r
+                                             KHUI_NC_RESPONSE_SUCCESS);\r
                     } else {\r
                         wchar_t tbuf[1024];\r
                         DWORD suggestion;\r
@@ -2049,14 +2090,14 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                     }\r
 \r
                     if (wcscmp(wnpwd, wnpwd2)) {\r
-                        rv = KHM_ERROR_INVALID_PARM;\r
+                        rv = KHM_ERROR_INVALID_PARAM;\r
                         _report_mr0(KHERR_ERROR, MSG_PWD_NOT_SAME);\r
                         _suggest_mr(MSG_PWD_S_NOT_SAME, KHERR_SUGGEST_INTERACT);\r
                         goto _pwd_exit;\r
                     }\r
 \r
                     if (!wcscmp(wpwd, wnpwd)) {\r
-                        rv = KHM_ERROR_INVALID_PARM;\r
+                        rv = KHM_ERROR_INVALID_PARAM;\r
                         _report_mr0(KHERR_ERROR, MSG_PWD_SAME);\r
                         _suggest_mr(MSG_PWD_S_SAME, KHERR_SUGGEST_INTERACT);\r
                         goto _pwd_exit;\r
@@ -2082,7 +2123,7 @@ k5_msg_cred_dialog(khm_int32 msg_type,
 \r
                         StringCchLengthA(result, KHERR_MAXCCH_STRING,\r
                                          &len);\r
-                        wresult = malloc((len + 1) * sizeof(wchar_t));\r
+                        wresult = PMALLOC((len + 1) * sizeof(wchar_t));\r
 #ifdef DEBUG\r
                         assert(wresult);\r
 #endif\r
@@ -2092,8 +2133,8 @@ k5_msg_cred_dialog(khm_int32 msg_type,
                         _report_cs1(KHERR_ERROR, L"%1!s!", _cstr(wresult));\r
                         _resolve();\r
 \r
-                        free(result);\r
-                        free(wresult);\r
+                        PFREE(result);\r
+                        PFREE(wresult);\r
 \r
                         /* leave wresult.  It will get freed when the\r
                            reported event is freed. */\r
@@ -2149,10 +2190,12 @@ k5_msg_cred_dialog(khm_int32 msg_type,
 \r
             khui_cw_del_type(nc, credtype_id_krb5);\r
     \r
-            if(nct->name)\r
-                free(nct->name);\r
+            if (nct->name)\r
+                PFREE(nct->name);\r
+            if (nct->credtext)\r
+                PFREE(nct->credtext);\r
 \r
-            free(nct);\r
+            PFREE(nct);\r
         }\r
         break;\r
 \r
index 4b53ed3e8fb773c0ca60db537375bc19b951f8fc..ecfde2f5a70a12c4599c37828b8317f1107f1414 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -47,91 +47,90 @@ krb5_context k5_identpro_ctx = NULL;
 /*  The system message handler.\r
 \r
     Runs in the context of the plugin thread */\r
-khm_int32 KHMAPI k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, \r
+              khm_ui_4 uparam, void * vparam)\r
 {\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     switch(msg_subtype) {\r
-        case KMSG_SYSTEM_INIT:\r
-            {\r
-                kcdb_credtype ct;\r
-                wchar_t buf[KCDB_MAXCCH_SHORT_DESC];\r
-                size_t cbsize;\r
-\r
-                /* perform critical registrations and initialization\r
-                   stuff */\r
-                ZeroMemory(&ct, sizeof(ct));\r
-                ct.id = KCDB_CREDTYPE_AUTO;\r
-                ct.name = KRB5_CREDTYPE_NAME;\r
-\r
-                if(LoadString(hResModule, IDS_KRB5_SHORT_DESC, buf, ARRAYLENGTH(buf)))\r
-                {\r
-                    StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
-                    cbsize += sizeof(wchar_t);\r
-                    ct.short_desc = malloc(cbsize);\r
-                    StringCbCopy(ct.short_desc, cbsize, buf);\r
-                }\r
-\r
-                /* even though ideally we should be setting limits\r
-                    based KCDB_MAXCB_LONG_DESC, our long description\r
-                    actually fits nicely in KCDB_MAXCB_SHORT_DESC */\r
-                if(LoadString(hResModule, IDS_KRB5_LONG_DESC, buf, ARRAYLENGTH(buf)))\r
-                {\r
-                    StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
-                    cbsize += sizeof(wchar_t);\r
-                    ct.long_desc = malloc(cbsize);\r
-                    StringCbCopy(ct.long_desc, cbsize, buf);\r
-                }\r
+    case KMSG_SYSTEM_INIT:\r
+        {\r
+            kcdb_credtype ct;\r
+            wchar_t buf[KCDB_MAXCCH_SHORT_DESC];\r
+            size_t cbsize;\r
+\r
+            /* perform critical registrations and initialization\r
+               stuff */\r
+            ZeroMemory(&ct, sizeof(ct));\r
+            ct.id = KCDB_CREDTYPE_AUTO;\r
+            ct.name = KRB5_CREDTYPE_NAME;\r
+\r
+            if(LoadString(hResModule, IDS_KRB5_SHORT_DESC, \r
+                          buf, ARRAYLENGTH(buf))) {\r
+                StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
+                cbsize += sizeof(wchar_t);\r
+                ct.short_desc = PMALLOC(cbsize);\r
+                StringCbCopy(ct.short_desc, cbsize, buf);\r
+            }\r
 \r
-                ct.icon = NULL; /* TODO: set a proper icon */\r
+            /* even though ideally we should be setting limits\r
+               based KCDB_MAXCB_LONG_DESC, our long description\r
+               actually fits nicely in KCDB_MAXCB_SHORT_DESC */\r
+            if(LoadString(hResModule, IDS_KRB5_LONG_DESC, \r
+                          buf, ARRAYLENGTH(buf))) {\r
+                StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
+                cbsize += sizeof(wchar_t);\r
+                ct.long_desc = PMALLOC(cbsize);\r
+                StringCbCopy(ct.long_desc, cbsize, buf);\r
+            }\r
 \r
-                kmq_create_subscription(k5_msg_callback, &ct.sub);\r
+            ct.icon = NULL; /* TODO: set a proper icon */\r
 \r
-                rv = kcdb_credtype_register(&ct, &credtype_id_krb5);\r
+            kmq_create_subscription(k5_msg_callback, &ct.sub);\r
 \r
-                if(KHM_SUCCEEDED(rv))\r
-                    rv = kcdb_credset_create(&krb5_credset);\r
+            ct.is_equal = khm_krb5_creds_is_equal;\r
 \r
-                if(ct.short_desc)\r
-                    free(ct.short_desc);\r
+            rv = kcdb_credtype_register(&ct, &credtype_id_krb5);\r
 \r
-                if(ct.long_desc)\r
-                    free(ct.long_desc);\r
+            if(KHM_SUCCEEDED(rv))\r
+                rv = kcdb_credset_create(&krb5_credset);\r
 \r
-                if (is_k5_identpro)\r
-                    kcdb_identity_set_type(credtype_id_krb5);\r
+            if(ct.short_desc)\r
+                PFREE(ct.short_desc);\r
 \r
-                if(KHM_SUCCEEDED(rv)) {\r
-                    krb5_context ctx = NULL;\r
+            if(ct.long_desc)\r
+                PFREE(ct.long_desc);\r
 \r
-                    krb5_initialized = TRUE;\r
+            if(KHM_SUCCEEDED(rv)) {\r
+                krb5_context ctx = NULL;\r
 \r
-                    khm_krb5_list_tickets(&ctx);\r
+                krb5_initialized = TRUE;\r
 \r
-                    if(ctx != NULL)\r
-                        pkrb5_free_context(ctx);\r
+                if(ctx != NULL)\r
+                    pkrb5_free_context(ctx);\r
 \r
-                    /* now convert this thread to a fiber and create a\r
-                       separate fiber to do kinit stuff */\r
-                    k5_main_fiber = ConvertThreadToFiber(NULL);\r
-                    k5_kinit_fiber = CreateFiber(0,k5_kinit_fiber_proc,NULL);\r
+                /* now convert this thread to a fiber and create a\r
+                   separate fiber to do kinit stuff */\r
+                k5_main_fiber = ConvertThreadToFiber(NULL);\r
+                k5_kinit_fiber = CreateFiber(0,k5_kinit_fiber_proc,NULL);\r
 \r
-                    ZeroMemory(&g_fjob, sizeof(g_fjob));\r
+                ZeroMemory(&g_fjob, sizeof(g_fjob));\r
 \r
-                    kmq_create_subscription(k5_msg_callback, &k5_sub);\r
+                kmq_create_subscription(k5_msg_callback, &k5_sub);\r
 \r
-                    pkrb5_init_context(&k5_identpro_ctx);\r
+                k5_register_config_panels();\r
 \r
-                    k5_register_config_panels();\r
-                }\r
+                khm_krb5_list_tickets(&ctx);\r
             }\r
-            break;\r
+        }\r
+        break;\r
 \r
-        case KMSG_SYSTEM_EXIT:\r
+    case KMSG_SYSTEM_EXIT:\r
 \r
-            k5_unregister_config_panels();\r
+        k5_unregister_config_panels();\r
 \r
-            if(credtype_id_krb5 >= 0)\r
+        if(credtype_id_krb5 >= 0)\r
             {\r
                 /* basically just unregister the credential type */\r
                 kcdb_credtype_unregister(credtype_id_krb5);\r
@@ -141,22 +140,19 @@ khm_int32 KHMAPI k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui
                 krb5_credset = NULL;\r
             }\r
 \r
-            if(k5_main_fiber != NULL) {\r
-                ConvertFiberToThread();\r
-                k5_main_fiber = NULL;\r
-            }\r
+        if(k5_main_fiber != NULL) {\r
+#if (_WIN32_WINNT >= 0x0501)\r
+            ConvertFiberToThread();\r
+#endif\r
+            k5_main_fiber = NULL;\r
+        }\r
 \r
-            if(k5_sub != NULL) {\r
-                kmq_delete_subscription(k5_sub);\r
-                k5_sub = NULL;\r
-            }\r
+        if(k5_sub != NULL) {\r
+            kmq_delete_subscription(k5_sub);\r
+            k5_sub = NULL;\r
+        }\r
 \r
-            if (k5_identpro_ctx) {\r
-                pkrb5_free_context(k5_identpro_ctx);\r
-                k5_identpro_ctx = NULL;\r
-            }\r
-\r
-            break;\r
+        break;\r
     }\r
 \r
     return rv;\r
@@ -167,45 +163,47 @@ khm_int32 KHMAPI k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui
 \r
     Runs in the context of the Krb5 plugin\r
 */\r
-khm_int32 KHMAPI k5_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype, \r
+            khm_ui_4 uparam, void * vparam)\r
 {\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     switch(msg_subtype) {\r
-        case KMSG_CRED_REFRESH:\r
-            {\r
-                krb5_context ctx = NULL;\r
+    case KMSG_CRED_REFRESH:\r
+        {\r
+            krb5_context ctx = NULL;\r
 \r
-                khm_krb5_list_tickets(&ctx);\r
+            khm_krb5_list_tickets(&ctx);\r
 \r
-                if(ctx != NULL)\r
-                    pkrb5_free_context(ctx);\r
-            }\r
-            break;\r
+            if(ctx != NULL)\r
+                pkrb5_free_context(ctx);\r
+        }\r
+        break;\r
 \r
-        case KMSG_CRED_DESTROY_CREDS:\r
-            {\r
-                khui_action_context * ctx;\r
+    case KMSG_CRED_DESTROY_CREDS:\r
+        {\r
+            khui_action_context * ctx;\r
 \r
-                ctx = (khui_action_context *) vparam;\r
+            ctx = (khui_action_context *) vparam;\r
                 \r
-                if (ctx->credset)\r
-                    khm_krb5_destroy_by_credset(ctx->credset);\r
-            }\r
-            break;\r
-\r
-        case KMSG_CRED_PP_BEGIN:\r
-            k5_pp_begin((khui_property_sheet *) vparam);\r
-            break;\r
-\r
-        case KMSG_CRED_PP_END:\r
-            k5_pp_end((khui_property_sheet *) vparam);\r
-            break;\r
-\r
-        default:\r
-            if(IS_CRED_ACQ_MSG(msg_subtype))\r
-                return k5_msg_cred_dialog(msg_type, msg_subtype, \r
-                                            uparam, vparam);\r
+            if (ctx->credset)\r
+                khm_krb5_destroy_by_credset(ctx->credset);\r
+        }\r
+        break;\r
+\r
+    case KMSG_CRED_PP_BEGIN:\r
+        k5_pp_begin((khui_property_sheet *) vparam);\r
+        break;\r
+\r
+    case KMSG_CRED_PP_END:\r
+        k5_pp_end((khui_property_sheet *) vparam);\r
+        break;\r
+\r
+    default:\r
+        if(IS_CRED_ACQ_MSG(msg_subtype))\r
+            return k5_msg_cred_dialog(msg_type, msg_subtype, \r
+                                      uparam, vparam);\r
     }\r
 \r
     return rv;\r
@@ -216,15 +214,15 @@ khm_int32 KHMAPI k5_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4
 \r
     Runs in the context of the Krb5 plugin\r
 */\r
-khm_int32 KHMAPI k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, \r
+                khm_ui_4 uparam, void * vparam)\r
 {\r
     switch(msg_type) {\r
-        case KMSG_SYSTEM:\r
-            return k5_msg_system(msg_type, msg_subtype, uparam, vparam);\r
-        case KMSG_CRED:\r
-            return k5_msg_cred(msg_type, msg_subtype, uparam, vparam);\r
-        case KMSG_IDENT:\r
-            return k5_msg_ident(msg_type, msg_subtype, uparam, vparam);\r
+    case KMSG_SYSTEM:\r
+        return k5_msg_system(msg_type, msg_subtype, uparam, vparam);\r
+    case KMSG_CRED:\r
+        return k5_msg_cred(msg_type, msg_subtype, uparam, vparam);\r
     }\r
     return KHM_ERROR_SUCCESS;\r
 }\r
index 9134de2925527de12f608182717e8db8391d1a8d..0d8d27276e4ceda7eae3ed37b7852e8d50120b25 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -30,6 +30,9 @@
 #include<commctrl.h>\r
 #include<strsafe.h>\r
 #include<krb5.h>\r
+#ifdef DEBUG\r
+#include<assert.h>\r
+#endif\r
 \r
 /* Property page\r
 \r
@@ -42,44 +45,99 @@ INT_PTR CALLBACK krb5_pp_proc(HWND hwnd,
     ) \r
 {\r
     switch(uMsg) {\r
-        case WM_INITDIALOG:\r
-            {\r
-                khui_property_sheet * s;\r
-                PROPSHEETPAGE * p;\r
-                wchar_t buf[512];\r
-                khm_size cbsize;\r
-\r
-                p = (PROPSHEETPAGE *) lParam;\r
-                s = (khui_property_sheet *) p->lParam;\r
+    case WM_INITDIALOG:\r
+        {\r
+            khui_property_sheet * s;\r
+            PROPSHEETPAGE * p;\r
+            wchar_t buf[512];\r
+            wchar_t unavailable[64];\r
+            khm_size cbsize;\r
+            khm_int32 rv;\r
+            khm_int32 tflags;\r
+\r
+            p = (PROPSHEETPAGE *) lParam;\r
+            s = (khui_property_sheet *) p->lParam;\r
 \r
 #pragma warning(push)\r
 #pragma warning(disable: 4244)\r
-                SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);\r
+            SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);\r
 #pragma warning(pop)\r
 \r
-                if(s->cred) {\r
-                    cbsize = sizeof(buf);\r
-                    kcdb_cred_get_name(s->cred, buf, &cbsize);\r
-                    SetDlgItemText(hwnd, IDC_PPK5_NAME, buf);\r
+            LoadString(hResModule, IDS_UNAVAILABLE,\r
+                       unavailable, ARRAYLENGTH(unavailable));\r
 \r
-                    cbsize = sizeof(buf);\r
-                    kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_ISSUE, buf, &cbsize, 0);\r
-                    SetDlgItemText(hwnd, IDC_PPK5_ISSUE, buf);\r
+            if(s->cred) {\r
+                cbsize = sizeof(buf);\r
+                kcdb_cred_get_name(s->cred, buf, &cbsize);\r
+                SetDlgItemText(hwnd, IDC_PPK5_NAME, buf);\r
 \r
-                    cbsize = sizeof(buf);\r
-                    kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_EXPIRE, buf, &cbsize, 0);\r
+                cbsize = sizeof(buf);\r
+                rv = kcdb_cred_get_attr_string(s->cred, \r
+                                               KCDB_ATTR_ISSUE, \r
+                                               buf, &cbsize, 0);\r
+                if (KHM_SUCCEEDED(rv))\r
+                    SetDlgItemText(hwnd, IDC_PPK5_ISSUE, buf);\r
+                else\r
+                    SetDlgItemText(hwnd, IDC_PPK5_ISSUE, unavailable);\r
+\r
+                cbsize = sizeof(buf);\r
+                rv = kcdb_cred_get_attr_string(s->cred, \r
+                                               KCDB_ATTR_EXPIRE, \r
+                                               buf, &cbsize, 0);\r
+                if (KHM_SUCCEEDED(rv))\r
                     SetDlgItemText(hwnd, IDC_PPK5_VALID, buf);\r
-\r
-                    cbsize = sizeof(buf);\r
-                    kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_RENEW_EXPIRE, buf, &cbsize, 0);\r
+                else\r
+                    SetDlgItemText(hwnd, IDC_PPK5_VALID, unavailable);\r
+\r
+                cbsize = sizeof(buf);\r
+                rv = kcdb_cred_get_attr_string(s->cred, \r
+                                               KCDB_ATTR_RENEW_EXPIRE, \r
+                                               buf, &cbsize, 0);\r
+                if (KHM_SUCCEEDED(rv))\r
                     SetDlgItemText(hwnd, IDC_PPK5_RENEW, buf);\r
+                else\r
+                    SetDlgItemText(hwnd, IDC_PPK5_RENEW, unavailable);\r
+\r
+                tflags = 0;\r
+                cbsize = sizeof(tflags);\r
+                rv = kcdb_cred_get_attr(s->cred,\r
+                                        attr_id_krb5_flags,\r
+                                        NULL,\r
+                                        &tflags,\r
+                                        &cbsize);\r
+                if (KHM_SUCCEEDED(rv)) {\r
+\r
+#define ADDBITFLAG(f,s) \\r
+   if (tflags & f) {    \\r
+     LoadString(hResModule, s, buf, ARRAYLENGTH(buf)); \\r
+     SendDlgItemMessage(hwnd, IDC_PPK5_FLAGS, LB_ADDSTRING, 0, (LPARAM) buf); \\r
+   }\r
+\r
+                    ADDBITFLAG(TKT_FLG_FORWARDABLE, IDS_FLG_FORWARDABLE);\r
+                    ADDBITFLAG(TKT_FLG_FORWARDED, IDS_FLG_FORWARDED);\r
+                    ADDBITFLAG(TKT_FLG_PROXIABLE, IDS_FLG_PROXIABLE);\r
+                    ADDBITFLAG(TKT_FLG_PROXY, IDS_FLG_PROXY);\r
+                    ADDBITFLAG(TKT_FLG_MAY_POSTDATE, IDS_FLG_MAY_POSTDATE);\r
+                    ADDBITFLAG(TKT_FLG_POSTDATED, IDS_FLG_POSTDATED);\r
+                    ADDBITFLAG(TKT_FLG_INVALID, IDS_FLG_INVALID);\r
+                    ADDBITFLAG(TKT_FLG_RENEWABLE, IDS_FLG_RENEWABLE);\r
+                    ADDBITFLAG(TKT_FLG_INITIAL, IDS_FLG_INITIAL);\r
+                    ADDBITFLAG(TKT_FLG_PRE_AUTH, IDS_FLG_PRE_AUTH);\r
+                    ADDBITFLAG(TKT_FLG_HW_AUTH, IDS_FLG_HW_AUTH);\r
+                    ADDBITFLAG(TKT_FLG_TRANSIT_POLICY_CHECKED, IDS_FLG_TRANSIT_POL);\r
+                    ADDBITFLAG(TKT_FLG_OK_AS_DELEGATE, IDS_FLG_OK_DELEGATE);\r
+                    ADDBITFLAG(TKT_FLG_ANONYMOUS, IDS_FLG_ANONYMOUS);\r
+\r
+#undef ADDBITFLAG\r
 \r
-                    /*TODO: select other properties */\r
-                } else {\r
-                    /*TODO: select properties */\r
                 }\r
+            } else {\r
+#ifdef DEBUG\r
+                assert(FALSE);\r
+#endif\r
             }\r
-            return FALSE;\r
+        }\r
+        return FALSE;\r
     }\r
 \r
     return FALSE;\r
@@ -89,14 +147,15 @@ void k5_pp_begin(khui_property_sheet * s)
 {\r
     PROPSHEETPAGE *p;\r
 \r
-    if(s->credtype == credtype_id_krb5) {\r
-        p = malloc(sizeof(*p));\r
+    if(s->credtype == credtype_id_krb5 &&\r
+       s->cred) {\r
+        p = PMALLOC(sizeof(*p));\r
         ZeroMemory(p, sizeof(*p));\r
 \r
         p->dwSize = sizeof(*p);\r
         p->dwFlags = 0;\r
         p->hInstance = hResModule;\r
-        p->pszTemplate = (s->cred)? MAKEINTRESOURCE(IDD_PP_KRB5C): MAKEINTRESOURCE(IDD_PP_KRB5);\r
+        p->pszTemplate = MAKEINTRESOURCE(IDD_PP_KRB5C);\r
         p->pfnDlgProc = krb5_pp_proc;\r
         p->lParam = (LPARAM) s;\r
         khui_ps_add_page(s, credtype_id_krb5, 0, p, NULL);\r
@@ -110,7 +169,7 @@ void k5_pp_end(khui_property_sheet * s)
     khui_ps_find_page(s, credtype_id_krb5, &p);\r
     if(p) {\r
         if(p->p_page)\r
-            free(p->p_page);\r
+            PFREE(p->p_page);\r
         p->p_page = NULL;\r
     }\r
 }\r
index b892531afc9b36f911837601e86817c9a4396651..7be0f8e26010ca9d2532b16b26a4bd77901d6352 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -178,8 +178,8 @@ make_postfix(
 \r
     base_size = strlen(base) + 1;\r
     ret_size = base_size + strlen(postfix) + 1;\r
-    copy = malloc(base_size);\r
-    ret = malloc(ret_size);\r
+    copy = PMALLOC(base_size);\r
+    ret = PMALLOC(ret_size);\r
 \r
     if (!copy || !ret)\r
         goto cleanup;\r
@@ -194,9 +194,9 @@ make_postfix(
  cleanup:\r
     if (!copy || !ret) {\r
         if (copy)\r
-            free(copy);\r
+            PFREE(copy);\r
         if (ret)\r
-            free(ret);\r
+            PFREE(ret);\r
         copy = ret = 0;\r
     }\r
     // INVARIANT: (ret ==> copy) && (copy ==> ret)\r
@@ -218,7 +218,7 @@ make_temp_cache_v4(
     if (old_cache) {\r
         pdest_tkt();\r
         pkrb_set_tkt_string(old_cache);\r
-        free(old_cache);\r
+        PFREE(old_cache);\r
         old_cache = 0;\r
     }\r
 \r
@@ -230,7 +230,7 @@ make_temp_cache_v4(
             return KFAILURE;\r
 \r
         pkrb_set_tkt_string(tmp_cache);\r
-        free(tmp_cache);\r
+        PFREE(tmp_cache);\r
     }\r
     return 0;\r
 }\r
@@ -259,7 +259,7 @@ make_temp_cache_v5(
         if (!pkrb5_cc_resolve(ctx, pkrb5_cc_default_name(ctx), &cc))\r
             pkrb5_cc_destroy(ctx, cc);\r
         pkrb5_cc_set_default_name(ctx, old_cache);\r
-        free(old_cache);\r
+        PFREE(old_cache);\r
         old_cache = 0;\r
     }\r
     if (ctx) {\r
@@ -291,7 +291,7 @@ make_temp_cache_v5(
             ctx = 0;\r
         }\r
         if (tmp_cache)\r
-            free(tmp_cache);\r
+            PFREE(tmp_cache);\r
         if (pctx)\r
             *pctx = ctx;\r
         return rc;\r
@@ -408,7 +408,7 @@ Leash_changepwd_v5(char * principal,
            (result_string.length ? (sizeof(": ") - 1) : 0) +\r
            result_string.length;\r
        if (len && error_str) {\r
-           *error_str = malloc(len + 1);\r
+           *error_str = PMALLOC(len + 1);\r
            if (*error_str)\r
                _snprintf(*error_str, len + 1,\r
                          "%.*s%s%.*s",\r
@@ -516,7 +516,7 @@ Leash_int_changepwd(
         if (v4_error_str)\r
             len += sizeof(sep) + sizeof(v4_prefix) + strlen(v4_error_str) + \r
                 sizeof(sep);\r
-        error_str = malloc(len + 1);\r
+        error_str = PMALLOC(len + 1);\r
         if (error_str) {\r
             char* p = error_str;\r
             int size = len + 1;\r
@@ -1019,27 +1019,27 @@ not_an_API_LeashFreeTicketList(TicketList** ticketList)
         killList = tempList;\r
            \r
         tempList = (TicketList*)tempList->next;\r
-        free(killList->theTicket);\r
+        PFREE(killList->theTicket);\r
         if (killList->tktEncType)\r
-            free(killList->tktEncType);\r
+            PFREE(killList->tktEncType);\r
         if (killList->keyEncType)\r
-            free(killList->keyEncType);\r
+            PFREE(killList->keyEncType);\r
         if (killList->addrCount) {\r
             int n;\r
             for ( n=0; n<killList->addrCount; n++) {\r
                 if (killList->addrList[n])\r
-                    free(killList->addrList[n]);\r
+                    PFREE(killList->addrList[n]);\r
             }\r
         }\r
         if (killList->addrList)\r
-            free(killList->addrList);\r
+            PFREE(killList->addrList);\r
         if (killList->name)\r
-            free(killList->name);\r
+            PFREE(killList->name);\r
         if (killList->inst)\r
-            free(killList->inst);\r
+            PFREE(killList->inst);\r
         if (killList->realm)\r
-            free(killList->realm);\r
-        free(killList);\r
+            PFREE(killList->realm);\r
+        PFREE(killList);\r
     }\r
 \r
     *ticketList = NULL;\r
index c577eec3b9f4eb308cc059a7e5751f8ea440e202..0059f0ab1aa09ba502dff14e5b0a2ccd9e5eca19 100644 (file)
@@ -6,7 +6,9 @@ Krb5Cred,KC_SPACE,0,Kerberos V Credentials Provider
   Flags,KC_INT32,0,\r
   Parameters,KC_SPACE,0,Parameters for KrbCred\r
     CreateMissingConfig,KC_INT32,0,Create missing configuration files\r
-    MsLsaImport,KC_INT32,2,Automatically import MSLSA credentials\r
+    MsLsaImport,KC_INT32,1,Automatically import MSLSA credentials: 0-never 1-always 2-if principle matches\r
+    MsLsaList,KC_INT32,1,Include MSLSA in the credentials list\r
+    FileCCList,KC_STRING,,List of file CCaches to include in listing\r
     AutoRenewTickets,KC_INT32,1,Automatically renew expiring tickets\r
     DefaultLifetime,KC_INT32,36000,Default ticket lifetime\r
     MaxLifetime,KC_INT32,86400,Maximum lifetime\r
@@ -20,6 +22,8 @@ Krb5Cred,KC_SPACE,0,Kerberos V Credentials Provider
     MinRenewLifetime,KC_INT32,60,Maximum renewable lifetime\r
     LRURealms,KC_STRING,,\r
     LRUPrincipals,KC_STRING,,\r
+    LastDefaultIdent,KC_STRING,,Last known default identity\r
+    DefaultCCName,KC_STRING,,Default CC name (only per identity)\r
     PromptCache,KC_SPACE,0,Cache of prompts (only per identity)\r
       Name,KC_STRING,,\r
       Banner,KC_STRING,,\r
index 08978f11fd6ea3e78b02466ce4c4b41e8b2dbdc6..7efc360a0447afc306df8abb98d1bf7c3a4fba5d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -41,6 +41,7 @@
 #include<kconfig.h>\r
 #include<khuidefs.h>\r
 #include<kherr.h>\r
+#include<utils.h>\r
 \r
 #include<krb5funcs.h>\r
 #include<krb5common.h>\r
 #include<datarep.h>\r
 #include<krb5_msgs.h>\r
 \r
+typedef enum tag_k5_lsa_import {\r
+    K5_LSAIMPORT_NEVER = 0,\r
+    K5_LSAIMPORT_ALWAYS = 1,\r
+    K5_LSAIMPORT_MATCH = 2,     /* only when the principal name matches */\r
+} k5_lsa_import;\r
+\r
 #define TYPENAME_ENCTYPE        L"EncType"\r
 #define TYPENAME_ADDR_LIST      L"AddrList"\r
 #define TYPENAME_KRB5_FLAGS     L"Krb5Flags"\r
+#define TYPENAME_KRB5_PRINC     L"Krb5Principal"\r
 \r
 #define ATTRNAME_KEY_ENCTYPE    L"KeyEncType"\r
 #define ATTRNAME_TKT_ENCTYPE    L"TktEncType"\r
@@ -75,6 +83,9 @@ extern const wchar_t * k5_facility;
 extern khm_int32 type_id_enctype;\r
 extern khm_int32 type_id_addr_list;\r
 extern khm_int32 type_id_krb5_flags;\r
+extern khm_int32 type_id_krb5_princ;\r
+\r
+extern BOOL      type_regd_krb5_princ;\r
 \r
 extern khm_int32 attr_id_key_enctype;\r
 extern khm_int32 attr_id_tkt_enctype;\r
@@ -89,9 +100,23 @@ extern khm_int32 attr_id_krb5_ccname;
 \r
 /* plugin constants */\r
 #define KRB5_PLUGIN_NAME    L"Krb5Cred"\r
+#define KRB5_IDENTPRO_NAME  L"Krb5Ident"\r
 \r
 #define KRB5_CREDTYPE_NAME  L"Krb5Cred"\r
 \r
+/* limits */\r
+/* maximum number of characters in a realm name */\r
+#define K5_MAXCCH_REALM 256\r
+\r
+/* maximum number of characters in a host name */\r
+#define K5_MAXCCH_HOST  128\r
+\r
+/* maximum number of KDC's per realm */\r
+#define K5_MAX_KDC      64\r
+\r
+/* maximum number of domains that map to a realm */\r
+#define K5_MAX_DOMAIN_MAPPINGS 32\r
+\r
 extern khm_handle csp_plugins;\r
 extern khm_handle csp_krbcred;\r
 extern khm_handle csp_params;\r
@@ -113,6 +138,7 @@ extern BOOL is_k5_identpro;
 \r
 /* plugin callbacks */\r
 khm_int32 KHMAPI k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);\r
+khm_int32 KHMAPI k5_ident_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);\r
 \r
 /* kinit fiber */\r
 typedef struct _fiber_job_t {\r
@@ -179,4 +205,22 @@ k5_register_config_panels(void);
 void\r
 k5_unregister_config_panels(void);\r
 \r
+INT_PTR CALLBACK \r
+k5_ccconfig_dlgproc(HWND hwnd,\r
+                    UINT uMsg,\r
+                    WPARAM wParam,\r
+                    LPARAM lParam);\r
+\r
+INT_PTR CALLBACK \r
+k5_id_tab_dlgproc(HWND hwndDlg,\r
+                  UINT uMsg,\r
+                  WPARAM wParam,\r
+                  LPARAM lParam);\r
+\r
+INT_PTR CALLBACK \r
+k5_ids_tab_dlgproc(HWND hwnd,\r
+                   UINT uMsg,\r
+                   WPARAM wParam,\r
+                   LPARAM lParam);\r
+\r
 #endif\r
index 087b93e47ce7269954561365c4eea0826a1a9bf5..d95c58d860e4aaccc115e3ed86858362d5a891f0 100644 (file)
@@ -83,22 +83,14 @@ BEGIN
     LTEXT           "Name",IDC_STATIC,7,7,19,8\r
     LTEXT           "Valid till",IDC_STATIC,7,39,24,8\r
     LTEXT           "Renewable till",IDC_STATIC,7,55,45,12\r
-    CONTROL         "Renewable",IDC_PPK5_CRENEW,"Button",BS_AUTOCHECKBOX | \r
-                    WS_DISABLED | WS_TABSTOP,31,125,51,10\r
-    CONTROL         "Forwardable",IDC_PPK5_CFORWARD,"Button",BS_AUTOCHECKBOX | \r
-                    WS_DISABLED | WS_TABSTOP,91,125,56,10\r
-    CONTROL         "Proxiable",IDC_PPK5_CPROXY,"Button",BS_AUTOCHECKBOX | \r
-                    WS_DISABLED | WS_TABSTOP,156,125,45,10\r
     LTEXT           "Issued on",IDC_STATIC,7,23,32,8\r
-    GROUPBOX        "Ticket flags",IDC_STATIC,7,108,221,41\r
-    LTEXT           "Static",IDC_PPK5_NAME,72,7,156,12,NOT WS_GROUP,\r
-                    WS_EX_CLIENTEDGE\r
-    LTEXT           "Static",IDC_PPK5_ISSUE,72,23,156,12,NOT WS_GROUP,\r
-                    WS_EX_CLIENTEDGE\r
-    LTEXT           "Static",IDC_PPK5_VALID,72,39,156,12,NOT WS_GROUP,\r
-                    WS_EX_CLIENTEDGE\r
-    LTEXT           "Static",IDC_PPK5_RENEW,72,55,156,12,NOT WS_GROUP,\r
-                    WS_EX_CLIENTEDGE\r
+    LTEXT           "Ticket flags",IDC_STATIC,7,75,37,8\r
+    EDITTEXT        IDC_PPK5_NAME,72,7,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+    EDITTEXT        IDC_PPK5_ISSUE,72,23,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+    EDITTEXT        IDC_PPK5_VALID,72,39,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+    EDITTEXT        IDC_PPK5_RENEW,72,55,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+    LISTBOX         IDC_PPK5_FLAGS,72,74,156,75,LBS_SORT | \r
+                    LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\r
 END\r
 \r
 IDD_PP_KRB5 DIALOGEX 0, 0, 235, 156\r
@@ -137,14 +129,15 @@ BEGIN
     LTEXT           "Default Realm",IDC_CFG_LBL_REALM,13,9,46,8\r
     COMBOBOX        IDC_CFG_DEFREALM,76,7,166,30,CBS_DROPDOWN | CBS_SORT | \r
                     WS_VSCROLL | WS_TABSTOP\r
-    PUSHBUTTON      "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14\r
+    PUSHBUTTON      "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14,\r
+                    WS_DISABLED\r
     GROUPBOX        "Keberos Configuration File",IDC_CFG_CFGFILEGRP,7,57,241,\r
                     48\r
     LTEXT           "Location",IDC_CFG_LBL_CFGFILE,13,71,28,8\r
     EDITTEXT        IDC_CFG_CFGFILE,76,68,119,14,ES_AUTOHSCROLL\r
     PUSHBUTTON      "Browse...",IDC_CFG_BROWSE,198,68,44,14\r
     CONTROL         "Create file if missing",IDC_CFG_CREATECONFIG,"Button",\r
-                    BS_AUTOCHECKBOX | WS_TABSTOP,76,89,80,10\r
+                    BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,76,89,80,10\r
     GROUPBOX        "Windows® Options",IDC_CFG_WINGRP,7,110,241,65\r
     LTEXT           "Hostname",IDC_CFG_LBL_HOSTNAME,13,123,33,8\r
     EDITTEXT        IDC_CFG_HOSTNAME,76,120,166,14,ES_AUTOHSCROLL | \r
@@ -153,7 +146,7 @@ BEGIN
     EDITTEXT        IDC_CFG_DOMAIN,76,138,166,14,ES_AUTOHSCROLL | \r
                     ES_READONLY\r
     LTEXT           "Import tickets",IDC_LBL_IMPORT,13,158,45,8\r
-    COMBOBOX        IDC_CFG_IMPORT,76,156,166,30,CBS_DROPDOWNLIST | CBS_SORT | \r
+    COMBOBOX        IDC_CFG_IMPORT,76,156,166,30,CBS_DROPDOWNLIST | \r
                     WS_VSCROLL | WS_TABSTOP\r
 END\r
 \r
@@ -162,15 +155,17 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
 EXSTYLE WS_EX_CONTROLPARENT\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
-    CONTROL         "",IDC_CFG_REALMS,"SysListView32",LVS_ALIGNLEFT | \r
-                    WS_BORDER | WS_TABSTOP,7,19,81,148\r
-    GROUPBOX        "Servers",IDC_CFG_SERVERSGRP,93,7,155,91\r
-    GROUPBOX        "Domain/Hostname mappings",IDC_CFG_DOMAINGRP,93,101,155,\r
-                    74\r
-    CONTROL         "",IDC_LIST3,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
-                    WS_TABSTOP,99,19,143,72\r
-    CONTROL         "",IDC_LIST4,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
-                    WS_TABSTOP,99,111,143,56\r
+    CONTROL         "",IDC_CFG_REALMS,"SysListView32",LVS_REPORT | \r
+                    LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_EDITLABELS | \r
+                    LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_TABSTOP,7,19,81,\r
+                    148\r
+    GROUPBOX        "Kerberos Servers",IDC_CFG_SERVERSGRP,93,7,155,91\r
+    GROUPBOX        "Domain mappings",IDC_CFG_DOMAINGRP,93,101,155,74\r
+    CONTROL         "",IDC_CFG_KDC,"SysListView32",LVS_REPORT | \r
+                    LVS_EDITLABELS | LVS_ALIGNLEFT | WS_TABSTOP,99,19,143,72\r
+    CONTROL         "",IDC_CFG_DMAP,"SysListView32",LVS_REPORT | \r
+                    LVS_EDITLABELS | LVS_ALIGNLEFT | WS_TABSTOP,99,111,143,\r
+                    56\r
 END\r
 \r
 IDD_CFG_IDS_TAB DIALOGEX 0, 0, 235, 151\r
@@ -197,6 +192,7 @@ END
 \r
 IDD_CFG_ID_TAB DIALOGEX 0, 0, 235, 151\r
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
     LTEXT           "Ticket lifetime",IDC_CFG_LBL_DEFLIFE,7,10,44,8\r
@@ -222,6 +218,25 @@ BEGIN
                     43,112,16,BS_NOTIFY | WS_DISABLED\r
 END\r
 \r
+IDD_CFG_CACHES DIALOGEX 0, 0, 255, 182\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+    GROUPBOX        "File Caches",IDC_CFG_FCGRP,7,38,241,137\r
+    CONTROL         "",IDC_CFG_FCLIST,"SysListView32",LVS_REPORT | \r
+                    LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | \r
+                    WS_TABSTOP,13,48,229,86\r
+    EDITTEXT        IDC_CFG_FCNAME,13,139,173,14,ES_AUTOHSCROLL\r
+    PUSHBUTTON      "&Browse ...",IDC_CFG_BROWSE,192,139,50,14\r
+    PUSHBUTTON      "Add",IDC_CFG_ADD,13,156,50,14\r
+    PUSHBUTTON      "Remove Selected",IDC_CFG_REMOVE,88,156,80,14\r
+    CHECKBOX        "Include all API: credentials caches",IDC_CFG_INCAPI,13,\r
+                    7,125,10\r
+    CONTROL         "Include Windows LSA cache (MSLSA:)",IDC_CFG_INCMSLSA,\r
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,22,136,10\r
+END\r
+\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -306,10 +321,34 @@ BEGIN
         TOPMARGIN, 7\r
         BOTTOMMARGIN, 159\r
     END\r
+\r
+    IDD_CFG_CACHES, DIALOG\r
+    BEGIN\r
+        LEFTMARGIN, 7\r
+        RIGHTMARGIN, 248\r
+        VERTGUIDE, 7\r
+        VERTGUIDE, 13\r
+        VERTGUIDE, 242\r
+        TOPMARGIN, 7\r
+        BOTTOMMARGIN, 175\r
+    END\r
 END\r
 #endif    // APSTUDIO_INVOKED\r
 \r
 \r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Icon\r
+//\r
+\r
+// Icon with lowest ID value placed first to ensure application icon\r
+// remains consistent on all systems.\r
+IDI_PLUGIN              ICON                    "..\\..\\images\\krb5plugin.ico"\r
+IDI_DELETED             ICON                    "..\\..\\images\\deleted.ico"\r
+IDI_NEW                 ICON                    "..\\..\\images\\new.ico"\r
+IDI_NORMAL              ICON                    "..\\..\\images\\normal.ico"\r
+IDI_MODIFIED            ICON                    "..\\..\\images\\modified.ico"\r
+\r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
 // String Table\r
@@ -386,7 +425,61 @@ BEGIN
     IDS_NC_PWD_NPWD_AGAIN   "New Password again"\r
     IDS_KRB5_CREDTEXT_P0    "<p><a id=""SwitchPanel"" param=""Krb5Cred""><b>Krb5</b></a><tab>: Changing password for %s</p>"\r
     IDS_K5CFG_IMPORT_OPTIONS \r
-                            "Never\000Always\000Only when the principal name matches\000 \000"\r
+                            "Never\000Always\000Only when the principal name matches\000 "\r
+    IDS_IDENTPRO_DESC       "Kerberos 5 Identity Provider"\r
+    IDS_K5CCC_SHORT_DESC    "Credentials Caches"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+    IDS_K5CCC_LONG_DESC     "Kerberos 5 Credentials Caches"\r
+    IDS_CFG_FCTITLE         "File based Credential Caches"\r
+    IDS_CFG_FCN_WARNING     "Warning:"\r
+    IDS_CFG_FCN_W_NOTFOUND  "The credentials cache you specified does not exist."\r
+    IDS_CFG_FCN_W_RELATIVE  "The path you specified not an absolute path."\r
+    IDS_CFG_FCOPENTITLE     "Select a credential cache to add"\r
+    IDS_UNAVAILABLE         "(Not available)"\r
+    IDS_FLG_FORWARDABLE     "Forwardable"\r
+    IDS_FLG_FORWARDED       "Forwarded"\r
+    IDS_FLG_PROXIABLE       "Proxiable"\r
+    IDS_FLG_PROXY           "Proxy"\r
+    IDS_FLG_MAY_POSTDATE    "May postdate"\r
+    IDS_FLG_POSTDATED       "Postdated"\r
+    IDS_FLG_INVALID         "Invalid"\r
+    IDS_FLG_RENEWABLE       "Renewable"\r
+    IDS_FLG_INITIAL         "Initial"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+    IDS_FLG_PRE_AUTH        "Pre-authenticated"\r
+    IDS_FLG_HW_AUTH         "Hardware authentication"\r
+    IDS_FLG_TRANSIT_POL     "Transit policy checked"\r
+    IDS_FLG_OK_DELEGATE     "Approved for delegation"\r
+    IDS_FLG_ANONYMOUS       "Anonymous"\r
+    IDS_K5ERR_CANTWRITEPROFILE \r
+                            "The Kerberos 5 profile file could not be written"\r
+    IDS_K5ERR_PROFNOWRITE   "The file %s could not be opened as a profile file for writing."\r
+    IDS_K5ERR_PROFUSETEMP   "The file %s could not be opened for writing.  The current changes will be saved to %s temporarily."\r
+    IDS_K5ERR_PROFSUGGEST   "This may be due to not having privileges to modify the configuration file.  Please contact your system administrator to resolve the issue."\r
+    IDS_CFG_RE_REALMS       "Kerberos Realms"\r
+    IDS_CFG_RE_KDCS         "Kerberos Servers"\r
+    IDS_CFG_RE_DMAPS        "Domain mappings"\r
+    IDS_CFG_RE_KDCS_R       "Kerberos Servers for %s"\r
+    IDS_CFG_RE_DMAPS_R      "Domains that map to %s"\r
+    IDS_CFG_RE_HEAD_SVR     "Server"\r
+    IDS_CFG_RE_HEAD_ADMIN   "Admin"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+    IDS_CFG_RE_HEAD_MASTER  "Master"\r
+    IDS_CFG_RE_HEAD_DOMAIN  "Domain"\r
+    IDS_CFG_RE_NEWREALM     "<New realm...>"\r
+    IDS_YES                 "Yes"\r
+    IDS_NO                  "No"\r
+    IDS_CFG_RE_NEWSERVER    "<New server...>"\r
+    IDS_CFG_RE_NEWDMAP      "<New domain mapping...>"\r
 END\r
 \r
 #endif    // English (U.S.) resources\r
index 87f74f547adb5ea2dc579ab77097ee23dee7c6c2..52adc34e3f6e72cbf0b014cd79b52120262a20d1 100644 (file)
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}\r
 // Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\plugins\krb5\lang\en_us\langres.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\plugins\krb5\lang\en_us\langres.rc\r
 //\r
 #define IDS_UNK_ADDR_FMT                101\r
 #define IDD_NC_KRB5                     102\r
 #define IDS_ETYPE_NULL                  110\r
 #define IDD_NC_KRB5_PASSWORD            110\r
 #define IDS_ETYPE_DES_CBC_CRC           111\r
+#define IDD_CFG_CACHES                  111\r
 #define IDS_ETYPE_DES_CBC_MD4           112\r
+#define IDI_PLUGIN                      112\r
 #define IDS_ETYPE_DES_CBC_MD5           113\r
+#define IDI_DELETED                     113\r
 #define IDS_ETYPE_DES_CBC_RAW           114\r
+#define IDI_NEW                         114\r
 #define IDS_ETYPE_DES3_CBC_SHA          115\r
+#define IDI_NORMAL                      115\r
 #define IDS_ETYPE_DES3_CBC_RAW          116\r
+#define IDI_MODIFIED                    116\r
 #define IDS_ETYPE_DES_HMAC_SHA1         117\r
 #define IDS_ETYPE_DES3_CBC_SHA1         118\r
 #define IDS_ETYPE_AES128_CTS_HMAC_SHA1_96 119\r
 #define IDS_NC_PWD_NPWD_AGAIN           155\r
 #define IDS_KRB5_CREDTEXT_P0            156\r
 #define IDS_K5CFG_IMPORT_OPTIONS        157\r
+#define IDS_IDENTPRO_DESC               158\r
+#define IDS_K5CCC_SHORT_DESC            159\r
+#define IDS_K5CCC_LONG_DESC             160\r
+#define IDS_CFG_FCTITLE                 161\r
+#define IDS_CFG_FCN_WARNING             162\r
+#define IDS_CFG_FCN_W_NOTFOUND          163\r
+#define IDS_CFG_FCN_W_RELATIVE          164\r
+#define IDS_CFG_FCOPENTITLE             165\r
+#define IDS_UNAVAILABLE                 166\r
+#define IDS_FLG_FORWARDABLE             167\r
+#define IDS_FLG_FORWARDED               168\r
+#define IDS_FLG_PROXIABLE               169\r
+#define IDS_FLG_PROXY                   170\r
+#define IDS_FLG_MAY_POSTDATE            171\r
+#define IDS_FLG_POSTDATED               172\r
+#define IDS_FLG_INVALID                 173\r
+#define IDS_FLG_RENEWABLE               174\r
+#define IDS_FLG_INITIAL                 175\r
+#define IDS_FLG_PRE_AUTH                176\r
+#define IDS_FLG_HW_AUTH                 177\r
+#define IDS_FLG_TRANSIT_POL             178\r
+#define IDS_FLG_OK_DELEGATE             179\r
+#define IDS_FLG_ANONYMOUS               180\r
+#define IDS_K5ERR_CANTWRITEPROFILE      181\r
+#define IDS_K5ERR_PROFNOWRITE           182\r
+#define IDS_K5ERR_PROFUSETEMP           183\r
+#define IDS_K5ERR_PROFSUGGEST           184\r
+#define IDS_CFG_RE_REALMS               185\r
+#define IDS_CFG_RE_KDCS                 186\r
+#define IDS_CFG_RE_DMAPS                187\r
+#define IDS_CFG_RE_KDCS_R               188\r
+#define IDS_CFG_RE_DMAPS_R              189\r
+#define IDS_CFG_RE_HEAD_SVR             190\r
+#define IDS_CFG_RE_HEAD_ADMIN           191\r
+#define IDS_CFG_RE_HEAD_MASTER          192\r
+#define IDS_CFG_RE_HEAD_DOMAIN          193\r
+#define IDS_CFG_RE_NEWREALM             194\r
+#define IDS_YES                         195\r
+#define IDS_NO                          196\r
+#define IDS_CFG_RE_NEWSERVER            197\r
+#define IDS_CFG_RE_NEWDMAP              198\r
 #define IDC_NCK5_RENEWABLE              1002\r
 #define IDC_NCK5_FORWARDABLE            1004\r
 #define IDC_NCK5_REALM                  1005\r
 #define IDC_CFG_DOMAINGRP               1045\r
 #define IDC_CFG_SERVERSGRP              1046\r
 #define IDC_LIST3                       1047\r
+#define IDC_CFG_KDC                     1047\r
 #define IDC_LIST4                       1048\r
+#define IDC_CFG_DMAP                    1048\r
 #define IDC_CFG_LBL_DEFLIFE             1049\r
 #define IDC_CFG_DEFLIFE                 1050\r
 #define IDC_CFG_LBL_DEFRLIFE            1051\r
 #define IDC_CFG_RLRNG_MIN               1056\r
 #define IDC_CFG_RLRNG_MAX               1057\r
 #define IDC_CFG_CCACHE                  1058\r
+#define IDC_CFG_FCGRP                   1059\r
+#define IDC_CFG_FCLIST                  1060\r
+#define IDC_CFG_FCNAME                  1062\r
+#define IDC_CFG_ADD                     1064\r
+#define IDC_CFG_REMOVE                  1065\r
+#define IDC_CFG_INCAPI                  1066\r
+#define IDC_CFG_INCMSLSA                1067\r
+#define IDC_PPK5_FLAGS                  1072\r
 \r
 // Next default values for new objects\r
 // \r
 #ifdef APSTUDIO_INVOKED\r
 #ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE        111\r
+#define _APS_NEXT_RESOURCE_VALUE        117\r
 #define _APS_NEXT_COMMAND_VALUE         40001\r
-#define _APS_NEXT_CONTROL_VALUE         1059\r
+#define _APS_NEXT_CONTROL_VALUE         1073\r
 #define _APS_NEXT_SYMED_VALUE           101\r
 #endif\r
 #endif\r
diff --git a/src/windows/identity/plugins/krb5/version.rc b/src/windows/identity/plugins/krb5/version.rc
new file mode 100644 (file)
index 0000000..10b16dd
--- /dev/null
@@ -0,0 +1,64 @@
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<netidmgr_intver.h>\r
+\r
+1 VERSIONINFO \r
+        FILEVERSION     KH_VERSION_LIST\r
+        PRODUCTVERSION  KH_VERSION_LIST\r
+        FILEFLAGSMASK   KH_VER_FILEFLAGMASK\r
+        FILEFLAGS       KH_VER_FILEFLAGS\r
+        FILEOS          KH_VER_FILEOS\r
+        FILETYPE        KH_VER_FILETYPEDLL\r
+        FILESUBTYPE     0\r
+  {\r
+    BLOCK "StringFileInfo"\r
+    {\r
+      BLOCK "040904b0"\r
+      {\r
+        VALUE "CompanyName",     KH_VERSTR_COMPANY_1033\r
+        VALUE "FileDescription", "Kerberos 5 plugin for NetIDMgr"\r
+        VALUE "FileVersion",     KH_VERSTR_VERSION_1033\r
+        VALUE "InternalName",    "krb5cred"\r
+        VALUE "LegalCopyright",  KH_VERSTR_COPYRIGHT_1033\r
+        VALUE "OriginalFilename", "krb5cred.dll"\r
+        VALUE "ProductName",     "NetIDMgr"\r
+        VALUE "ProductVersion",  KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+        VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+        VALUE NIMV_MODULE,       "MITKrb5"\r
+        VALUE NIMV_PLUGINS,      "Krb5Cred,Krb5Ident"\r
+        VALUE NIMV_APIVER,       KH_VERSION_STRINGAPI\r
+        VALUE NIMV_SUPPORT,      "http://web.mit.edu/kerberos"\r
+      }\r
+    }\r
+\r
+    BLOCK "VarFileInfo"\r
+    {\r
+        VALUE "Translation", 0x409, 0x4b0\r
+    }\r
+  }\r
index 402fc5d885b4e4d5a2e005816c1eea7b4349a680..4419444a304c008275eb458b222e88ba68ebdbd6 100644 (file)
@@ -47,24 +47,32 @@ OBJFILES=                   \
        $(OBJ)\configwnd.obj    \\r
        $(OBJ)\aboutwnd.obj     \\r
        $(OBJ)\reqdaemon.obj    \\r
+       $(OBJ)\addrchange.obj   \\r
        $(OBJ)\cfg_general_wnd.obj \\r
        $(OBJ)\cfg_identities_wnd.obj \\r
        $(OBJ)\cfg_notif_wnd.obj \\r
        $(OBJ)\cfg_plugins_wnd.obj\r
 \r
-RESFILE=$(OBJ)\khapp.res\r
+RESFILES= \\r
+       $(OBJ)\khapp.res        \\r
+       $(OBJ)\appver.res\r
 \r
 LIBFILES=                      \\r
        $(LIBDIR)\nidmgr32.lib\r
 \r
 SDKLIBFILES=                   \\r
        comctl32.lib            \\r
-       shell32.lib\r
+       shell32.lib             \\r
+       htmlhelp.lib            \\r
+       iphlpapi.lib\r
 \r
 $(OBJ)\uiconfig.c: uiconfig.csv $(CONFDIR)\csvschema.cfg\r
        $(CCSV) $** $@\r
 \r
-$(RESFILE): lang\en_us\khapp.rc\r
+$(OBJ)\khapp.res: lang\en_us\khapp.rc\r
+       $(RC2RES)\r
+\r
+$(OBJ)\appver.res: appver.rc\r
        $(RC2RES)\r
 \r
 !if "$(KH_BUILD)"=="RETAIL"\r
@@ -74,7 +82,7 @@ $(MANIFESTFILE): netidmgr.manifest.$(CPU).$(KH_CLVER).debug
 !endif\r
        $(CP) $** $@\r
 \r
-$(EXEFILE): $(OBJFILES) $(RESFILE) $(LIBFILES)\r
+$(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES)\r
        $(EXEGUILINK) $(SDKLIBFILES)\r
 \r
 all: mkdirs $(EXEFILE) $(MANIFESTFILE)\r
index 2dde601a49dbb7538b31974aae2b1b9333f57378..4f5d38ef48d7010a7a3ee49c90f6bbb9d79e4868 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -25,7 +25,7 @@
 /* $Id$ */\r
 \r
 #include<khmapp.h>\r
-#include<khimaira_version.h>\r
+#include<netidmgr_intver.h>\r
 #include<tlhelp32.h>\r
 \r
 #if DEBUG\r
@@ -108,7 +108,11 @@ about_dlg_proc(HWND hwnd,
                     mod.dwSize = sizeof(mod);\r
                 } while(Module32Next(hsnap, &mod));\r
 \r
+#if (_WIN32_WINNT >= 0x501)\r
+                /* we are also setting the report style when creating\r
+                   the control.  this is actually optional. */\r
                 ListView_SetView(hw, LV_VIEW_DETAILS);\r
+#endif\r
 \r
             _done_with_modules:\r
                 CloseHandle(hsnap);\r
index a427b7dd0d1ad30f695253e36fa8d7b4a9ab237e..81b7e9047033ebb518f29ebf902b2bd6cb98bfe9 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
diff --git a/src/windows/identity/ui/addrchange.c b/src/windows/identity/ui/addrchange.c
new file mode 100644 (file)
index 0000000..8a671b3
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<khmapp.h>\r
+#include<iphlpapi.h>\r
+\r
+static HANDLE evt_terminate = NULL;\r
+static HANDLE h_thread = NULL;\r
+\r
+DWORD WINAPI\r
+addr_change_thread(LPVOID dummy) {\r
+\r
+    HANDLE h_waits[2];\r
+    HANDLE h_notify;\r
+\r
+    OVERLAPPED overlap;\r
+    DWORD ret;\r
+\r
+    ZeroMemory(&overlap, sizeof(overlap));\r
+\r
+    h_notify = NULL;\r
+    overlap.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);\r
+\r
+    do {\r
+        ret = NotifyAddrChange(&h_notify, &overlap);\r
+\r
+        if (ret != ERROR_IO_PENDING) {\r
+            goto _end_thread;   /* some error */\r
+        }\r
+\r
+        h_waits[0] = overlap.hEvent;\r
+        h_waits[1] = evt_terminate;\r
+\r
+        ret = WaitForMultipleObjects(2, h_waits, FALSE, INFINITE);\r
+\r
+        if ( ret == WAIT_OBJECT_0 ) {\r
+            kmq_post_message(KMSG_CRED, KMSG_CRED_ADDR_CHANGE,\r
+                             0, 0);\r
+        } else {\r
+            goto _end_thread;\r
+        }\r
+    } while(TRUE);\r
+    \r
+ _end_thread:\r
+    ExitThread(0);\r
+    return 0;                   /* unreachable */\r
+}\r
+\r
+void\r
+khm_addr_change_notifier_init(void) {\r
+    evt_terminate = CreateEvent(NULL, FALSE, FALSE, NULL);\r
+    h_thread = CreateThread(NULL,\r
+                            64 * 4096,\r
+                            addr_change_thread,\r
+                            NULL,\r
+                            0,\r
+                            NULL);\r
+}\r
+\r
+void\r
+khm_addr_change_notifier_exit(void) {\r
+    if (h_thread && evt_terminate) {\r
+        SetEvent(evt_terminate);\r
+        WaitForSingleObject(h_thread, INFINITE);\r
+\r
+        CloseHandle(h_thread);\r
+        CloseHandle(evt_terminate);\r
+    }\r
+}\r
similarity index 65%
rename from src/windows/identity/plugins/krb4/datarep.h
rename to src/windows/identity/ui/addrchange.h
index 9c7048e05e5ad21df209b13f79f67d4589d3aab8..08c15041f43f6beafee144754690f819c8ec3a0c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 /* $Id$ */\r
 \r
-#ifndef __KHIMAIRA_KRB_DATAREP_H\r
-#define __KHIMAIRA_KRB_DATAREP_H\r
+#ifndef __NETIDMGR_ADDRCHANGE_H\r
+#define __NETIDMGR_ADDRCHANGE_H\r
 \r
+void\r
+khm_addr_change_notifier_init(void);\r
 \r
-khm_int32 KHMAPI enctype_toString(const void * data, khm_int32 cbdata, wchar_t *destbuf, khm_int32 *pcbdestbuf, khm_int32 flags);\r
-khm_int32 KHMAPI addr_list_toString(const void *, khm_int32, wchar_t *, khm_int32 *, khm_int32);\r
-khm_int32 KHMAPI krb5flags_toString(const void *, khm_int32, wchar_t *, khm_int32 *, khm_int32);\r
-khm_int32 KHMAPI renew_for_cb(khm_handle cred, khm_int32 id, void * buffer, khm_int32 * pcbsize);\r
+void\r
+khm_addr_change_notifier_exit(void);\r
 \r
-\r
-#endif
\ No newline at end of file
+#endif\r
index 41fca2d17ef3c46f0c389974637739779bab3990..d7e5667afb885e05f04b388b16efe1662f39876d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
diff --git a/src/windows/identity/ui/appver.rc b/src/windows/identity/ui/appver.rc
new file mode 100644 (file)
index 0000000..9d2dbc4
--- /dev/null
@@ -0,0 +1,40 @@
+\r
+#include<windows.h>\r
+#include<netidmgr_intver.h>\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Version\r
+//\r
+\r
+VS_VERSION_INFO VERSIONINFO\r
+ FILEVERSION    KH_VERSION_LIST\r
+ PRODUCTVERSION KH_VERSION_LIST\r
+ FILEFLAGSMASK  0x17L\r
+ FILEFLAGS      KH_VER_FILEFLAGS\r
+ FILEOS         KH_VER_FILEOS\r
+ FILETYPE       0x0L\r
+ FILESUBTYPE    0x0L\r
+BEGIN\r
+    BLOCK "StringFileInfo"\r
+    BEGIN\r
+        BLOCK "040904b0"\r
+        BEGIN\r
+            VALUE "CompanyName", KH_VERSTR_COMPANY_1033\r
+            VALUE "FileDescription", "Network Identity Manager"\r
+            VALUE "FileVersion", KH_VERSTR_VERSION_1033\r
+            VALUE "InternalName", "NetIDMgr"\r
+            VALUE "LegalCopyright", KH_VERSTR_COPYRIGHT_1033\r
+            VALUE "OriginalFilename", "netidmgr.exe"\r
+            VALUE "ProductName", "NetIDMgr"\r
+            VALUE "ProductVersion", KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+            VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+        END\r
+    END\r
+    BLOCK "VarFileInfo"\r
+    BEGIN\r
+        VALUE "Translation", 0x409, 1200\r
+    END\r
+END\r
index 37c7ba7d11bdc6e1ea7b3438345b5198d1d12b5c..7b48975a974f6af76c109f306f648c508323b218 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -81,6 +81,7 @@ static void
 write_params(dlg_data * dd) {\r
     cfg_data * d, * s;\r
     khm_handle csp_cw;\r
+    BOOL applied = FALSE;\r
 \r
     d = &dd->work;\r
     s = &dd->saved;\r
@@ -93,25 +94,35 @@ write_params(dlg_data * dd) {
         return;\r
     }\r
 \r
-    if (!!d->auto_init != !!s->auto_init)\r
+    if (!!d->auto_init != !!s->auto_init) {\r
         khc_write_int32(csp_cw, L"AutoInit", d->auto_init);\r
+        applied = TRUE;\r
+    }\r
 \r
-    if (!!d->auto_start != !!s->auto_start)\r
+    if (!!d->auto_start != !!s->auto_start) {\r
         khc_write_int32(csp_cw, L"AutoStart", d->auto_start);\r
+        applied = TRUE;\r
+    }\r
 \r
-    if (!!d->auto_import != !!s->auto_import)\r
+    if (!!d->auto_import != !!s->auto_import) {\r
         khc_write_int32(csp_cw, L"AutoImport", d->auto_import);\r
+        applied = TRUE;\r
+    }\r
 \r
-    if (!!d->keep_running != !!s->keep_running)\r
+    if (!!d->keep_running != !!s->keep_running) {\r
         khc_write_int32(csp_cw, L"KeepRunning", d->keep_running);\r
+        applied = TRUE;\r
+    }\r
 \r
-    if (!!d->auto_detect_net != !!s->auto_detect_net)\r
+    if (!!d->auto_detect_net != !!s->auto_detect_net) {\r
         khc_write_int32(csp_cw, L"AutoDetectNet", d->auto_detect_net);\r
+        applied = TRUE;\r
+    }\r
 \r
     khc_close_space(csp_cw);\r
 \r
     khui_cfg_set_flags(dd->node,\r
-                       KHUI_CNFLAG_APPLIED,\r
+                       (applied) ? KHUI_CNFLAG_APPLIED : 0,\r
                        KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
 \r
     *s = *d;\r
@@ -179,7 +190,7 @@ khm_cfg_general_proc(HWND hwnd,
 \r
     switch(uMsg) {\r
     case WM_INITDIALOG:\r
-        d = malloc(sizeof(*d));\r
+        d = PMALLOC(sizeof(*d));\r
 #ifdef DEBUG\r
         assert(d != NULL);\r
 #endif\r
index 1cef2d7ce76f9aba0660c40dadef930aab04df19..8b27c3334c08da172a74911d8683c38589ae07eb 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -46,6 +46,7 @@ static void
 add_subpanels(HWND hwnd, \r
               khui_config_node ctx_node,\r
               khui_config_node ref_node) {\r
+\r
     HWND hw_tab;\r
     HWND hw_target;\r
     khui_config_node sub;\r
@@ -315,6 +316,7 @@ typedef struct tag_idents_data {
     int          idx_deleted;\r
 \r
     HWND         hwnd;\r
+    khui_config_init_data cfg;\r
 } idents_data;\r
 \r
 static idents_data cfg_idents = {FALSE, NULL, 0, 0, 0, NULL };\r
@@ -411,14 +413,9 @@ write_params_ident(ident_data * d) {
         khc_write_int32(csp_ident, L"AllowAutoRenew", !!d->work.auto_renew);\r
 \r
     if (d->saved.sticky != d->work.sticky) {\r
-        khc_write_int32(csp_ident, L"Sticky", !!d->work.sticky);\r
-        if (d->work.sticky) {\r
-            kcdb_identity_set_flags(d->ident, KCDB_IDENT_FLAG_STICKY);\r
-        } else {\r
-            kcdb_identity_set_flags(d->ident, \r
-                                    KCDB_IDENT_FLAG_STICKY |\r
-                                    KCDB_IDENT_FLAG_INVERT);\r
-        }\r
+        kcdb_identity_set_flags(d->ident,\r
+                                (d->work.sticky)?KCDB_IDENT_FLAG_STICKY:0,\r
+                                KCDB_IDENT_FLAG_STICKY);\r
     }\r
 \r
     khc_close_space(csp_ident);\r
@@ -476,8 +473,8 @@ init_idents_data(void) {
             break;\r
 \r
         if (widnames)\r
-            free(widnames);\r
-        widnames = malloc(cb);\r
+            PFREE(widnames);\r
+        widnames = PMALLOC(cb);\r
 #ifdef DEBUG\r
         assert(widnames);\r
 #endif\r
@@ -497,7 +494,7 @@ init_idents_data(void) {
         goto _cleanup;\r
     }\r
 \r
-    cfg_idents.idents = malloc(sizeof(*cfg_idents.idents) * \r
+    cfg_idents.idents = PMALLOC(sizeof(*cfg_idents.idents) * \r
                                cfg_idents.n_idents);\r
 #ifdef DEBUG\r
     assert(cfg_idents.idents);\r
@@ -518,7 +515,7 @@ init_idents_data(void) {
         StringCbLength(t, KCDB_IDENT_MAXCB_NAME, &cb);\r
         cb += sizeof(wchar_t);\r
 \r
-        cfg_idents.idents[i].idname = malloc(cb);\r
+        cfg_idents.idents[i].idname = PMALLOC(cb);\r
 #ifdef DEBUG\r
         assert(cfg_idents.idents[i].idname);\r
 #endif\r
@@ -540,7 +537,7 @@ init_idents_data(void) {
     cfg_idents.valid = TRUE;\r
 \r
     if (widnames)\r
-        free(widnames);\r
+        PFREE(widnames);\r
 }\r
 \r
 static void\r
@@ -554,11 +551,11 @@ free_idents_data(void) {
         if (cfg_idents.idents[i].ident)\r
             kcdb_identity_release(cfg_idents.idents[i].ident);\r
         if (cfg_idents.idents[i].idname)\r
-            free(cfg_idents.idents[i].idname);\r
+            PFREE(cfg_idents.idents[i].idname);\r
     }\r
 \r
     if (cfg_idents.idents)\r
-        free(cfg_idents.idents);\r
+        PFREE(cfg_idents.idents);\r
 \r
     cfg_idents.idents = NULL;\r
     cfg_idents.n_idents = 0;\r
@@ -658,8 +655,14 @@ refresh_view_idents_sel(HWND hwnd) {
                     BST_INDETERMINATE));\r
 \r
     if (sel_count > 0) {\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), TRUE);\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), TRUE);\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), TRUE);\r
         EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), TRUE);\r
     } else {\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), FALSE);\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), FALSE);\r
+        EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), FALSE);\r
         EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), FALSE);\r
     }\r
 }\r
@@ -781,19 +784,14 @@ refresh_view_idents_state(HWND hwnd) {
 \r
     {\r
         khm_int32 flags = 0;\r
-        khui_config_node node = NULL;\r
 \r
         if (modified)\r
             flags |= KHUI_CNFLAG_MODIFIED;\r
         if (applied)\r
             flags |= KHUI_CNFLAG_APPLIED;\r
 \r
-        khui_cfg_open(NULL, L"KhmIdentities", &node);\r
-#ifdef DEBUG\r
-        assert(node);\r
-#endif\r
-        khui_cfg_set_flags(node, flags,\r
-                           KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+        khui_cfg_set_flags_inst(&cfg_idents.cfg, flags,\r
+                                KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
     }\r
 }\r
 \r
@@ -853,6 +851,7 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             hold_idents_data();\r
 \r
             cfg_idents.hwnd = hwnd;\r
+            cfg_idents.cfg = *((khui_config_init_data *) lParam);\r
 \r
             /* first add the column */\r
             hw = GetDlgItem(hwnd, IDC_CFG_IDENTS);\r
@@ -875,12 +874,17 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             if (cfg_idents.hi_status)\r
                 goto _done_with_icons;\r
 \r
-            cfg_idents.hi_status = ImageList_Create(SM_CXICON, SM_CYICON, \r
-                                                    ILC_COLOR8 | ILC_MASK,\r
-                                                    4,4);\r
+            cfg_idents.hi_status = \r
+                ImageList_Create(GetSystemMetrics(SM_CXSMICON),\r
+                                 GetSystemMetrics(SM_CYSMICON), \r
+                                 ILC_COLOR8 | ILC_MASK,\r
+                                 4,4);\r
 \r
-            hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ID),\r
-                              IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+            hicon =\r
+                LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ID),\r
+                          IMAGE_ICON,\r
+                          GetSystemMetrics(SM_CXSMICON),\r
+                          GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
             cfg_idents.idx_id = ImageList_AddIcon(cfg_idents.hi_status,\r
                                                   hicon);\r
@@ -888,7 +892,8 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             DestroyIcon(hicon);\r
 \r
             hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),\r
-                              IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                              IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+                              GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
             cfg_idents.idx_default = ImageList_AddIcon(cfg_idents.hi_status, \r
                                                        hicon) + 1;\r
@@ -896,7 +901,8 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             DestroyIcon(hicon);\r
 \r
             hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),\r
-                              IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                              IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+                              GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
             cfg_idents.idx_modified = ImageList_AddIcon(cfg_idents.hi_status, \r
                                                         hicon) + 1;\r
@@ -904,7 +910,8 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             DestroyIcon(hicon);\r
 \r
             hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),\r
-                              IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                              IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+                              GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
             cfg_idents.idx_applied = ImageList_AddIcon(cfg_idents.hi_status, \r
                                                        hicon) + 1;\r
@@ -912,7 +919,8 @@ khm_cfg_ids_tab_proc(HWND hwnd,
             DestroyIcon(hicon);\r
 \r
             hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DELETED),\r
-                              IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                              IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+                              GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
             cfg_idents.idx_deleted = ImageList_AddIcon(cfg_idents.hi_status, \r
                                                        hicon) + 1;\r
@@ -938,7 +946,9 @@ khm_cfg_ids_tab_proc(HWND hwnd,
                 cfg_idents.idents[i].lv_idx = ListView_InsertItem(hw, &lvi);\r
             }\r
 \r
+#if (_WIN32_WINNT >= 0x501)\r
             ListView_SetView(hw, LV_VIEW_DETAILS);\r
+#endif\r
         }\r
         return FALSE;\r
 \r
index aafa12d723a750716146e4cc209161c9ae5d1f72..bca18012c71040a8a168a643cad7c5791ae8c3ba 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -30,6 +30,8 @@
 typedef struct tag_notif_data {\r
     khui_config_node node;\r
 \r
+    BOOL modified;\r
+\r
     BOOL monitor;\r
     BOOL renew;\r
     BOOL warn1;\r
@@ -90,6 +92,8 @@ read_params(notif_data * d) {
     d->tc_warn2.min = t;\r
 \r
     khc_close_space(csp_cw);\r
+\r
+    d->modified = FALSE;\r
 }\r
 \r
 static void\r
@@ -112,10 +116,14 @@ check_for_modification(notif_data * d) {
                            KHUI_CNFLAG_MODIFIED,\r
                            KHUI_CNFLAG_MODIFIED);\r
 \r
+        d->modified = TRUE;\r
+\r
     } else {\r
         khui_cfg_set_flags(d->node,\r
                            0,\r
                            KHUI_CNFLAG_MODIFIED);\r
+\r
+        d->modified = FALSE;\r
     }\r
 }\r
 \r
@@ -124,6 +132,9 @@ write_params(notif_data * d) {
     khm_handle csp_cw;\r
     khm_int32 rv;\r
 \r
+    if (!d->modified)\r
+        return;\r
+\r
     rv = khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE, &csp_cw);\r
     assert(KHM_SUCCEEDED(rv));\r
 \r
@@ -215,7 +226,7 @@ khm_cfg_notifications_proc(HWND hwnd,
     case WM_INITDIALOG: {\r
         HWND hw;\r
 \r
-        d = malloc(sizeof(*d));\r
+        d = PMALLOC(sizeof(*d));\r
 #ifdef DEBUG\r
         assert(d != NULL);\r
 #endif\r
@@ -286,7 +297,7 @@ khm_cfg_notifications_proc(HWND hwnd,
         khui_tracker_kill_controls(&d->tc_warn1);\r
         khui_tracker_kill_controls(&d->tc_warn2);\r
 \r
-        free(d);\r
+        PFREE(d);\r
 \r
         SetWindowLongPtr(hwnd, DWLP_USER, 0);\r
 \r
index 16a344275cbdb4ec1fe418f8e2b65331756e7785..8bf767e8c3e141545703e64da3c0525c2977a340 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -60,7 +60,7 @@ khm_cfg_plugins_proc(HWND hwnd,
             wchar_t buf[256];\r
 \r
 \r
-            d = malloc(sizeof(*d));\r
+            d = PMALLOC(sizeof(*d));\r
 #ifdef DEBUG\r
             assert(d);\r
 #endif\r
@@ -83,13 +83,13 @@ khm_cfg_plugins_proc(HWND hwnd,
 #ifdef DEBUG\r
                 assert(d->info[i] == NULL);\r
 #endif\r
-                d->info[i] = malloc(sizeof(*(d->info[i])));\r
+                d->info[i] = PMALLOC(sizeof(*(d->info[i])));\r
 #ifdef DEBUG\r
                 assert(d->info[i]);\r
 #endif\r
 \r
                 if (KHM_FAILED(kmm_get_plugin_info_i(p, &d->info[i]->plugin))) {\r
-                    free(d->info[i]);\r
+                    PFREE(d->info[i]);\r
                     d->info[i] = NULL;\r
                     break;\r
                 }\r
@@ -120,8 +120,9 @@ khm_cfg_plugins_proc(HWND hwnd,
 #ifdef DEBUG\r
             assert(hw);\r
 #endif\r
+#if (_WIN32_WINNT >= 0x501)\r
             ListView_SetView(hw, LV_VIEW_DETAILS);\r
-\r
+#endif\r
             ZeroMemory(&lvc, sizeof(lvc));\r
 \r
             lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
@@ -305,10 +306,10 @@ khm_cfg_plugins_proc(HWND hwnd,
 #endif\r
                 kmm_release_plugin_info_i(&d->info[i]->plugin);\r
                 kmm_release_module_info_i(&d->info[i]->module);\r
-                free(d->info[i]);\r
+                PFREE(d->info[i]);\r
             }\r
 \r
-            free(d);\r
+            PFREE(d);\r
 \r
             khm_set_dialog_result(hwnd, 0);\r
         }\r
index 22a41eeb5ad2079e89bf959bbc9ac09f20692244..970599e853496d307b1a302732975e606ac24756 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -145,12 +145,12 @@ cfgui_initialize_dialog(HWND hwnd) {
 \r
     /* create and fill the image list for the treeview */\r
 \r
-    d->hi_status = ImageList_Create(SM_CXICON, SM_CYICON\r
+    d->hi_status = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)\r
                                     ILC_COLOR8 | ILC_MASK,\r
                                     4,4);\r
 \r
     hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),\r
-                      IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                      IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
     /* note that we can't use index 0 because that is used to indicate\r
        that there is no state image for the node */\r
@@ -161,14 +161,14 @@ cfgui_initialize_dialog(HWND hwnd) {
     DestroyIcon(hicon);\r
 \r
     hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),\r
-                      IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                      IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
     d->idx_modified = ImageList_AddIcon(d->hi_status, hicon);\r
 \r
     DestroyIcon(hicon);\r
 \r
     hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),\r
-                      IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+                      IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
 \r
     d->idx_applied = ImageList_AddIcon(d->hi_status, hicon);\r
 \r
@@ -253,6 +253,42 @@ cfgui_uninitialize_dialog(HWND hwnd) {
         ImageList_Destroy(d->hi_status);\r
 }\r
 \r
+static HWND\r
+cfgui_create_config_node_window(HWND hwnd, khui_config_node node) {\r
+    khui_config_node_reg reg;\r
+    khm_int32 rv;\r
+    HWND hw_new;\r
+\r
+    khui_config_node parent;\r
+\r
+    if (KHM_SUCCEEDED(khui_cfg_get_parent(node, &parent))) {\r
+        HWND hwp;\r
+\r
+        hwp = khui_cfg_get_hwnd(parent);\r
+\r
+        if (hwp == NULL)\r
+            cfgui_create_config_node_window(hwnd, parent);\r
+\r
+        khui_cfg_release(parent);\r
+    }\r
+\r
+    rv = khui_cfg_get_reg(node, &reg);\r
+#ifdef DEBUG\r
+    assert(KHM_SUCCEEDED(rv));\r
+#endif\r
+    hw_new = CreateDialogParam(reg.h_module,\r
+                               reg.dlg_template,\r
+                               hwnd,\r
+                               reg.dlg_proc,\r
+                               (LPARAM) node);\r
+#ifdef DEBUG\r
+    assert(hw_new);\r
+#endif\r
+    khui_cfg_set_hwnd(node, hw_new);\r
+\r
+    return hw_new;\r
+}\r
+\r
 static void\r
 cfgui_activate_node(HWND hwnd, khui_config_node node) {\r
 \r
@@ -273,25 +309,11 @@ cfgui_activate_node(HWND hwnd, khui_config_node node) {
     if (node == NULL) {\r
         hw_new = d->hw_generic_pane;\r
     } else {\r
-        khui_config_node_reg reg;\r
-        khm_int32 rv;\r
 \r
         hw_new = khui_cfg_get_hwnd(node);\r
 \r
         if (hw_new == NULL) {\r
-            rv = khui_cfg_get_reg(node, &reg);\r
-#ifdef DEBUG\r
-            assert(KHM_SUCCEEDED(rv));\r
-#endif\r
-            hw_new = CreateDialogParam(reg.h_module,\r
-                                       reg.dlg_template,\r
-                                       hwnd,\r
-                                       reg.dlg_proc,\r
-                                       (LPARAM) node);\r
-#ifdef DEBUG\r
-            assert(hw_new);\r
-#endif\r
-            khui_cfg_set_hwnd(node, hw_new);\r
+            hw_new = cfgui_create_config_node_window(hwnd, node);\r
         }\r
     }\r
 \r
@@ -513,7 +535,7 @@ cfgui_dlgproc(HWND hwnd,
 \r
         khui_cfg_clear_params();\r
 \r
-        d = malloc(sizeof(*d));\r
+        d = PMALLOC(sizeof(*d));\r
         ZeroMemory(d, sizeof(*d));\r
 \r
         d->hbr_white = CreateSolidBrush(RGB(255,255,255));\r
@@ -682,8 +704,8 @@ void khm_refresh_config(void) {
             return;\r
 \r
         if (idents)\r
-            free(idents);\r
-        idents = malloc(cb);\r
+            PFREE(idents);\r
+        idents = PMALLOC(cb);\r
 #ifdef DEBUG\r
         assert(idents);\r
 #endif\r
@@ -749,7 +771,7 @@ void khm_refresh_config(void) {
         khui_cfg_release(cfg_ids);\r
 \r
     if (idents)\r
-        free(idents);\r
+        PFREE(idents);\r
 }\r
 \r
 void khm_init_config(void) {\r
index 64da771532d7e610beb4bde2683e0ecbb6bfe733..62747fcad153e919fb1bc4ea5f46a76c6bb4446b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index b92e5d4a834c2113ed5ad163701f4c71fbf12710..b88f3d14e95c1880762c0640be691a6bfed099de 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -214,7 +214,10 @@ kmsg_cred_completion(kmq_message *m)
                 khui_alert * alert;\r
                 kherr_event * evt;\r
                 kherr_context * ctx;\r
-                wchar_t ws_title[1024];\r
+                wchar_t ws_tfmt[512];\r
+                wchar_t w_idname[KCDB_IDENT_MAXCCH_NAME];\r
+                wchar_t ws_title[ARRAYLENGTH(ws_tfmt) + KCDB_IDENT_MAXCCH_NAME];\r
+                khm_size cb;\r
 \r
                 ctx = kherr_peek_context();\r
                 evt = kherr_get_err_event(ctx);\r
@@ -224,10 +227,24 @@ kmsg_cred_completion(kmq_message *m)
 \r
                 if (nc->subtype == KMSG_CRED_PASSWORD)\r
                     LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE,\r
-                               ws_title, ARRAYLENGTH(ws_title));\r
+                               ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
+                else if (nc->subtype == KMSG_CRED_RENEW_CREDS)\r
+                    LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE,\r
+                               ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
                 else\r
                     LoadString(khm_hInstance, IDS_NC_FAILED_TITLE,\r
-                               ws_title, ARRAYLENGTH(ws_title));\r
+                               ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
+\r
+                if (nc->n_identities > 0) {\r
+                    cb = sizeof(w_idname);\r
+                    if (KHM_FAILED(kcdb_identity_get_name(nc->identities[0], \r
+                                                          w_idname, &cb)))\r
+                        StringCbCopy(w_idname, sizeof(w_idname), L"(?)");\r
+                } else {\r
+                    StringCbCopy(w_idname, sizeof(w_idname), L"(?)");\r
+                }\r
+\r
+                StringCbPrintf(ws_title, sizeof(ws_title), ws_tfmt, w_idname);\r
 \r
                 khui_alert_set_title(alert, ws_title);\r
                 khui_alert_set_severity(alert, evt->severity);\r
@@ -267,8 +284,10 @@ kmsg_cred_completion(kmq_message *m)
             if (nc->subtype == KMSG_CRED_NEW_CREDS ||\r
                 nc->subtype == KMSG_CRED_PASSWORD) {\r
 \r
+                /*\r
                 if (nc->subtype == KMSG_CRED_NEW_CREDS)\r
                     khui_context_reset();\r
+                */\r
 \r
                 khm_cred_end_dialog(nc->result);\r
             }\r
@@ -300,7 +319,7 @@ kmsg_cred_completion(kmq_message *m)
         assert(m->vparam != NULL);\r
 #endif\r
         khui_context_release((khui_action_context *) m->vparam);\r
-        free(m->vparam);\r
+        PFREE(m->vparam);\r
 \r
         kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);\r
 \r
@@ -310,6 +329,10 @@ kmsg_cred_completion(kmq_message *m)
     case KMSG_CRED_IMPORT:\r
         khm_cred_process_commandline();\r
         break;\r
+\r
+    case KMSG_CRED_REFRESH:\r
+        kcdb_identity_refresh_all();\r
+        break;\r
     }\r
 }\r
 \r
@@ -342,7 +365,7 @@ void khm_cred_destroy_creds(void)
 {\r
     khui_action_context * pctx;\r
 \r
-    pctx = malloc(sizeof(*pctx));\r
+    pctx = PMALLOC(sizeof(*pctx));\r
 #ifdef DEBUG\r
     assert(pctx);\r
 #endif\r
@@ -370,7 +393,7 @@ void khm_cred_destroy_creds(void)
                                KHERR_WARNING);\r
 \r
         khui_context_release(pctx);\r
-        free(pctx);\r
+        PFREE(pctx);\r
     } else {\r
         _begin_task(KHERR_CF_TRANSITIVE);\r
         _report_sr0(KHERR_NONE, IDS_CTX_RENEW_CREDS);\r
@@ -472,7 +495,7 @@ void khm_cred_change_password(wchar_t * title)
         if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {\r
             cb += sizeof(wchar_t);\r
 \r
-            nc->window_title = malloc(cb);\r
+            nc->window_title = PMALLOC(cb);\r
 #ifdef DEBUG\r
             assert(nc->window_title);\r
 #endif\r
@@ -487,7 +510,7 @@ void khm_cred_change_password(wchar_t * title)
                                          &cb))) {\r
 \r
         cb = (cb + 1) * sizeof(wchar_t);\r
-        nc->window_title = malloc(cb);\r
+        nc->window_title = PMALLOC(cb);\r
 #ifdef DEBUG\r
         assert(nc->window_title);\r
 #endif\r
@@ -526,13 +549,40 @@ void khm_cred_obtain_new_creds(wchar_t * title)
 \r
     kcdb_identpro_get_ui_cb((void *) &nc->ident_cb);\r
 \r
-    assert(nc->ident_cb);\r
+    if (nc->ident_cb == NULL) {\r
+        wchar_t title[256];\r
+        wchar_t msg[512];\r
+        wchar_t suggestion[512];\r
+        khui_alert * a;\r
+\r
+        LoadString(khm_hInstance, IDS_ERR_TITLE_NO_IDENTPRO,\r
+                   title, ARRAYLENGTH(title));\r
+        LoadString(khm_hInstance, IDS_ERR_MSG_NO_IDENTPRO,\r
+                   msg, ARRAYLENGTH(msg));\r
+        LoadString(khm_hInstance, IDS_ERR_SUGG_NO_IDENTPRO,\r
+                   suggestion, ARRAYLENGTH(suggestion));\r
+\r
+        khui_alert_create_simple(title,\r
+                                 msg,\r
+                                 KHERR_ERROR,\r
+                                 &a);\r
+        khui_alert_set_suggestion(a, suggestion);\r
+\r
+        khui_alert_show(a);\r
+\r
+        khui_alert_release(a);\r
+\r
+        khui_context_release(&nc->ctx);\r
+        khui_cw_destroy_cred_blob(nc);\r
+        khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL);\r
+        return;\r
+    }\r
 \r
     if (title) {\r
         if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {\r
             cb += sizeof(wchar_t);\r
 \r
-            nc->window_title = malloc(cb);\r
+            nc->window_title = PMALLOC(cb);\r
 #ifdef DEBUG\r
             assert(nc->window_title);\r
 #endif\r
@@ -547,7 +597,7 @@ void khm_cred_obtain_new_creds(wchar_t * title)
                                          &cb))) {\r
 \r
         cb = (cb + 1) * sizeof(wchar_t);\r
-        nc->window_title = malloc(cb);\r
+        nc->window_title = PMALLOC(cb);\r
 #ifdef DEBUG\r
         assert(nc->window_title);\r
 #endif\r
@@ -566,7 +616,9 @@ void khm_cred_obtain_new_creds(wchar_t * title)
 \r
         _end_task();\r
     } else {\r
+        khui_context_release(&nc->ctx);\r
         khui_cw_destroy_cred_blob(nc);\r
+        khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL);\r
     }\r
 }\r
 \r
@@ -825,3 +877,94 @@ khm_cred_begin_commandline(void) {
 \r
     khm_cred_process_commandline();\r
 }\r
+\r
+void\r
+khm_cred_refresh(void) {\r
+    kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, NULL);\r
+}\r
+\r
+void\r
+khm_cred_addr_change(void) {\r
+    khm_handle csp_cw = NULL;\r
+    khm_int32 check_net = 0;\r
+\r
+    wchar_t * ids = NULL;\r
+    wchar_t * t;\r
+    khm_size cb;\r
+    khm_size n_idents;\r
+\r
+    __int64 ft_now;\r
+    __int64 ft_exp;\r
+    __int64 ft_issue;\r
+\r
+    if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",\r
+                                     0, &csp_cw))) {\r
+        khc_read_int32(csp_cw, L"AutoDetectNet", &check_net);\r
+\r
+        khc_close_space(csp_cw);\r
+    }\r
+\r
+    if (!check_net)\r
+        return;\r
+\r
+    while(TRUE) {\r
+        if (ids)\r
+            PFREE(ids);\r
+        ids = NULL;\r
+\r
+        if (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |\r
+                               KCDB_IDENT_FLAG_RENEWABLE,\r
+                               KCDB_IDENT_FLAG_VALID |\r
+                               KCDB_IDENT_FLAG_RENEWABLE,\r
+                               NULL,\r
+                               &cb,\r
+                               &n_idents) != KHM_ERROR_TOO_LONG)\r
+            break;\r
+\r
+        ids = PMALLOC(cb);\r
+\r
+        if (KHM_SUCCEEDED\r
+            (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |\r
+                                KCDB_IDENT_FLAG_RENEWABLE,\r
+                                KCDB_IDENT_FLAG_VALID |\r
+                                KCDB_IDENT_FLAG_RENEWABLE,\r
+                                ids,\r
+                                &cb,\r
+                                &n_idents)))\r
+            break;\r
+    }\r
+\r
+    if (!ids)\r
+        return;\r
+\r
+    GetSystemTimeAsFileTime((LPFILETIME) &ft_now);\r
+\r
+    for (t=ids; t && *t; t = multi_string_next(t)) {\r
+        khm_handle ident;\r
+\r
+\r
+        if (KHM_FAILED\r
+            (kcdb_identity_create(t, 0, &ident)))\r
+            continue;\r
+\r
+        cb = sizeof(ft_issue);\r
+\r
+        if (KHM_SUCCEEDED\r
+            (kcdb_identity_get_attr(ident, KCDB_ATTR_ISSUE, NULL,\r
+                                    &ft_issue, &cb)) &&\r
+\r
+            (cb = sizeof(ft_exp)) &&\r
+            KHM_SUCCEEDED\r
+            (kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE, NULL,\r
+                                    &ft_exp, &cb)) &&\r
+\r
+            ft_now > (ft_issue + ft_exp)/2 &&\r
+            ft_now < ft_exp) {\r
+\r
+            khm_cred_renew_identity(ident);\r
+\r
+        }\r
+\r
+        kcdb_identity_release(ident);\r
+    }\r
+}\r
index b25b6630ebfda75cb5c6b260297948a458823bc2..6337830982128835fe600088b3b579c129b61bcb 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -69,4 +69,10 @@ khm_cred_begin_commandline(void);
 void\r
 khm_cred_process_commandline(void);\r
 \r
+void\r
+khm_cred_refresh(void);\r
+\r
+void\r
+khm_cred_addr_change(void);\r
+\r
 #endif\r
index 784a7f90b9a8a642c15116f1b85dec900b6d3d42..be7610497a2e679bb9d1e679e7dfc97071838b33 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -60,6 +60,7 @@ cw_load_view(khui_credwnd_tbl * tbl, wchar_t * view, HWND hwnd) {
 \r
     if(KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ, &hc_cw)))\r
         return;\r
+\r
     if(KHM_FAILED(khc_open_space(hc_cw, L"Views", KHM_PERM_READ, &hc_vs)))\r
         goto _exit;\r
 \r
@@ -80,14 +81,15 @@ cw_load_view(khui_credwnd_tbl * tbl, wchar_t * view, HWND hwnd) {
     if(khc_read_multi_string(hc_v, L"ColumnList", NULL, &cbsize) != KHM_ERROR_TOO_LONG)\r
         goto _exit;\r
 \r
-    clist = malloc(cbsize);\r
+    /* temporary */\r
+    clist = PMALLOC(cbsize);\r
 \r
     if(KHM_FAILED(khc_read_multi_string(hc_v, L"ColumnList", clist, &cbsize)))\r
         goto _exit;\r
 \r
     tbl->n_cols = (int) multi_string_length_n(clist);\r
     tbl->n_total_cols = UBOUNDSS(tbl->n_cols, KHUI_CW_COL_INITIAL, KHUI_CW_COL_INCREMENT);\r
-    tbl->cols = malloc(sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
+    tbl->cols = PMALLOC(sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
     ZeroMemory(tbl->cols, sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
 \r
     iter = clist;\r
@@ -103,7 +105,7 @@ cw_load_view(khui_credwnd_tbl * tbl, wchar_t * view, HWND hwnd) {
             if(kcdb_attrib_describe(attr_id, NULL, &cbsize, KCDB_TS_SHORT) != KHM_ERROR_TOO_LONG ||\r
                 cbsize == 0)\r
                 goto _skip_col;\r
-            tbl->cols[i].title = malloc(cbsize);\r
+            tbl->cols[i].title = PMALLOC(cbsize);\r
             kcdb_attrib_describe(attr_id, tbl->cols[i].title, &cbsize, KCDB_TS_SHORT);\r
         } else {\r
             /* All current custom attributes are represented by icons,\r
@@ -234,6 +236,7 @@ _skip_col:
     tbl->hb_hdr_bg_crit =   CreateSolidBrush(RGB(240,133,117));\r
     tbl->hb_hdr_bg_warn =   CreateSolidBrush(RGB(251,199,77));\r
     tbl->hb_hdr_bg_exp =    CreateSolidBrush(RGB(255,144,144));\r
+    tbl->hb_hdr_bg_def =    CreateSolidBrush(RGB(186,254,184));\r
 \r
     tbl->cr_normal = RGB(0,0,0);\r
     tbl->cr_sel = RGB(0,0,0);\r
@@ -241,7 +244,7 @@ _skip_col:
     tbl->cr_hdr_normal = RGB(0,0,0);\r
     tbl->cr_hdr_sel = RGB(255,255,255);\r
 \r
-    tbl->ilist = khui_create_ilist(KHUI_SMICON_CX, KHUI_SMICON_CY-1, 16, 8, 0);\r
+    tbl->ilist = khui_create_ilist(KHUI_SMICON_CX, KHUI_SMICON_CY-1, 20, 8, 0);\r
     {\r
         HBITMAP hbm;\r
 \r
@@ -265,6 +268,10 @@ _skip_col:
         ADD_BITMAP(IDB_FLAG_WARN);\r
         ADD_BITMAP(IDB_FLAG_EXPIRED);\r
         ADD_BITMAP(IDB_FLAG_CRITICAL);\r
+        ADD_BITMAP(IDB_WDG_STUCK);\r
+        ADD_BITMAP(IDB_WDG_STUCK_HI);\r
+        ADD_BITMAP(IDB_WDG_STICK);\r
+        ADD_BITMAP(IDB_WDG_STICK_HI);\r
 \r
 #undef ADD_BITMAP\r
     }\r
@@ -285,7 +292,7 @@ _exit:
     if(hc_cs)\r
         khc_close_space(hc_cs);\r
     if(clist)\r
-        free(clist);\r
+        PFREE(clist);\r
 }\r
 \r
 void \r
@@ -316,13 +323,13 @@ cw_update_creds(khui_credwnd_tbl * tbl)
         &delta);\r
 \r
     /* now we need to figure out how to sort the credentials */\r
-    fields = malloc(sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
+    fields = PMALLOC(sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
     ZeroMemory(fields, sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
 \r
     for(i=0, n=0; i<tbl->n_cols; i++) {\r
         if((tbl->cols[i].flags & KHUI_CW_COL_SORT_INC) ||\r
-            (tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC) ||\r
-            (tbl->cols[i].flags & KHUI_CW_COL_GROUP))\r
+           (tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC) ||\r
+           (tbl->cols[i].flags & KHUI_CW_COL_GROUP))\r
         {\r
             int si;\r
             /* we need to sort by this column */\r
@@ -377,15 +384,20 @@ cw_update_creds(khui_credwnd_tbl * tbl)
 \r
         kcdb_credset_get_size(tbl->credset, &s);\r
         for(i=0;i<s;i++) {\r
-            if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset, (khm_int32) i, &hc)))\r
+            if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset, \r
+                                                (khm_int32) i, &hc)))\r
                 continue; /* lost a race */\r
-            if(KHM_FAILED(kcdb_cred_get_attr(hc, khui_cw_flag_id, NULL, NULL, NULL))) {\r
+            if(KHM_FAILED(kcdb_cred_get_attr(hc, khui_cw_flag_id, NULL, \r
+                                             NULL, NULL))) {\r
                 flags = 0;\r
                 kcdb_cred_set_attr(hc, khui_cw_flag_id, &flags, sizeof(flags));\r
             }\r
             kcdb_cred_release(hc);\r
         }\r
     }\r
+\r
+    if (fields)\r
+        PFREE(fields);\r
 }\r
 \r
 void \r
@@ -399,10 +411,14 @@ cw_del_outline(khui_credwnd_outline *o) {
         return;\r
 \r
     if(o->header)\r
-        free(o->header);\r
+        PFREE(o->header);\r
     if ((o->flags & KHUI_CW_O_DATAALLOC) &&\r
         o->data)\r
-        free(o->data);\r
+        PFREE(o->data);\r
+\r
+    if ((o->flags & KHUI_CW_O_STICKY) &&\r
+        o->data)\r
+        kcdb_identity_release((khm_handle) o->data);\r
 \r
     LPOP(&(o->children), &c);\r
     while(c) {\r
@@ -410,7 +426,7 @@ cw_del_outline(khui_credwnd_outline *o) {
         LPOP(&(o->children), &c);\r
     }\r
 \r
-    free(o);\r
+    PFREE(o);\r
 }\r
 \r
 khui_credwnd_outline * \r
@@ -418,12 +434,12 @@ cw_new_outline_node(wchar_t * heading) {
     khui_credwnd_outline * o;\r
     size_t cblen;\r
 \r
-    o = malloc(sizeof(khui_credwnd_outline));\r
+    o = PMALLOC(sizeof(khui_credwnd_outline));\r
     ZeroMemory(o, sizeof(khui_credwnd_outline));\r
     \r
     if(SUCCEEDED(StringCbLength(heading, KHUI_MAXCB_HEADING, &cblen))) {\r
         cblen += sizeof(wchar_t);\r
-        o->header = malloc(cblen);\r
+        o->header = PMALLOC(cblen);\r
         StringCbCopy(o->header, cblen, heading);\r
     }\r
 \r
@@ -531,9 +547,9 @@ cw_set_tbl_row_cred(khui_credwnd_tbl * tbl,
         khm_size newsize;\r
 \r
         newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);\r
-        newrows = malloc(sizeof(khui_credwnd_row) * newsize);\r
+        newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);\r
         memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);\r
-        free(tbl->rows);\r
+        PFREE(tbl->rows);\r
         tbl->rows = newrows;\r
         tbl->n_total_rows = newsize;\r
     }\r
@@ -564,9 +580,9 @@ cw_set_tbl_row_header(khui_credwnd_tbl * tbl,
         khm_size newsize;\r
 \r
         newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);\r
-        newrows = malloc(sizeof(khui_credwnd_row) * newsize);\r
+        newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);\r
         memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);\r
-        free(tbl->rows);\r
+        PFREE(tbl->rows);\r
         tbl->rows = newrows;\r
         tbl->n_total_rows = newsize;\r
     }\r
@@ -635,9 +651,8 @@ cw_update_outline(khui_credwnd_tbl * tbl)
         }\r
     }\r
 \r
-\r
     /* determine the grouping order */\r
-    grouping = malloc(sizeof(khm_int32) * tbl->n_cols);\r
+    grouping = PMALLOC(sizeof(khm_int32) * tbl->n_cols);\r
     for(i=0; i < (int) tbl->n_cols; i++)\r
         grouping[i] = -1;\r
     n_grouping = 0;\r
@@ -664,7 +679,7 @@ cw_update_outline(khui_credwnd_tbl * tbl)
         /* we haven't allocated memory yet */\r
         tbl->n_total_rows = KHUI_CW_ROW_INITIAL;\r
         tbl->n_rows = 0;\r
-        tbl->rows = malloc(sizeof(khui_credwnd_row) * tbl->n_total_rows);\r
+        tbl->rows = PMALLOC(sizeof(khui_credwnd_row) * tbl->n_total_rows);\r
     } else {\r
         /* kill any pending timers */\r
         for(i=0; i < (int) tbl->n_rows; i++) \r
@@ -690,7 +705,8 @@ cw_update_outline(khui_credwnd_tbl * tbl)
            this view, we skip it */\r
         if(prevcred) {\r
             for(j=0; j < (int) tbl->n_cols; j++) {\r
-                if(kcdb_creds_comp_attr(prevcred, thiscred, tbl->cols[j].attr_id))\r
+                if(kcdb_creds_comp_attr(prevcred, thiscred,\r
+                                        tbl->cols[j].attr_id))\r
                     break;\r
             }\r
 \r
@@ -708,7 +724,8 @@ cw_update_outline(khui_credwnd_tbl * tbl)
             for(j=0; j < n_grouping; j++) {\r
                 /* determine the grouping level at which thiscred\r
                    differs from prevcred */\r
-                if(kcdb_creds_comp_attr(prevcred,thiscred,tbl->cols[grouping[j]].attr_id))\r
+                if(kcdb_creds_comp_attr(prevcred,thiscred,\r
+                                        tbl->cols[grouping[j]].attr_id))\r
                     break;\r
             }\r
             level = j;\r
@@ -791,6 +808,7 @@ cw_update_outline(khui_credwnd_tbl * tbl)
                 } else if(tbl->cols[grouping[j]].attr_id == \r
                           KCDB_ATTR_TYPE_NAME) {\r
                     khm_int32 t;\r
+\r
                     ol->attr_id = KCDB_ATTR_TYPE;\r
                     if(KHM_SUCCEEDED(kcdb_cred_get_type(thiscred, &t)))\r
                         ol->data = (void *)(ssize_t) t;\r
@@ -823,7 +841,7 @@ cw_update_outline(khui_credwnd_tbl * tbl)
                     if (rv != KHM_ERROR_TOO_LONG || cbbuf == 0) {\r
                         ol->data = NULL;\r
                     } else {\r
-                        ol->data = malloc(cbbuf);\r
+                        ol->data = PMALLOC(cbbuf);\r
                         assert(ol->data);\r
                         rv = kcdb_cred_get_attr(thiscred,\r
                                                 alt_id,\r
@@ -945,8 +963,8 @@ cw_update_outline(khui_credwnd_tbl * tbl)
             cb_names == 0)\r
             goto _cleanup_sticky;\r
 \r
-        idnames = malloc(cb_names);\r
-        idarray = malloc(n_idents * sizeof(*idarray));\r
+        idnames = PMALLOC(cb_names);\r
+        idarray = PMALLOC(n_idents * sizeof(*idarray));\r
 #ifdef DEBUG\r
         assert(idnames);\r
         assert(idarray);\r
@@ -966,6 +984,12 @@ cw_update_outline(khui_credwnd_tbl * tbl)
         qsort(idarray, n_idents, sizeof(*idarray), iwcscmp);\r
 \r
         for (i=0; i < (int) n_idents; i++) {\r
+            khm_handle h;\r
+\r
+            if (KHM_FAILED(kcdb_identity_create(idarray[i], \r
+                                                KCDB_IDENT_FLAG_CREATE, &h)))\r
+                continue;\r
+\r
             for (o = tbl->outline; o; o = LNEXT(o)) {\r
                 if (!wcscmp(idarray[i], o->header))\r
                     break;\r
@@ -975,15 +999,23 @@ cw_update_outline(khui_credwnd_tbl * tbl)
                 /* found it */\r
                 if (o->start != -1) /* already visible? */\r
                     continue;\r
+                o->flags &= KHUI_CW_O_STICKY;\r
+                o->flags |= KHUI_CW_O_VISIBLE;\r
             } else {\r
                 /* not found.  create */\r
                 o = cw_new_outline_node(idarray[i]);\r
                 o->flags = KHUI_CW_O_VISIBLE;\r
                 o->level = 0;\r
                 o->col = grouping[0];\r
+                o->data = (void *) h;\r
             }\r
 \r
-            o->flags |= KHUI_CW_O_STICKY;\r
+            if (o->flags & KHUI_CW_O_STICKY)\r
+                kcdb_identity_release(h);\r
+            else\r
+                /* leave identity held in this case */\r
+                o->flags |= KHUI_CW_O_STICKY;\r
+\r
             o->flags &= ~KHUI_CW_O_EXPAND;\r
             o->start = n_rows;\r
             o->length = 1;\r
@@ -996,9 +1028,9 @@ cw_update_outline(khui_credwnd_tbl * tbl)
 \r
     _cleanup_sticky:\r
         if (idnames)\r
-            free(idnames);\r
+            PFREE(idnames);\r
         if (idarray)\r
-            free(idarray);\r
+            PFREE(idarray);\r
     }\r
 \r
     tbl->n_rows = n_rows;\r
@@ -1007,7 +1039,7 @@ cw_update_outline(khui_credwnd_tbl * tbl)
     tbl->flags &= ~KHUI_CW_TBL_COL_DIRTY;\r
 _exit:\r
     if(grouping)\r
-        free(grouping);\r
+        PFREE(grouping);\r
 }\r
 \r
 void \r
@@ -1033,6 +1065,7 @@ cw_unload_view(khui_credwnd_tbl * tbl)
     SafeDeleteObject(tbl->hb_hdr_bg_crit);\r
     SafeDeleteObject(tbl->hb_hdr_bg_exp);\r
     SafeDeleteObject(tbl->hb_hdr_bg_warn);\r
+    SafeDeleteObject(tbl->hb_hdr_bg_def);\r
 \r
 #undef SafeDeleteObject\r
 \r
@@ -1049,17 +1082,17 @@ cw_unload_view(khui_credwnd_tbl * tbl)
         khm_size i;\r
         for(i=0; i < tbl->n_cols; i++) {\r
             if(tbl->cols[i].title)\r
-                free(tbl->cols[i].title);\r
+                PFREE(tbl->cols[i].title);\r
             Header_DeleteItem(tbl->hwnd_header, 0);\r
         }\r
-        free(tbl->cols);\r
+        PFREE(tbl->cols);\r
         tbl->cols = NULL;\r
         tbl->n_cols = 0;\r
         tbl->n_total_cols = 0;\r
     }\r
 \r
     if(tbl->rows) {\r
-        free(tbl->rows);\r
+        PFREE(tbl->rows);\r
         tbl->rows = NULL;\r
         tbl->n_rows = 0;\r
         tbl->n_total_rows = 0;\r
@@ -1091,11 +1124,13 @@ cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi)
         phi->fmt = HDF_CENTER | HDF_STRING;\r
     }\r
     phi->lParam = col->attr_id;\r
+#if (_WIN32_WINNT >= 0x501)\r
     if(col->flags & KHUI_CW_COL_SORT_INC) {\r
         phi->fmt |= HDF_SORTUP;\r
     } else if(col->flags & KHUI_CW_COL_SORT_DEC) {\r
         phi->fmt |= HDF_SORTDOWN;\r
     }\r
+#endif\r
     if(col->width < 0) {\r
         /*TODO: come up with a better way to handle this case */\r
         col->width = 200;\r
@@ -1328,7 +1363,8 @@ cw_draw_header(HDC hdc,
     khui_credwnd_row * cr;\r
     khui_credwnd_outline * o;\r
     int selected = 0;\r
\r
+    khm_int32 idf = 0;\r
+\r
     /* each header consists of a 'expose' widget and some text */\r
     /* we need to figure out the background color first */\r
     \r
@@ -1337,18 +1373,26 @@ cw_draw_header(HDC hdc,
 \r
     colattr = tbl->cols[cr->col].attr_id;\r
 \r
+    if (colattr == KCDB_ATTR_ID_NAME) {\r
+        khm_handle ident = o->data;\r
+\r
+        kcdb_identity_get_flags(ident, &idf);\r
+    }\r
+\r
     selected = o->flags & KHUI_CW_O_SELECTED;\r
 \r
     {\r
         HBRUSH hbr;\r
         if(selected)\r
             hbr = tbl->hb_hdr_bg_sel;\r
-        else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)\r
+        else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)\r
             hbr = tbl->hb_hdr_bg_exp;\r
-        else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)\r
+        else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)\r
             hbr = tbl->hb_hdr_bg_crit;\r
-        else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)\r
+        else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)\r
             hbr = tbl->hb_hdr_bg_warn;\r
+        else if (idf & KCDB_IDENT_FLAG_DEFAULT)\r
+            hbr = tbl->hb_hdr_bg_def;\r
         else\r
             hbr = tbl->hb_hdr_bg;\r
 \r
@@ -1365,24 +1409,45 @@ cw_draw_header(HDC hdc,
     if (o->flags & KHUI_CW_O_STICKY) {\r
         /* khui_ilist_draw_id(tbl->ilist, IDB_TK_NEW_SM, hdc, \r
            r->left, r->bottom - KHUI_SMICON_CY, 0); */\r
-    } else if((tbl->mouse_state & CW_MOUSE_OUTLINE) && tbl->mouse_row == row) {\r
+    } else if((tbl->mouse_state & CW_MOUSE_WOUTLINE) && \r
+              tbl->mouse_row == row) {\r
         if(o->flags & KHUI_CW_O_EXPAND) {\r
-            khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND_HI, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+            khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND_HI,\r
+                               hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
         } else {\r
-            khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE_HI, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+            khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE_HI,\r
+                               hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
         }\r
     } else {\r
         if(o->flags & KHUI_CW_O_EXPAND) {\r
-            khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+            khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND,\r
+                               hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
         } else {\r
-            khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+            khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE,\r
+                               hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
         }\r
     }\r
 \r
-    r->left += KHUI_SMICON_CX * 2;\r
+    r->left += KHUI_SMICON_CX * 3 / 2;\r
 \r
     /* try to draw the icon, if there is one */\r
     if(colattr == KCDB_ATTR_ID_NAME) {\r
+\r
+        khui_ilist_draw_id(tbl->ilist,\r
+                           (((tbl->mouse_state & CW_MOUSE_WSTICKY) &&\r
+                             tbl->mouse_row == row)?\r
+                            ((idf & KCDB_IDENT_FLAG_STICKY)?\r
+                             IDB_WDG_STUCK_HI:\r
+                             IDB_WDG_STICK_HI):\r
+                            ((idf & KCDB_IDENT_FLAG_STICKY)?\r
+                             IDB_WDG_STUCK:\r
+                             IDB_WDG_STICK)),\r
+                           hdc,\r
+                           r->left, r->bottom - KHUI_SMICON_CY,\r
+                           0);\r
+\r
+        r->left += KHUI_SMICON_CX * 3 / 2;\r
+\r
         khui_ilist_draw_id(tbl->ilist, \r
                            ((o->flags & KHUI_CW_O_STICKY)?\r
                             IDB_ID_DIS_SM:\r
@@ -1404,6 +1469,23 @@ cw_draw_header(HDC hdc,
         SetTextColor(hdc, tbl->cr_hdr_normal);\r
 \r
     TextOut(hdc, r->left, r->bottom - tbl->vpad, o->header, (int) wcslen(o->header));\r
+\r
+    if (colattr == KCDB_ATTR_ID_NAME &&\r
+        (idf & KCDB_IDENT_FLAG_DEFAULT)) {\r
+        wchar_t defstr[64];\r
+        SIZE size;\r
+\r
+        LoadString(khm_hInstance, IDS_CW_DEFAULT,\r
+                   defstr, ARRAYLENGTH(defstr));\r
+\r
+        GetTextExtentPoint32(hdc, o->header, (int) wcslen(o->header),\r
+                             &size);\r
+\r
+        r->left += size.cx + KHUI_SMICON_CX * 2;\r
+\r
+        TextOut(hdc, r->left, r->bottom - tbl->vpad, \r
+                defstr, (int) wcslen(defstr));\r
+    }\r
 }\r
 \r
 LRESULT \r
@@ -1474,8 +1556,10 @@ cw_wm_create(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     khui_credwnd_tbl * tbl;\r
 \r
     kmq_subscribe_hwnd(KMSG_CRED, hwnd);\r
+    kmq_subscribe_hwnd(KMSG_KCDB, hwnd);\r
 \r
-    tbl = malloc(sizeof(*tbl));\r
+    /* freed in cw_wm_destroy  */\r
+    tbl = PMALLOC(sizeof(*tbl));\r
     ZeroMemory(tbl, sizeof(*tbl));\r
 \r
     /* some versions of VC generate portability warnings for\r
@@ -1490,7 +1574,11 @@ cw_wm_create(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
         WC_HEADER,\r
         (LPWSTR) NULL,\r
         WS_CHILD | HDS_BUTTONS |\r
-        HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK | HDS_FLAT,\r
+        HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK\r
+#if (_WIN32_WINNT >= 0x501)\r
+        | HDS_FLAT\r
+#endif\r
+        ,\r
         0,0,0,0,hwnd, (HMENU) 0, khm_hInstance, NULL);\r
 \r
     cw_load_view(tbl, NULL /* default view */, hwnd);\r
@@ -1530,12 +1618,13 @@ cw_wm_destroy(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     khui_credwnd_tbl * tbl;\r
 \r
     kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);\r
+    kmq_unsubscribe_hwnd(KMSG_KCDB, hwnd);\r
 \r
     tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
 \r
     cw_unload_view(tbl);\r
 \r
-    free(tbl);\r
+    PFREE(tbl);\r
     return DefWindowProc(hwnd, uMsg, wParam, lParam);\r
 }\r
 \r
@@ -1838,19 +1927,42 @@ cw_kmq_wm_dispatch(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 \r
     kmq_wm_begin(lParam, &m);\r
     if(m->type == KMSG_CRED) {\r
-        if(m->subtype == KMSG_CRED_ROOTDELTA) {\r
+        switch (m->subtype) {\r
+        case KMSG_CRED_ROOTDELTA:\r
             cw_update_creds(tbl);\r
             cw_update_outline(tbl);\r
             cw_update_extents(tbl, TRUE);\r
             InvalidateRect(hwnd, NULL, FALSE);\r
-        } else if(m->subtype == KMSG_CRED_PP_BEGIN) {\r
+            break;\r
+\r
+        case KMSG_CRED_PP_BEGIN:\r
             cw_pp_begin((khui_property_sheet *) m->vparam);\r
-        } else if(m->subtype == KMSG_CRED_PP_PRECREATE) {\r
+            break;\r
+\r
+        case KMSG_CRED_PP_PRECREATE:\r
             cw_pp_precreate((khui_property_sheet *) m->vparam);\r
-        } else if(m->subtype == KMSG_CRED_PP_END) {\r
+            break;\r
+\r
+        case KMSG_CRED_PP_END:\r
             cw_pp_end((khui_property_sheet *) m->vparam);\r
-        } else if(m->subtype == KMSG_CRED_PP_DESTROY) {\r
+            break;\r
+\r
+        case KMSG_CRED_PP_DESTROY:\r
             cw_pp_destroy((khui_property_sheet *) m->vparam);\r
+            break;\r
+        }\r
+    } else if (m->type == KMSG_KCDB) {\r
+        if (m->subtype == KMSG_KCDB_IDENT &&\r
+            m->uparam == KCDB_OP_MODIFY) {\r
+\r
+            cw_update_outline(tbl);\r
+            cw_update_extents(tbl, TRUE);\r
+            InvalidateRect(hwnd, NULL, FALSE);\r
+        }\r
+        else if (m->subtype == KMSG_KCDB_IDENT && \r
+                 m->uparam == KCDB_OP_NEW_DEFAULT) {\r
+\r
+            InvalidateRect(hwnd, NULL, FALSE);\r
         }\r
     }\r
     return kmq_wm_end(m, rv);\r
@@ -1963,6 +2075,15 @@ cw_set_row_context(khui_credwnd_tbl * tbl, int row)
     khui_credwnd_outline * o;\r
     BOOL set_context = TRUE;\r
 \r
+    if (row < 0 || row >= (int) tbl->n_rows) {\r
+        if (tbl->n_rows > 0)\r
+            row = 0;\r
+        else {\r
+            khui_context_reset();\r
+            return;\r
+        }\r
+    }\r
+\r
     if (tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {\r
 \r
         o = (khui_credwnd_outline *) tbl->rows[row].data;\r
@@ -2077,6 +2198,28 @@ cw_set_row_context(khui_credwnd_tbl * tbl, int row)
     }\r
 }\r
 \r
+static void\r
+cw_select_all(khui_credwnd_tbl * tbl)\r
+{\r
+    khm_size i;\r
+\r
+    for(i=0; i<tbl->n_rows; i++) {\r
+        tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;\r
+        if (!(tbl->rows[i].flags & KHUI_CW_ROW_HEADER))\r
+            kcdb_cred_set_flags((khm_handle) tbl->rows[i].data,\r
+                                KCDB_CRED_FLAG_SELECTED,\r
+                                KCDB_CRED_FLAG_SELECTED);\r
+    }\r
+\r
+    cw_select_outline_level(tbl->outline, TRUE);\r
+\r
+    cw_update_selection_state(tbl);\r
+\r
+    cw_set_row_context(tbl, tbl->cursor_row);\r
+\r
+    InvalidateRect(tbl->hwnd, NULL, FALSE);\r
+}\r
+\r
 static void \r
 cw_select_row(khui_credwnd_tbl * tbl, int row, WPARAM wParam)\r
 {\r
@@ -2231,11 +2374,10 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
 \r
     /* we are basically trying to capture events where the mouse is\r
-    hovering over one of the 'hotspots'.  There are two kinds of\r
-    hotspots one is the little widget thinggy that you click on to\r
-    expand or collapse an outline.  The other is a text cell that is\r
-    partially concealed.\r
-    */\r
+       hovering over one of the 'hotspots'.  There are two kinds of\r
+       hotspots one is the little widget thinggy that you click on to\r
+       expand or collapse an outline.  The other is a text cell that\r
+       is partially concealed. */\r
 \r
     x = GET_X_LPARAM(lParam);\r
     y = GET_Y_LPARAM(lParam);\r
@@ -2246,10 +2388,10 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     col = -1;\r
     nm_state = CW_MOUSE_NONE;\r
     nm_row = nm_col = -1;\r
+\r
     for(i=0; i < (int) tbl->n_cols; i++) {\r
         if(x >= tbl->cols[i].x &&\r
-            x < tbl->cols[i].x + tbl->cols[i].width) \r
-        {\r
+           x < tbl->cols[i].x + tbl->cols[i].width) {\r
             col = i;\r
             break;\r
         }\r
@@ -2266,68 +2408,126 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
             /* are we on a widget then? */\r
             x -= tbl->cols[tbl->rows[row].col].x;\r
             if(x >= 0 && x < KHUI_SMICON_CX) /* hit */ {\r
-                nm_state |= CW_MOUSE_OUTLINE;\r
+                nm_state |= CW_MOUSE_WOUTLINE | CW_MOUSE_WIDGET;\r
+            } else if (tbl->cols[tbl->rows[row].col].attr_id == \r
+                       KCDB_ATTR_ID_NAME &&\r
+                       col == tbl->rows[row].col &&\r
+                       x >= KHUI_SMICON_CX * 3 / 2 &&\r
+                       x < KHUI_SMICON_CX * 5 / 2){\r
+                nm_state |= CW_MOUSE_WSTICKY | CW_MOUSE_WIDGET;\r
             }\r
         }\r
     }\r
 \r
-    if((tbl->mouse_state & CW_MOUSE_LDOWN) && \r
-        (tbl->mouse_state & CW_MOUSE_OUTLINE) && \r
-        (nm_row != tbl->mouse_row))\r
-    {\r
-        nm_state &= ~CW_MOUSE_OUTLINE;\r
+    /* did the user drag the cursor off the current row? */\r
+    if((tbl->mouse_state & CW_MOUSE_LDOWN) &&\r
+       (nm_row != tbl->mouse_row)) {\r
+        nm_state &= ~(CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE | CW_MOUSE_WSTICKY);\r
     }\r
     \r
     if(!(nm_state & CW_MOUSE_LDOWN) && \r
-       (tbl->mouse_state & CW_MOUSE_LDOWN)) {\r
+       (tbl->mouse_state & CW_MOUSE_LDOWN) &&\r
+       tbl->mouse_row == nm_row) {\r
 \r
-        if((nm_state & CW_MOUSE_OUTLINE) &&\r
-           (tbl->mouse_state & CW_MOUSE_OUTLINE)) {\r
-            /* click on a widget */\r
+        if((nm_state & CW_MOUSE_WOUTLINE) &&\r
+           (tbl->mouse_state & CW_MOUSE_WOUTLINE)) {\r
+            /* click on an outline widget */\r
             khui_credwnd_outline * o;\r
 \r
             o = (khui_credwnd_outline *) tbl->rows[nm_row].data;\r
-            tbl->mouse_state = CW_MOUSE_OUTLINE;\r
+            tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE;\r
 \r
             cw_toggle_outline_state(tbl, o);\r
 \r
             return 0;\r
-        } else if(nm_row == tbl->mouse_row) {\r
+        } else if ((nm_state & CW_MOUSE_WSTICKY) &&\r
+                   (tbl->mouse_state & CW_MOUSE_WSTICKY)) {\r
+\r
+            khui_credwnd_outline * o;\r
+            khm_handle ident;\r
+            khm_int32 idf = 0;\r
+\r
+            o = tbl->rows[nm_row].data;\r
+            ident = o->data;\r
+\r
+            kcdb_identity_get_flags(ident, &idf);\r
+            idf &= KCDB_IDENT_FLAG_STICKY;\r
+            kcdb_identity_set_flags(ident, (idf ^ KCDB_IDENT_FLAG_STICKY),\r
+                                    KCDB_IDENT_FLAG_STICKY);\r
+\r
+            tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WSTICKY;\r
+\r
+            return 0;\r
+        } else {\r
             /* click on a row */\r
             cw_select_row(tbl, nm_row, wParam);\r
         }\r
-\r
     }\r
 \r
-    /*TODO: if a user clicks somewhere and drags on to an exand widget, it activates the widet. should not */\r
-\r
     /* ok, now if we are changing state, we need to invalidate a few\r
        regions */\r
-    if((tbl->mouse_state ^ nm_state) & CW_MOUSE_OUTLINE) {\r
-        if(tbl->mouse_state & CW_MOUSE_OUTLINE) {\r
+    if (((tbl->mouse_state ^ nm_state) & (CW_MOUSE_WIDGET |\r
+                                          CW_MOUSE_WOUTLINE |\r
+                                          CW_MOUSE_WSTICKY)) ||\r
+        tbl->mouse_row != nm_row) {\r
+\r
+        if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {\r
             r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
-            r.top = tbl->mouse_row * tbl->cell_height + tbl->header_height - tbl->scr_top;\r
+            r.top = tbl->mouse_row * tbl->cell_height + \r
+                tbl->header_height - tbl->scr_top;\r
+            r.right = r.left + KHUI_SMICON_CX;\r
+            r.bottom = r.top + tbl->cell_height;\r
+            InvalidateRect(tbl->hwnd, &r, TRUE);\r
+        }\r
+        if(tbl->mouse_state & CW_MOUSE_WSTICKY) {\r
+            r.left = KHUI_SMICON_CX * 3 / 2 + \r
+                tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
+            r.top = tbl->mouse_row * tbl->cell_height + \r
+                tbl->header_height - tbl->scr_top;\r
             r.right = r.left + KHUI_SMICON_CX;\r
             r.bottom = r.top + tbl->cell_height;\r
             InvalidateRect(tbl->hwnd, &r, TRUE);\r
         }\r
 \r
-        tbl->mouse_col = nm_col;\r
-        tbl->mouse_row = nm_row;\r
+        if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {\r
+            if (tbl->mouse_row == nm_row)\r
+                tbl->mouse_col = nm_col;\r
+        } else {\r
+            tbl->mouse_col = nm_col;\r
+            tbl->mouse_row = nm_row;\r
+        }\r
         tbl->mouse_state = nm_state;\r
 \r
         /* same code block as above */\r
-        if(tbl->mouse_state & CW_MOUSE_OUTLINE) {\r
+        if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {\r
             r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
-            r.top = tbl->mouse_row * tbl->cell_height + tbl->header_height - tbl->scr_top;\r
+            r.top = tbl->mouse_row * tbl->cell_height + \r
+                tbl->header_height - tbl->scr_top;\r
+            r.right = r.left + KHUI_SMICON_CX;\r
+            r.bottom = r.top + tbl->cell_height;\r
+            InvalidateRect(tbl->hwnd, &r, TRUE);\r
+        }\r
+        if(tbl->mouse_state & CW_MOUSE_WSTICKY) {\r
+            r.left = KHUI_SMICON_CX * 3 / 2 + \r
+                tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
+            r.top = tbl->mouse_row * tbl->cell_height + \r
+                tbl->header_height - tbl->scr_top;\r
             r.right = r.left + KHUI_SMICON_CX;\r
             r.bottom = r.top + tbl->cell_height;\r
             InvalidateRect(tbl->hwnd, &r, TRUE);\r
         }\r
     } else if(tbl->mouse_state != nm_state) {\r
-        tbl->mouse_col = nm_col;\r
-        tbl->mouse_row = nm_row;\r
-        tbl->mouse_state = nm_state;\r
+\r
+        if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {\r
+            if (tbl->mouse_row == nm_row) {\r
+                tbl->mouse_col = nm_col;\r
+                tbl->mouse_state = nm_state;\r
+            }\r
+        } else {\r
+            tbl->mouse_col = nm_col;\r
+            tbl->mouse_row = nm_row;\r
+            tbl->mouse_state = nm_state;\r
+        }\r
     }\r
 \r
     /* if it was a double click, also show the property\r
@@ -2553,13 +2753,13 @@ static INT_PTR CALLBACK
 cw_pp_ident_proc(HWND hwnd,\r
                  UINT uMsg,\r
                  WPARAM wParam,\r
-                 LPARAM lParam\r
-                 )\r
+                 LPARAM lParam)\r
 {\r
+    khui_property_sheet * s;\r
+\r
     switch(uMsg) {\r
     case WM_INITDIALOG:\r
         {\r
-            khui_property_sheet * s;\r
             PROPSHEETPAGE * p;\r
             khm_handle ident;\r
             wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
@@ -2582,23 +2782,108 @@ cw_pp_ident_proc(HWND hwnd,
 \r
             kcdb_identity_get_flags(ident, &i);\r
 \r
-            SendDlgItemMessage(hwnd, \r
-                               IDC_PP_IDDEF, \r
-                               BM_SETCHECK, \r
-                               (WPARAM) ((i & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:BST_UNCHECKED),\r
-                               0);\r
+            CheckDlgButton(hwnd, IDC_PP_IDDEF,\r
+                           ((i & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:\r
+                            BST_UNCHECKED));\r
+\r
+            /* if it's default, you can't change it further */\r
+            if (i & KCDB_IDENT_FLAG_DEFAULT) {\r
+                EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);\r
+            }\r
+\r
+            CheckDlgButton(hwnd, IDC_PP_IDSEARCH,\r
+                           ((i & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:\r
+                            BST_UNCHECKED));\r
 \r
-            SendDlgItemMessage(\r
-                               hwnd,\r
-                               IDC_PP_IDSEARCH,\r
-                               BM_SETCHECK,\r
-                               (WPARAM) ((i & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:BST_UNCHECKED),\r
-                               0);\r
+            CheckDlgButton(hwnd, IDC_PP_STICKY,\r
+                           ((i & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:\r
+                            BST_UNCHECKED));\r
 \r
             khui_property_wnd_set_record(GetDlgItem(hwnd, IDC_PP_PROPLIST),\r
                                          ident);\r
         }\r
         return TRUE;\r
+\r
+    case WM_COMMAND:\r
+        s = (khui_property_sheet *) (LONG_PTR) \r
+            GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+        switch(wParam) {\r
+        case MAKEWPARAM(IDC_PP_IDDEF, BN_CLICKED):\r
+            /* fallthrough */\r
+        case MAKEWPARAM(IDC_PP_STICKY, BN_CLICKED):\r
+\r
+            if (s->status != KHUI_PS_STATUS_NONE)\r
+                PropSheet_Changed(s->hwnd, hwnd);\r
+            return TRUE;\r
+\r
+        case MAKEWPARAM(IDC_PP_CONFIG, BN_CLICKED):\r
+            {\r
+                khui_config_node cfg_ids = NULL;\r
+                khm_int32 rv;\r
+\r
+                khm_refresh_config();\r
+\r
+                rv = khui_cfg_open(NULL,\r
+                                   L"KhmIdentities",\r
+                                   &cfg_ids);\r
+\r
+                if (KHM_FAILED(rv))\r
+                    return TRUE;\r
+\r
+                khm_show_config_pane(cfg_ids);\r
+\r
+                if (cfg_ids)\r
+                    khui_cfg_release(cfg_ids);\r
+            }\r
+            return TRUE;\r
+        }\r
+        return FALSE;\r
+\r
+    case WM_NOTIFY:\r
+        {\r
+            LPPSHNOTIFY lpp;\r
+            khm_int32 flags;\r
+\r
+            lpp = (LPPSHNOTIFY) lParam;\r
+            s = (khui_property_sheet *) (LONG_PTR) \r
+                GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+            switch(lpp->hdr.code) {\r
+            case PSN_APPLY:\r
+                flags = 0;\r
+                if (IsDlgButtonChecked(hwnd, IDC_PP_STICKY) == BST_CHECKED)\r
+                    flags |= KCDB_IDENT_FLAG_STICKY;\r
+                if (IsDlgButtonChecked(hwnd, IDC_PP_IDDEF) == BST_CHECKED)\r
+                    flags |= KCDB_IDENT_FLAG_DEFAULT;\r
+\r
+                kcdb_identity_set_flags(s->identity, flags,\r
+                                        KCDB_IDENT_FLAG_STICKY |\r
+                                        KCDB_IDENT_FLAG_DEFAULT);\r
+                return TRUE;\r
+\r
+            case PSN_RESET:\r
+                kcdb_identity_get_flags(s->identity, &flags);\r
+\r
+                CheckDlgButton(hwnd, \r
+                               IDC_PP_IDDEF, \r
+                               ((flags & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:\r
+                                BST_UNCHECKED));\r
+\r
+                /* if it's default, you can't change it further */\r
+                if (flags & KCDB_IDENT_FLAG_DEFAULT) {\r
+                    EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);\r
+                }\r
+\r
+                CheckDlgButton(hwnd, IDC_PP_IDSEARCH,\r
+                               ((flags & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:BST_UNCHECKED));\r
+\r
+                CheckDlgButton(hwnd, IDC_PP_STICKY,\r
+                               ((flags & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:BST_UNCHECKED));\r
+                return TRUE;\r
+            }\r
+        }\r
+        break;\r
     }\r
     return FALSE;\r
 }\r
@@ -2642,7 +2927,7 @@ cw_pp_begin(khui_property_sheet * s)
     PROPSHEETPAGE *p;\r
 \r
     if(s->identity) {\r
-        p = malloc(sizeof(*p));\r
+        p = PMALLOC(sizeof(*p));\r
         ZeroMemory(p, sizeof(*p));\r
 \r
         p->dwSize = sizeof(*p);\r
@@ -2651,11 +2936,12 @@ cw_pp_begin(khui_property_sheet * s)
         p->pszTemplate = MAKEINTRESOURCE(IDD_PP_IDENT);\r
         p->pfnDlgProc = cw_pp_ident_proc;\r
         p->lParam = (LPARAM) s;\r
-        khui_ps_add_page(s, KHUI_PPCT_IDENTITY, 0, p, NULL);\r
+\r
+        khui_ps_add_page(s, KHUI_PPCT_IDENTITY, 129, p, NULL);\r
     }\r
 \r
     if(s->cred) {\r
-        p = malloc(sizeof(*p));\r
+        p = PMALLOC(sizeof(*p));\r
         ZeroMemory(p, sizeof(*p));\r
 \r
         p->dwSize = sizeof(*p);\r
@@ -2664,7 +2950,8 @@ cw_pp_begin(khui_property_sheet * s)
         p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);\r
         p->pfnDlgProc = cw_pp_cred_proc;\r
         p->lParam = (LPARAM) s;\r
-        khui_ps_add_page(s, KHUI_PPCT_CREDENTIAL, 0, p, NULL);\r
+\r
+        khui_ps_add_page(s, KHUI_PPCT_CREDENTIAL, 128, p, NULL);\r
     }\r
 }\r
 \r
@@ -2683,7 +2970,7 @@ cw_pp_end(khui_property_sheet * s)
 \r
     khui_ps_find_page(s, KHUI_PPCT_IDENTITY, &p);\r
     if(p) {\r
-        free(p->p_page);\r
+        PFREE(p->p_page);\r
         p->p_page = NULL;\r
     }\r
 \r
@@ -2691,7 +2978,7 @@ cw_pp_end(khui_property_sheet * s)
 \r
     khui_ps_find_page(s, KHUI_PPCT_CREDENTIAL, &p);\r
     if(p) {\r
-        free(p->p_page);\r
+        PFREE(p->p_page);\r
         p->p_page = NULL;\r
     }\r
 }\r
@@ -2701,24 +2988,26 @@ cw_pp_destroy(khui_property_sheet *ps)
 {\r
     if(ps->ctx.scope == KHUI_SCOPE_CRED) {\r
         if(ps->header.pszCaption)\r
-            free((LPWSTR) ps->header.pszCaption);\r
+            PFREE((LPWSTR) ps->header.pszCaption);\r
     }\r
 \r
+    khui_context_release(&ps->ctx);\r
+\r
     khui_ps_destroy_sheet(ps);\r
 \r
     /* this is pretty weird because ps gets freed when\r
-    khui_ps_destroy_sheet() is called.  However, since destroying ps\r
-    involves sending a WM_DESTROY message to the property sheet, we\r
-    still need to keep it on the property sheet chain (or else the\r
-    messages will not be delivered).  This is only safe because we are\r
-    not relinquishing the thread in-between destroying ps and removing\r
-    it from the chain. */\r
-\r
-    /*TODO: fix this */\r
+       khui_ps_destroy_sheet() is called.  However, since destroying\r
+       ps involves sending a WM_DESTROY message to the property sheet,\r
+       we still need to keep it on the property sheet chain (or else\r
+       the messages will not be delivered).  This is only safe because\r
+       we are not relinquishing the thread in-between destroying ps\r
+       and removing it from the chain. */\r
+\r
+    /* TODO: fix this */\r
     khm_del_property_sheet(ps);\r
 }\r
 \r
-LRESULT \r
+LRESULT\r
 cw_properties(HWND hwnd)\r
 {\r
     /* show a property sheet of some sort */\r
@@ -2730,7 +3019,7 @@ cw_properties(HWND hwnd)
     tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
 \r
     if(ctx.scope == KHUI_SCOPE_NONE) {\r
-\r
+        khui_context_release(&ctx);\r
         return FALSE;\r
 \r
         /* While it seems like a good idea, doing this is not */\r
@@ -2764,6 +3053,7 @@ cw_properties(HWND hwnd)
 \r
     /* if still no context, then we can't show a property sheet */\r
     if(ctx.scope == KHUI_SCOPE_NONE) {\r
+        khui_context_release(&ctx);\r
         return FALSE;\r
     }\r
 \r
@@ -2781,8 +3071,9 @@ cw_properties(HWND hwnd)
         kcdb_identity_get_name(ident, NULL, &t);\r
 \r
         if(t > 0) {\r
-            ps->header.pszCaption = malloc(t);\r
-            kcdb_identity_get_name(ident, (wchar_t *) ps->header.pszCaption, &t);\r
+            ps->header.pszCaption = PMALLOC(t);\r
+            kcdb_identity_get_name(ident,\r
+                                   (wchar_t *) ps->header.pszCaption, &t);\r
         } else {\r
             ps->header.pszCaption = NULL;\r
         }\r
@@ -2813,7 +3104,7 @@ cw_properties(HWND hwnd)
                something else */\r
             kcdb_identity_get_name(ctx.identity, NULL, &t);\r
             if (t > 0) {\r
-                ps->header.pszCaption = malloc(t);\r
+                ps->header.pszCaption = PMALLOC(t);\r
                 kcdb_identity_get_name(ctx.identity, (wchar_t *) ps->header.pszCaption, &t);\r
             } else {\r
                 ps->header.pszCaption = NULL;\r
@@ -2821,7 +3112,7 @@ cw_properties(HWND hwnd)
         } else {\r
             kcdb_credtype_describe(cred_type, NULL, &t, KCDB_TS_LONG);\r
             if(t > 0) {\r
-                ps->header.pszCaption = malloc(t);\r
+                ps->header.pszCaption = PMALLOC(t);\r
                 kcdb_credtype_describe(cred_type, (wchar_t *) ps->header.pszCaption, &t, KCDB_TS_LONG);\r
             } else {\r
                 ps->header.pszCaption = NULL;\r
@@ -2840,7 +3131,7 @@ cw_properties(HWND hwnd)
         ps->ctx = ctx;\r
 \r
         kcdb_cred_get_name(cred, NULL, &t);\r
-        ps->header.pszCaption = malloc(t);\r
+        ps->header.pszCaption = PMALLOC(t);\r
         kcdb_cred_get_name(cred, (LPWSTR) ps->header.pszCaption, &t);\r
 \r
         kcdb_cred_get_identity(cred, &ps->identity);\r
@@ -2849,10 +3140,13 @@ cw_properties(HWND hwnd)
 \r
         kmq_post_message(KMSG_CRED, KMSG_CRED_PP_BEGIN, 0, (void *) ps);\r
     } else {\r
+        khui_context_release(&ctx);\r
         khui_ps_destroy_sheet(ps);\r
     }\r
 \r
-    khui_context_reset();\r
+    /* by the way, if we are actually opening a property sheet, we\r
+       leave ctx held (which is now copied to ps->ctx).  it will be\r
+       released when the property sheet is destroyed */\r
 \r
     return TRUE;\r
 }\r
@@ -2989,6 +3283,12 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
         }\r
         break;\r
 \r
+    case KHUI_PACTION_SELALL:\r
+        {\r
+            cw_select_all(tbl);\r
+        }\r
+        break;\r
+\r
     case KHUI_PACTION_LEFT:\r
         { /* collapse and up*/\r
             khui_credwnd_outline * o;\r
index 66fc3d2fbc1283aec9a3f03fc530a572cc5e9db2..5d1137f8460d6904925564298f5227f55d26cefd 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -173,6 +173,7 @@ typedef struct khui_credwnd_tbl_t {
     HBRUSH hb_hdr_bg_warn;  /* header background color (warn) */\r
     HBRUSH hb_hdr_bg_crit;  /* header background color (critical) */\r
     HBRUSH hb_hdr_bg_sel;   /* header background color (selected) */\r
+    HBRUSH hb_hdr_bg_def;   /* header background color (default) */\r
     HCURSOR hc_hand;        /* the HAND cursor */\r
     khui_ilist * ilist;     /* image list */\r
 \r
@@ -205,10 +206,16 @@ typedef struct khui_credwnd_tbl_t {
 #define KHUI_CW_TBL_ACTIVE      0x00000100\r
 \r
 /* mouse_state constants */\r
-#define CW_MOUSE_NONE       0   /* nothing interesting */\r
-#define CW_MOUSE_OUTLINE    1   /* mouse is highlighting an outline widget */\r
-#define CW_MOUSE_LDOWN      2   /* left button is down */\r
-#define CW_MOUSE_ROW        4   /* mouse is acive over a valid row */\r
+#define CW_MOUSE_NONE       0x00000000 /* nothing interesting */\r
+#define CW_MOUSE_WIDGET     0x00000001 /* mouse is highlighting a\r
+                                          widget */\r
+#define CW_MOUSE_LDOWN      0x00000002 /* left button is down */\r
+#define CW_MOUSE_ROW        0x00000004 /* mouse is acive over a valid\r
+                                          row */\r
+#define CW_MOUSE_WOUTLINE   0x00000008 /* mouse is highlighting an\r
+                                          outline widget */\r
+#define CW_MOUSE_WSTICKY    0x00000010 /* mouse is highlighting a\r
+                                          sticky widget */\r
 \r
 void khm_unregister_credwnd_class(void);\r
 \r
index 9acbac704e70cca3497efc328fa7b0d68b5161ec..0ad9c880f48e7938c543272cb5bb716929f09ff1 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -384,7 +384,7 @@ static int htw_parse_tag(
             khui_htwnd_link * l;\r
 \r
             if(!d->links) {\r
-                d->links = malloc(sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
+                d->links = PMALLOC(sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
                 ZeroMemory(d->links, sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
                 d->max_links = HTW_LINK_ALLOC;\r
                 d->n_links = 0;\r
@@ -396,17 +396,17 @@ static int htw_parse_tag(
 \r
                 n_new = UBOUNDSS(d->n_links + 1, HTW_LINK_ALLOC, HTW_LINK_ALLOC);\r
 \r
-                ll = malloc(sizeof(khui_htwnd_link *) * n_new);\r
+                ll = PMALLOC(sizeof(khui_htwnd_link *) * n_new);\r
                 ZeroMemory(ll, sizeof(khui_htwnd_link *) * n_new);\r
                 memcpy(ll, d->links, sizeof(khui_htwnd_link *) * d->max_links);\r
-                free(d->links);\r
+                PFREE(d->links);\r
                 d->links = ll;\r
                 d->max_links = n_new;\r
             }\r
 \r
             l = d->links[d->n_links];\r
             if(!l) {\r
-                l = malloc(sizeof(khui_htwnd_link));\r
+                l = PMALLOC(sizeof(khui_htwnd_link));\r
                 d->links[d->n_links] = l;\r
             }\r
 \r
@@ -807,7 +807,7 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
 \r
                 cs = (CREATESTRUCT *) lParam;\r
 \r
-                d = malloc(sizeof(*d));\r
+                d = PMALLOC(sizeof(*d));\r
                 ZeroMemory(d, sizeof(*d));\r
 \r
                 if(cs->dwExStyle & WS_EX_TRANSPARENT) {\r
@@ -824,7 +824,7 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
 \r
                 if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {\r
                     cbsize += sizeof(wchar_t);\r
-                    d->text = malloc(cbsize);\r
+                    d->text = PMALLOC(cbsize);\r
                     StringCbCopy(d->text, cbsize, cs->lpszName);\r
                 }\r
 \r
@@ -848,13 +848,13 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
                 newtext = (wchar_t *) lParam;\r
 \r
                 if(d->text) {\r
-                    free(d->text);\r
+                    PFREE(d->text);\r
                     d->text = NULL;\r
                 }\r
 \r
                 if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {\r
                     cbsize += sizeof(wchar_t);\r
-                    d->text = malloc(cbsize);\r
+                    d->text = PMALLOC(cbsize);\r
                     StringCbCopy(d->text, cbsize, newtext);\r
                     rv = TRUE;\r
                 } else\r
@@ -875,20 +875,20 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd,
 \r
                 d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
                 if(d->text)\r
-                    free(d->text);\r
+                    PFREE(d->text);\r
                 d->text = 0;\r
 \r
                 if(d->links) {\r
                     for(i=0;i<d->max_links;i++) {\r
                         if(d->links[i])\r
-                            free(d->links[i]);\r
+                            PFREE(d->links[i]);\r
                     }\r
-                    free(d->links);\r
+                    PFREE(d->links);\r
                 }\r
 \r
                 clear_styles(d);\r
 \r
-                free(d);\r
+                PFREE(d);\r
             }\r
             break;\r
 \r
index 9e747880385b76a32bdb6b38dbb4fcd431f7a042..e83dbb68445be4d909c5f1217fdc6c5ffcd854a4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
diff --git a/src/windows/identity/ui/images/Thumbs.db b/src/windows/identity/ui/images/Thumbs.db
deleted file mode 100644 (file)
index a80265f..0000000
Binary files a/src/windows/identity/ui/images/Thumbs.db and /dev/null differ
diff --git a/src/windows/identity/ui/images/bitmap1.bmp b/src/windows/identity/ui/images/bitmap1.bmp
deleted file mode 100644 (file)
index 1f07309..0000000
Binary files a/src/windows/identity/ui/images/bitmap1.bmp and /dev/null differ
diff --git a/src/windows/identity/ui/images/cfg_plugin.ico b/src/windows/identity/ui/images/cfg_plugin.ico
new file mode 100644 (file)
index 0000000..710a962
Binary files /dev/null and b/src/windows/identity/ui/images/cfg_plugin.ico differ
index 688da40df318687db35d1ba6c97c2d68ea4a626d..71c95ad4ab86dc604782a084b96ee72e124e64fa 100644 (file)
Binary files a/src/windows/identity/ui/images/chpw.bmp and b/src/windows/identity/ui/images/chpw.bmp differ
index d7d4eafacca37cc90c33f900c2a82289bd54c295..568c46bec871cfc538f175fad4a4b2c88b1685bb 100644 (file)
Binary files a/src/windows/identity/ui/images/help.bmp and b/src/windows/identity/ui/images/help.bmp differ
diff --git a/src/windows/identity/ui/images/icon1.ico b/src/windows/identity/ui/images/icon1.ico
deleted file mode 100644 (file)
index c2746b0..0000000
Binary files a/src/windows/identity/ui/images/icon1.ico and /dev/null differ
index ff0c38e4d169e66a2356c1b41a0687d9bb51dc1f..d028d84ca89804ab8d62141f18eac3d16a89820b 100644 (file)
Binary files a/src/windows/identity/ui/images/id-dis-sm.bmp and b/src/windows/identity/ui/images/id-dis-sm.bmp differ
index 6a428c979ebb9fd4ca7c5b0fcc388cc88cc772f9..b067166b7383408cb67145e1657e043a11d132e7 100644 (file)
Binary files a/src/windows/identity/ui/images/import.bmp and b/src/windows/identity/ui/images/import.bmp differ
diff --git a/src/windows/identity/ui/images/main_app_old.ico b/src/windows/identity/ui/images/main_app_old.ico
deleted file mode 100644 (file)
index e3222e7..0000000
Binary files a/src/windows/identity/ui/images/main_app_old.ico and /dev/null differ
diff --git a/src/windows/identity/ui/images/text1138.png b/src/windows/identity/ui/images/text1138.png
deleted file mode 100644 (file)
index cf5ee37..0000000
Binary files a/src/windows/identity/ui/images/text1138.png and /dev/null differ
index 501ff6e241421f7c3a303d4fac59eed020a41acf..a60bf819920b20fddd5030df3eaec882e45a8f34 100644 (file)
Binary files a/src/windows/identity/ui/images/tk-delete.bmp and b/src/windows/identity/ui/images/tk-delete.bmp differ
index e0e7bc0d65a2405ec261660f64fedb1f7fce129e..9d0eec64fe02d61ee8244f1c4b34107fa956f5d9 100644 (file)
Binary files a/src/windows/identity/ui/images/tk-new.bmp and b/src/windows/identity/ui/images/tk-new.bmp differ
index 6e39f877486cd850d9431ef8889d9915a576fb75..9b8b1b0cb1a3db371faa0779ce238f7415ecbc6d 100644 (file)
Binary files a/src/windows/identity/ui/images/tk-refresh.bmp and b/src/windows/identity/ui/images/tk-refresh.bmp differ
index 76b68ddf758d97b377305f789cd1469cd8150d39..6d284a50e59150861c46b66a08edcfbcecd61e2c 100644 (file)
Binary files a/src/windows/identity/ui/images/vw-refresh.bmp and b/src/windows/identity/ui/images/vw-refresh.bmp differ
index f4d82977cabc95bd7750d96ca63208ee86c83c58..4299854d37656e8af34046a7288c9fdcd5ff0d10 100644 (file)
Binary files a/src/windows/identity/ui/images/wdg_collapsed.bmp and b/src/windows/identity/ui/images/wdg_collapsed.bmp differ
index 90ab26d679f1448d9687ce4b0c7fe0b8ad004caa..cb06b8acbffb74d8fc7208bcf2044038cf4230b1 100644 (file)
Binary files a/src/windows/identity/ui/images/wdg_collapsed_hi.bmp and b/src/windows/identity/ui/images/wdg_collapsed_hi.bmp differ
index c59072230989db705691a25cd94c51a23fd1bf7f..76ee5b016d83fd71f1bcdc92a204eae9607d71b2 100644 (file)
Binary files a/src/windows/identity/ui/images/wdg_expanded.bmp and b/src/windows/identity/ui/images/wdg_expanded.bmp differ
index 6b2affc6dfc261ff6ded5a5610a6a6fc8d4d5b67..8180b33337d8a120782268a15105acd581e7e1d5 100644 (file)
Binary files a/src/windows/identity/ui/images/wdg_expanded_hi.bmp and b/src/windows/identity/ui/images/wdg_expanded_hi.bmp differ
diff --git a/src/windows/identity/ui/images/wdg_stick.bmp b/src/windows/identity/ui/images/wdg_stick.bmp
new file mode 100644 (file)
index 0000000..071a238
Binary files /dev/null and b/src/windows/identity/ui/images/wdg_stick.bmp differ
diff --git a/src/windows/identity/ui/images/wdg_stick_hi.bmp b/src/windows/identity/ui/images/wdg_stick_hi.bmp
new file mode 100644 (file)
index 0000000..8857fec
Binary files /dev/null and b/src/windows/identity/ui/images/wdg_stick_hi.bmp differ
diff --git a/src/windows/identity/ui/images/wdg_stuck.bmp b/src/windows/identity/ui/images/wdg_stuck.bmp
new file mode 100644 (file)
index 0000000..6829518
Binary files /dev/null and b/src/windows/identity/ui/images/wdg_stuck.bmp differ
diff --git a/src/windows/identity/ui/images/wdg_stuck_hi.bmp b/src/windows/identity/ui/images/wdg_stuck_hi.bmp
new file mode 100644 (file)
index 0000000..3b78071
Binary files /dev/null and b/src/windows/identity/ui/images/wdg_stuck_hi.bmp differ
index bd53bde28c0cf6a90d327e2e3fbc3cc99f403e17..7f12c7ffaf2803dacc43e1fb73e4983893bbba6a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -31,6 +31,7 @@
 #include<windowsx.h>\r
 #include<strsafe.h>\r
 #include<commctrl.h>\r
+#include<htmlhelp.h>\r
 \r
 #define KHERR_HMODULE khm_hInstance\r
 #define KHERR_FACILITY khm_facility\r
@@ -46,6 +47,7 @@
 #include<kmm.h>\r
 #include<khhelp.h>\r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 \r
 #include<resource.h>\r
 #include<credfuncs.h>\r
@@ -65,5 +67,6 @@
 #include<reqdaemon.h>\r
 #include<notifier.h>\r
 #include<timer.h>\r
+#include<addrchange.h>\r
 \r
 #endif\r
index a1b03b411cb9fc7c392bdecfb603e9f94cc1b057..eb2d4a9bb30083f51bbbaf48e3933ab3ecf41add 100644 (file)
@@ -8,7 +8,7 @@
 // Generated from the TEXTINCLUDE 2 resource.\r
 //\r
 #include "afxres.h"\r
-#include <khimaira_version.h>\r
+\r
 /////////////////////////////////////////////////////////////////////////////\r
 #undef APSTUDIO_READONLY_SYMBOLS\r
 \r
@@ -35,7 +35,6 @@ END
 2 TEXTINCLUDE \r
 BEGIN\r
     "#include ""afxres.h""\r\n"\r
-    "#include <khimaira_version.h>\0"\r
 END\r
 \r
 3 TEXTINCLUDE \r
@@ -55,8 +54,6 @@ END
 // Icon with lowest ID value placed first to ensure application icon\r
 // remains consistent on all systems.\r
 IDI_MAIN_APP            ICON                    "..\\..\\images\\main_app.ico"\r
-IDI_WGT_COLLAPSE        ICON                    "..\\..\\images\\wgt_arrow_collapse.ico"\r
-IDI_WGT_EXPAND          ICON                    "..\\..\\images\\wgt_arrow_expand.ico"\r
 IDI_ENABLED             ICON                    "..\\..\\images\\enabled.ico"\r
 IDI_DISABLED            ICON                    "..\\..\\images\\disabled.ico"\r
 IDI_NOTIFY_NONE         ICON                    "..\\..\\images\\app_notify_none.ico"\r
@@ -69,45 +66,6 @@ IDI_CFG_APPLIED         ICON                    "..\\..\\images\\cfg_applied.ico
 IDI_CFG_DELETED         ICON                    "..\\..\\images\\cfg_deleted.ico"\r
 IDI_ID                  ICON                    "..\\..\\images\\id.ico"\r
 \r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Version\r
-//\r
-\r
-VS_VERSION_INFO VERSIONINFO\r
- FILEVERSION 0,1,1,0\r
- PRODUCTVERSION 0,1,1,0\r
- FILEFLAGSMASK 0x17L\r
-#ifdef _DEBUG\r
- FILEFLAGS 0x1L\r
-#else\r
- FILEFLAGS 0x0L\r
-#endif\r
- FILEOS 0x4L\r
- FILETYPE 0x0L\r
- FILESUBTYPE 0x0L\r
-BEGIN\r
-    BLOCK "StringFileInfo"\r
-    BEGIN\r
-        BLOCK "040904b0"\r
-        BEGIN\r
-            VALUE "CompanyName", "Massachusetts Institute of Technology"\r
-            VALUE "FileDescription", "Network Identity Manager"\r
-            VALUE "FileVersion", "0.1.1.0"\r
-            VALUE "InternalName", "NetIDMgr"\r
-            VALUE "LegalCopyright", "Copyright (C) 2005 Massachusetts Institute of Technology"\r
-            VALUE "OriginalFilename", "netidmgr.exe"\r
-            VALUE "ProductName", "NetIDMgr"\r
-            VALUE "ProductVersion", "0.1.1.0"\r
-        END\r
-    END\r
-    BLOCK "VarFileInfo"\r
-    BEGIN\r
-        VALUE "Translation", 0x409, 1200\r
-    END\r
-END\r
-\r
-\r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
 // Bitmap\r
@@ -170,6 +128,10 @@ IDB_CHPW                BITMAP                  "..\\..\\images\\chpw.bmp"
 IDB_CHPW_DIS            BITMAP                  "..\\..\\images\\chpw-dis.bmp"\r
 IDB_CHPW_DIS_SM         BITMAP                  "..\\..\\images\\chpw-dis-sm.bmp"\r
 IDB_TB_SPACE            BITMAP                  "..\\..\\images\\tb-space.bmp"\r
+IDB_WDG_STUCK_HI        BITMAP                  "..\\..\\images\\wdg_stuck_hi.bmp"\r
+IDB_WDG_STICK           BITMAP                  "..\\..\\images\\wdg_stick.bmp"\r
+IDB_WDG_STICK_HI        BITMAP                  "..\\..\\images\\wdg_stick_hi.bmp"\r
+IDB_WDG_STUCK           BITMAP                  "..\\..\\images\\wdg_stuck.bmp"\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -248,13 +210,15 @@ BEGIN
     LTEXT           "IdentityName",IDC_PP_IDNAME,34,7,194,12,NOT WS_GROUP,\r
                     WS_EX_CLIENTEDGE\r
     CONTROL         "Default identity",IDC_PP_IDDEF,"Button",BS_AUTOCHECKBOX | \r
-                    WS_TABSTOP,34,25,71,12\r
+                    WS_TABSTOP,34,22,71,12\r
     CONTROL         "Searchable",IDC_PP_IDSEARCH,"Button",BS_AUTOCHECKBOX | \r
-                    WS_TABSTOP,34,43,74,12\r
+                    WS_DISABLED | WS_TABSTOP,117,36,74,12\r
     CONTROL         "Custom1",IDC_PP_PROPLIST,"NetIDMgrPropertyWnd",\r
-                    WS_TABSTOP,7,61,221,88\r
+                    WS_TABSTOP,7,51,221,80\r
     CONTROL         "Always visible (sticky)",IDC_PP_STICKY,"Button",\r
-                    BS_AUTOCHECKBOX | WS_TABSTOP,117,25,85,10\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,117,22,85,12\r
+    PUSHBUTTON      "Identity configuration ...",IDC_PP_CONFIG,117,135,111,\r
+                    14\r
 END\r
 \r
 IDD_PP_CRED DIALOGEX 0, 0, 236, 158\r
@@ -272,7 +236,7 @@ IDD_CFG_MAIN DIALOGEX 0, 0, 357, 222
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | \r
     WS_SYSMENU\r
 EXSTYLE WS_EX_CONTEXTHELP\r
-CAPTION "Khimaira Configuration"\r
+CAPTION "NetIDMgr Configuration"\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
     LTEXT           "Title",IDC_CFG_TITLE,0,0,357,20,SS_CENTERIMAGE\r
@@ -311,7 +275,7 @@ BEGIN
                     IDC_CFG_KEEPRUNNING,"Button",BS_AUTOCHECKBOX | \r
                     WS_TABSTOP,16,78,158,10\r
     CONTROL         "Detect network connectivity",IDC_CFG_NETDETECT,"Button",\r
-                    BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,16,96,106,10\r
+                    BS_AUTOCHECKBOX | WS_TABSTOP,16,96,106,10\r
     CONTROL         "A&utomatically import credentials from Windows",\r
                     IDC_CFG_AUTOIMPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,\r
                     16,113,165,10\r
@@ -349,8 +313,8 @@ IDD_CFG_PLUGINS DIALOGEX 0, 0, 255, 182
 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
-    CONTROL         "",IDC_CFG_PLUGINS,"SysListView32",LVS_ALIGNLEFT | \r
-                    WS_BORDER | WS_TABSTOP,7,7,75,168\r
+    CONTROL         "",IDC_CFG_PLUGINS,"SysListView32",LVS_REPORT | \r
+                    LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,75,168\r
     GROUPBOX        "Plugin",IDC_CFG_PLUGINGRP,86,7,162,103\r
     LTEXT           "Description",IDC_CFG_LBL_DESC,90,20,36,8\r
     EDITTEXT        IDC_CFG_DESC,134,17,109,14,ES_AUTOHSCROLL | ES_READONLY\r
@@ -387,16 +351,17 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
 EXSTYLE WS_EX_CONTROLPARENT\r
 FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
 BEGIN\r
-    CONTROL         "",IDC_CFG_IDENTS,"SysListView32",LVS_SHAREIMAGELISTS | \r
-                    LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,221,72\r
+    CONTROL         "",IDC_CFG_IDENTS,"SysListView32",LVS_REPORT | \r
+                    LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | \r
+                    WS_TABSTOP,7,7,221,72\r
     GROUPBOX        "Selected identity",IDC_CFG_IDENTITY,7,81,221,63\r
     CONTROL         "Monitor credential expiration",IDC_CFG_MONITOR,"Button",\r
-                    BS_3STATE | WS_TABSTOP,13,92,107,10\r
+                    BS_3STATE | WS_DISABLED | WS_TABSTOP,13,92,107,10\r
     CONTROL         "Automatically renew",IDC_CFG_RENEW,"Button",BS_3STATE | \r
-                    WS_TABSTOP,13,106,81,10\r
+                    WS_DISABLED | WS_TABSTOP,13,106,81,10\r
     CONTROL         "Always show in the credentials list (Sticky)",\r
-                    IDC_CFG_STICKY,"Button",BS_3STATE | WS_TABSTOP,13,120,\r
-                    151,10\r
+                    IDC_CFG_STICKY,"Button",BS_3STATE | WS_DISABLED | \r
+                    WS_TABSTOP,13,120,151,10\r
     PUSHBUTTON      "&Remove",IDC_CFG_REMOVE,174,126,50,14,WS_DISABLED\r
 END\r
 \r
@@ -425,8 +390,8 @@ BEGIN
                     IDC_COPYRIGHT,41,23,220,18,NOT WS_GROUP\r
     LTEXT           "BuildInfo",IDC_BUILDINFO,41,41,220,17,NOT WS_GROUP\r
     ICON            IDI_MAIN_APP,IDC_STATIC,6,7,21,20\r
-    CONTROL         "",IDC_MODULES,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
-                    WS_TABSTOP,41,72,220,91\r
+    CONTROL         "",IDC_MODULES,"SysListView32",LVS_REPORT | \r
+                    LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,41,72,220,91\r
     LTEXT           "Loaded modules",IDC_STATIC,41,60,52,8\r
 END\r
 \r
@@ -709,6 +674,17 @@ BEGIN
     IDS_CTX_PROC_PASSWORD   "Changing password for %1!s!"\r
     IDS_NC_PWD_FAILED_TITLE "Failed to change password"\r
     IDS_CMDLINE_HELP        "Command line options for NetIDMgr are :\n\n-a or --autoinit: Auto initialize credentials\n-i or --kinit: Obtain new credentials\n-d or --destroy: Destroy default identity\n-r or --renew: Renew all credentials"\r
+    IDS_PACTION_NEXT        "Next alert..."\r
+    IDS_ERR_TITLE_NO_IDENTPRO "Cannot proceed without identity provider"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+    IDS_ERR_MSG_NO_IDENTPRO "There is no identity provider currently loaded.  The identity provider is the component of Network Identity Manager that verifies and performs operations on actual identities.  Without this provider, many critical operations cannot be performed."\r
+    IDS_ERR_SUGG_NO_IDENTPRO \r
+                            "This is quite possibly caused by the identity provider module failing to load properly."\r
+    IDS_NC_REN_FAILED_TITLE "Failed to renew credentials"\r
+    IDS_CW_DEFAULT          "(Default)"\r
 END\r
 \r
 #endif    // English (U.S.) resources\r
index b92c540b5b829a09303af2de499307f32fbb12b5..4f1aa7d5de8c56d48bbaab8c8fbd9bc307d5e397 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -41,13 +41,13 @@ void khm_init_gui(void) {
     khui_init_rescache();\r
     khui_init_menu();\r
     khui_init_toolbar();\r
-    khui_init_notifier();\r
+    khm_init_notifier();\r
     khm_init_config();\r
 }\r
 \r
 void khm_exit_gui(void) {\r
     khm_exit_config();\r
-    khui_exit_notifier();\r
+    khm_exit_notifier();\r
     khui_exit_toolbar();\r
     khui_exit_menu();\r
     khui_exit_rescache();\r
@@ -67,31 +67,36 @@ void khm_parse_commandline(void) {
 \r
     for (i=1; i<wargc; i++) {\r
         if (!wcscmp(wargs[i], L"-i") ||\r
-            !wcscmp(wargs[i], L"--kinit")) {\r
+            !wcscmp(wargs[i], L"--kinit") ||\r
+            !wcscmp(wargs[i], L"-kinit")) {\r
             khm_startup.init = TRUE;\r
             khm_startup.exit = TRUE;\r
             khm_startup.no_main_window = TRUE;\r
         }\r
         else if (!wcscmp(wargs[i], L"-m") ||\r
-                 !wcscmp(wargs[i], L"--import")) {\r
+                 !wcscmp(wargs[i], L"--import") ||\r
+                 !wcscmp(wargs[i], L"-import")) {\r
             khm_startup.import = TRUE;\r
             khm_startup.exit = TRUE;\r
             khm_startup.no_main_window = TRUE;\r
         }\r
         else if (!wcscmp(wargs[i], L"-r") ||\r
-                 !wcscmp(wargs[i], L"--renew")) {\r
+                 !wcscmp(wargs[i], L"--renew") ||\r
+                 !wcscmp(wargs[i], L"-renew")) {\r
             khm_startup.renew = TRUE;\r
             khm_startup.exit = TRUE;\r
             khm_startup.no_main_window = TRUE;\r
         }\r
         else if (!wcscmp(wargs[i], L"-d") ||\r
-                 !wcscmp(wargs[i], L"--destroy")) {\r
+                 !wcscmp(wargs[i], L"--destroy") ||\r
+                 !wcscmp(wargs[i], L"-destroy")) {\r
             khm_startup.destroy = TRUE;\r
             khm_startup.exit = TRUE;\r
             khm_startup.no_main_window = TRUE;\r
         }\r
         else if (!wcscmp(wargs[i], L"-a") ||\r
-                 !wcscmp(wargs[i], L"--autoinit")) {\r
+                 !wcscmp(wargs[i], L"--autoinit") ||\r
+                 !wcscmp(wargs[i], L"-autoinit")) {\r
             khm_startup.autoinit = TRUE;\r
         }\r
         else {\r
@@ -118,9 +123,11 @@ void khm_register_window_classes(void) {
         ICC_BAR_CLASSES |\r
         ICC_DATE_CLASSES |\r
         ICC_HOTKEY_CLASS |\r
+#if (_WIN32_WINNT >= 0x501)\r
         ICC_LINK_CLASS |\r
-        ICC_LISTVIEW_CLASSES |\r
         ICC_STANDARD_CLASSES |\r
+#endif\r
+        ICC_LISTVIEW_CLASSES |\r
         ICC_TAB_CLASSES;\r
     InitCommonControlsEx(&ics);\r
 \r
@@ -184,7 +191,7 @@ void khm_enter_modal(HWND hwnd) {
         }\r
     }\r
 \r
-    khui_main_window_active = IsWindowEnabled(khm_hwnd_main);\r
+    khui_main_window_active = khm_is_main_window_active();\r
     EnableWindow(khm_hwnd_main, FALSE);\r
 \r
     khui_modal_dialog = hwnd;\r
@@ -200,7 +207,9 @@ void khm_leave_modal(void) {
         }\r
     }\r
 \r
-    EnableWindow(khm_hwnd_main, khui_main_window_active);\r
+    EnableWindow(khm_hwnd_main, TRUE);\r
+    if (khui_main_window_active)\r
+        SetForegroundWindow(khm_hwnd_main);\r
 \r
     khui_modal_dialog = NULL;\r
 }\r
@@ -225,15 +234,15 @@ void khm_del_dialog(HWND dlg) {
 \r
 BOOL khm_check_dlg_message(LPMSG pmsg) {\r
     int i;\r
+    BOOL found = FALSE;\r
     for(i=0;i<n_khui_dialogs;i++) {\r
-        if(IsDialogMessage(khui_dialogs[i].hwnd, pmsg))\r
+        if(IsDialogMessage(khui_dialogs[i].hwnd, pmsg)) {\r
+            found = TRUE;\r
             break;\r
+        }\r
     }\r
 \r
-    if(i<n_khui_dialogs)\r
-        return TRUE;\r
-    else\r
-        return FALSE;\r
+    return found;\r
 }\r
 \r
 BOOL khm_is_dialog_active(void) {\r
@@ -324,6 +333,57 @@ WPARAM khm_message_loop(void) {
     return msg.wParam;\r
 }\r
 \r
+void KHMAPI\r
+khm_module_load_ctx_handler(enum kherr_ctx_event evt,\r
+                            kherr_context * c) {\r
+    kherr_event * e;\r
+    khui_alert * a;\r
+\r
+    for(e = kherr_get_first_event(c);\r
+        e;\r
+        e = kherr_get_next_event(e)) {\r
+\r
+        kherr_evaluate_event(e);\r
+\r
+        if ((e->severity == KHERR_ERROR ||\r
+             e->severity == KHERR_WARNING) &&\r
+            e->short_desc &&\r
+            e->long_desc) {\r
+\r
+            khui_alert_create_empty(&a);\r
+\r
+            khui_alert_set_severity(a, e->severity);\r
+            khui_alert_set_title(a, e->short_desc);\r
+            khui_alert_set_message(a, e->long_desc);\r
+            if (e->suggestion)\r
+                khui_alert_set_suggestion(a, e->suggestion);\r
+\r
+            khui_alert_queue(a);\r
+\r
+            khui_alert_release(a);\r
+        }\r
+    }\r
+\r
+    kherr_remove_ctx_handler(khm_module_load_ctx_handler,\r
+                             c->serial);\r
+}\r
+\r
+void khm_load_default_modules(void) {\r
+    kherr_context * c;\r
+\r
+    _begin_task(KHERR_CF_TRANSITIVE);\r
+\r
+    kmm_load_default_modules();\r
+\r
+    c = kherr_peek_context();\r
+    kherr_add_ctx_handler(khm_module_load_ctx_handler,\r
+                          KHERR_CTX_END,\r
+                          c->serial);\r
+    kherr_release_context(c);\r
+\r
+    _end_task();\r
+}\r
+\r
 int WINAPI WinMain(HINSTANCE hInstance,\r
                    HINSTANCE hPrevInstance,\r
                    LPSTR lpCmdLine,\r
@@ -350,6 +410,14 @@ int WINAPI WinMain(HINSTANCE hInstance,
     khc_load_schema(NULL, schema_uiconfig);\r
 \r
     if(!slave) {\r
+\r
+        /* set this so that we don't accidently invoke an API that\r
+           inadvertently puts up the new creds dialog at an\r
+           inopportune moment, like, say, during the new creds dialog\r
+           is open.  This only affects this process, and any child\r
+           processes started by plugins. */\r
+        SetEnvironmentVariable(L"KERBEROSLOGIN_NEVER_PROMPT", L"1");\r
+\r
         /* we only open a main window if this is the only instance \r
            of the application that is running. */\r
         kmq_init();\r
@@ -359,7 +427,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
         kmq_set_completion_handler(KMSG_CRED, kmsg_cred_completion);\r
 \r
         /* load the standard plugins */\r
-        kmm_load_default_modules();\r
+        khm_load_default_modules();\r
 \r
         khm_register_window_classes();\r
 \r
@@ -438,5 +506,11 @@ int WINAPI WinMain(HINSTANCE hInstance,
             CloseHandle(hmap);\r
     }\r
 \r
+#if 0\r
+    /* writes a report of memory leaks to the specified file.  Should\r
+       only be enabled on development versions. */\r
+    PDUMP("memleak.txt");\r
+#endif\r
+\r
     return rv;\r
 }\r
index 6115204f3be6147cbf71627599c81190368c587d..c7bf94da1c1d578de3176032fcaa2c7a3e945140 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -147,7 +147,8 @@ static HMENU mm_create_menu_from_def(khui_menu_def * def) {
     hm = CreatePopupMenu();\r
     act = def->items;\r
     i = 0;\r
-    while(act->action != KHUI_MENU_END) {\r
+    while((def->n_items == -1 && act->action != KHUI_MENU_END) ||\r
+          (def->n_items >= 0 && i < (int) def->n_items)) {\r
         add_action_to_menu(hm,khui_find_action(act->action),i,act->flags);\r
         act++; i++;\r
     }\r
@@ -223,7 +224,6 @@ LRESULT khm_menu_activate(int menu_id) {
         TB_SETHOTITEM,\r
         menu_id,\r
         0);\r
-    \r
 \r
     khm_menu_track_current();\r
 \r
@@ -321,7 +321,7 @@ LRESULT khm_menu_handle_select(WPARAM wParam, LPARAM lParam) {
     if((HIWORD(wParam) == 0xffff && lParam == 0) || \r
        (HIWORD(wParam) & MF_POPUP)) {\r
         /* the menu was closed */\r
-        khui_statusbar_set_text(KHUI_SBPART_INFO, NULL);\r
+        khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);\r
     } else {\r
         khui_action * act;\r
         int id;\r
@@ -330,12 +330,12 @@ LRESULT khm_menu_handle_select(WPARAM wParam, LPARAM lParam) {
         id = LOWORD(wParam);\r
         act = khui_find_action(id);\r
         if(act == NULL || act->is_tooltip == 0)\r
-            khui_statusbar_set_text(KHUI_SBPART_INFO, NULL);\r
+            khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);\r
         else {\r
             LoadString(khm_hInstance, \r
                        act->is_tooltip, \r
                        buf, ARRAYLENGTH(buf));\r
-            khui_statusbar_set_text(KHUI_SBPART_INFO, buf);\r
+            khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);\r
         }\r
     }\r
     return 0;\r
@@ -429,7 +429,7 @@ LRESULT khm_menu_notify_main(LPNMHDR notice) {
         ret = TBDDRET_DEFAULT;\r
         break;\r
 \r
-    case TBN_HOTITEMCHANGE: \r
+    case TBN_HOTITEMCHANGE:\r
         {\r
             LPNMTBHOTITEM nmhi;\r
             int new_item = -1;\r
@@ -485,21 +485,24 @@ void khm_menu_create_main(HWND rebar) {
     mm = mmdef->items;\r
     nmm = (int) khui_action_list_length(mm);\r
 \r
-    hwtb = CreateWindowEx(\r
-        TBSTYLE_EX_MIXEDBUTTONS,\r
-        TOOLBARCLASSNAME,\r
-        (LPWSTR) NULL,\r
-        WS_CHILD | \r
-        CCS_ADJUSTABLE | \r
-        TBSTYLE_FLAT |\r
-        TBSTYLE_AUTOSIZE |\r
-        TBSTYLE_LIST |\r
-        CCS_NORESIZE |\r
-        CCS_NOPARENTALIGN |\r
-        CCS_NODIVIDER,\r
-        0, 0, 0, 0, rebar,\r
-        (HMENU) NULL, khm_hInstance,\r
-        NULL);\r
+    hwtb = CreateWindowEx(0\r
+#if (_WIN32_IE >= 0x0501)\r
+                          | TBSTYLE_EX_MIXEDBUTTONS\r
+#endif\r
+                          ,\r
+                          TOOLBARCLASSNAME,\r
+                          (LPWSTR) NULL,\r
+                          WS_CHILD | \r
+                          CCS_ADJUSTABLE | \r
+                          TBSTYLE_FLAT |\r
+                          TBSTYLE_AUTOSIZE |\r
+                          TBSTYLE_LIST |\r
+                          CCS_NORESIZE |\r
+                          CCS_NOPARENTALIGN |\r
+                          CCS_NODIVIDER,\r
+                          0, 0, 0, 0, rebar,\r
+                          (HMENU) NULL, khm_hInstance,\r
+                          NULL);\r
 \r
     if(!hwtb) {\r
 #ifdef DEBUG\r
index 7cd8e01ca9e96125758105cd385ec4378e399739..59638cdd4e2377e88bba8bcb3894b862ae59a929 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 0f5c7e0439ea0945d25caddafcad98424e557aba..5fbd1ec9b1296fb58a7a519d187999cb7cda1521 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -94,6 +94,7 @@ LRESULT CALLBACK khm_main_wnd_proc(
     case WM_DESTROY:\r
         kmq_unsubscribe_hwnd(KMSG_ACT, hwnd);\r
         kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);\r
+        HtmlHelp(NULL, NULL, HH_CLOSE_ALL, 0);\r
         PostQuitMessage(0);\r
         break;\r
 \r
@@ -105,15 +106,21 @@ LRESULT CALLBACK khm_main_wnd_proc(
             return khm_toolbar_notify(lpnm);\r
         } else if(lpnm->hwndFrom == khm_hwnd_rebar) {\r
             return khm_rebar_notify(lpnm);\r
+        } else if(lpnm->hwndFrom == khm_hwnd_statusbar) {\r
+            return khm_statusbar_notify(lpnm);\r
         }\r
         break;\r
 \r
+    case WM_HELP:\r
+        MessageBox(khm_hwnd_main, L"WM_HELP", L"Notice", MB_OK);\r
+        break;\r
+\r
     case WM_COMMAND:\r
         switch(LOWORD(wParam)) {\r
             /* general actions */\r
         case KHUI_ACTION_VIEW_REFRESH:\r
+            khm_cred_refresh();\r
             InvalidateRect(khm_hwnd_main_cred, NULL, FALSE);\r
-            kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, NULL);\r
             return 0;\r
 \r
         case KHUI_ACTION_PASSWD_ID:\r
@@ -168,6 +175,21 @@ LRESULT CALLBACK khm_main_wnd_proc(
         }\r
             break;\r
 \r
+        case KHUI_ACTION_HELP_CTX:\r
+            HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+                     HH_HELP_CONTEXT, IDH_WELCOME);\r
+            break;\r
+\r
+        case KHUI_ACTION_HELP_CONTENTS:\r
+            HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+                     HH_DISPLAY_TOC, 0);\r
+            break;\r
+\r
+        case KHUI_ACTION_HELP_INDEX:\r
+            HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+                     HH_DISPLAY_INDEX, (DWORD_PTR) L"");\r
+            break;\r
+\r
         case KHUI_ACTION_HELP_ABOUT:\r
             khm_create_about_window();\r
             break;\r
@@ -223,6 +245,7 @@ LRESULT CALLBACK khm_main_wnd_proc(
 \r
         case KHUI_PACTION_DELETE:\r
 \r
+        case KHUI_PACTION_SELALL:\r
         case KHUI_ACTION_LAYOUT_ID:\r
         case KHUI_ACTION_LAYOUT_TYPE:\r
         case KHUI_ACTION_LAYOUT_LOC:\r
@@ -301,10 +324,10 @@ LRESULT CALLBACK khm_main_wnd_proc(
             /* resize the rebar control */\r
             SendMessage(khm_hwnd_rebar, WM_SIZE, 0, 0);\r
 \r
-            khui_update_statusbar(hwnd);\r
+            khm_update_statusbar(hwnd);\r
             \r
             GetWindowRect(khm_hwnd_rebar, &r_rebar);\r
-            GetWindowRect(khui_hwnd_statusbar, &r_status);\r
+            GetWindowRect(khm_hwnd_statusbar, &r_status);\r
 \r
             /* the cred window fills the area between the rebar\r
                and the status bar */\r
@@ -383,6 +406,9 @@ LRESULT CALLBACK khm_main_wnd_proc(
             } else if (m->type == KMSG_CRED &&\r
                   m->subtype == KMSG_CRED_REFRESH) {\r
                 mw_restart_refresh_timer(hwnd);\r
+            } else if (m->type == KMSG_CRED &&\r
+                       m->subtype == KMSG_CRED_ADDR_CHANGE) {\r
+                khm_cred_addr_change();\r
             } else if (m->type == KMSG_KMM &&\r
                        m->subtype == KMSG_KMM_I_DONE) {\r
                 kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0);\r
@@ -442,13 +468,14 @@ LRESULT CALLBACK khm_null_wnd_proc(
 \r
 LRESULT khm_rebar_notify(LPNMHDR lpnm) {\r
     switch(lpnm->code) {\r
+#if (_WIN32_WINNT >= 0x0501)\r
     case RBN_AUTOBREAK:\r
         {\r
             LPNMREBARAUTOBREAK lpra = (LPNMREBARAUTOBREAK) lpnm;\r
             lpra->fAutoBreak = TRUE;\r
         }\r
         break;\r
-\r
+#endif\r
     case RBN_BEGINDRAG:\r
         {\r
             LPNMREBAR lprb = (LPNMREBAR) lpnm;\r
@@ -505,7 +532,7 @@ void khm_create_main_window_controls(HWND hwnd_main) {
     /* self attach */\r
     khm_menu_create_main(hwRebar);\r
     khm_create_standard_toolbar(hwRebar);\r
-    khui_create_statusbar(hwnd_main);\r
+    khm_create_statusbar(hwnd_main);\r
 \r
     /* manual attach */\r
     khm_hwnd_main_cred = khm_create_credwnd(hwnd_main);\r
@@ -517,7 +544,8 @@ void khm_create_main_window(void) {
     khm_handle csp_mw = NULL;\r
     int x,y,width,height;\r
 \r
-    LoadString(khm_hInstance, IDS_MAIN_WINDOW_TITLE, buf, sizeof(buf)/sizeof(buf[0]));\r
+    LoadString(khm_hInstance, IDS_MAIN_WINDOW_TITLE, \r
+               buf, ARRAYLENGTH(buf));\r
 \r
     khm_hwnd_null =\r
         CreateWindow(MAKEINTATOM(khm_null_window_class),\r
@@ -573,8 +601,6 @@ void khm_create_main_window(void) {
                        NULL,\r
                        NULL);\r
 \r
-    if (!khm_hwnd_main)\r
-        return;\r
 }\r
 \r
 void khm_show_main_window(void) {\r
@@ -587,8 +613,14 @@ void khm_show_main_window(void) {
             SetForegroundWindow(khm_hwnd_main);\r
     }\r
 \r
-    ShowWindow(khm_hwnd_main, khm_nCmdShow);\r
-    UpdateWindow(khm_hwnd_main);\r
+    if (khm_nCmdShow == SW_SHOWMINIMIZED ||\r
+        khm_nCmdShow == SW_SHOWMINNOACTIVE ||\r
+        khm_nCmdShow == SW_MINIMIZE) {\r
+        khm_hide_main_window();\r
+    } else {\r
+        ShowWindow(khm_hwnd_main, khm_nCmdShow);\r
+        UpdateWindow(khm_hwnd_main);\r
+    }\r
 \r
     khm_nCmdShow = SW_RESTORE;\r
 }\r
@@ -597,11 +629,13 @@ void khm_hide_main_window(void) {
     khm_handle csp_notices = NULL;\r
     khm_int32 show_warning = FALSE;\r
 \r
-    if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow\\Notices",\r
+    if (khm_nCmdShow != SW_MINIMIZE &&\r
+        KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow\\Notices",\r
                                      KHM_PERM_WRITE, &csp_notices)) &&\r
         KHM_SUCCEEDED(khc_read_int32(csp_notices, L"MinimizeWarning",\r
                                      &show_warning)) &&\r
         show_warning != 0) {\r
+\r
         khui_alert * alert;\r
         wchar_t title[KHUI_MAXCCH_TITLE];\r
         wchar_t msg[KHUI_MAXCCH_MESSAGE];\r
index cdaac1e96896d3a10983790e601c0d2c36192151..95b28b73343f47efb1d10d4d88316683132cd9ce 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 4b6ce08bf3820bef7cfcc2f6b46bcaa15af50eeb..6852846fb410679f518ba74c64fa8a4842c6dca4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -244,7 +244,7 @@ nc_update_credtext(khui_nc_wnd_data * d)
     HWND hw = NULL;\r
     size_t cch = 0;\r
 \r
-    ctbuf = malloc(NC_MAXCB_CREDTEXT);\r
+    ctbuf = PMALLOC(NC_MAXCB_CREDTEXT);\r
 \r
     assert(ctbuf != NULL);\r
 \r
@@ -308,7 +308,7 @@ nc_update_credtext(khui_nc_wnd_data * d)
            a comma separated string */\r
 \r
         /* d->nc->n_identities is at least 2 */\r
-        ids_string = malloc((KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
+        ids_string = PMALLOC((KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
                             (d->nc->n_identities - 1));\r
         cb_ids_string = \r
             (KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
@@ -365,7 +365,7 @@ nc_update_credtext(khui_nc_wnd_data * d)
             StringCbPrintf(buf, NC_MAXCB_CREDTEXT - cch*sizeof(wchar_t), \r
                            main_fmt, id_string, ids_string);\r
 \r
-            free(ids_string);\r
+            PFREE(ids_string);\r
         }\r
     } else {\r
         LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_NONE, \r
@@ -393,7 +393,7 @@ nc_update_credtext(khui_nc_wnd_data * d)
 \r
     SetDlgItemText(d->dlg_main, IDC_NC_CREDTEXT, ctbuf);\r
 \r
-    free(ctbuf);\r
+    PFREE(ctbuf);\r
 \r
     /* so depending on whether the primary identity was found to be\r
        invalid, we need to disable the Ok button and set the title to\r
@@ -471,7 +471,7 @@ nc_handle_wm_create(HWND hwnd,
 \r
     lpc = (LPCREATESTRUCT) lParam;\r
 \r
-    ncd = malloc(sizeof(*ncd));\r
+    ncd = PMALLOC(sizeof(*ncd));\r
     ZeroMemory(ncd, sizeof(*ncd));\r
 \r
     c = (khui_new_creds *) lpc->lpCreateParams;\r
@@ -821,7 +821,7 @@ nc_handle_wm_destroy(HWND hwnd,
     d->dlg_main = NULL;\r
     d->dlg_ts = NULL;\r
 \r
-    free(d);\r
+    PFREE(d);\r
 \r
     return TRUE;\r
 }\r
@@ -1188,7 +1188,7 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd,
                             &cbsize, \r
                             KCDB_TS_SHORT) == KHM_ERROR_TOO_LONG) {\r
 \r
-                            name = malloc(cbsize);\r
+                            name = PMALLOC(cbsize);\r
                             kcdb_credtype_describe(d->nc->types[i]->type, \r
                                                    name, \r
                                                    &cbsize, \r
@@ -1235,7 +1235,7 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd,
                     x += width;\r
 \r
                     if(!(d->nc->types[i]->name))\r
-                        free(name);\r
+                        PFREE(name);\r
 \r
                     /* Now set the position of the type panel */\r
                     ShowWindow(d->nc->types[i]->hwnd_panel, SW_HIDE);\r
index d0b67642214bdb53d84c8a452b6d913510e5138f..22505bc746263a4f443ff0f04aed90082e04757b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 0ebdbd4cb389080bb0f5ce894ddcc0f360711dde..c795245b12a58e604b3b39d0e09cfedcc28d5c87 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -37,6 +37,8 @@
 /* notifier message for notification icon */\r
 #define KHUI_WM_NOTIFIER            WM_COMMAND\r
 \r
+#define KHUI_ALERT_QUEUE_MAX        64\r
+\r
 /* window class registration atom for message only notifier window\r
    class */\r
 ATOM atom_notifier = 0;\r
@@ -51,6 +53,70 @@ BOOL notifier_ready = FALSE;
 \r
 khui_alert * current_alert = NULL;\r
 \r
+khui_alert * alert_queue[KHUI_ALERT_QUEUE_MAX];\r
+khm_int32    alert_queue_head = 0;\r
+khm_int32    alert_queue_tail = 0;\r
+\r
+#define is_alert_queue_empty() (alert_queue_head == alert_queue_tail)\r
+#define is_alert_queue_full()  (((alert_queue_tail + 1) % KHUI_ALERT_QUEUE_MAX) == alert_queue_head)\r
+\r
+static void \r
+add_to_alert_queue(khui_alert * a) {\r
+    if (is_alert_queue_full()) return;\r
+    alert_queue[alert_queue_tail++] = a;\r
+    khui_alert_hold(a);\r
+    alert_queue_tail %= KHUI_ALERT_QUEUE_MAX;\r
+}\r
+\r
+static khui_alert * \r
+del_from_alert_queue(void) {\r
+    khui_alert * a;\r
+\r
+    if (is_alert_queue_empty()) return NULL;\r
+    a = alert_queue[alert_queue_head++];\r
+    alert_queue_head %= KHUI_ALERT_QUEUE_MAX;\r
+\r
+    return a;                   /* held */\r
+}\r
+\r
+static khui_alert * \r
+peek_alert_queue(void) {\r
+    if (is_alert_queue_empty()) return NULL;\r
+    return alert_queue[alert_queue_head];\r
+}\r
+\r
+static void\r
+check_for_queued_alerts(void) {\r
+    if (!is_alert_queue_empty()) {\r
+        khui_alert * a;\r
+\r
+        a = peek_alert_queue();\r
+\r
+        if (a->title) {\r
+            HICON hi;\r
+            int res;\r
+\r
+            if (a->severity == KHERR_ERROR)\r
+                res = OIC_ERROR;\r
+            else if (a->severity == KHERR_WARNING)\r
+                res = OIC_WARNING;\r
+            else\r
+                res = OIC_INFORMATION;\r
+\r
+            hi = LoadImage(0, MAKEINTRESOURCE(res),\r
+                           IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
+                           LR_SHARED);\r
+\r
+            khm_statusbar_set_part(KHUI_SBPART_NOTICE,\r
+                                   hi,\r
+                                   a->title);\r
+        }\r
+    } else {\r
+        khm_statusbar_set_part(KHUI_SBPART_NOTICE,\r
+                               NULL, NULL);\r
+    }\r
+}\r
+\r
 \r
 /* forward dcls */\r
 static khm_int32 \r
@@ -62,6 +128,9 @@ alert_show_minimized(khui_alert * a);
 static khm_int32\r
 alert_show_normal(khui_alert * a);\r
 \r
+static khm_int32\r
+alert_enqueue(khui_alert * a);\r
+\r
 /**********************************************************************\r
   Notifier\r
 ***********************************************************************\r
@@ -87,17 +156,41 @@ notifier_wnd_proc(HWND hwnd,
         if(m->type == KMSG_ALERT) {\r
             /* handle notifier messages */\r
             switch(m->subtype) {\r
-                case KMSG_ALERT_SHOW:\r
-                    rv = alert_show((khui_alert *) m->vparam);\r
-                    khui_alert_release((khui_alert *) m->vparam);\r
-                    break;\r
+            case KMSG_ALERT_SHOW:\r
+                rv = alert_show((khui_alert *) m->vparam);\r
+                khui_alert_release((khui_alert *) m->vparam);\r
+                break;\r
+\r
+            case KMSG_ALERT_QUEUE:\r
+                rv = alert_enqueue((khui_alert *) m->vparam);\r
+                khui_alert_release((khui_alert *) m->vparam);\r
+                break;\r
+\r
+            case KMSG_ALERT_CHECK_QUEUE:\r
+                check_for_queued_alerts();\r
+                break;\r
+\r
+            case KMSG_ALERT_SHOW_QUEUED:\r
+                if (current_alert == NULL) {\r
+                    khui_alert * a;\r
+\r
+                    a = del_from_alert_queue();\r
+                    if (a) {\r
+                        rv = alert_show(a);\r
+                        check_for_queued_alerts();\r
+                        khui_alert_release(a);\r
+                    }\r
+                }\r
+                break;\r
             }\r
         } else if (m->type == KMSG_CRED &&\r
                    m->subtype == KMSG_CRED_ROOTDELTA) {\r
+\r
             KillTimer(hwnd, KHUI_REFRESH_TIMER_ID);\r
             SetTimer(hwnd, KHUI_REFRESH_TIMER_ID,\r
                      KHUI_REFRESH_TIMEOUT,\r
                      NULL);\r
+\r
         }\r
 \r
         return kmq_wm_end(m, rv);\r
@@ -140,26 +233,30 @@ notifier_wnd_proc(HWND hwnd,
             khm_show_main_window();\r
             break;\r
 \r
+#if (_WIN32_IE >= 0x0501)\r
         case NIN_BALLOONUSERCLICK:\r
             if (current_alert) {\r
                 if ((current_alert->flags & KHUI_ALERT_FLAG_DEFACTION) &&\r
                     current_alert->n_alert_commands > 0) {\r
                     PostMessage(khm_hwnd_main, WM_COMMAND,\r
-                                MAKEWPARAM(current_alert->alert_commands[0], 0),\r
+                                MAKEWPARAM(current_alert->alert_commands[0], \r
+                                           0),\r
                                 0);\r
-                } else if (current_alert->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW) {\r
+                } else if (current_alert->flags & \r
+                           KHUI_ALERT_FLAG_REQUEST_WINDOW) {\r
                     khm_show_main_window();\r
                     alert_show_normal(current_alert);\r
                 }\r
             }\r
             /* fallthrough */\r
         case NIN_BALLOONTIMEOUT:\r
-            khui_notify_icon_change(KHERR_NONE);\r
+            khm_notify_icon_change(KHERR_NONE);\r
             if (current_alert) {\r
                 khui_alert_release(current_alert);\r
                 current_alert = NULL;\r
             }\r
             break;\r
+#endif\r
         }\r
     } else if (uMsg == WM_TIMER) {\r
         if (wParam == KHUI_TRIGGER_TIMER_ID) {\r
@@ -175,7 +272,7 @@ notifier_wnd_proc(HWND hwnd,
 }\r
 \r
 ATOM \r
-khui_register_notifier_wnd_class(void)\r
+khm_register_notifier_wnd_class(void)\r
 {\r
     WNDCLASSEX wcx;\r
 \r
@@ -315,10 +412,12 @@ alert_show_minimized(khui_alert * a) {
 \r
     a->flags |= KHUI_ALERT_FLAG_DISPLAY_BALLOON;\r
 \r
+#if (_WIN32_IE >= 0x0501)\r
     current_alert = a;\r
     khui_alert_hold(a);\r
+#endif\r
 \r
-    khui_notify_icon_balloon(a->severity,\r
+    khm_notify_icon_balloon(a->severity,\r
                              tbuf,\r
                              mbuf,\r
                              NTF_TIMEOUT);\r
@@ -340,10 +439,14 @@ alert_show_normal(khui_alert * a) {
         title = a->title;\r
 \r
     /* if we don't have any commands, we just add a "close" button */\r
-    if(a->n_alert_commands == 0) {\r
+    if (a->n_alert_commands == 0) {\r
         khui_alert_add_command(a, KHUI_PACTION_CLOSE);\r
     }\r
 \r
+    if (!is_alert_queue_empty()) {\r
+        khui_alert_add_command(a, KHUI_PACTION_NEXT);\r
+    }\r
+\r
     /* we don't need to keep track of the window handle\r
        because the window procedure adds it to the dialog\r
        list automatically */\r
@@ -365,6 +468,12 @@ alert_show_normal(khui_alert * a) {
 \r
 static khm_int32 \r
 alert_show(khui_alert * a) {\r
+    /* is there an alert already?  If so, we just enqueue the message\r
+       and let it sit. */\r
+    if (current_alert) {\r
+        return alert_enqueue(a);\r
+    }\r
+\r
     /* the window has already been shown */\r
     if((a->flags & KHUI_ALERT_FLAG_DISPLAY_WINDOW) ||\r
         ((a->flags & KHUI_ALERT_FLAG_DISPLAY_BALLOON) &&\r
@@ -387,6 +496,17 @@ alert_show(khui_alert * a) {
         return alert_show_minimized(a);\r
 }\r
 \r
+static khm_int32\r
+alert_enqueue(khui_alert * a) {\r
+    if (is_alert_queue_full())\r
+        return KHM_ERROR_NO_RESOURCES;\r
+\r
+    add_to_alert_queue(a);\r
+    check_for_queued_alerts();\r
+\r
+    return KHM_ERROR_SUCCESS;\r
+}\r
+\r
 /* the alerter window is actually a dialog */\r
 static LRESULT CALLBACK \r
 alerter_wnd_proc(HWND hwnd,\r
@@ -410,7 +530,7 @@ alerter_wnd_proc(HWND hwnd,
             a = (khui_alert *) lpcs->lpCreateParams;\r
             khui_alert_hold(a);\r
 \r
-            d = malloc(sizeof(*d));\r
+            d = PMALLOC(sizeof(*d));\r
             ZeroMemory(d, sizeof(*d));\r
 \r
             d->alert = a;\r
@@ -570,7 +690,7 @@ alerter_wnd_proc(HWND hwnd,
                 }\r
             }\r
 \r
-            khui_notify_icon_change(a->severity);\r
+            khm_notify_icon_change(a->severity);\r
 \r
             khui_alert_unlock(a);\r
 \r
@@ -603,9 +723,9 @@ alerter_wnd_proc(HWND hwnd,
 \r
             DeleteObject(d->hfont);\r
 \r
-            free(d);\r
+            PFREE(d);\r
 \r
-            khui_notify_icon_change(KHERR_NONE);\r
+            khm_notify_icon_change(KHERR_NONE);\r
 \r
             return TRUE;\r
         }\r
@@ -659,7 +779,7 @@ alerter_wnd_proc(HWND hwnd,
                 hicon = LoadImage(NULL, \r
                                   MAKEINTRESOURCE(iid), \r
                                   IMAGE_ICON,\r
-                                  SM_CXICON, SM_CYICON,\r
+                                  GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
                                   LR_SHARED);\r
 \r
                 DrawIcon(hdc, x, y, hicon);\r
@@ -718,7 +838,7 @@ alerter_wnd_proc(HWND hwnd,
                 CopyRect(&ro, &r);\r
 \r
                 // adjust for icon and padding\r
-                r.left += SM_CXICON + d->dx_suggest_pad * 2;\r
+                r.left += GetSystemMetrics(SM_CXSMICON) + d->dx_suggest_pad * 2;\r
                 r.top += d->dx_suggest_pad;\r
                 r.right -= d->dx_suggest_pad;\r
                 r.bottom -= d->dx_suggest_pad;\r
@@ -748,7 +868,7 @@ alerter_wnd_proc(HWND hwnd,
                         LoadImage(0,\r
                                   MAKEINTRESOURCE(OIC_INFORMATION),\r
                                   IMAGE_ICON,\r
-                                  SM_CXICON, SM_CYICON,\r
+                                  GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
                                   LR_SHARED);\r
 \r
                     assert(h_sug_ico != NULL);\r
@@ -757,7 +877,7 @@ alerter_wnd_proc(HWND hwnd,
                                ro.left + d->dx_suggest_pad, \r
                                ro.top + d->dx_suggest_pad, \r
                                h_sug_ico,\r
-                               SM_CXICON, SM_CYICON,\r
+                               GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
                                0, NULL,\r
                                DI_NORMAL);\r
 \r
@@ -847,6 +967,9 @@ alerter_wnd_proc(HWND hwnd,
                 khm_leave_modal();\r
 \r
                 DestroyWindow(hwnd);\r
+\r
+                if (LOWORD(wParam) == KHUI_PACTION_NEXT)\r
+                    kmq_post_message(KMSG_ALERT, KMSG_ALERT_SHOW_QUEUED, 0, 0);\r
                 return 0;\r
             }\r
         }\r
@@ -857,14 +980,18 @@ alerter_wnd_proc(HWND hwnd,
     //return DefWindowProc(hwnd, uMsg, wParam, lParam);\r
 }\r
 \r
-ATOM khui_register_alerter_wnd_class(void)\r
+ATOM khm_register_alerter_wnd_class(void)\r
 {\r
     WNDCLASSEX wcx;\r
 \r
     ZeroMemory(&wcx, sizeof(wcx));\r
 \r
     wcx.cbSize = sizeof(wcx);\r
-    wcx.style = CS_DROPSHADOW | CS_OWNDC;\r
+    wcx.style =\r
+#if(_WIN32_WINNT >= 0x0501)\r
+        CS_DROPSHADOW |\r
+#endif\r
+        CS_OWNDC;\r
     wcx.lpfnWndProc = alerter_wnd_proc;\r
     wcx.cbClsExtra = 0;\r
     wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR);\r
@@ -887,7 +1014,7 @@ ATOM khui_register_alerter_wnd_class(void)
 \r
 #define KHUI_NOTIFY_ICON_ID 0\r
 \r
-void khui_notify_icon_add(void) {\r
+void khm_notify_icon_add(void) {\r
     NOTIFYICONDATA ni;\r
     wchar_t buf[256];\r
 \r
@@ -914,7 +1041,7 @@ void khui_notify_icon_add(void) {
 }\r
 \r
 void \r
-khui_notify_icon_balloon(khm_int32 severity,\r
+khm_notify_icon_balloon(khm_int32 severity,\r
                          wchar_t * title,\r
                          wchar_t * msg,\r
                          khm_int32 timeout) {\r
@@ -970,7 +1097,7 @@ khui_notify_icon_balloon(khm_int32 severity,
     DestroyIcon(ni.hIcon);\r
 }\r
 \r
-void khui_notify_icon_change(khm_int32 severity) {\r
+void khm_notify_icon_change(khm_int32 severity) {\r
     NOTIFYICONDATA ni;\r
     wchar_t buf[256];\r
     int iid;\r
@@ -1004,7 +1131,7 @@ void khui_notify_icon_change(khm_int32 severity) {
     DestroyIcon(ni.hIcon);\r
 }\r
 \r
-void khui_notify_icon_remove(void) {\r
+void khm_notify_icon_remove(void) {\r
     NOTIFYICONDATA ni;\r
 \r
     ZeroMemory(&ni, sizeof(ni));\r
@@ -1020,12 +1147,12 @@ void khui_notify_icon_remove(void) {
   Initialization\r
 **********************************************************************/\r
 \r
-void khui_init_notifier(void)\r
+void khm_init_notifier(void)\r
 {\r
-    if(!khui_register_notifier_wnd_class())\r
+    if(!khm_register_notifier_wnd_class())\r
         return;\r
 \r
-    if(!khui_register_alerter_wnd_class())\r
+    if(!khm_register_alerter_wnd_class())\r
         return;\r
 \r
     hwnd_notifier = CreateWindowEx(0,\r
@@ -1043,7 +1170,7 @@ void khui_init_notifier(void)
         kmq_subscribe_hwnd(KMSG_CRED, hwnd_notifier);\r
         notifier_ready = TRUE;\r
 \r
-        khui_notify_icon_add();\r
+        khm_notify_icon_add();\r
     }\r
 #ifdef DEBUG\r
     else {\r
@@ -1051,14 +1178,18 @@ void khui_init_notifier(void)
     }\r
 #endif\r
     khm_timer_init();\r
+\r
+    khm_addr_change_notifier_init();\r
 }\r
 \r
-void khui_exit_notifier(void)\r
+void khm_exit_notifier(void)\r
 {\r
+    khm_addr_change_notifier_exit();\r
+\r
     khm_timer_exit();\r
 \r
     if(hwnd_notifier != NULL) {\r
-        khui_notify_icon_remove();\r
+        khm_notify_icon_remove();\r
         kmq_unsubscribe_hwnd(KMSG_ALERT, hwnd_notifier);\r
         kmq_unsubscribe_hwnd(KMSG_CRED, hwnd_notifier);\r
         DestroyWindow(hwnd_notifier);\r
index bfe9656b89cdb1083f6544826a1c93063b47168b..de9fb60fa9fdbad64c82881df0f0c802130bf7e4 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 #define __KHIMAIRA_NOTIFIER_H\r
 \r
 void \r
-khui_init_notifier(void);\r
+khm_init_notifier(void);\r
 \r
 void \r
-khui_exit_notifier(void);\r
+khm_exit_notifier(void);\r
 \r
 void \r
-khui_notify_icon_change(khm_int32 severity);\r
+khm_notify_icon_change(khm_int32 severity);\r
 \r
 void \r
-khui_notify_icon_balloon(khm_int32 severity,\r
+khm_notify_icon_balloon(khm_int32 severity,\r
                          wchar_t * title,\r
                          wchar_t * msg,\r
                          khm_int32 timeout);\r
index f8c17f68e159ca2b0e670149625a0dca12f23cb6..b0adcf68934dbbb48d7f585f302fb339c07ea34d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index fe603c0154bd34a31f69563cf230ce198c783e0e..79a6cc35a03b32dea41be62057b1d146ccb1d4ea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -66,7 +66,7 @@ void pw_update_property_data(HWND hw, pw_data * d)
             &attr_count)))\r
             return;\r
 \r
-        attrs = malloc(sizeof(khm_int32) * attr_count);\r
+        attrs = PMALLOC(sizeof(khm_int32) * attr_count);\r
         assert(attrs != NULL);\r
 \r
         kcdb_attrib_get_ids(\r
@@ -77,7 +77,7 @@ void pw_update_property_data(HWND hw, pw_data * d)
             &attr_count);\r
 \r
         cb_buf = sizeof(wchar_t) * 2048;\r
-        buffer = malloc(cb_buf);\r
+        buffer = PMALLOC(cb_buf);\r
         assert(buffer != NULL);\r
 \r
         for(i=0; i<attr_count; i++) {\r
@@ -108,8 +108,8 @@ void pw_update_property_data(HWND hw, pw_data * d)
             ListView_SetItem(hwnd_lv, &lvi);\r
         }\r
 \r
-        free(attrs);\r
-        free(buffer);\r
+        PFREE(attrs);\r
+        PFREE(buffer);\r
     }\r
 }\r
 \r
@@ -131,7 +131,7 @@ LRESULT CALLBACK khui_property_wnd_proc(
 \r
                 cs = (CREATESTRUCT *) lParam;\r
 \r
-                child = malloc(sizeof(*child));\r
+                child = PMALLOC(sizeof(*child));\r
                 ZeroMemory(child, sizeof(*child));\r
 \r
 #pragma warning(push)\r
@@ -198,7 +198,7 @@ LRESULT CALLBACK khui_property_wnd_proc(
             {\r
                 child = (pw_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
                 kcdb_buf_release(child->record);\r
-                free(child);\r
+                PFREE(child);\r
             }\r
             break;\r
 \r
index 67250c96d92c83f8dcf16269f2ef778e8f831bd4..89305dd7ba7f4ed263282194db07be2fef15705c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index b73ec4820ba03d2f5c60cadf987ea82f37fcc51e..620bdc54e6ff0f7fb6715615b8df6497ca9b47ac 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -172,7 +172,7 @@ reqdaemonwnd_proc(HWND hwnd,
 #ifdef DEBUG\r
                     assert(FALSE);\r
 #endif\r
-                    rv = KHM_ERROR_INVALID_PARM;\r
+                    rv = KHM_ERROR_INVALID_PARAM;\r
                     goto _exit_tgt_with_lparam;\r
                 }\r
 \r
@@ -185,7 +185,7 @@ reqdaemonwnd_proc(HWND hwnd,
 #ifdef DEBUG\r
                     assert(FALSE);\r
 #endif\r
-                    rv = KHM_ERROR_INVALID_PARM;\r
+                    rv = KHM_ERROR_INVALID_PARAM;\r
                     goto _exit_tgt_with_lparam;\r
                 }\r
 \r
@@ -198,7 +198,7 @@ reqdaemonwnd_proc(HWND hwnd,
 #ifdef DEBUG\r
                     assert(FALSE);\r
 #endif\r
-                    rv = KHM_ERROR_INVALID_PARM;\r
+                    rv = KHM_ERROR_INVALID_PARAM;\r
                     goto _exit_tgt_with_lparam;\r
                 }\r
 \r
@@ -212,7 +212,7 @@ reqdaemonwnd_proc(HWND hwnd,
 \r
                 if (FAILED(StringCbPrintf(widname, sizeof(widname),\r
                                           L"%hs@%hs", username, realm))) {\r
-                    rv = KHM_ERROR_INVALID_PARM;\r
+                    rv = KHM_ERROR_INVALID_PARAM;\r
                     goto _exit_tgt_with_lparam;\r
                 }\r
 \r
index 13b0ebd2c14bc788f13c2975c230dc6104392171..b55e93c992b3d6d3e6e6e6fb3d27ed15a19e6493 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index a58cebb8d3e74176c0eee2c8a845f07c2a121e67..4bee5f206a179b16eb808578a24c501ae63495ea 100644 (file)
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}\r
 // Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\ui\lang\en_us\khapp.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\ui\lang\en_us\khapp.rc\r
 //\r
 #define IDI_MAIN_APP                    104\r
 #define IDD_PROPPAGE_MEDIUM             106\r
@@ -94,9 +94,7 @@
 #define IDS_NC_CREDTEXT_ID_MANY         148\r
 #define IDB_LOGO_SHADE                  149\r
 #define IDS_NC_CREDTEXT_ID_INVALID      149\r
-#define IDI_WGT_COLLAPSE                150\r
 #define IDS_WTPOST_INIT_CREDS           150\r
-#define IDI_WGT_EXPAND                  151\r
 #define IDS_WTPOST_NEW_CREDS            151\r
 #define IDB_WDG_EXPAND                  152\r
 #define IDS_ACTION_RENEW_CRED           152\r
 #define IDS_CFG_ID_TAB_SHORT            197\r
 #define IDB_TB_SPACE                    197\r
 #define IDS_CFG_ID_TAB_LONG             198\r
+#define IDB_WDG_STUCK_HI                198\r
 #define IDS_CFG_IDS_TAB_SHORT           199\r
+#define IDB_WDG_STICK                   199\r
 #define IDS_CFG_IDS_TAB_LONG            200\r
+#define IDB_WDG_STICK_HI                200\r
 #define IDS_CFG_IDS_IDENTITY            201\r
+#define IDB_WDG_STUCK                   201\r
 #define IDS_ACTION_IMPORT               202\r
 #define IDS_CTX_IMPORT                  203\r
 #define IDS_CFG_PI_COL_PLUGINS          204\r
 #define IDS_CTX_PROC_PASSWORD           219\r
 #define IDS_NC_PWD_FAILED_TITLE         220\r
 #define IDS_CMDLINE_HELP                221\r
+#define IDS_PACTION_NEXT                222\r
+#define IDS_ERR_TITLE_NO_IDENTPRO       223\r
+#define IDS_ERR_MSG_NO_IDENTPRO         224\r
+#define IDS_ERR_SUGG_NO_IDENTPRO        225\r
+#define IDS_NC_REN_FAILED_TITLE         226\r
+#define IDS_CW_DEFAULT                  227\r
 #define IDC_NC_USERNAME                 1007\r
 #define IDC_NC_PASSWORD                 1008\r
 #define IDC_NC_CREDTEXT_LABEL           1009\r
 #define IDC_BUILDINFO                   1102\r
 #define IDC_LIST1                       1103\r
 #define IDC_MODULES                     1103\r
+#define IDC_PP_CONFIG                   1104\r
 #define IDA_ACTIVATE_MENU               40003\r
 #define IDA_UP                          40004\r
 #define IDA_DOWN                        40005\r
 // \r
 #ifdef APSTUDIO_INVOKED\r
 #ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE        198\r
+#define _APS_NEXT_RESOURCE_VALUE        202\r
 #define _APS_NEXT_COMMAND_VALUE         40010\r
-#define _APS_NEXT_CONTROL_VALUE         1104\r
+#define _APS_NEXT_CONTROL_VALUE         1105\r
 #define _APS_NEXT_SYMED_VALUE           101\r
 #endif\r
 #endif\r
index 75f520c575db7989bd94c4eb4df01c896f02e2d7..9a2f8e79c93db9646a3fd23ee97e43f45bb700d6 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 #include<khmapp.h>\r
 \r
-khui_statusbar_part khui_statusbar_parts[] = {\r
+khm_statusbar_part khm_statusbar_parts[] = {\r
     {KHUI_SBPART_INFO, 0, KHUI_SB_WTYPE_FILLER},\r
     {KHUI_SBPART_NOTICE, 40, KHUI_SB_WTYPE_RELATIVE},\r
     {KHUI_SBPART_LOC, 40, KHUI_SB_WTYPE_ABSOLUTE}\r
 };\r
 \r
-int khui_n_statusbar_parts = sizeof(khui_statusbar_parts) / sizeof(khui_statusbar_part);\r
+int khm_n_statusbar_parts = sizeof(khm_statusbar_parts) / sizeof(khm_statusbar_part);\r
 \r
-HWND khui_hwnd_statusbar = NULL;\r
+HWND khm_hwnd_statusbar = NULL;\r
 \r
-void khui_statusbar_set_parts(HWND parent) {\r
+LRESULT \r
+khm_statusbar_notify(LPNMHDR nmhdr) {\r
+    LPNMMOUSE pnmm;\r
+\r
+    switch(nmhdr->code) {\r
+    case NM_CLICK:\r
+    case NM_DBLCLK:\r
+        pnmm = (LPNMMOUSE) nmhdr;\r
+\r
+        if (pnmm->dwItemSpec >= (DWORD) khm_n_statusbar_parts)\r
+            return TRUE;\r
+\r
+        if (khm_statusbar_parts[pnmm->dwItemSpec].id == KHUI_SBPART_NOTICE) {\r
+            /* means, show next notification */\r
+            kmq_post_message(KMSG_ALERT, KMSG_ALERT_SHOW_QUEUED, 0, 0);\r
+        }\r
+\r
+        return TRUE;\r
+    }\r
+\r
+    return FALSE;\r
+}\r
+\r
+void \r
+khui_statusbar_set_parts(HWND parent) {\r
     int i;\r
     int fillerwidth;\r
     int staticwidth;\r
@@ -50,28 +74,28 @@ void khui_statusbar_set_parts(HWND parent) {
 \r
     /* calculate fillerwidth and staticwidth */\r
     staticwidth = 0;\r
-    for(i=0;i<khui_n_statusbar_parts;i++) {\r
-        if(khui_statusbar_parts[i].wtype == KHUI_SB_WTYPE_ABSOLUTE) {\r
-            staticwidth += khui_statusbar_parts[i].width;\r
-        } else if(khui_statusbar_parts[i].wtype == KHUI_SB_WTYPE_RELATIVE) {\r
-            staticwidth += (khui_statusbar_parts[i].width * width) / 100;\r
+    for(i=0;i<khm_n_statusbar_parts;i++) {\r
+        if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_ABSOLUTE) {\r
+            staticwidth += khm_statusbar_parts[i].width;\r
+        } else if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_RELATIVE) {\r
+            staticwidth += (khm_statusbar_parts[i].width * width) / 100;\r
         }\r
     }\r
 \r
     fillerwidth = width - staticwidth;\r
 \r
-    parts = malloc(sizeof(INT) * khui_n_statusbar_parts);\r
+    parts = PMALLOC(sizeof(INT) * khm_n_statusbar_parts);\r
 \r
     lastx = 0;\r
-    for(i=0;i<khui_n_statusbar_parts;i++) {\r
+    for(i=0;i<khm_n_statusbar_parts;i++) {\r
         int w;\r
-        switch(khui_statusbar_parts[i].wtype) {\r
+        switch(khm_statusbar_parts[i].wtype) {\r
             case KHUI_SB_WTYPE_ABSOLUTE:\r
-                w = khui_statusbar_parts[i].width;\r
+                w = khm_statusbar_parts[i].width;\r
                 break;\r
 \r
             case KHUI_SB_WTYPE_RELATIVE:\r
-                w = (khui_statusbar_parts[i].width * width) / 100;\r
+                w = (khm_statusbar_parts[i].width * width) / 100;\r
                 break;\r
 \r
             case KHUI_SB_WTYPE_FILLER:\r
@@ -80,22 +104,22 @@ void khui_statusbar_set_parts(HWND parent) {
         }\r
         lastx += w;\r
 \r
-        if(i==khui_n_statusbar_parts - 1)\r
+        if(i==khm_n_statusbar_parts - 1)\r
             parts[i] = -1;\r
         else\r
             parts[i] = lastx;\r
     }\r
 \r
     SendMessage(\r
-        khui_hwnd_statusbar,\r
+        khm_hwnd_statusbar,\r
         SB_SETPARTS,\r
-        khui_n_statusbar_parts,\r
+        khm_n_statusbar_parts,\r
         (LPARAM) parts);\r
 \r
-    free(parts);\r
+    PFREE(parts);\r
 }\r
 \r
-void khui_create_statusbar(HWND parent) {\r
+void khm_create_statusbar(HWND parent) {\r
     HWND hwsb;\r
 \r
     hwsb = CreateWindowEx(\r
@@ -112,38 +136,47 @@ void khui_create_statusbar(HWND parent) {
     if(!hwsb)\r
         return;\r
 \r
-    khui_hwnd_statusbar = hwsb;\r
+    khm_hwnd_statusbar = hwsb;\r
 \r
     khui_statusbar_set_parts(parent);\r
+\r
+    kmq_post_message(KMSG_ALERT, KMSG_ALERT_CHECK_QUEUE, 0, 0);\r
 }\r
 \r
-void khui_update_statusbar(HWND parent) {\r
-    MoveWindow(khui_hwnd_statusbar, 0, 0, 0, 0, TRUE);\r
+void khm_update_statusbar(HWND parent) {\r
+    MoveWindow(khm_hwnd_statusbar, 0, 0, 0, 0, TRUE);\r
     khui_statusbar_set_parts(parent);\r
 }\r
 \r
 int sb_find_index(int id) {\r
     int i;\r
 \r
-    for(i=0;i<khui_n_statusbar_parts;i++) {\r
-        if(khui_statusbar_parts[i].id == id)\r
+    for(i=0;i<khm_n_statusbar_parts;i++) {\r
+        if(khm_statusbar_parts[i].id == id)\r
             return i;\r
     }\r
 \r
     return -1;\r
 }\r
 \r
-void khui_statusbar_set_text(int id, wchar_t * text) {\r
+void khm_statusbar_set_part(int id, HICON icon, wchar_t * text) {\r
     int idx;\r
 \r
+    if (!khm_hwnd_statusbar)\r
+        return;\r
+\r
     idx = sb_find_index(id);\r
     if(idx < 0)\r
         return;\r
 \r
-    SendMessage(\r
-        khui_hwnd_statusbar,\r
-        SB_SETTEXT,\r
-        idx,\r
-        (LPARAM) text);\r
+    SendMessage(khm_hwnd_statusbar,\r
+                SB_SETICON,\r
+                idx,\r
+                (LPARAM) icon);\r
+\r
+    SendMessage(khm_hwnd_statusbar,\r
+                SB_SETTEXT,\r
+                idx,\r
+                (LPARAM) text);\r
 }\r
 \r
index b4f2a6e30fb6f69e2ec04e416a7da1ac03913427..2fd267e9e1f586d2d3ba1b0b0fbf14c60c6740dc 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 #ifndef __KHIMAIRA_STATUSBAR_H\r
 #define __KHIMAIRA_STATUSBAR_H\r
 \r
-typedef struct khui_statusbar_part_t {\r
+typedef struct khm_statusbar_part_t {\r
     int id;\r
     int width;\r
     int wtype; /* one of KHUI_SB_WTYPE_* */\r
-} khui_statusbar_part;\r
+} khm_statusbar_part;\r
 \r
 #define KHUI_SB_WTYPE_RELATIVE    1\r
 #define KHUI_SB_WTYPE_ABSOLUTE    2\r
@@ -42,12 +42,13 @@ typedef struct khui_statusbar_part_t {
 #define KHUI_SBPART_NOTICE  2\r
 #define KHUI_SBPART_LOC     3\r
 \r
-extern HWND khui_hwnd_statusbar;\r
-extern khui_statusbar_part khui_statusbar_parts[];\r
-extern int khui_n_statusbar_parts;\r
+extern HWND khm_hwnd_statusbar;\r
+extern khm_statusbar_part khm_statusbar_parts[];\r
+extern int khm_n_statusbar_parts;\r
 \r
-void khui_create_statusbar(HWND p);\r
-void khui_update_statusbar(HWND parent);\r
-void khui_statusbar_set_text(int id, wchar_t * text);\r
+void khm_create_statusbar(HWND p);\r
+void khm_update_statusbar(HWND parent);\r
+void khm_statusbar_set_part(int id, HICON icon, wchar_t * text);\r
+LRESULT khm_statusbar_notify(LPNMHDR nmhdr);\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index bd5b30eff6276725b697fb96439efcbc2c2963ef..98957858c5d636ed45ac01267f97f800abbfc5fb 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -59,7 +59,7 @@ khm_timer_init(void) {
 \r
     khui_nc_timers = KHUI_TIMER_ALLOC_INCR;\r
     khui_n_timers = 0;\r
-    khui_timers = malloc(sizeof(*khui_timers) * khui_nc_timers);\r
+    khui_timers = PMALLOC(sizeof(*khui_timers) * khui_nc_timers);\r
 \r
 #ifdef DEBUG\r
     assert(khui_timers != NULL);\r
@@ -68,12 +68,12 @@ khm_timer_init(void) {
     InitializeCriticalSection(&cs_timers);\r
 }\r
 \r
-void \r
+void\r
 khm_timer_exit(void) {\r
     EnterCriticalSection(&cs_timers);\r
 \r
     if (khui_timers)\r
-        free(khui_timers);\r
+        PFREE(khui_timers);\r
     khui_timers = NULL;\r
     khui_n_timers = 0;\r
     khui_nc_timers = 0;\r
@@ -252,7 +252,7 @@ khm_timer_fire(HWND hwnd) {
 \r
 static int\r
 tmr_update(khm_handle key, khui_timer_type type, __int64 expire,\r
-           __int64 offset, void * data) {\r
+           __int64 offset, void * data, khm_boolean reinstate) {\r
     int i;\r
 \r
     for (i=0; i < (int) khui_n_timers; i++) {\r
@@ -271,13 +271,13 @@ tmr_update(khm_handle key, khui_timer_type type, __int64 expire,
 #endif\r
             khui_nc_timers = UBOUNDSS(i+1, KHUI_TIMER_ALLOC_INCR,\r
                                       KHUI_TIMER_ALLOC_INCR);\r
-            nt = malloc(sizeof(*nt) * khui_nc_timers);\r
+            nt = PMALLOC(sizeof(*nt) * khui_nc_timers);\r
 #ifdef DEBUG\r
             assert(nt);\r
 #endif\r
             memcpy(nt, khui_timers, sizeof(*nt) * khui_n_timers);\r
 \r
-            free(khui_timers);\r
+            PFREE(khui_timers);\r
             khui_timers = nt;\r
         }\r
 \r
@@ -292,6 +292,8 @@ tmr_update(khm_handle key, khui_timer_type type, __int64 expire,
     khui_timers[i].data = data;\r
 \r
     khui_timers[i].flags &= ~KHUI_TE_FLAG_STALE;\r
+    if (reinstate)\r
+        khui_timers[i].flags &= ~KHUI_TE_FLAG_EXPIRED;\r
 \r
     return i;\r
 }\r
@@ -328,6 +330,7 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
     __int64 ft_cred_expiry;\r
     __int64 ft;\r
     __int64 fte;\r
+    __int64 ft_reinst;\r
     khm_size cb;\r
 \r
     kcdb_cred_get_identity(cred, &ident);\r
@@ -351,10 +354,12 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
     /* and the current time */\r
     GetSystemTimeAsFileTime((LPFILETIME) &ft_current);\r
 \r
+    TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, (LPFILETIME) &ft_reinst);\r
+\r
     mark_idx = tmr_find(ident, KHUI_TTYPE_ID_MARK, 0, 0);\r
 \r
     if (mark_idx < 0) {\r
-        mark_idx = tmr_update(ident, KHUI_TTYPE_ID_MARK, 0, 0, 0);\r
+        mark_idx = tmr_update(ident, KHUI_TTYPE_ID_MARK, 0, 0, 0, FALSE);\r
         kcdb_identity_hold(ident);\r
 #ifdef DEBUG\r
         assert(mark_idx >= 0);\r
@@ -426,12 +431,37 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
         khc_close_space(csp_id);\r
 \r
         if (monitor && do_renew) {\r
+            int prev;\r
+\r
             TimetToFileTimeInterval(to_renew, (LPFILETIME) &ft);\r
             fte = ft_expiry - ft;\r
 \r
-            if (fte > ft_current) {\r
-                tmr_update(ident, KHUI_TTYPE_ID_RENEW, fte, ft, 0);\r
+            prev =\r
+                tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0);\r
+\r
+            /* we set off a renew notification immediately if the\r
+               renew threshold has passed but a renew was never sent.\r
+               This maybe because that NetIDMgr was started at the\r
+               last minute, or because for some reason the renew timer\r
+               could not be triggered earlier. */\r
+            if (fte > ft_current ||\r
+                prev == -1 ||\r
+                !(khui_timers[prev].flags & KHUI_TE_FLAG_EXPIRED)) {\r
+\r
+                if (fte <= ft_current)\r
+                    fte = ft_current;\r
+\r
+                tmr_update(ident, KHUI_TTYPE_ID_RENEW, \r
+                           fte, ft, 0, fte > ft_current + ft_reinst);\r
                 renew_done = TRUE;\r
+            } else {\r
+                /* special case.  If the renew timer was in the past\r
+                   and it was expired, then we retain the record as\r
+                   long as the credentials are around.  If the renewal\r
+                   failed we don't want to automatically retry\r
+                   everytime we check the timers. */\r
+                tmr_update(ident, KHUI_TTYPE_ID_RENEW,\r
+                           fte, ft, 0, FALSE);\r
             }\r
         }\r
 \r
@@ -440,7 +470,8 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
             fte = ft_expiry - ft;\r
 \r
             if (fte > ft_current)\r
-                tmr_update(ident, KHUI_TTYPE_ID_WARN, fte, ft, 0);\r
+                tmr_update(ident, KHUI_TTYPE_ID_WARN,\r
+                           fte, ft, 0, fte > ft_current + ft_reinst);\r
         }\r
 \r
         if (monitor && do_crit && !renew_done) {\r
@@ -448,12 +479,14 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
             fte = ft_expiry - ft;\r
 \r
             if (fte > ft_current)\r
-                tmr_update(ident, KHUI_TTYPE_ID_CRIT, fte, ft, 0);\r
+                tmr_update(ident, KHUI_TTYPE_ID_CRIT,\r
+                           fte, ft, 0, fte > ft_current + ft_reinst);\r
         }\r
 \r
         if (monitor && !renew_done) {\r
             if (ft_expiry > ft_current)\r
-                tmr_update(ident, KHUI_TTYPE_ID_EXP, ft_expiry, 0, 0);\r
+                tmr_update(ident, KHUI_TTYPE_ID_EXP, \r
+                           ft_expiry, 0, 0, fte > ft_current + ft_reinst);\r
         }\r
 \r
     _done_with_ident:\r
@@ -474,12 +507,13 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
         goto _cleanup;\r
 \r
     if ((idx = tmr_find(ident, KHUI_TTYPE_ID_WARN, 0, 0)) >= 0 &&\r
-       !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {\r
+        !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {\r
 \r
         fte = ft_cred_expiry - khui_timers[idx].offset;\r
         if (fte > ft_current) {\r
             tmr_update(cred, KHUI_TTYPE_CRED_WARN, fte, \r
-                       khui_timers[idx].offset, 0);\r
+                       khui_timers[idx].offset, 0,\r
+                       fte > ft_current + ft_reinst);\r
             kcdb_cred_hold(cred);\r
         }\r
     }\r
@@ -490,7 +524,8 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
         fte = ft_cred_expiry - khui_timers[idx].offset;\r
         if (fte > ft_current) {\r
             tmr_update(cred, KHUI_TTYPE_CRED_CRIT, fte,\r
-                       khui_timers[idx].offset, 0);\r
+                       khui_timers[idx].offset, 0,\r
+                       fte > ft_current + ft_reinst);\r
             kcdb_cred_hold(cred);\r
         }\r
     }\r
@@ -501,7 +536,8 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
         fte = ft_cred_expiry - khui_timers[idx].offset;\r
         if (fte > ft_current) {\r
             tmr_update(cred, KHUI_TTYPE_CRED_RENEW, fte,\r
-                       khui_timers[idx].offset, 0);\r
+                       khui_timers[idx].offset, 0,\r
+                       fte > ft_current + ft_reinst);\r
             kcdb_cred_hold(cred);\r
         }\r
     }\r
@@ -511,7 +547,8 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) {
 \r
         if (ft_cred_expiry > ft_current) {\r
             tmr_update(cred, KHUI_TTYPE_CRED_EXP, ft_cred_expiry,\r
-                       0, 0);\r
+                       0, 0,\r
+                       ft_cred_expiry > ft_current + ft_reinst);\r
         }\r
     }\r
 \r
@@ -577,6 +614,7 @@ tmr_purge(void) {
     khui_n_timers = j;\r
 }\r
 \r
+/* go through all the credentials and set timers as appropriate. */\r
 void \r
 khm_timer_refresh(HWND hwnd) {\r
     int i;\r
@@ -608,10 +646,11 @@ khm_timer_refresh(HWND hwnd) {
 \r
     next_event = 0;\r
     for (i=0; i < (int) khui_n_timers; i++) {\r
-        if (next_event == 0 ||\r
-            (!(khui_timers[i].flags & KHUI_TE_FLAG_EXPIRED) &&\r
-             khui_timers[i].type != KHUI_TTYPE_ID_MARK &&\r
+        if (!(khui_timers[i].flags & KHUI_TE_FLAG_EXPIRED) &&\r
+            khui_timers[i].type != KHUI_TTYPE_ID_MARK &&\r
+            (next_event == 0 ||\r
              next_event > khui_timers[i].expire))\r
+\r
             next_event = khui_timers[i].expire;\r
     }\r
 \r
index 921b9dcc53acd2009aed67b78ecb6190c78b27c3..3a57917214d01d3876e63cf089ae2fb111f912e9 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index d1a84e235b7a2255065ca034b5890dd2d261ba20..fcc0d9ebd79389ffc5fb024a864eaaaf06a1c162 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -124,8 +124,7 @@ void khui_add_action_to_toolbar(HWND tb, khui_action *a, int opt, HIMAGELIST hiL
         bn.fsStyle = BTNS_SEP;\r
         bn.iBitmap = 3;\r
 \r
-        lr = SendMessage(\r
-                         tb,\r
+        lr = SendMessage(tb,\r
                          TB_ADDBUTTONS,\r
                          1,\r
                          (LPARAM) &bn);\r
@@ -158,7 +157,9 @@ void khui_add_action_to_toolbar(HWND tb, khui_action *a, int opt, HIMAGELIST hiL
                                             TB_ADDSTRING,\r
                                             (WPARAM) NULL,\r
                                             (LPARAM) buf);\r
+#if (_WIN32_IE >= 0x0501)\r
             bn.fsStyle |= BTNS_SHOWTEXT;\r
+#endif\r
             bn.iString = idx_caption;\r
         }\r
     }\r
@@ -170,8 +171,11 @@ void khui_add_action_to_toolbar(HWND tb, khui_action *a, int opt, HIMAGELIST hiL
     if((opt & KHUI_TOOLBAR_ADD_BITMAP) && a->ib_normal) {\r
         bn.fsStyle |= TBSTYLE_CUSTOMERASE;\r
         bn.iBitmap = khui_tb_blank;\r
-    } else\r
+    } else {\r
+#if (_WIN32_IE >= 0x0501)\r
         bn.iBitmap = I_IMAGENONE;\r
+#endif\r
+    }\r
 \r
     bn.idCommand = a->cmd;\r
 \r
@@ -242,21 +246,24 @@ void khm_create_standard_toolbar(HWND rebar) {
 \r
     def = khui_find_menu(KHUI_TOOLBAR_STANDARD);\r
 \r
-    hwtb = CreateWindowEx(\r
-        TBSTYLE_EX_MIXEDBUTTONS,\r
-        TOOLBARCLASSNAME,\r
-        (LPWSTR) NULL,\r
-        WS_CHILD |\r
-        TBSTYLE_FLAT |\r
-        TBSTYLE_AUTOSIZE | \r
-        TBSTYLE_LIST |\r
-        CCS_NORESIZE | \r
-        CCS_NOPARENTALIGN |\r
-        CCS_ADJUSTABLE |\r
-        CCS_NODIVIDER,\r
-        0, 0, 0, 0, rebar,\r
-        (HMENU) NULL, khm_hInstance,\r
-        NULL);\r
+    hwtb = CreateWindowEx(0\r
+#if (_WIN32_IE >= 0x0501)\r
+                          | TBSTYLE_EX_MIXEDBUTTONS\r
+#endif\r
+                          ,\r
+                          TOOLBARCLASSNAME,\r
+                          (LPWSTR) NULL,\r
+                          WS_CHILD |\r
+                          TBSTYLE_FLAT |\r
+                          TBSTYLE_AUTOSIZE | \r
+                          TBSTYLE_LIST |\r
+                          CCS_NORESIZE | \r
+                          CCS_NOPARENTALIGN |\r
+                          CCS_ADJUSTABLE |\r
+                          CCS_NODIVIDER,\r
+                          0, 0, 0, 0, rebar,\r
+                          (HMENU) NULL, khm_hInstance,\r
+                          NULL);\r
 \r
     if(!hwtb) {\r
 #ifdef DEBUG\r
index 65598debce5b46fe872b7c0681723e815223e0fb..89700f2e4e2fcba43c545fdb2d8370260421c6a7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -49,4 +49,4 @@ void khm_update_standard_toolbar(void);
 #define KHUI_TOOLBAR_BGCOLOR RGB(0xd7,0xd7,0xd7)\r
 #define KHUI_TOOLBAR_MAX_BTNS 64\r
 \r
-#endif
\ No newline at end of file
+#endif\r
index 80b6ad05f98aea332fe29a6426fdd028f939991c..05b9455149aa68ab5a76ed1689ce35a57f28c856 100644 (file)
@@ -12,6 +12,7 @@ KHUI_PACTION_ENTER,FVIRTKEY,VK_RETURN,KHUI_ACCEL_SCOPE_GLOBAL
 KHUI_PACTION_ESC,FVIRTKEY,VK_ESCAPE,KHUI_ACCEL_SCOPE_GLOBAL\r
 #KHUI_PACTION_DELETE,FVIRTKEY,VK_DELETE,KHUI_ACCEL_SCOPE_GLOBAL\r
 KHUI_ACTION_DESTROY_CRED,FVIRTKEY,VK_DELETE,KHUI_ACCEL_SCOPE_GLOBAL\r
-KHUI_ACTION_EXIT,FCONTROL,\'X\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_ACTION_EXIT,FCONTROL|FVIRTKEY,\'X\',KHUI_ACCEL_SCOPE_GLOBAL\r
 KHUI_ACTION_VIEW_REFRESH,FVIRTKEY,VK_F5,KHUI_ACCEL_SCOPE_GLOBAL\r
-KHUI_ACTION_NEW_CRED,FCONTROL,\'N\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_ACTION_NEW_CRED,FCONTROL|FVIRTKEY,\'N\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_PACTION_SELALL,FCONTROL|FVIRTKEY,\'A\',KHUI_ACCEL_SCOPE_GLOBAL\r
index cc383c689b5b7b047ca4de3103c0df366969e48d..0ebb9ae0c0ff040b71c695507b195406092b5c39 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -26,6 +26,7 @@
 \r
 #define NOEXPORT\r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 #include<assert.h>\r
 \r
 khui_action_ref khui_main_menu[] = {\r
@@ -212,12 +213,13 @@ KHMEXP khui_menu_def * KHMAPI
 khui_menu_create(int cmd)\r
 {\r
     khui_menu_def * d;\r
-    d = malloc(sizeof(*d));\r
+\r
+    d = PMALLOC(sizeof(*d));\r
     ZeroMemory(d, sizeof(*d));\r
 \r
     d->cmd = cmd;\r
     d->nc_items = MENU_NC_ITEMS;\r
-    d->items = malloc(sizeof(*(d->items)) *  d->nc_items);\r
+    d->items = PMALLOC(sizeof(*(d->items)) *  d->nc_items);\r
 \r
     d->state = KHUI_MENUSTATE_ALLOCD;\r
 \r
@@ -261,12 +263,12 @@ khui_menu_delete(khui_menu_def * d)
 \r
     for(i=0; i< (int) d->n_items; i++) {\r
         if(d->items[i].flags & KHUI_ACTIONREF_FREE_PACTION)\r
-            free(d->items[i].p_action);\r
+            PFREE(d->items[i].p_action);\r
     }\r
 \r
     if(d->items)\r
-        free(d->items);\r
-    free(d);\r
+        PFREE(d->items);\r
+    PFREE(d);\r
 }\r
 \r
 static void khui_menu_assert_size(khui_menu_def * d, size_t n)\r
@@ -275,9 +277,9 @@ static void khui_menu_assert_size(khui_menu_def * d, size_t n)
         khui_action_ref * ni;\r
 \r
         d->nc_items = UBOUNDSS(n, MENU_NC_ITEMS, MENU_NC_ITEMS);\r
-        ni = malloc(sizeof(*(d->items)) * d->nc_items);\r
+        ni = PMALLOC(sizeof(*(d->items)) * d->nc_items);\r
         memcpy(ni, d->items, sizeof(*(d->items)) * d->n_items);\r
-        free(d->items);\r
+        PFREE(d->items);\r
         d->items = ni;\r
     }\r
 }\r
@@ -420,7 +422,7 @@ KHMEXP void KHMAPI khui_enable_actions(khui_menu_def * d, khm_boolean enable)
     }\r
 \r
     if(delta) {\r
-        kmq_send_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
+        kmq_post_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
     }\r
 }\r
 \r
@@ -438,7 +440,7 @@ KHMEXP void KHMAPI khui_enable_action(int cmd, khm_boolean enable) {
     } else\r
         return;\r
 \r
-    kmq_send_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
+    kmq_post_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
 }\r
 \r
 KHMEXP HACCEL KHMAPI khui_create_global_accel_table(void) {\r
@@ -446,7 +448,7 @@ KHMEXP HACCEL KHMAPI khui_create_global_accel_table(void) {
     ACCEL * accels;\r
     HACCEL ha;\r
 \r
-    accels = malloc(sizeof(ACCEL) * khui_n_accel_global);\r
+    accels = PMALLOC(sizeof(ACCEL) * khui_n_accel_global);\r
     for(i=0;i<khui_n_accel_global;i++) {\r
         accels[i].cmd = khui_accel_global[i].cmd;\r
         accels[i].fVirt = khui_accel_global[i].mod;\r
@@ -455,7 +457,7 @@ KHMEXP HACCEL KHMAPI khui_create_global_accel_table(void) {
 \r
     ha = CreateAcceleratorTable(accels, khui_n_accel_global);\r
 \r
-    free(accels);\r
+    PFREE(accels);\r
 \r
     return ha;\r
 }\r
@@ -623,10 +625,10 @@ khuiint_copy_context(khui_action_context * ctxdest,
         if (ctxdest->int_cb_buf < cb_total) {\r
 \r
             if (ctxdest->int_buf)\r
-                free(ctxdest->int_buf);\r
+                PFREE(ctxdest->int_buf);\r
 \r
             ctxdest->int_cb_buf = cb_total;\r
-            ctxdest->int_buf = malloc(cb_total);\r
+            ctxdest->int_buf = PMALLOC(cb_total);\r
         }\r
 \r
 #ifdef DEBUG\r
@@ -680,7 +682,7 @@ khuiint_copy_context(khui_action_context * ctxdest,
        khui_context_release() to free the allocated buffer */\r
 #if 0\r
     if (ctxsrc->vparam && ctxsrc->cb_vparam) {\r
-        ctxdest->vparam = malloc(ctxsrc->cb_vparam);\r
+        ctxdest->vparam = PMALLOC(ctxsrc->cb_vparam);\r
 #ifdef DEBUG\r
         assert(ctxdest->vparam);\r
 #endif\r
@@ -891,11 +893,11 @@ khui_context_release(khui_action_context * ctx)
     }\r
     ctx->credset = NULL;\r
     if (ctx->int_buf)\r
-        free(ctx->int_buf);\r
+        PFREE(ctx->int_buf);\r
     ctx->int_buf = NULL;\r
 #if 0\r
     if (ctx->vparam && ctx->cb_vparam > 0) {\r
-        free(ctx->vparam);\r
+        PFREE(ctx->vparam);\r
         ctx->vparam = NULL;\r
     }\r
     ctx->cb_vparam = 0;\r
index e317c7cc5461403b49cd2f72159077cb0e031ffa..371fb8798ebd1cfcc441a97e546e73f723d19128 100644 (file)
@@ -35,3 +35,4 @@ KHUI_PACTION_OK,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_OK,0,0,0
 KHUI_PACTION_CANCEL,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CANCEL,0,0,0\r
 KHUI_PACTION_CLOSE,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CLOSE,0,0,0\r
 KHUI_PACTION_BLANK,0,,IDB_TB_SPACE,0,IDB_TB_SPACE,IDB_TB_BLANK_SM,IDB_TB_BLANK_SM,0,0,0,KHUI_ACTIONSTATE_DISABLED\r
+KHUI_PACTION_NEXT,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_NEXT,0,0,0\r
index 69ef01f93c00ca82069366df2033f0b560d0047b..dd096063b12135f3484f27e780b943fb1f9fb430 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -25,6 +25,7 @@
 /* $Id$ */\r
 \r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 #include<assert.h>\r
 \r
 /***********************************************************************\r
@@ -51,7 +52,7 @@ khui_alert_create_empty(khui_alert ** result)
 {\r
     khui_alert * a;\r
 \r
-    a = malloc(sizeof(*a));\r
+    a = PMALLOC(sizeof(*a));\r
     ZeroMemory(a, sizeof(*a));\r
 \r
     a->magic = KHUI_ALERT_MAGIC;\r
@@ -97,21 +98,21 @@ khui_alert_set_title(khui_alert * alert, const wchar_t * title)
 \r
     if(title) {\r
         if(FAILED(StringCbLength(title, \r
-                                 KHUI_MAXCB_TITLE - sizeof(wchar_t)\r
+                                 KHUI_MAXCB_TITLE, \r
                                  &cb))) {\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         }\r
         cb += sizeof(wchar_t);\r
     }\r
 \r
     EnterCriticalSection(&cs_alerts);\r
     if(alert->title && (alert->flags & KHUI_ALERT_FLAG_FREE_TITLE)) {\r
-        free(alert->title);\r
+        PFREE(alert->title);\r
         alert->title = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_TITLE;\r
     }\r
     if(title) {\r
-        alert->title = malloc(cb);\r
+        alert->title = PMALLOC(cb);\r
         StringCbCopy(alert->title, cb, title);\r
         alert->flags |= KHUI_ALERT_FLAG_FREE_TITLE;\r
     }\r
@@ -126,7 +127,7 @@ khui_alert_set_flags(khui_alert * alert, khm_int32 mask, khm_int32 flags)
     assert(alert->magic == KHUI_ALERT_MAGIC);\r
 \r
     if (mask & ~KHUI_ALERT_FLAGMASK_RDWR)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_alerts);\r
     alert->flags = \r
@@ -160,7 +161,7 @@ khui_alert_set_suggestion(khui_alert * alert,
         if(FAILED(StringCbLength(suggestion, \r
                                  KHUI_MAXCB_MESSAGE - sizeof(wchar_t), \r
                                  &cb))) {\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         }\r
         cb += sizeof(wchar_t);\r
     }\r
@@ -169,14 +170,14 @@ khui_alert_set_suggestion(khui_alert * alert,
     if(alert->suggestion && \r
        (alert->flags & KHUI_ALERT_FLAG_FREE_SUGGEST)) {\r
 \r
-        free(alert->suggestion);\r
+        PFREE(alert->suggestion);\r
         alert->suggestion = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_SUGGEST;\r
 \r
     }\r
 \r
     if(suggestion) {\r
-        alert->suggestion = malloc(cb);\r
+        alert->suggestion = PMALLOC(cb);\r
         StringCbCopy(alert->suggestion, cb, suggestion);\r
         alert->flags |= KHUI_ALERT_FLAG_FREE_SUGGEST;\r
     }\r
@@ -196,7 +197,7 @@ khui_alert_set_message(khui_alert * alert, const wchar_t * message)
         if(FAILED(StringCbLength(message, \r
                                  KHUI_MAXCB_MESSAGE - sizeof(wchar_t), \r
                                  &cb))) {\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         }\r
         cb += sizeof(wchar_t);\r
     }\r
@@ -205,14 +206,14 @@ khui_alert_set_message(khui_alert * alert, const wchar_t * message)
     if(alert->message && \r
        (alert->flags & KHUI_ALERT_FLAG_FREE_MESSAGE)) {\r
 \r
-        free(alert->message);\r
+        PFREE(alert->message);\r
         alert->message = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_MESSAGE;\r
 \r
     }\r
 \r
     if(message) {\r
-        alert->message = malloc(cb);\r
+        alert->message = PMALLOC(cb);\r
         StringCbCopy(alert->message, cb, message);\r
         alert->flags |= KHUI_ALERT_FLAG_FREE_MESSAGE;\r
     }\r
@@ -262,6 +263,17 @@ khui_alert_show(khui_alert * alert)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
+KHMEXP khm_int32 KHMAPI\r
+khui_alert_queue(khui_alert * alert)\r
+{\r
+    assert(alert->magic == KHUI_ALERT_MAGIC);\r
+\r
+    khui_alert_hold(alert);\r
+    kmq_post_message(KMSG_ALERT, KMSG_ALERT_QUEUE, 0, (void *) alert);\r
+\r
+    return KHM_ERROR_SUCCESS;\r
+}\r
+\r
 KHMEXP khm_int32 KHMAPI \r
 khui_alert_show_simple(const wchar_t * title, \r
                        const wchar_t * message, \r
@@ -303,26 +315,26 @@ free_alert(khui_alert * alert)
 \r
     if(alert->flags & KHUI_ALERT_FLAG_FREE_TITLE) {\r
         assert(alert->title);\r
-        free(alert->title);\r
+        PFREE(alert->title);\r
         alert->title = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_TITLE;\r
     }\r
     if(alert->flags & KHUI_ALERT_FLAG_FREE_MESSAGE) {\r
         assert(alert->message);\r
-        free(alert->message);\r
+        PFREE(alert->message);\r
         alert->message = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_MESSAGE;\r
     }\r
     if(alert->flags & KHUI_ALERT_FLAG_FREE_SUGGEST) {\r
         assert(alert->suggestion);\r
-        free(alert->suggestion);\r
+        PFREE(alert->suggestion);\r
         alert->suggestion = NULL;\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_SUGGEST;\r
     }\r
     if(alert->flags & KHUI_ALERT_FLAG_FREE_STRUCT) {\r
         alert->flags &= ~KHUI_ALERT_FLAG_FREE_STRUCT;\r
         alert->magic = 0;\r
-        free(alert);\r
+        PFREE(alert);\r
     }\r
 }\r
 \r
index 5c97c701fa7b4c56ca74cb1944112da43c77ea33..51498c0b203134438bf3765187c787aa6fdfb121 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -27,6 +27,7 @@
 #include<khuidefs.h>\r
 #include<kmm.h>\r
 #include<configui.h>\r
+#include<utils.h>\r
 #include<assert.h>\r
 \r
 khm_int32 cfgui_node_serial;\r
@@ -39,7 +40,7 @@ static khui_config_node_i *
 cfgui_create_new_node(void) {\r
     khui_config_node_i * node;\r
 \r
-    node = malloc(sizeof(*node));\r
+    node = PMALLOC(sizeof(*node));\r
 #ifdef DEBUG\r
     assert(node);\r
 #endif\r
@@ -60,13 +61,13 @@ cfgui_free_node(khui_config_node_i * node) {
         return;\r
 \r
     if (node->reg.name)\r
-        free((void *) node->reg.name);\r
+        PFREE((void *) node->reg.name);\r
 \r
     if (node->reg.short_desc)\r
-        free((void *) node->reg.short_desc);\r
+        PFREE((void *) node->reg.short_desc);\r
 \r
     if (node->reg.long_desc)\r
-        free((void *) node->reg.long_desc);\r
+        PFREE((void *) node->reg.long_desc);\r
 \r
     node->magic = 0;\r
 \r
@@ -75,7 +76,7 @@ cfgui_free_node(khui_config_node_i * node) {
 \r
     ZeroMemory(node, sizeof(*node));\r
 \r
-    free(node);\r
+    PFREE(node);\r
 }\r
 \r
 \r
@@ -145,7 +146,7 @@ khui_cfg_register(khui_config_node vparent,
                               &cb_long_desc)) ||\r
         (vparent &&\r
          !cfgui_is_valid_node_handle(vparent)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if (KHM_SUCCEEDED(khui_cfg_open(vparent,\r
                                   reg->name,\r
@@ -163,11 +164,11 @@ khui_cfg_register(khui_config_node vparent,
     node->reg = *reg;\r
     node->reg.flags &= KHUI_CNFLAGMASK_STATIC;\r
 \r
-    name = malloc(cb_name);\r
+    name = PMALLOC(cb_name);\r
     StringCbCopy(name, cb_name, reg->name);\r
-    short_desc = malloc(cb_short_desc);\r
+    short_desc = PMALLOC(cb_short_desc);\r
     StringCbCopy(short_desc, cb_short_desc, reg->short_desc);\r
-    long_desc = malloc(cb_long_desc);\r
+    long_desc = PMALLOC(cb_long_desc);\r
     StringCbCopy(long_desc, cb_long_desc, reg->long_desc);\r
 \r
     node->reg.name = name;\r
@@ -204,7 +205,7 @@ khui_cfg_open(khui_config_node vparent,
          !cfgui_is_valid_node_handle(vparent)) ||\r
         FAILED(StringCbLength(name, KHUI_MAXCCH_NAME, &sz)) ||\r
         !result)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (vparent)\r
@@ -238,7 +239,7 @@ KHMEXP khm_int32 KHMAPI
 khui_cfg_remove(khui_config_node vnode) {\r
     khui_config_node_i * node;\r
     if (!cfgui_is_valid_node_handle(vnode))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     node = cfgui_node_i_from_handle(vnode);\r
@@ -251,7 +252,7 @@ khui_cfg_remove(khui_config_node vnode) {
 KHMEXP khm_int32 KHMAPI\r
 khui_cfg_hold(khui_config_node vnode) {\r
     if (!cfgui_is_valid_node_handle(vnode))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cfgui_hold_node(cfgui_node_i_from_handle(vnode));\r
 \r
@@ -261,13 +262,46 @@ khui_cfg_hold(khui_config_node vnode) {
 KHMEXP khm_int32 KHMAPI\r
 khui_cfg_release(khui_config_node vnode) {\r
     if (!cfgui_is_valid_node_handle(vnode))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cfgui_release_node(cfgui_node_i_from_handle(vnode));\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
+KHMEXP khm_int32 KHMAPI\r
+khui_cfg_get_parent(khui_config_node vnode,\r
+                    khui_config_node * result) {\r
+\r
+    khui_config_node_i * node;\r
+    khui_config_node_i * parent;\r
+\r
+    if(!cfgui_is_valid_node_handle(vnode) ||\r
+       !result)\r
+        return KHM_ERROR_INVALID_PARAM;\r
+\r
+    EnterCriticalSection(&cs_cfgui);\r
+    if (cfgui_is_valid_node_handle(vnode)) {\r
+        node = cfgui_node_i_from_handle(vnode);\r
+        parent = TPARENT(node);\r
+        if (parent == cfgui_root_config)\r
+            parent = NULL;\r
+    } else {\r
+        parent = NULL;\r
+    }\r
+    if (parent) {\r
+        cfgui_hold_node(parent);\r
+    }\r
+    LeaveCriticalSection(&cs_cfgui);\r
+\r
+    *result = parent;\r
+\r
+    if (parent)\r
+        return KHM_ERROR_SUCCESS;\r
+    else\r
+        return KHM_ERROR_NOT_FOUND;\r
+}\r
+\r
 KHMEXP khm_int32 KHMAPI\r
 khui_cfg_get_first_child(khui_config_node vparent,\r
                          khui_config_node * result) {\r
@@ -278,7 +312,7 @@ khui_cfg_get_first_child(khui_config_node vparent,
 \r
     if((vparent && !cfgui_is_valid_node_handle(vparent)) ||\r
        !result)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(vparent)) {\r
@@ -319,7 +353,7 @@ khui_cfg_get_first_subpanel(khui_config_node vparent,
 \r
     if((vparent && !cfgui_is_valid_node_handle(vparent)) ||\r
        !result)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(vparent)) {\r
@@ -360,7 +394,7 @@ khui_cfg_get_next(khui_config_node vnode,
 \r
     if (!cfgui_is_valid_node_handle(vnode) ||\r
         !result)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(vnode)) {\r
@@ -393,7 +427,7 @@ khui_cfg_get_next_release(khui_config_node * pvnode) {
 \r
     if (!pvnode || \r
         !cfgui_is_valid_node_handle(*pvnode))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(*pvnode)) {\r
@@ -429,7 +463,7 @@ khui_cfg_get_reg(khui_config_node vnode,
 \r
     if ((vnode && !cfgui_is_valid_node_handle(vnode)) ||\r
         !reg)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(vnode)) {\r
@@ -447,7 +481,7 @@ khui_cfg_get_reg(khui_config_node vnode,
     if (node)\r
         return KHM_ERROR_SUCCESS;\r
     else\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 }\r
 \r
 KHMEXP HWND KHMAPI\r
@@ -575,7 +609,7 @@ get_node_data(khui_config_node_i * node,
 #ifdef DEBUG\r
         assert(node->nc_data >= node->n_data + 1);\r
 #endif\r
-        newdata = malloc(sizeof(*newdata) * node->nc_data);\r
+        newdata = PMALLOC(sizeof(*newdata) * node->nc_data);\r
 #ifdef DEBUG\r
         assert(newdata);\r
 #endif\r
@@ -583,7 +617,7 @@ get_node_data(khui_config_node_i * node,
 \r
         if (node->data && node->n_data > 0) {\r
             memcpy(newdata, node->data, node->n_data * sizeof(*newdata));\r
-            free(node->data);\r
+            PFREE(node->data);\r
         }\r
         node->data = newdata;\r
     }\r
@@ -790,11 +824,12 @@ khui_cfg_set_flags(khui_config_node vnode,
 \r
 /* called with cs_cfgui held */\r
 static void\r
-recalc_node_flags(khui_config_node vnode) {\r
+recalc_node_flags(khui_config_node vnode, khm_boolean plural) {\r
     khui_config_node_i * node;\r
     khui_config_node_i * parent;\r
+    khui_config_node_i * subpanel;\r
+    cfg_node_data * data;\r
     khm_int32 flags;\r
-    khm_size i;\r
 \r
 #ifdef DEBUG\r
     assert(cfgui_is_valid_node_handle(vnode));\r
@@ -802,33 +837,43 @@ recalc_node_flags(khui_config_node vnode) {
 \r
     node = cfgui_node_i_from_handle(vnode);\r
 \r
-    parent = TPARENT(node);\r
+    if (plural)\r
+        parent = TPARENT(node);\r
+    else\r
+        parent = node;\r
 #ifdef DEBUG\r
     assert(parent);\r
 #endif\r
 \r
     flags = 0;\r
 \r
-    /* this code is wrong.  we need to go through all the subpanels in\r
-       the parent and pick the data record corresponding to this node\r
-       and then merge the flags from there. */\r
-    /* TODO: fix this */\r
-    for (i=0; i < parent->n_data; i++) {\r
-        if (parent->data[i].key == vnode)\r
-            flags |= parent->data[i].flags;\r
+    for(subpanel = TFIRSTCHILD(parent); subpanel;\r
+        subpanel = LNEXT(subpanel)) {\r
+        if (!(subpanel->reg.flags & KHUI_CNFLAG_SUBPANEL) ||\r
+            (plural && !(subpanel->reg.flags & KHUI_CNFLAG_PLURAL)) ||\r
+            (!plural && (subpanel->reg.flags & KHUI_CNFLAG_PLURAL)))\r
+            continue;\r
+\r
+        data = get_node_data(subpanel,\r
+                             vnode,\r
+                             FALSE);\r
+\r
+        if (data) {\r
+            flags |= data->flags;\r
+        }\r
     }\r
 \r
     flags &= KHUI_CNFLAGMASK_DYNAMIC;\r
 \r
-    if ((node->flags & flags) != flags) {\r
-        node->flags = flags |\r
-            (node->flags & ~KHUI_CNFLAGMASK_DYNAMIC);\r
+    if ((node->flags & KHUI_CNFLAGMASK_DYNAMIC) == flags)\r
+        return;\r
+\r
+    node->flags = (node->flags & ~KHUI_CNFLAGMASK_DYNAMIC) | flags;\r
 \r
-        if (hwnd_cfgui)\r
-            PostMessage(hwnd_cfgui, KHUI_WM_CFG_NOTIFY,\r
-                        MAKEWPARAM((WORD) node->flags, WMCFG_UPDATE_STATE),\r
-                        (LPARAM) vnode);\r
-    }\r
+    if (hwnd_cfgui)\r
+        PostMessage(hwnd_cfgui, KHUI_WM_CFG_NOTIFY,\r
+                    MAKEWPARAM((WORD) node->flags, WMCFG_UPDATE_STATE),\r
+                    (LPARAM) vnode);\r
 }\r
 \r
 KHMEXP void KHMAPI\r
@@ -862,7 +907,9 @@ khui_cfg_set_flags_inst(khui_config_init_data * d,
                 data->flags = new_flags;\r
 \r
                 if (d->ctx_node != d->ref_node)\r
-                    recalc_node_flags(d->ctx_node);\r
+                    recalc_node_flags(d->ctx_node, TRUE);\r
+                else\r
+                    recalc_node_flags(d->ctx_node, FALSE);\r
             }\r
         }\r
     }\r
@@ -900,7 +947,7 @@ khui_cfg_get_name(khui_config_node vnode,
 \r
     if (!cb_buf ||\r
         !cfgui_is_valid_node_handle(vnode))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     EnterCriticalSection(&cs_cfgui);\r
     if (cfgui_is_valid_node_handle(vnode) &&\r
@@ -919,7 +966,7 @@ khui_cfg_get_name(khui_config_node vnode,
             *cb_buf = cb;\r
         }\r
     } else {\r
-        rv = KHM_ERROR_INVALID_PARM;\r
+        rv = KHM_ERROR_INVALID_PARAM;\r
     }\r
     LeaveCriticalSection(&cs_cfgui);\r
 \r
@@ -936,7 +983,7 @@ khui_cfg_init_dialog_data(HWND hwnd_dlg,
     khui_config_init_data * d;\r
 \r
     cb = sizeof(khui_config_init_data) + cb_extra;\r
-    d = malloc(cb);\r
+    d = PMALLOC(cb);\r
 #ifdef DEBUG\r
     assert(d);\r
 #endif\r
@@ -994,7 +1041,7 @@ khui_cfg_free_dialog_data(HWND hwnd_dlg) {
 #endif\r
 \r
     if (d) {\r
-        free(d);\r
+        PFREE(d);\r
     }\r
 \r
     return (d)?KHM_ERROR_SUCCESS: KHM_ERROR_NOT_FOUND;\r
index 37d5e97058d89c6af7122d0e2379d1318c1f4b93..c7ff88bdb1cb67f60c4b34dc21ff23c7779f975d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index ccc27b4019c6e86d833f27d6253234d7c4d9f837..2cb4e92f991d71c0a712fdbe86f7b68bd1de700c 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -25,6 +25,7 @@
 /* $Id$ */\r
 \r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 #include<assert.h>\r
 \r
 #define CW_ALLOC_INCR 8\r
@@ -46,7 +47,7 @@ khui_cw_create_cred_blob(khui_new_creds ** ppnc)
 {\r
     khui_new_creds * c;\r
 \r
-    c = malloc(sizeof(*c));\r
+    c = PMALLOC(sizeof(*c));\r
     ZeroMemory(c, sizeof(*c));\r
 \r
     c->magic = KHUI_NC_MAGIC;\r
@@ -73,22 +74,25 @@ khui_cw_destroy_cred_blob(khui_new_creds *c)
     LeaveCriticalSection(&c->cs);\r
     DeleteCriticalSection(&c->cs);\r
 \r
-    if(c->password) {\r
+    if (c->password) {\r
         len = wcslen(c->password);\r
         SecureZeroMemory(c->password, sizeof(wchar_t) * len);\r
-        free(c->password);\r
+        PFREE(c->password);\r
     }\r
 \r
-    if(c->identities)\r
-        free(c->identities);\r
+    if (c->identities)\r
+        PFREE(c->identities);\r
 \r
-    if(c->types)\r
-        free(c->types);\r
+    if (c->types)\r
+        PFREE(c->types);\r
+\r
+    if (c->type_subs)\r
+        PFREE(c->type_subs);\r
 \r
     if (c->window_title)\r
-        free(c->window_title);\r
+        PFREE(c->window_title);\r
 \r
-    free(c);\r
+    PFREE(c);\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
@@ -121,7 +125,7 @@ khui_cw_add_identity(khui_new_creds * c,
 \r
     if(c->identities == NULL) {\r
         c->nc_identities = NC_N_IDENTITIES;\r
-        c->identities = malloc(sizeof(*(c->identities)) * \r
+        c->identities = PMALLOC(sizeof(*(c->identities)) * \r
                                c->nc_identities);\r
         c->n_identities = 0;\r
     } else if(c->n_identities + 1 > c->nc_identities) {\r
@@ -130,10 +134,10 @@ khui_cw_add_identity(khui_new_creds * c,
         c->nc_identities = UBOUNDSS(c->n_identities + 1, \r
                                     NC_N_IDENTITIES, \r
                                     NC_N_IDENTITIES);\r
-        ni = malloc(sizeof(*(c->identities)) * c->nc_identities);\r
+        ni = PMALLOC(sizeof(*(c->identities)) * c->nc_identities);\r
         memcpy(ni, c->identities, \r
                sizeof(*(c->identities)) * c->n_identities);\r
-        free(c->identities);\r
+        PFREE(c->identities);\r
         c->identities = ni;\r
     }\r
 \r
@@ -187,8 +191,8 @@ khui_cw_add_type(khui_new_creds * c,
 \r
     if(c->types == NULL) {\r
         c->nc_types = CW_ALLOC_INCR;\r
-        c->types = malloc(sizeof(*(c->types)) * c->nc_types);\r
-        c->type_subs = malloc(sizeof(*(c->type_subs)) * c->nc_types);\r
+        c->types = PMALLOC(sizeof(*(c->types)) * c->nc_types);\r
+        c->type_subs = PMALLOC(sizeof(*(c->type_subs)) * c->nc_types);\r
         c->n_types = 0;\r
     }\r
 \r
@@ -198,14 +202,14 @@ khui_cw_add_type(khui_new_creds * c,
 \r
         n = UBOUNDSS(c->n_types + 1, CW_ALLOC_INCR, CW_ALLOC_INCR);\r
 \r
-        t = malloc(sizeof(*(c->types)) * n);\r
+        t = PMALLOC(sizeof(*(c->types)) * n);\r
         memcpy(t, (void *) c->types, sizeof(*(c->types)) * c->n_types);\r
-        free(c->types);\r
+        PFREE(c->types);\r
         c->types = t;\r
 \r
-        t = malloc(sizeof(*(c->type_subs)) * n);\r
+        t = PMALLOC(sizeof(*(c->type_subs)) * n);\r
         memcpy(t, (void *) c->type_subs, sizeof(*(c->type_subs)) * c->n_types);\r
-        free(c->type_subs);\r
+        PFREE(c->type_subs);\r
         c->type_subs = t;\r
 \r
         c->nc_types = n;\r
@@ -329,22 +333,22 @@ cw_create_prompt(khm_size idx,
     if(def && FAILED(StringCbLength(def, KHUI_MAXCB_PROMPT_VALUE, &cb_def)))\r
         return NULL;\r
 \r
-    p = malloc(sizeof(*p));\r
+    p = PMALLOC(sizeof(*p));\r
     ZeroMemory(p, sizeof(*p));\r
 \r
     if(prompt) {\r
         cb_prompt += sizeof(wchar_t);\r
-        p->prompt = malloc(cb_prompt);\r
+        p->prompt = PMALLOC(cb_prompt);\r
         StringCbCopy(p->prompt, cb_prompt, prompt);\r
     }\r
 \r
     if(def) {\r
         cb_def += sizeof(wchar_t);\r
-        p->def = malloc(cb_def);\r
+        p->def = PMALLOC(cb_def);\r
         StringCbCopy(p->def, cb_def, def);\r
     }\r
 \r
-    p->value = malloc(KHUI_MAXCB_PROMPT_VALUE);\r
+    p->value = PMALLOC(KHUI_MAXCB_PROMPT_VALUE);\r
     ZeroMemory(p->value, KHUI_MAXCB_PROMPT_VALUE);\r
 \r
     p->type = type;\r
@@ -361,22 +365,22 @@ cw_free_prompt(khui_new_creds_prompt * p) {
     if(p->prompt) {\r
         if(SUCCEEDED(StringCbLength(p->prompt, KHUI_MAXCB_PROMPT, &cb)))\r
             SecureZeroMemory(p->prompt, cb);\r
-        free(p->prompt);\r
+        PFREE(p->prompt);\r
     }\r
 \r
     if(p->def) {\r
         if(SUCCEEDED(StringCbLength(p->def, KHUI_MAXCB_PROMPT, &cb)))\r
             SecureZeroMemory(p->def, cb);\r
-        free(p->def);\r
+        PFREE(p->def);\r
     }\r
 \r
     if(p->value) {\r
         if(SUCCEEDED(StringCbLength(p->value, KHUI_MAXCB_PROMPT_VALUE, &cb)))\r
             SecureZeroMemory(p->value, cb);\r
-        free(p->value);\r
+        PFREE(p->value);\r
     }\r
 \r
-    free(p);\r
+    PFREE(p);\r
 }\r
 \r
 static void \r
@@ -385,12 +389,12 @@ cw_free_prompts(khui_new_creds * c)
     khm_size i;\r
 \r
     if(c->banner != NULL) {\r
-        free(c->banner);\r
+        PFREE(c->banner);\r
         c->banner = NULL;\r
     }\r
 \r
     if(c->pname != NULL) {\r
-        free(c->pname);\r
+        PFREE(c->pname);\r
         c->pname = NULL;\r
     }\r
 \r
@@ -402,7 +406,7 @@ cw_free_prompts(khui_new_creds * c)
     }\r
 \r
     if(c->prompts != NULL) {\r
-        free(c->prompts);\r
+        PFREE(c->prompts);\r
         c->prompts = NULL;\r
     }\r
 \r
@@ -443,7 +447,7 @@ khui_cw_begin_custom_prompts(khui_new_creds * c,
     if(SUCCEEDED(StringCbLength(banner, KHUI_MAXCB_BANNER, &cb)) && \r
        cb > 0) {\r
         cb += sizeof(wchar_t);\r
-        c->banner = malloc(cb);\r
+        c->banner = PMALLOC(cb);\r
         StringCbCopy(c->banner, cb, banner);\r
     } else {\r
         c->banner = NULL;\r
@@ -453,7 +457,7 @@ khui_cw_begin_custom_prompts(khui_new_creds * c,
        cb > 0) {\r
 \r
         cb += sizeof(wchar_t);\r
-        c->pname = malloc(cb);\r
+        c->pname = PMALLOC(cb);\r
         StringCbCopy(c->pname, cb, pname);\r
 \r
     } else {\r
@@ -463,8 +467,7 @@ khui_cw_begin_custom_prompts(khui_new_creds * c,
     }\r
 \r
     if(n_prompts > 0) {\r
-\r
-        c->prompts = malloc(sizeof(*(c->prompts)) * n_prompts);\r
+        c->prompts = PMALLOC(sizeof(*(c->prompts)) * n_prompts);\r
         ZeroMemory(c->prompts, sizeof(*(c->prompts)) * n_prompts);\r
         c->nc_prompts = n_prompts;\r
         c->n_prompts = 0;\r
@@ -505,7 +508,7 @@ khui_cw_add_prompt(khui_new_creds * c,
     p = cw_create_prompt(c->n_prompts, type, prompt, def, flags);\r
     if(p == NULL) {\r
         LeaveCriticalSection(&c->cs);\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
     c->prompts[c->n_prompts++] = p;\r
     LeaveCriticalSection(&c->cs);\r
@@ -637,6 +640,7 @@ khui_cw_set_response(khui_new_creds * c,
     if(t) {\r
         t->flags &= ~KHUI_NCMASK_RESULT;\r
         t->flags |= (response & KHUI_NCMASK_RESULT);\r
+\r
         if (!(response & KHUI_NC_RESPONSE_NOEXIT) &&\r
             !(response & KHUI_NC_RESPONSE_PENDING))\r
             t->flags |= KHUI_NC_RESPONSE_COMPLETED;\r
@@ -666,6 +670,6 @@ khui_cw_add_control_row(khui_new_creds * c,
 \r
         return KHM_ERROR_SUCCESS;\r
     } else {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 }\r
index 7b7c22a57b71f63d2b8924610cf9f29f28de4ac4..fccdab5492928b93ffde5ff9eed24fa52a841f70 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index d01eb2addc4488a2a3f3fd8185c21bcbaeb0923a..b880721b63ca2f9eb31ddd6783038a96b2f5b9c1 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -89,6 +89,8 @@ context.
 #define KHUI_PACTION_DOWN_EXTEND (KHUI_PACTION_BASE + 13)\r
 #define KHUI_PACTION_DOWN_TOGGLE (KHUI_PACTION_BASE + 14)\r
 #define KHUI_PACTION_BLANK  (KHUI_PACTION_BASE + 15)\r
+#define KHUI_PACTION_NEXT   (KHUI_PACTION_BASE + 16)\r
+#define KHUI_PACTION_SELALL (KHUI_PACTION_BASE + 17)\r
 /*@}*/\r
 \r
 /*! \name Menus\r
index c41dddf1fa164c128112e183dee025f83ff17fe5..36b13a3338155ca0f946996164eae7e6e93c5aea 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -306,6 +306,16 @@ khui_alert_add_command(khui_alert * alert,
 KHMEXP khm_int32 KHMAPI \r
 khui_alert_show(khui_alert * alert);\r
 \r
+/*! \brief Queue an alert\r
+\r
+    Instead of displaying the alert immediately, the alert is queued\r
+    and the status bar updated to notify the user that there is a\r
+    pending alert.  Once the user activates the pending alert, it will\r
+    be displayed as if khui_alert_show() was called.\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khui_alert_queue(khui_alert * alert);\r
+\r
 /*! \brief Display a simple alert\r
 \r
     \see khui_alert_show()\r
index 9a96d41f974fe0b4cad2eca1abc1fe7370d79e22..ac9fc614c5256822a0e0dee32371fb4f1da80e03 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -246,7 +246,7 @@ typedef struct tag_khui_config_init_data {
         required.\r
 \r
     \retval KHM_ERROR_SUCCESS Success\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters, or fields\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters, or fields\r
         of reg were invalid\r
     \retval KHM_ERROR_DUPLICATE A node with the same name exists as a\r
         child of the specified parent node.\r
@@ -293,6 +293,19 @@ khui_cfg_hold(khui_config_node node);
 KHMEXP khm_int32 KHMAPI\r
 khui_cfg_release(khui_config_node node);\r
 \r
+/*! \brief Get the parent of a node\r
+\r
+    Returns a held handle to the parent of the node, or NULL if the\r
+    current node is a top level node.  The returned handle must be\r
+    released with khui_cfg_release().\r
+\r
+    \retval KHM_ERROR_SUCCESS The handle to the parent node is in \a result\r
+    \retval KHM_ERROR_NOT_FOUND The node is a top level node\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khui_cfg_get_parent(khui_config_node vnode,\r
+                    khui_config_node * result);\r
+\r
 /*! \brief Get a handle to the first child node\r
 \r
     If the call is successful, \a result will receieve a handle to the\r
@@ -366,7 +379,7 @@ khui_cfg_get_next(khui_config_node node,
         the function is released.\r
 \r
     \retval KHM_ERROR_SUCCESS The next node is now in \a node\r
-    \retval KHM_ERROR_INVALID_PARM \a node was not a valid handle\r
+    \retval KHM_ERROR_INVALID_PARAM \a node was not a valid handle\r
     \retval KHM_ERROR_NOT_FOUND There are no more siblings.  \a node\r
         is set to NULL.\r
 \r
index dcbf328ff6a00648adc0e4fa947e9d2879264248..f5fb3deeff73f24d3efb356f6a69f90c068f2c61 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 1742f4a1af32d442d8b8980f948f257218780dfe..ff693b3b157a5aae317fd60cb0b7340e80502c3b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -146,6 +146,12 @@ enum khui_wm_nc_notifications {
       internal message. */\r
 };\r
 \r
+/*! \brief Plugins can use WMNC_NOTIFY message codes from here on up\r
+\r
+    \see ::KHUI_WM_NC_NOTIFY\r
+ */\r
+#define WMNC_USER 2048\r
+\r
 /*! \brief Notifications to the identity provider\r
 \r
     These notifications are sent through to the identity provider's UI\r
index b7726902161cd045e37c312a92843a0a987a72e6..fc5629dc946803ce7ae1a04af0d9961ff16b01ef 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -141,7 +141,12 @@ khui_ps_create_sheet(khui_property_sheet ** sheet);
         used to order the pages in a property sheet.  The pages are\r
         ordered based on ordinal first and then alphabetically by\r
         credentials type name.  If the type is unavailable, then the\r
-        ordering is undefined.\r
+        ordering is undefined.  Ordinals for credential type property\r
+        pages can be in the range from 0 to 127.  Ordinals 128 and\r
+        above are reserved.  Passing in 0 will work for credentials\r
+        providers unless they provide more than one property page per\r
+        credential, in which case the ordinal should be used to\r
+        enforce an order.\r
 \r
     \param[in] ppage Pointer to structure that will be passed to\r
         CreatePropertySheetPage() to create the property page.  The\r
index a5b9d67de31707b647419f41fed4087d7e6b2be4..accff416bd3afd65c291b4a08f0fd8c431feda75 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 96bec88ab8943c3cc2f4c4b270f0f1b9eb954b57..eeb4f6585c0bc93f4d9a8d33d44f783a38bec5bf 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index f03d2b425f3a600d1d380dae265e2749074956d4..c12cd4fac6b4196ee23328e5980c8c4b970a8a9e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -77,6 +77,7 @@ typedef struct tag_khui_tracker {
     int lbl_y;\r
     int lbl_lx;\r
     int lbl_rx;\r
+    DWORD act_time;\r
 \r
     time_t current;             /*!< Current selection */\r
     time_t min;                 /*!< Minimum (inclusive)  */\r
index d92eb644440b2caabe6600de914400bc6069a58e..50214c373252a0a818390f8ae80447d17759d22e 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 749aa53bf384848864a237abb8bfaade845eaae5..705dd96a391ab6f78b5fcb2136e94b6ad088e89d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 /* $Id$ */\r
 \r
 #include<khuidefs.h>\r
+#include<utils.h>\r
 #ifdef DEBUG\r
 #include<assert.h>\r
 #endif\r
 \r
-KHMEXP khm_int32 KHMAPI khui_ps_create_sheet(khui_property_sheet ** sheet)\r
+CRITICAL_SECTION cs_props;\r
+\r
+void\r
+ps_init(void) {\r
+    InitializeCriticalSection(&cs_props);\r
+}\r
+\r
+void\r
+ps_exit(void) {\r
+    DeleteCriticalSection(&cs_props);\r
+}\r
+\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_create_sheet(khui_property_sheet ** sheet)\r
 {\r
     khui_property_sheet * ps;\r
 \r
-    ps = malloc(sizeof(*ps));\r
+    ps = PMALLOC(sizeof(*ps));\r
     ZeroMemory(ps, sizeof(*ps));\r
 \r
     ps->header.dwSize = sizeof(ps->header);\r
@@ -45,24 +59,26 @@ KHMEXP khm_int32 KHMAPI khui_ps_create_sheet(khui_property_sheet ** sheet)
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khui_ps_add_page(\r
-    khui_property_sheet * sheet,\r
-    khm_int32 credtype,\r
-    khm_int32 ordinal,\r
-    LPPROPSHEETPAGE ppage,\r
-    khui_property_page ** page)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_add_page(khui_property_sheet * sheet,\r
+                 khm_int32 credtype,\r
+                 khm_int32 ordinal,\r
+                 LPPROPSHEETPAGE ppage,\r
+                 khui_property_page ** page)\r
 {\r
     khui_property_page * p;\r
 \r
-    p = malloc(sizeof(*p));\r
+    p = PMALLOC(sizeof(*p));\r
     ZeroMemory(p, sizeof(*p));\r
 \r
     p->credtype = credtype;\r
     p->ordinal = ordinal;\r
     p->p_page = ppage;\r
-    \r
+\r
+    EnterCriticalSection(&cs_props);    \r
     QPUT(sheet, p);\r
     sheet->n_pages++;\r
+    LeaveCriticalSection(&cs_props);\r
 \r
     if(page)\r
         *page = p;\r
@@ -70,13 +86,14 @@ KHMEXP khm_int32 KHMAPI khui_ps_add_page(
     return KHM_ERROR_SUCCESS;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khui_ps_find_page(\r
-    khui_property_sheet * sheet,\r
-    khm_int32 credtype,\r
-    khui_property_page ** page)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_find_page(khui_property_sheet * sheet,\r
+                  khm_int32 credtype,\r
+                  khui_property_page ** page)\r
 {\r
     khui_property_page * p;\r
 \r
+    EnterCriticalSection(&cs_props);\r
     p = QTOP(sheet);\r
 \r
     while(p) {\r
@@ -84,6 +101,7 @@ KHMEXP khm_int32 KHMAPI khui_ps_find_page(
             break;\r
         p = QNEXT(p);\r
     }\r
+    LeaveCriticalSection(&cs_props);\r
 \r
     if(p) {\r
         *page = p;\r
@@ -94,12 +112,22 @@ KHMEXP khm_int32 KHMAPI khui_ps_find_page(
     }\r
 }\r
 \r
-int __cdecl ps_order_func(const void *l, const void * r) {\r
-  /* l is a ** */\r
-    return 0;\r
+int __cdecl \r
+ps_order_func(const void *l, const void * r) {\r
+    khui_property_page * lp;\r
+    khui_property_page * rp;\r
+\r
+    lp = *(khui_property_page **)l;\r
+    rp = *(khui_property_page **)r;\r
+\r
+    if (lp->ordinal == rp->ordinal)\r
+        return lp->credtype - rp->credtype;\r
+    else\r
+        return lp->ordinal - rp->ordinal;\r
 }\r
 \r
-KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)\r
+KHMEXP HWND KHMAPI \r
+khui_ps_show_sheet(HWND parent, khui_property_sheet * s)\r
 {\r
     khui_property_page * p;\r
     HPROPSHEETPAGE phpsp[KHUI_PS_MAX_PSP];\r
@@ -108,6 +136,8 @@ KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)
     INT_PTR prv;\r
     HWND hw;\r
 \r
+    EnterCriticalSection(&cs_props);\r
+\r
     s->header.hwndParent = parent;\r
     s->header.nPages = s->n_pages;\r
 \r
@@ -118,16 +148,26 @@ KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)
 #ifdef DEBUG\r
         assert(p->h_page);\r
 #endif\r
-        ppgs[i] = p;\r
-        phpsp[i++] = p->h_page;\r
+        ppgs[i++] = p;\r
         p = QNEXT(p);\r
     }\r
 \r
-    /*TODO: sort property sheets */\r
+#ifdef DEBUG\r
+    assert(i == s->n_pages);\r
+#endif\r
+\r
+    qsort(ppgs, s->n_pages, sizeof(ppgs[0]), ps_order_func);\r
+\r
+    for (i=0; i < s->n_pages; i++) {\r
+        phpsp[i] = ppgs[i]->h_page;\r
+    }\r
 \r
     s->header.phpage = phpsp;\r
 \r
     prv = PropertySheet(&s->header);\r
+\r
+    s->header.phpage = NULL;\r
+\r
     if(prv <= 0) {\r
 #ifdef DEBUG\r
         assert(FALSE);\r
@@ -135,22 +175,20 @@ KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)
         /*TODO: better handling for this */\r
         hw = NULL;\r
     } else {\r
-        DWORD dw;\r
-\r
-        dw = GetLastError();\r
         s->status = KHUI_PS_STATUS_RUNNING;\r
 \r
         hw = (HWND) prv;\r
         s->hwnd = hw;\r
         s->hwnd_page = PropSheet_GetCurrentPageHwnd(hw);\r
     }\r
+    LeaveCriticalSection(&cs_props);\r
 \r
     return hw;\r
 }\r
 \r
-KHMEXP LRESULT KHMAPI khui_ps_check_message(\r
-    khui_property_sheet * sheet, \r
-    PMSG pmsg)\r
+KHMEXP LRESULT KHMAPI \r
+khui_ps_check_message(khui_property_sheet * sheet, \r
+                      PMSG pmsg)\r
 {\r
     LRESULT lr;\r
 \r
@@ -169,20 +207,24 @@ KHMEXP LRESULT KHMAPI khui_ps_check_message(
     return lr;\r
 }\r
 \r
-KHMEXP khm_int32 KHMAPI khui_ps_destroy_sheet(khui_property_sheet * sheet)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_destroy_sheet(khui_property_sheet * sheet)\r
 {\r
     khui_property_page * p;\r
 \r
+    EnterCriticalSection(&cs_props);\r
+\r
     DestroyWindow(sheet->hwnd);\r
     sheet->hwnd = NULL;\r
 \r
     QGET(sheet, &p);\r
     while(p) {\r
-        free(p);\r
+        PFREE(p);\r
         QGET(sheet, &p);\r
     }\r
+    PFREE(sheet);\r
 \r
-    free(sheet);\r
+    LeaveCriticalSection(&cs_props);\r
 \r
     return KHM_ERROR_SUCCESS;\r
 }\r
index 4d5d5488d90d2ead52f4c4bb2a4bb8ca7d7bfb45..5ae93a7a5b6b3579f1867808b723bc1c03960960 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 57ff309078911e146e4181dccd370a6f0c0ca703..6d52591423b1cbc66ba57734b755f827544ab355 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -25,7 +25,7 @@
 /* $Id$ */\r
 \r
 #include<khuidefs.h>\r
-#include<hashtable.h>\r
+#include<utils.h>\r
 \r
 hashtable * h_bitmaps;\r
 \r
@@ -76,7 +76,7 @@ khui_create_ilist(int cx, int cy, int n, int ng, int opt) {
     BITMAPV5HEADER head;\r
     HDC hdc;\r
 \r
-    khui_ilist * il = malloc(sizeof(khui_ilist));\r
+    khui_ilist * il = PMALLOC(sizeof(khui_ilist));\r
     il->cx = cx;\r
     il->cy = cy;\r
     il->n = n;\r
@@ -102,7 +102,7 @@ khui_create_ilist(int cx, int cy, int n, int ng, int opt) {
     head.bV5Reserved = 0;\r
     il->img = CreateDIBitmap(hdc, (BITMAPINFOHEADER *) &head, 0, NULL, NULL, DIB_RGB_COLORS);\r
     il->mask = CreateBitmap(cx * n, cy, 1, 1, NULL);\r
-    il->idlist = malloc(sizeof(int) * n);\r
+    il->idlist = PMALLOC(sizeof(int) * n);\r
 \r
     return il;\r
 }\r
@@ -111,8 +111,8 @@ KHMEXP BOOL KHMAPI
 khui_delete_ilist(khui_ilist * il) {\r
     DeleteObject(il->img);\r
     DeleteObject(il->mask);\r
-    free(il->idlist);\r
-    free(il);\r
+    PFREE(il->idlist);\r
+    PFREE(il);\r
 \r
     return TRUE;\r
 }\r
index 04de09641dbad17be22feb466e1b9c5908f541c4..814e2880827fad65039b0d85d6910b64c1f226da 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -261,7 +261,10 @@ create_edit_sliders(HWND hwnd,
                        TRACKBAR_CLASS,\r
                        L"NetIDMgrTimeTickerTrackbar",\r
                        WS_POPUP | TBS_AUTOTICKS | TBS_BOTTOM |\r
-                       TBS_DOWNISLEFT | TBS_HORZ | WS_CLIPCHILDREN,\r
+#if (_WIN32_IE >= 0x0501)\r
+                       TBS_DOWNISLEFT | \r
+#endif\r
+                       TBS_HORZ | WS_CLIPCHILDREN,\r
                        r.left,r.bottom,rs.right,rs.bottom,\r
                        hwnd,\r
                        NULL,\r
@@ -311,6 +314,8 @@ duration_edit_proc(HWND hwnd,
             }\r
             khui_tracker_reposition(tc);\r
             ShowWindow(tc->hw_slider, SW_SHOWNOACTIVATE);\r
+\r
+            tc->act_time = GetTickCount();\r
             //SetActiveWindow(p);\r
         }\r
         break;\r
@@ -347,6 +352,18 @@ duration_edit_proc(HWND hwnd,
             }\r
         return TRUE;\r
 \r
+    case WM_LBUTTONUP:\r
+        if (IsWindowVisible(tc->hw_slider)) {\r
+            DWORD tm;\r
+\r
+            tm = GetTickCount();\r
+            if (tm - tc->act_time > 500)\r
+                ShowWindow(tc->hw_slider, SW_HIDE);\r
+        } else {\r
+            ShowWindow(tc->hw_slider, SW_SHOWNOACTIVATE);\r
+        }\r
+        break;\r
+\r
         /*  these messages can potentially change the text in the edit\r
             control.  We intercept them and see what changed.  We may\r
             need to grab and handle them */\r
@@ -354,7 +371,9 @@ duration_edit_proc(HWND hwnd,
     case EM_UNDO:\r
     case WM_UNDO:\r
     case WM_CHAR:\r
+#if (_WIN32_WINNT >= 0x0501)\r
     case WM_UNICHAR:\r
+#endif\r
         {\r
             wchar_t buf[256];\r
             size_t nchars;\r
index 65fa7aff581c09e1e8660327a5f1774ab24faf86..4d0b012f11f8adbff78755c3055878e81e5ba98b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
 \r
 extern void alert_init(void);\r
 extern void alert_exit(void);\r
+extern void ps_init(void);\r
+extern void ps_exit(void);\r
 \r
 void\r
 uilib_process_attach(void) {\r
     alert_init();\r
+    ps_init();\r
 }\r
 \r
 void\r
 uilib_process_detach(void) {\r
+    ps_exit();\r
     alert_exit();\r
 }\r
-\r
index b9fc80e2097a3e318c67c884ac10646ad0f3b0f8..9d1cad2f0f6849fee7d13ad50dc3e5384866dae2 100644 (file)
@@ -26,15 +26,17 @@ MODULE=util
 !include <../config/Makefile.w32>\r
 \r
 INCFILES= \\r
-       $(INCDIR)\utils.h \\r
-       $(INCDIR)\hashtable.h \\r
-       $(INCDIR)\mstring.h \\r
-       $(INCDIR)\sync.h\r
+       $(INCDIR)\utils.h       \\r
+       $(INCDIR)\hashtable.h   \\r
+       $(INCDIR)\mstring.h     \\r
+       $(INCDIR)\sync.h        \\r
+       $(INCDIR)\perfstat.h\r
 \r
 OBJFILES= \\r
-       $(OBJ)\hashtable.obj \\r
-       $(OBJ)\mstring.obj \\r
-       $(OBJ)\sync.obj\r
+       $(OBJ)\hashtable.obj    \\r
+       $(OBJ)\mstring.obj      \\r
+       $(OBJ)\sync.obj         \\r
+       $(OBJ)\perfstat.obj\r
 \r
 LIBFILES=\r
 \r
index 41f785a952eecf0c95eeb336ab9f82f97f7495af..d1b02e64ffd6b903635b6b731a7e824e39c31a58 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -24,6 +24,7 @@
 \r
 /* $Id$ */\r
 \r
+#include<perfstat.h>\r
 #include<hashtable.h>\r
 #include<stdlib.h>\r
 \r
@@ -35,7 +36,7 @@ KHMEXP hashtable * KHMAPI hash_new_hashtable(khm_int32 n,
 {\r
     hashtable * h;\r
 \r
-    h = malloc(sizeof(hashtable));\r
+    h = PMALLOC(sizeof(hashtable));\r
 \r
     h->n = n;\r
     h->addr = addr;\r
@@ -57,12 +58,12 @@ KHMEXP void KHMAPI hash_del_hashtable(hashtable * h) {
         while(b) {\r
             if(h->delr)\r
                 h->delr(b->key, b->data);\r
-            free(b);\r
+            PFREE(b);\r
             LPOP(&h->bins[i], &b);\r
         }\r
     }\r
 \r
-    free(h);\r
+    PFREE(h);\r
 }\r
 \r
 KHMEXP void KHMAPI hash_add(hashtable * h, void * key, void * data) {\r
@@ -86,7 +87,7 @@ KHMEXP void KHMAPI hash_add(hashtable * h, void * key, void * data) {
     }\r
 \r
     if(!b) {\r
-        b = malloc(sizeof(hash_bin));\r
+        b = PMALLOC(sizeof(hash_bin));\r
         b->data = data;\r
         b->key = key;\r
         LINIT(b);\r
@@ -109,7 +110,7 @@ KHMEXP void KHMAPI hash_del(hashtable * h, void * key) {
             LDELETE(&h->bins[hv], b);\r
             if(h->delr)\r
                 h->delr(b->key, b->data);\r
-            free(b);\r
+            PFREE(b);\r
             break;\r
         }\r
         b = LNEXT(b);\r
index 179d311f8b3d07f139fd2ff62c6a7b393c6229a6..fc7d829f2fcdf38cbcec427bcc226106690bd688 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index e9120d6009d374f938fbd5e65ce91573ef1b6563..75bab017432afd0df1eb4a4e7a6f555d25e5db25 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
 *\r
 * Permission is hereby granted, free of charge, to any person\r
 * obtaining a copy of this software and associated documentation\r
@@ -34,9 +34,9 @@
 \r
 KHMEXP khm_int32 KHMAPI\r
 multi_string_init(wchar_t * ms,\r
-                      khm_size cb_ms) {\r
+                  khm_size cb_ms) {\r
     if (!ms || cb_ms < sizeof(wchar_t) * 2)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     memset(ms, 0, cb_ms);\r
 \r
@@ -44,10 +44,9 @@ multi_string_init(wchar_t * ms,
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-multi_string_append(\r
-                        wchar_t * ms,\r
-                        khm_size * pcb_ms,\r
-                        const wchar_t * str)\r
+multi_string_append(wchar_t * ms,\r
+                    khm_size * pcb_ms,\r
+                    const wchar_t * str)\r
 {\r
     wchar_t * s;\r
     size_t cch_s;\r
@@ -55,22 +54,22 @@ multi_string_append(
     size_t cch_r;\r
 \r
     if(!ms || !pcb_ms || !str)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(FAILED(StringCchLength(str, KHM_MAXCCH_STRING, &cch_s)) || cch_s == 0)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     cch_s++;\r
 \r
     s = ms;\r
 \r
     while(*s && ((s - ms) < KHM_MAXCCH_STRING)) {\r
         if(FAILED(StringCchLength(s, KHM_MAXCB_STRING, &cch_t)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         s += cch_t + 1;\r
     }\r
 \r
     if(*s || (s - ms) >= KHM_MAXCCH_STRING) {\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     }\r
 \r
     /* now s points to the second NULL of the terminating double NULL */\r
@@ -91,10 +90,9 @@ multi_string_append(
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-multi_string_prepend(\r
-                        wchar_t * ms,\r
-                        khm_size * pcb_ms,\r
-                        const wchar_t * str)\r
+multi_string_prepend(wchar_t * ms,\r
+                     khm_size * pcb_ms,\r
+                     const wchar_t * str)\r
 {\r
     size_t cch_s;\r
     size_t cch_t;\r
@@ -102,16 +100,16 @@ multi_string_prepend(
     khm_size cb_r;\r
 \r
     if(!ms || !pcb_ms || !str)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(FAILED(StringCchLength(str, KHM_MAXCCH_STRING, &cch_s)) || cch_s == 0)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
     cch_s++;\r
 \r
     if(KHM_FAILED(multi_string_length_cch(ms,\r
                                               KHM_MAXCCH_STRING,\r
                                               &cch_r)))\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cch_t = cch_s + cch_r;\r
     cb_r = cch_t * sizeof(wchar_t);\r
@@ -130,10 +128,9 @@ multi_string_prepend(
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-multi_string_delete(\r
-                        wchar_t * ms,\r
-                        const wchar_t * str,\r
-                        const khm_int32 flags)\r
+multi_string_delete(wchar_t * ms,\r
+                    const wchar_t * str,\r
+                    const khm_int32 flags)\r
 {\r
     wchar_t * s;\r
     wchar_t * n;\r
@@ -141,7 +138,7 @@ multi_string_delete(
     size_t cch;\r
 \r
     if(!ms || !str)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     s = multi_string_find(ms, str, flags);\r
     if(!s)\r
@@ -151,7 +148,7 @@ multi_string_delete(
     n = NULL;\r
     while(*e && (e - s) < KHM_MAXCCH_STRING) {\r
         if(FAILED(StringCchLength(e, KHM_MAXCCH_STRING, &cch)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         e += cch + 1;\r
 \r
         if(!n)\r
@@ -159,7 +156,7 @@ multi_string_delete(
     }\r
 \r
     if(*e || (e - s) >= KHM_MAXCCH_STRING)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     if(e == s)\r
         return KHM_ERROR_SUCCESS;\r
@@ -170,10 +167,9 @@ multi_string_delete(
 }\r
 \r
 KHMEXP wchar_t * KHMAPI \r
-multi_string_find(\r
-                      const wchar_t * ms,\r
-                      const wchar_t * str,\r
-                      const khm_int32 flags)\r
+multi_string_find(const wchar_t * ms,\r
+                  const wchar_t * str,\r
+                  const khm_int32 flags)\r
 {\r
     const wchar_t *s;\r
     size_t cch;\r
@@ -210,10 +206,9 @@ multi_string_find(
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-multi_string_to_csv(\r
-                        wchar_t * csvbuf,\r
-                        khm_size * pcb_csvbuf,\r
-                        const wchar_t * ms)\r
+multi_string_to_csv(wchar_t * csvbuf,\r
+                    khm_size * pcb_csvbuf,\r
+                    const wchar_t * ms)\r
 {\r
     size_t cb;\r
     size_t cbt;\r
@@ -221,7 +216,7 @@ multi_string_to_csv(
     wchar_t * d;\r
 \r
     if(!pcb_csvbuf || !ms)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     /* dry run */\r
     cbt = 0;\r
@@ -230,7 +225,7 @@ multi_string_to_csv(
         khm_boolean quotes = FALSE;\r
 \r
         if(FAILED(StringCbLength(t, KHM_MAXCB_STRING, &cb)))\r
-            return KHM_ERROR_INVALID_PARM;\r
+            return KHM_ERROR_INVALID_PARAM;\r
         cb += sizeof(wchar_t);\r
 \r
         cbt += cb;\r
@@ -252,7 +247,7 @@ multi_string_to_csv(
     }\r
 \r
     if(cbt > KHM_MAXCB_STRING)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     /* happens if the multi string contained no strings */\r
     if(cbt == 0)\r
@@ -302,10 +297,9 @@ multi_string_to_csv(
 }\r
 \r
 KHMEXP khm_int32 KHMAPI \r
-csv_to_multi_string(\r
-                        wchar_t * ms,\r
-                        khm_size * pcb_ms,\r
-                        const wchar_t * csv)\r
+csv_to_multi_string(wchar_t * ms,\r
+                    khm_size * pcb_ms,\r
+                    const wchar_t * csv)\r
 {\r
     const wchar_t * t;\r
     wchar_t * p;\r
@@ -314,7 +308,7 @@ csv_to_multi_string(
 \r
 \r
     if(!pcb_ms || !csv)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cchr = 0;\r
 \r
@@ -346,7 +340,7 @@ csv_to_multi_string(
     }\r
 \r
     if((t - csv) >= KHM_MAXCCH_STRING)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     cchr++; /* last string ends */\r
     cchr++; /* double NULL */\r
@@ -427,8 +421,8 @@ multi_string_length_n(const wchar_t * str)
 \r
 KHMEXP khm_int32 KHMAPI \r
 multi_string_length_cb(const wchar_t * str, \r
-                           khm_size max_cb, \r
-                           khm_size * len_cb)\r
+                       khm_size max_cb, \r
+                       khm_size * len_cb)\r
 {\r
     khm_size cch;\r
     khm_int32 rv;\r
@@ -446,15 +440,15 @@ multi_string_length_cb(const wchar_t * str,
 \r
 KHMEXP khm_int32 KHMAPI \r
 multi_string_length_cch(const wchar_t * str, \r
-                            khm_size max_cch, \r
-                            khm_size * len_cch)\r
+                        khm_size max_cch, \r
+                        khm_size * len_cch)\r
 {\r
     const wchar_t * s;\r
     khm_size cch;\r
     size_t tcch;\r
 \r
     if(!str)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     s = str;\r
     cch = 0;\r
@@ -484,7 +478,7 @@ multi_string_copy_cb(wchar_t * s_dest,
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!s_dest)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     rv = multi_string_length_cb(src, max_cb_dest, &cb_dest);\r
     if(KHM_FAILED(rv))\r
@@ -497,14 +491,14 @@ multi_string_copy_cb(wchar_t * s_dest,
 \r
 KHMEXP khm_int32 KHMAPI \r
 multi_string_copy_cch(wchar_t * s_dest, \r
-                          khm_size max_cch_dest, \r
-                          const wchar_t * src)\r
+                      khm_size max_cch_dest, \r
+                      const wchar_t * src)\r
 {\r
     khm_size cch_dest;\r
     khm_int32 rv = KHM_ERROR_SUCCESS;\r
 \r
     if(!s_dest)\r
-        return KHM_ERROR_INVALID_PARM;\r
+        return KHM_ERROR_INVALID_PARAM;\r
 \r
     rv = multi_string_length_cch(src, max_cch_dest, &cch_dest);\r
     if(KHM_FAILED(rv))\r
index 9b4e3800e42d7edfaa44c18196535cfdfa1cea93..a7f6cf5234ff2f27cddb524be0b34042f97d29a7 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -95,7 +95,7 @@ multi_string_prepend(wchar_t * ms,
     \retval KHM_ERROR_TOO_LONG The buffer pointed to by \a ms was\r
         insufficient.  The required size of the buffer is in \a pcb_ms\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One of more of the parameters were invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One of more of the parameters were invalid.\r
  */\r
 KHMEXP khm_int32 KHMAPI \r
 multi_string_append(wchar_t * ms,\r
@@ -127,7 +127,7 @@ multi_string_append(wchar_t * ms,
 \r
     \retval KHM_ERROR_NOT_FOUND No matches were found\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were incorrect.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were incorrect.\r
 \r
     \note The search for the existing string is done with\r
         multi_string_find()\r
@@ -209,7 +209,7 @@ multi_string_find(const wchar_t * ms,
         was NULL.  The required number of bytes in the buffer is in \a\r
         pcb_csvbuf.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were ivnalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were ivnalid.\r
 \r
     \see csv_to_multi_string()\r
 */\r
@@ -240,7 +240,7 @@ multi_string_to_csv(wchar_t * csvbuf,
         ms was NULL. The required size of the buffer in bytes is in \a\r
         pcb_ms.\r
 \r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
 \r
  */\r
 KHMEXP khm_int32 KHMAPI \r
@@ -281,7 +281,7 @@ multi_string_next(const wchar_t * str);
         is successful.\r
 \r
     \retval KHM_ERROR_SUCCESS The length of the string is in \a len_cb\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TOO_LONG The multi string is longer than \a\r
         max_cb bytes.\r
  */\r
@@ -302,7 +302,7 @@ multi_string_length_cb(const wchar_t * str,
         is successful.\r
 \r
     \retval KHM_ERROR_SUCCESS The length of the string is in \a len_cch\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
     \retval KHM_ERROR_TOO_LONG The multi string is longer than \a\r
         max_cch characters.\r
  */\r
@@ -326,7 +326,7 @@ multi_string_length_n(const wchar_t * str);
     \param[in] src The source multi string\r
 \r
     \retval KHM_ERROR_SUCCESS The multi string was copied successfully\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
         invalid.\r
     \retval KHM_ERROR_TOO_LONG The size of the destination buffer was\r
         insufficient.\r
@@ -346,7 +346,7 @@ multi_string_copy_cb(wchar_t * s_dest,
     \param[in] src The source multi string\r
 \r
     \retval KHM_ERROR_SUCCESS The multi string was copied successfully\r
-    \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+    \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
         invalid.\r
     \retval KHM_ERROR_TOO_LONG The size of the destination buffer was\r
         insufficient.\r
diff --git a/src/windows/identity/util/perfstat.c b/src/windows/identity/util/perfstat.c
new file mode 100644 (file)
index 0000000..2ddcedb
--- /dev/null
@@ -0,0 +1,249 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<windows.h>\r
+#include<utils.h>\r
+#include<malloc.h>\r
+#include<stdio.h>\r
+#include<strsafe.h>\r
+#include<assert.h>\r
+\r
+#define HASHSIZE 1151\r
+#define ALLOCBLOCK 1024\r
+\r
+#define HASHPTR(p) (((size_t) (p)) % HASHSIZE)\r
+\r
+typedef struct tag_allocation {\r
+    char   file[8];\r
+    int    line;\r
+    size_t size;\r
+    void * ptr;\r
+\r
+    LDCL(struct tag_allocation);\r
+} allocation;\r
+\r
+static allocation * ht[HASHSIZE];\r
+\r
+static allocation * next_alloc = NULL;\r
+static size_t       idx_next_alloc = 0;\r
+static allocation * free_alloc = NULL;\r
+\r
+static CRITICAL_SECTION cs_alloc;\r
+static LONG ctr = 0;\r
+static int  perf_ready = 0;\r
+\r
+static void perf_once(void) {\r
+    if (InterlockedIncrement(&ctr) == 1) {\r
+        InitializeCriticalSection(&cs_alloc);\r
+        ZeroMemory(ht, sizeof(ht));\r
+\r
+        next_alloc = malloc(sizeof(allocation) * ALLOCBLOCK);\r
+        assert(next_alloc);\r
+        idx_next_alloc = 0;\r
+        free_alloc = NULL;\r
+\r
+        perf_ready = 1;\r
+    } else {\r
+        while(!perf_ready) {\r
+            Sleep(0);           /* relinquish control to the thread\r
+                                   that is initializing the alloc\r
+                                   data. */\r
+        }\r
+    }\r
+}\r
+\r
+static allocation * get_allocation(void) {\r
+    allocation * a;\r
+\r
+    LPOP(&free_alloc, &a);\r
+    if (!a) {\r
+        if (idx_next_alloc == ALLOCBLOCK) {\r
+            next_alloc = malloc(sizeof(allocation) * ALLOCBLOCK);\r
+            assert(next_alloc);\r
+            idx_next_alloc = 0;\r
+        }\r
+\r
+        a = &next_alloc[idx_next_alloc];\r
+        idx_next_alloc++;\r
+    }\r
+\r
+    return a;\r
+}\r
+\r
+#define MAXCB_STR 32768\r
+\r
+KHMEXP wchar_t *\r
+perf_wcsdup(char * file, int line, const wchar_t * str) {\r
+    size_t cb;\r
+    wchar_t * dest;\r
+\r
+    if (FAILED(StringCbLength(str, MAXCB_STR, &cb)))\r
+        return NULL;\r
+    cb += sizeof(wchar_t);\r
+\r
+    dest = (wchar_t *) perf_malloc(file, line, cb);\r
+    StringCbCopy(dest, cb, str);\r
+\r
+    return dest;\r
+}\r
+\r
+KHMEXP char *\r
+perf_strdup(char * file, int line, const char * str) {\r
+    size_t cb;\r
+    char * dest;\r
+\r
+    if (FAILED(StringCbLengthA(str, MAXCB_STR, &cb)))\r
+        return NULL;\r
+    cb += sizeof(char);\r
+\r
+    dest = (char *) perf_malloc(file, line, cb);\r
+    StringCbCopyA(dest, cb, str);\r
+\r
+    return dest;\r
+}\r
+\r
+KHMEXP void * \r
+perf_malloc(char * file, int line, size_t s) {\r
+    allocation * a;\r
+    void * ptr;\r
+    size_t h;\r
+\r
+    perf_once();\r
+\r
+    assert(s > 0);\r
+\r
+    EnterCriticalSection(&cs_alloc);\r
+    a = get_allocation();\r
+\r
+    ptr = malloc(s);\r
+\r
+    assert(ptr);                /* TODO: handle this gracefully */\r
+\r
+    if (file[0] == '.' && file[1] == '\\')\r
+        file += 2;\r
+\r
+    StringCbCopyA(a->file, sizeof(a->file), file);\r
+    a->line = line;\r
+    a->size = s;\r
+    a->ptr = ptr;\r
+\r
+    h = HASHPTR(ptr);\r
+\r
+    LPUSH(&ht[h], a);\r
+    LeaveCriticalSection(&cs_alloc);\r
+\r
+    return ptr;\r
+}\r
+\r
+KHMEXP void *\r
+perf_realloc(char * file, int line, void * data, size_t s) {\r
+    void * n_data;\r
+    allocation * a;\r
+    size_t h;\r
+\r
+    if (data == NULL)\r
+        return perf_malloc(file, line, s);\r
+\r
+    perf_once();\r
+    h = HASHPTR(data);\r
+\r
+    n_data = realloc(data, s);\r
+\r
+    assert(n_data);\r
+\r
+    EnterCriticalSection(&cs_alloc);\r
+    for (a = ht[h]; a; a = LNEXT(a)) {\r
+        if (a->ptr == data)\r
+            break;\r
+    }\r
+\r
+    assert(a);\r
+\r
+    LDELETE(&ht[h], a);\r
+\r
+    a->size = s;\r
+    a->ptr = n_data;\r
+\r
+    h = HASHPTR(n_data);\r
+    LPUSH(&ht[h], a);\r
+    LeaveCriticalSection(&cs_alloc);\r
+\r
+    return n_data;\r
+}\r
+\r
+KHMEXP void\r
+perf_free  (void * b) {\r
+    size_t h;\r
+    allocation * a;\r
+\r
+    perf_once();\r
+    h = HASHPTR(b);\r
+\r
+    EnterCriticalSection(&cs_alloc);\r
+    for(a = ht[h]; a; a = LNEXT(a)) {\r
+        if (a->ptr == b)\r
+            break;\r
+    }\r
+\r
+    assert(a);\r
+\r
+    LDELETE(&ht[h], a);\r
+    LPUSH(&free_alloc, a);\r
+    LeaveCriticalSection(&cs_alloc);\r
+}\r
+\r
+KHMEXP void\r
+perf_dump(char * file) {\r
+    FILE * f;\r
+    size_t i;\r
+    allocation * a;\r
+    size_t total = 0;\r
+\r
+    perf_once();\r
+\r
+    EnterCriticalSection(&cs_alloc);\r
+    f = fopen(file, "w");\r
+    if (!f)\r
+        return;\r
+\r
+    fprintf(f, "Leaked allocations list ....\n");\r
+    fprintf(f, "File\tLine\tSize\n");\r
+\r
+    for (i=0; i < HASHSIZE; i++) {\r
+        for (a = ht[i]; a; a = LNEXT(a)) {\r
+            fprintf(f, "%s\t%6d\t%6d\n", a->file, a->line, a->size);\r
+            total += a->size;\r
+        }\r
+    }\r
+\r
+    fprintf(f, "----------------------------------------\n");\r
+    fprintf(f, "Total\t\t%d\n", total);\r
+    fprintf(f, "----------------- End ------------------\n");\r
+\r
+    fclose(f);\r
+\r
+    LeaveCriticalSection(&cs_alloc);\r
+}\r
diff --git a/src/windows/identity/util/perfstat.h b/src/windows/identity/util/perfstat.h
new file mode 100644 (file)
index 0000000..ad620fd
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#ifndef __KHIMAIRA_PERFSTAT_H\r
+#define __KHIMAIRA_PERFSTAT_H\r
+\r
+#include<khdefs.h>\r
+\r
+#ifdef DEBUG\r
+#define PMALLOC(s) perf_malloc(__FILE__,__LINE__,s)\r
+#define PREALLOC(d,s) perf_realloc(__FILE__,__LINE__,d,s)\r
+#define PFREE(p)   perf_free(p)\r
+#define PDUMP(f)   perf_dump(f)\r
+#define PWCSDUP(s) perf_wcsdup(__FILE__,__LINE__,s)\r
+#define PSTRDUP(s) perf_strdup(__FILE__,__LINE__,s)\r
+#else\r
+#define PMALLOC(s) malloc(s)\r
+#define PREALLOC(d,s) realloc(d,s)\r
+#define PFREE(p)   free(p)\r
+#define PDUMP(f)   ((void) 0)\r
+#define PWCSDUP(s) wcsdup(s)\r
+#define PSTRDUP(s) strdup(s)\r
+#endif\r
+\r
+KHMEXP void *\r
+perf_malloc(char * file, int line, size_t s);\r
+\r
+KHMEXP void *\r
+perf_realloc(char * file, int line, void * data, size_t s);\r
+\r
+KHMEXP void\r
+perf_free  (void * b);\r
+\r
+KHMEXP void\r
+perf_dump  (char * filename);\r
+\r
+KHMEXP wchar_t *\r
+perf_wcsdup(char * file, int line, const wchar_t * str);\r
+\r
+KHMEXP char *\r
+perf_strdup(char * file, int line, const char * str);\r
+\r
+#endif\r
index b50d484dafdd1134afa944cfa6363c7b7fa4fd0f..d686a8e80ab28de35f9df0adcace74bd5368f33b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -52,6 +52,8 @@ KHMEXP void KHMAPI DeleteRwLock(PRWLOCK pLock)
     DeleteCriticalSection(&(pLock->cs));\r
     CloseHandle(pLock->readwx);\r
     CloseHandle(pLock->writewx);\r
+    pLock->readwx = NULL;\r
+    pLock->writewx = NULL;\r
 }\r
 \r
 KHMEXP void KHMAPI LockObtainRead(PRWLOCK pLock)\r
@@ -91,6 +93,7 @@ KHMEXP void KHMAPI LockObtainWrite(PRWLOCK pLock)
        pLock->writer == GetCurrentThreadId()) {\r
         pLock->locks++;\r
         LeaveCriticalSection(&(pLock->cs));\r
+        assert(FALSE);\r
         return;\r
     }\r
     LeaveCriticalSection(&(pLock->cs));\r
@@ -103,6 +106,7 @@ KHMEXP void KHMAPI LockObtainWrite(PRWLOCK pLock)
     }\r
     pLock->status = LOCK_WRITING;\r
     pLock->locks++;\r
+    pLock->writer = GetCurrentThreadId();\r
     ResetEvent(pLock->readwx);\r
     LeaveCriticalSection(&(pLock->cs));\r
 }\r
@@ -114,6 +118,7 @@ KHMEXP void KHMAPI LockReleaseWrite(PRWLOCK pLock)
     pLock->locks--;\r
     if(!pLock->locks) {\r
         pLock->status = LOCK_OPEN;\r
+        pLock->writer = 0;\r
         SetEvent(pLock->readwx);\r
         SetEvent(pLock->writewx);\r
     }\r
index 5410d0e522f61ea8df090d37c2b8d3baa3a21984..e423e6766fdcfaf3e291b94cc79ed59df059126d 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
index 2e3b6b7daf33c0534b7fec30e0f2c65b99f90186..4ba86f6edb08090dcd367cf9fd9fdcda158ee142 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
  *\r
  * Permission is hereby granted, free of charge, to any person\r
  * obtaining a copy of this software and associated documentation\r
@@ -32,5 +32,6 @@
 #include<hashtable.h>\r
 #include<sync.h>\r
 #include<mstring.h>\r
+#include<perfstat.h>\r
 \r
 #endif\r