DEVEL15-windows-kfw-sdk-20060921

kfw 3.1


(cherry picked from commit faee281941502211c3ea8a62ffea85d934d9ba3a)
This commit is contained in:
Jeffrey Altman 2006-10-12 22:42:20 +00:00
parent b481c719ac
commit 0023dc617f
62 changed files with 17342 additions and 3506 deletions

View File

@ -26,7 +26,7 @@
* Include file for the Data Encryption Standard library.
*/
#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
#if defined(__MACH__) && defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_RT_MAC_CFM
# error "Use KfM 4.0 SDK headers for CFM compilation."
@ -51,10 +51,7 @@
KRBINT_BEGIN_DECLS
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import on
# endif
# pragma options align=mac68k
# pragma pack(push,2)
#endif
#if UINT_MAX >= 0xFFFFFFFFUL
@ -87,11 +84,7 @@ typedef unsigned char des_cblock[8]; /* crypto-block size */
typedef struct des_ks_struct { DES_INT32 _[2]; } des_key_schedule[16];
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma enumsalwaysint reset
# pragma import reset
# endif
# pragma options align=reset
# pragma pack(pop)
#endif
KRBINT_END_DECLS
@ -120,11 +113,7 @@ KRBINT_END_DECLS
KRBINT_BEGIN_DECLS
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import on
# pragma enumsalwaysint on
# endif
# pragma options align=mac68k
# pragma pack(push,2)
#endif
/* Windows declarations */
@ -197,10 +186,7 @@ int des_is_weak_key(des_cblock);
void des_cblock_print_file(des_cblock *, FILE *fp);
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import reset
# endif
# pragma options align=reset
# pragma pack(pop)
#endif
KRBINT_END_DECLS

View File

@ -47,7 +47,7 @@ extern const struct error_table et_kadm_error_table;
#if !defined(_WIN32)
/* for compatibility with older versions... */
extern void initialize_kadm_error_table () /*@modifies internalState@*/;
extern void initialize_kadm_error_table (void) /*@modifies internalState@*/;
#else
#define initialize_kadm_error_table()
#endif

View File

@ -34,7 +34,7 @@
* For MacOS, don't expose prototypes of various private functions.
* Unfortuantely, they've leaked out everywhere else.
*/
#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
#if defined(__MACH__) && defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_RT_MAC_CFM
# error "Use KfM 4.0 SDK headers for CFM compilation."
@ -73,11 +73,7 @@
KRBINT_BEGIN_DECLS
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import on
# pragma enumsalwaysint on
# endif
# pragma options align=mac68k
# pragma pack(push,2)
#endif
#define KRB4_32 DES_INT32
@ -783,10 +779,7 @@ long win_time_get_epoch(void);
#endif
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import reset
# endif
# pragma options align=reset
# pragma pack(pop)
#endif
KRBINT_END_DECLS

View File

@ -267,7 +267,7 @@ extern const struct error_table et_krb_error_table;
#if !defined(_WIN32)
/* for compatibility with older versions... */
extern void initialize_krb_error_table () /*@modifies internalState@*/;
extern void initialize_krb_error_table (void) /*@modifies internalState@*/;
#else
#define initialize_krb_error_table()
#endif

View File

@ -27,7 +27,7 @@
* Determine platform-dependent configuration.
*/
#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
#if defined(__MACH__) && defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_RT_MAC_CFM
# error "Use KfM 4.0 SDK headers for CFM compilation."
@ -39,9 +39,6 @@ extern "C" {
#endif /* __cplusplus */
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import on
# endif
# pragma options align=mac68k
#endif
@ -54,29 +51,16 @@ extern "C" {
#define KRB5_CALLCONV_C
#endif
#define GSS_SIZEOF_INT SIZEOF_INT
#define GSS_SIZEOF_LONG SIZEOF_LONG
#define GSS_SIZEOF_SHORT SIZEOF_SHORT
/*
* First, include stddef.h to get size_t defined.
*/
#if HAVE_STDDEF_H
#include <stddef.h>
#endif /* HAVE_STDDEF_H */
/*
* POSIX says that sys/types.h is where size_t is defined.
*/
#include <sys/types.h>
/*
* If the platform supports the xom.h header file, it should be included here.
*/
#if HAVE_XOM_H
#include <xom.h>
#endif /* HAVE_XOM_H */
/*
* $Id$
*/
@ -93,16 +77,8 @@ typedef void * gss_ctx_id_t;
* The following type must be defined as the smallest natural unsigned integer
* supported by the platform that has at least 32 bits of precision.
*/
#if (GSS_SIZEOF_SHORT == 4)
typedef unsigned short gss_uint32;
typedef short gss_int32;
#elif (GSS_SIZEOF_INT == 4)
typedef unsigned int gss_uint32;
typedef int gss_int32;
#elif (GSS_SIZEOF_LONG == 4)
typedef unsigned long gss_uint32;
typedef long gss_int32;
#endif
typedef uint32_t gss_uint32;
typedef int32_t gss_int32;
#ifdef OM_STRING
/*
@ -715,6 +691,13 @@ OM_uint32 KRB5_CALLCONV gss_inquire_names_for_mech
gss_OID_set * /* name_types */
);
/* New for V2 */
OM_uint32 KRB5_CALLCONV gss_inquire_mechs_for_name(
OM_uint32 *, /* minor_status */
const gss_name_t, /* input_name */
gss_OID_set * /* mech_types */
);
/*
* The following routines are obsolete variants of gss_get_mic, gss_wrap,
* gss_verify_mic and gss_unwrap. They should be provided by GSSAPI V2
@ -780,9 +763,6 @@ OM_uint32 KRB5_CALLCONV gss_canonicalize_name
);
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import reset
# endif
# pragma options align=reset
#endif

View File

@ -70,16 +70,17 @@ GSS_DLLIMP extern const gss_OID_desc * const GSS_KRB5_NT_PRINCIPAL_NAME;
* generic(1) string_uid_name(3)}. The recommended symbolic name for
* this type is "GSS_KRB5_NT_STRING_UID_NAME". */
extern const gss_OID_desc * const gss_mech_krb5;
extern const gss_OID_desc * const gss_mech_krb5_old;
extern const gss_OID_set_desc * const gss_mech_set_krb5;
extern const gss_OID_set_desc * const gss_mech_set_krb5_old;
extern const gss_OID_set_desc * const gss_mech_set_krb5_both;
GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5;
GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5_old;
GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5_wrong;
GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5;
GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5_old;
GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5_both;
extern const gss_OID_desc * const gss_nt_krb5_name;
extern const gss_OID_desc * const gss_nt_krb5_principal;
GSS_DLLIMP extern const gss_OID_desc * const gss_nt_krb5_name;
GSS_DLLIMP extern const gss_OID_desc * const gss_nt_krb5_principal;
extern const gss_OID_desc krb5_gss_oid_array[];
GSS_DLLIMP extern const gss_OID_desc krb5_gss_oid_array[];
#define gss_krb5_nt_general_name gss_nt_krb5_name
#define gss_krb5_nt_principal gss_nt_krb5_principal
@ -88,6 +89,71 @@ extern const gss_OID_desc krb5_gss_oid_array[];
#define gss_krb5_nt_machine_uid_name gss_nt_machine_uid_name
#define gss_krb5_nt_string_uid_name gss_nt_string_uid_name
#if defined(_WIN32)
typedef unsigned __int64 gss_uint64;
#else /*windows*/
#include <inttypes.h>
typedef uint64_t gss_uint64;
#endif
typedef struct gss_krb5_lucid_key {
OM_uint32 type; /* key encryption type */
OM_uint32 length; /* length of key data */
void * data; /* actual key data */
} gss_krb5_lucid_key_t;
typedef struct gss_krb5_rfc1964_keydata {
OM_uint32 sign_alg; /* signing algorthm */
OM_uint32 seal_alg; /* seal/encrypt algorthm */
gss_krb5_lucid_key_t ctx_key;
/* Context key
(Kerberos session key or subkey) */
} gss_krb5_rfc1964_keydata_t;
typedef struct gss_krb5_cfx_keydata {
OM_uint32 have_acceptor_subkey;
/* 1 if there is an acceptor_subkey
present, 0 otherwise */
gss_krb5_lucid_key_t ctx_key;
/* Context key
(Kerberos session key or subkey) */
gss_krb5_lucid_key_t acceptor_subkey;
/* acceptor-asserted subkey or
0's if no acceptor subkey */
} gss_krb5_cfx_keydata_t;
typedef struct gss_krb5_lucid_context_v1 {
OM_uint32 version; /* Structure version number (1)
MUST be at beginning of struct! */
OM_uint32 initiate; /* Are we the initiator? */
OM_uint32 endtime; /* expiration time of context */
gss_uint64 send_seq; /* sender sequence number */
gss_uint64 recv_seq; /* receive sequence number */
OM_uint32 protocol; /* 0: rfc1964,
1: draft-ietf-krb-wg-gssapi-cfx-07 */
/*
* if (protocol == 0) rfc1964_kd should be used
* and cfx_kd contents are invalid and should be zero
* if (protocol == 1) cfx_kd should be used
* and rfc1964_kd contents are invalid and should be zero
*/
gss_krb5_rfc1964_keydata_t rfc1964_kd;
gss_krb5_cfx_keydata_t cfx_kd;
} gss_krb5_lucid_context_v1_t;
/*
* Mask for determining the returned structure version.
* See example below for usage.
*/
typedef struct gss_krb5_lucid_context_version {
OM_uint32 version; /* Structure version number */
} gss_krb5_lucid_context_version_t;
/* Alias for Heimdal compat. */
#define gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity
@ -107,6 +173,98 @@ OM_uint32 KRB5_CALLCONV gss_krb5_ccache_name
(OM_uint32 *minor_status, const char *name,
const char **out_name);
/*
* gss_krb5_set_allowable_enctypes
*
* This function may be called by a context initiator after calling
* gss_acquire_cred(), but before calling gss_init_sec_context(),
* to restrict the set of enctypes which will be negotiated during
* context establishment to those in the provided array.
*
* 'cred' must be a valid credential handle obtained via
* gss_acquire_cred(). It may not be GSS_C_NO_CREDENTIAL.
* gss_acquire_cred() may have been called to get a handle to
* the default credential.
*
* The purpose of this function is to limit the keys that may
* be exported via gss_krb5_export_lucid_sec_context(); thus it
* should limit the enctypes of all keys that will be needed
* after the security context has been established.
* (i.e. context establishment may use a session key with a
* stronger enctype than in the provided array, however a
* subkey must be established within the enctype limits
* established by this function.)
*
*/
OM_uint32 KRB5_CALLCONV
gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
gss_cred_id_t cred,
OM_uint32 num_ktypes,
krb5_enctype *ktypes);
/*
* Returns a non-opaque (lucid) version of the internal context
* information.
*
* Note that context_handle must not be used again by the caller
* after this call. The GSS implementation is free to release any
* resources associated with the original context. It is up to the
* GSS implementation whether it returns pointers to existing data,
* or copies of the data. The caller should treat the returned
* lucid context as read-only.
*
* The caller must call gss_krb5_free_lucid_context() to free
* the context and allocated resources when it is finished with it.
*
* 'version' is an integer indicating the highest version of lucid
* context understood by the caller. The highest version
* understood by both the caller and the GSS implementation must
* be returned. The caller can determine which version of the
* structure was actually returned by examining the version field
* of the returned structure. gss_krb5_lucid_context_version_t
* may be used as a mask to examine the returned structure version.
*
* If there are no common versions, an error should be returned.
* (XXX Need error definition(s))
*
* For example:
* void *return_ctx;
* gss_krb5_lucid_context_v1_t *ctx;
* OM_uint32 min_stat, maj_stat;
* OM_uint32 vers;
* gss_ctx_id_t *ctx_handle;
*
* maj_stat = gss_krb5_export_lucid_sec_context(&min_stat,
* ctx_handle, 1, &return_ctx);
* // Verify success
*
* vers = ((gss_krb5_lucid_context_version_t *)return_ctx)->version;
* switch (vers) {
* case 1:
* ctx = (gss_krb5_lucid_context_v1_t *) return_ctx;
* break;
* default:
* // Error, unknown version returned
* break;
* }
*
*/
OM_uint32 KRB5_CALLCONV
gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
gss_ctx_id_t *context_handle,
OM_uint32 version,
void **kctx);
/*
* Frees the allocated storage associated with an
* exported struct gss_krb5_lucid_context.
*/
OM_uint32 KRB5_CALLCONV
gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status,
void *kctx);
#ifdef __cplusplus
}
#endif /* __cplusplus */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
#include <win-mac.h>
#endif
#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
#if defined(__MACH__) && defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_RT_MAC_CFM
# error "Use KfM 4.0 SDK headers for CFM compilation."
@ -34,12 +34,6 @@ typedef struct _profile_t *profile_t;
extern "C" {
#endif /* __cplusplus */
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import on
# endif
#endif
typedef char* profile_filespec_t; /* path as C string */
typedef char* profile_filespec_list_t; /* list of : separated paths, C string */
typedef const char * const_profile_filespec_t; /* path as C string */
@ -53,6 +47,17 @@ long KRB5_CALLCONV profile_init_path
long KRB5_CALLCONV profile_flush
(profile_t profile);
long KRB5_CALLCONV profile_flush_to_file
(profile_t profile, const_profile_filespec_t outfile);
long KRB5_CALLCONV profile_flush_to_buffer
(profile_t profile, char **bufp);
void KRB5_CALLCONV profile_free_buffer
(profile_t profile, char *buf);
long KRB5_CALLCONV profile_is_writable
(profile_t profile, int *writable);
long KRB5_CALLCONV profile_is_modified
(profile_t profile, int *modified);
void KRB5_CALLCONV profile_abandon
(profile_t profile);
@ -87,7 +92,7 @@ long KRB5_CALLCONV profile_get_subsection_names
(profile_t profile, const char **names, char ***ret_names);
long KRB5_CALLCONV profile_iterator_create
(profile_t profile, const char **names,
(profile_t profile, const char *const *names,
int flags, void **ret_iter);
void KRB5_CALLCONV profile_iterator_free
@ -113,12 +118,6 @@ long KRB5_CALLCONV profile_add_relation
(profile_t profile, const char **names,
const char *new_value);
#if TARGET_OS_MAC
# if defined(__MWERKS__)
# pragma import reset
# endif
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
@ -168,7 +167,7 @@ extern const struct error_table et_prof_error_table;
#if !defined(_WIN32)
/* for compatibility with older versions... */
extern void initialize_prof_error_table () /*@modifies internalState@*/;
extern void initialize_prof_error_table (void) /*@modifies internalState@*/;
#else
#define initialize_prof_error_table()
#endif

View File

@ -25,6 +25,21 @@
#else /* ! RES_ONLY */
/* To ensure backward compatibility of the ABI use 32-bit time_t on
* 32-bit Windows.
*/
#ifdef _KRB5_INT_H
#ifdef KRB5_GENERAL__
#error krb5.h included before k5-int.h
#endif /* KRB5_GENERAL__ */
#if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1400 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T)
#if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR)
#error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform.
#endif /* _TIME_T_DEFINED */
#define _USE_32BIT_TIME_T
#endif
#endif
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
@ -32,11 +47,13 @@
#include <windows.h>
#include <limits.h>
#define HAVE_LABS
#ifndef SIZE_MAX /* in case Microsoft defines max size of size_t */
#ifdef MAX_SIZE /* Microsoft defines MAX_SIZE as max size of size_t */
#define SIZE_MAX MAX_SIZE
#else
#define SIZE_MAX UINT_MAX
#endif
#endif
#ifndef KRB5_CALLCONV
# define KRB5_CALLCONV __stdcall
@ -55,10 +72,16 @@
#ifndef KRB5_SYSTYPES__
#define KRB5_SYSTYPES__
#include <sys/types.h>
typedef unsigned long u_long; /* Not part of sys/types.h on the pc */
typedef unsigned int u_int;
typedef unsigned short u_short;
typedef unsigned char u_char;
typedef unsigned long u_long; /* Not part of sys/types.h on the pc */
typedef unsigned int u_int;
typedef unsigned short u_short;
typedef unsigned char u_char;
typedef unsigned int uint32_t;
typedef int int32_t;
#if _INTEGRAL_MAX_BITS >= 64
typedef unsigned __int64 uint64_t;
typedef __int64 int64_t;
#endif
#endif /* KRB5_SYSTYPES__ */
#define MAXHOSTNAMELEN 512
@ -72,8 +95,17 @@ typedef unsigned char u_char;
#define HAVE_SRAND
#define HAVE_ERRNO
#define HAVE_STRDUP
#define HAVE_GETADDRINFO
#define HAVE_GETNAMEINFO
#define NO_USERID
#define NO_PASSWORD
#define HAVE_STRERROR
#define SYS_ERRLIST_DECLARED
/* if __STDC_VERSION__ >= 199901L this shouldn't be needed */
#define inline __inline
#define KRB5_USE_INET6
#define NEED_INSIXADDR_ANY
#define ENABLE_THREADS
#define WM_KERBEROS5_CHANGED "Kerberos5 Changed"
#ifdef KRB4
@ -159,6 +191,11 @@ typedef unsigned char u_char;
HINSTANCE get_lib_instance(void);
#define GETSOCKNAME_ARG2_TYPE struct sockaddr
#define GETSOCKNAME_ARG3_TYPE size_t
#define GETPEERNAME_ARG2_TYPE GETSOCKNAME_ARG2_TYPE
#define GETPEERNAME_ARG3_TYPE GETSOCKNAME_ARG3_TYPE
#endif /* !RES_ONLY */
#endif /* _WIN32 */

View File

@ -3,10 +3,10 @@
#include <krb.h>
typedef struct {
int dlgtype;
#define DLGTYPE_PASSWD 0
#define DLGTYPE_CHPASSWD 1
typedef struct {
int dlgtype;
// Tells whether dialog box is in change pwd more or init ticket mode???
// (verify this):
int dlgstatemax; // What is this???
@ -15,35 +15,83 @@ typedef struct {
LPSTR principal;
} LSH_DLGINFO, FAR *LPLSH_DLGINFO;
#define LEASH_USERNAME_SZ 64
#define LEASH_REALM_SZ 192
#define LEASH_USERNAME_SZ 64
#define LEASH_REALM_SZ 192
#define LEASH_TITLE_SZ 128
#define LEASH_CCACHE_NAME_SZ 264
typedef struct {
DWORD size;
DWORD size;
int dlgtype;
#define DLGTYPE_PASSWD 0
#define DLGTYPE_CHPASSWD 1
// Tells whether dialog box is in change pwd more or init ticket mode???
// (verify this):
LPSTR title;
LPSTR username;
LPSTR realm;
int use_defaults;
int forwardable;
int noaddresses;
int lifetime;
int renew_till;
int proxiable;
int publicip;
// Version 1 of this structure ended here
// Tells whether dialog box is in change pwd mode or init ticket mode
LPSTR title; // in v3, set to in.title
LPSTR username; // in v3, set to in.username
LPSTR realm; // in v3, set to in.realm
int use_defaults;
int forwardable;
int noaddresses;
int lifetime;
int renew_till;
int proxiable;
int publicip;
// Version 1 of this structure ends here
struct {
char username[LEASH_USERNAME_SZ];
char realm[LEASH_REALM_SZ];
// Version 2 of this structure ends here
char ccache[LEASH_CCACHE_NAME_SZ];
} out;
} LSH_DLGINFO_EX, FAR *LPLSH_DLGINFO_EX;
struct {
char title[LEASH_TITLE_SZ];
char username[LEASH_USERNAME_SZ];
char realm[LEASH_REALM_SZ];
char ccache[LEASH_CCACHE_NAME_SZ];
} in;
} LSH_DLGINFO_EX, *LPLSH_DLGINFO_EX;
#define LSH_DLGINFO_EX_V1_SZ (sizeof(DWORD) + 3 * sizeof(LPSTR) + 8 * sizeof(int))
#define LSH_DLGINFO_EX_V2_SZ (sizeof(DWORD) + 3 * sizeof(LPSTR) + 8 * sizeof(int) + max(LEASH_USERNAME_SZ,LEASH_REALM_SZ))
#define LSH_DLGINFO_EX_V2_SZ (LSH_DLGINFO_EX_V1_SZ + LEASH_USERNAME_SZ + LEASH_REALM_SZ)
#define LSH_DLGINFO_EX_V3_SZ (LSH_DLGINFO_EX_V2_SZ + LEASH_TITLE_SZ + LEASH_USERNAME_SZ + LEASH_REALM_SZ + 2 * LEASH_CCACHE_NAME_SZ)
#ifndef NETIDMGR
#define NETID_USERNAME_SZ 128
#define NETID_REALM_SZ 192
#define NETID_TITLE_SZ 256
#define NETID_CCACHE_NAME_SZ 264
#define NETID_DLGTYPE_TGT 0
#define NETID_DLGTYPE_CHPASSWD 1
typedef struct {
DWORD size;
DWORD dlgtype;
// Tells whether dialog box is in change pwd mode or init ticket mode
struct {
WCHAR title[NETID_TITLE_SZ];
WCHAR username[NETID_USERNAME_SZ];
WCHAR realm[NETID_REALM_SZ];
WCHAR ccache[NETID_CCACHE_NAME_SZ];
DWORD use_defaults;
DWORD forwardable;
DWORD noaddresses;
DWORD lifetime;
DWORD renew_till;
DWORD proxiable;
DWORD publicip;
DWORD must_use_specified_principal;
} in;
struct {
WCHAR username[NETID_USERNAME_SZ];
WCHAR realm[NETID_REALM_SZ];
WCHAR ccache[NETID_CCACHE_NAME_SZ];
} out;
// Version 1 of this structure ends here
} NETID_DLGINFO, *LPNETID_DLGINFO;
#define NETID_DLGINFO_V1_SZ (10 * sizeof(DWORD) \
+ sizeof(WCHAR) * (NETID_TITLE_SZ + \
2 * NETID_USERNAME_SZ + 2 * NETID_REALM_SZ + \
2 * NETID_CCACHE_NAME_SZ))
#endif /* NETIDMGR */
typedef struct {
char principal[MAX_K_NAME_SZ]; /* Principal name/instance/realm */

View File

@ -4,7 +4,11 @@
#include "loadfuncs.h"
#include <com_err.h>
#if defined(_WIN64)
#define COMERR_DLL "comerr64.dll"
#else
#define COMERR_DLL "comerr32.dll"
#endif
TYPEDEF_FUNC(
void,

View File

@ -4,7 +4,11 @@
#include "loadfuncs.h"
#include <krb5.h>
#if defined(_WIN64)
#define KRB5_DLL "krb5_64.dll"
#else
#define KRB5_DLL "krb5_32.dll"
#endif
TYPEDEF_FUNC(
void,

View File

@ -4,7 +4,11 @@
#include "loadfuncs.h"
#include <leashwin.h>
#if defined(_WIN64)
#define LEASH_DLL "leashw64.dll"
#else
#define LEASH_DLL "leashw32.dll"
#endif
#define CALLCONV_C

View File

@ -4,7 +4,11 @@
#include "loadfuncs.h"
#include <profile.h>
#if defined(_WIN64)
#define PROFILE_DLL "xpprof64.dll"
#else
#define PROFILE_DLL "xpprof32.dll"
#endif
TYPEDEF_FUNC(
long,

View File

@ -4,7 +4,11 @@
#include <loadfuncs.h>
#include <wshelper.h>
#if defined(_WIN64)
#define WSHELPER_DLL "wshelp64.dll"
#else
#define WSHELPER_DLL "wshelp32.dll"
#endif
#define CALLCONV_C
TYPEDEF_FUNC(

View File

@ -0,0 +1,223 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_HASHTABLE_H
#define __KHIMAIRA_HASHTABLE_H
/*! \addtogroup util
@{ */
/*! \defgroup util_ht Hashtable
@{*/
#include<khdefs.h>
#include<khlist.h>
/*! \brief A hash function
The function should take a key as a parameter and return an
khm_int32 that serves as the hash of the key.
*/
typedef khm_int32 (*hash_function_t)(const void *key);
/*! \brief A comparison function
The function takes two keys and returns a value indicating the
relative ordering of the two keys.
The return value should be:
- \b Zero if \a key1 == \a key2
- \b Negative if \a key1 &lt; \a key2
- \b Positive if \a key1 &gt; \a key2
*/
typedef khm_int32 (*comp_function_t)(const void *key1, const void *key2);
/*! \brief Add-reference function
When an object is successfully added to a hashtable, this function
will be called with the \a key and \a data used to add the object.
The function is allowed to modify \a data, however, the
modification should not alter the \a key or the relationship
between \a key and \a data.
*/
typedef void (*add_ref_function_t)(const void *key, void *data);
/*! \brief Delete-reference function
When an object is successfully removed from the hashtable, this
function will be called. As with the add-ref function, the object
can be modified, but the \a key and the relationship between \a
key and \a data should remain intact.
An object is removed if it is explicitly removed from the
hashtable or another object with the same \a key is added to the
hashtable. There should be a 1-1 correspondence with keys and
objects in the hashtable. The delete-reference function will be
called on all the remaining objects in the hashtable when the
hashtable is deleted.
*/
typedef void (*del_ref_function_t)(const void *key, void *data);
typedef struct tag_hash_bin {
void * data;
void * key;
LDCL(struct tag_hash_bin);
} hash_bin;
typedef struct hashtable_t {
khm_int32 n;
hash_function_t hash;
comp_function_t comp;
add_ref_function_t addr;
del_ref_function_t delr;
hash_bin ** bins;
} hashtable;
/*! \brief Create a new hashtable
\param[in] n Number of bins in hashtable.
\param[in] hash A hash function. Required.
\param[in] comp A comparator. Required.
\param[in] addr An add-ref function. Optional; can be NULL.
\param[in] delr A del-ref function. Optional; can be NULL.
*/
KHMEXP hashtable * KHMAPI hash_new_hashtable(khm_int32 n,
hash_function_t hash,
comp_function_t comp,
add_ref_function_t addr,
del_ref_function_t delr);
/*! \brief Delete a hashtable
\note Not thread-safe. Applications must serialize calls that
reference the same hashtable.
*/
KHMEXP void KHMAPI hash_del_hashtable(hashtable * h);
/*! \brief Add an object to a hashtable
Creates an association between the \a key and \a data in the
hashtable \a h. If there is an add-ref function defined for the
hashtable, it will be called with \a key and \data after the
object is added. If there is already an object with the same key
in the hashtable, that object will be removed (and the del-ref
function called, if appilcable) before adding the new object and
before the add-ref function is called for the new object.
Note that two keys \a key1 and \a key2 are equal (or same) in a
hashtable if the comparator returns zero when called with \a key1
and \a key2.
Also note that all additions and removals to the hashtable are
done by reference. No data is copied. Any objects pointed to are
expected to exist for the duration that the object and key are
contained in the hashtable.
\param[in] h Hashtable
\param[in] key A key. If \a key points to a location in memory,
it should be within the object pointed to by \a data, or be a
constant. Can be NULL.
\param[in] data Data. Cannot be NULL.
\note Not thread-safe. Applications must serialize calls that
reference the same hashtable.
*/
KHMEXP void KHMAPI hash_add(hashtable * h, void * key, void * data);
/*! \brief Delete an object from a hashtable
Deletes the object in the hashtable \a h that is associated with
key \a key. An object is associated with key \a key if the key \a
key_o that the object is associated with is the same as \a key as
determined by the comparator. If the del-ref function is defined
for the hash-table, it will be called with the \a key_o and \a
data that was used to add the object.
\note Not thread-safe. Applications must serialize calls that
reference the same hashtable.
*/
KHMEXP void KHMAPI hash_del(hashtable * h, void * key);
/*! \brief Resolve and association
Return the object that is associated with key \a key in hashtable
\a h. An object \a data is associated with key \a key in \a h if
the key \a key_o that was used to add \a data to \a h is equal to
\a key as determined by the comparator.
Returns NULL if no association is found.
\note Not thread-safe. Applications must serialize calls that
reference the same hashtable.
*/
KHMEXP void * KHMAPI hash_lookup(hashtable * h, void * key);
/*! \brief Check for the presence of an association
Returns non-zero if there exists an association between key \a key
and some object in hashtable \a h. See hash_lookup() for
definition of "association".
Returns zero if there is no association.
\note (hash_lookup(h,key) == NULL) iff (hash_exist(h,key)==0)
\note Not thead-safe. Application must serialize calls that
reference the same hashtable.
*/
KHMEXP khm_boolean KHMAPI hash_exist(hashtable * h, void * key);
/*! \brief Compute a hashvalue for a unicode string
The hash value is computed using DJB with parameter 13331.
This function is suitable for use as the hash function for a
hashtable if the keys are NULL terminated safe unicode strings
that are either part of the data objects or are constants.
\param[in] str A pointer to a NULL terminated wchar_t string cast
as (void *).
*/
KHMEXP khm_int32 hash_string(const void *str);
/*! \brief Compare two strings
Compares two strings are returns a value that is in accordance
with the comparator for a hashtable.
\param[in] vs1 A pointer to a NULL terminated wchar_t string cast
as (void *).
\param[in] vs2 A pointer to a NULL terminated wchar_t string cast
as (void *).
*/
KHMEXP khm_int32 hash_string_comp(const void *vs1, const void *vs2);
/*@}*/
/*@}*/
#endif

View File

@ -0,0 +1,954 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KCONFIG_H
#define __KHIMAIRA_KCONFIG_H
#include<khdefs.h>
#include<mstring.h>
/*! \defgroup kconf NetIDMgr Configuration Provider */
/*@{*/
/*! \brief Configuration schema descriptor record
The schema descriptor is a convenient way to provide a default set
of configuration options for a part of an application. It
describes the configuration spaces and the values and subspaces
contained in each space.
\see kconf_load_schema()
*/
typedef struct tag_kconf_schema {
wchar_t * name; /*!< name of the object being described.
Optional for KC_ENDSPACE type object,
but required for everything else.
Names can be upto KCONF_MAXCCH_NAME
characters in length. */
khm_int32 type; /*!< type of the object. Can be one of
KC_SPACE, KC_ENDSPACE, KC_INT32,
KC_INT64, KC_STRING or KC_BINARY */
khm_ui_8 value; /*!< the value of the object. It is not
used for KC_SPACE and KC_ENDSPACE
typed objects. For a KC_STRING, this
contains a pointer to the string
value. The string should not be
longer than KCONF_MAXCCH_STRING
characters. KC_INT32 and KC_INT64
objects store the value directly in
this field, while KC_BINARY objects do
not support defining a default value
here. */
wchar_t * description;/*!< a friendly description of the value
or configuration space. */
} kconf_schema;
/*! \name Configuration data types
@{*/
/*! \brief Not a known type */
#define KC_NONE 0
/*! \brief When used as ::kconf_schema \a type, defines the start of a configuration space.
There should be a subsequent KC_ENDSPACE record in the schema
which defines the end of this configuration space.
\a name specifies the name of the configuration space. Optionally
use \a description to provide a description.*/
#define KC_SPACE 1
/*! \brief Ends a configuration space started with KC_SPACE */
#define KC_ENDSPACE 2
/*! \brief A 32 bit integer
Specifies a configuration parameter named \a name which is of this
type. Use \a description to provide an optional description of
the value.
\a value specifies a default value for this parameter in the lower
32 bits.
*/
#define KC_INT32 3
/*! \brief A 64 bit integer
Specifies a configuration parameter named \a name which is of this
type. Use \a description to provide an optional description of
the value.
\a value specifies a default value for this parameter.
*/
#define KC_INT64 4
/*! \brief A unicode string
Specifies a configuration parameter named \a name which is of this
type. Use \a description to provide an optional description of
the value.
\a value specifies a default value for this parameter which should
be a pointer to a NULL terminated unicode string of no more than
::KCONF_MAXCCH_STRING characters.
*/
#define KC_STRING 5
/*! \brief An unparsed binary stream
Specifies a configuration parameter named \a name which is of this
type. Use \a description to provide an optional description of
the value.
Default values are not supported for binary streams. \a value is
ignored.
*/
#define KC_BINARY 6
/*@}*/
/*! \brief This is the root configuration space */
#define KCONF_FLAG_ROOT 0x00000001
/*! \brief Indicates the configuration store which stores user-specific information */
#define KCONF_FLAG_USER 0x00000002
/*! \brief Indicates the configuration store which stores machine-specific information */
#define KCONF_FLAG_MACHINE 0x00000004
/*! \brief Indicates the configuration store which stores the schema */
#define KCONF_FLAG_SCHEMA 0x00000008
/*! \brief Indicates that the last component of the given configuration path is to be considered to be a configuration value */
#define KCONF_FLAG_TRAILINGVALUE 0x00000020
/*! \brief Only write values back there is a change
Any write operations using the handle with check if the value
being written is different from the value being read from the
handle. It will only be written if the value is different.
\note Note that the value being read from a handle takes schema and
shadowed configuration handles into consideration while the value
being written is only written to the topmost layer of
configuration that can be written to.
\note Note also that this flag does not affect binary values.
*/
#define KCONF_FLAG_WRITEIFMOD 0x00000040
/*! \brief Use case-insensitive comparison for KCONF_FLAG_WRITEIFMOD
When used in combination with \a KCONF_FLAG_WRITEIFMOD , the
string comparison used when determining whether the string read
from the configuration handle is the same as the string being
written will be case insensitive. If this flag is not set, the
comparison will be case sensitive.
*/
#define KCONF_FLAG_IFMODCI 0x00000080
/*! \brief Do not parse the configuration space name
If set, disables the parsing of the configuration space for
subspaces. The space name is taken verbatim to be a configuration
space name. This can be used when there can be forward slashes or
backslahes in the name which are not escaped.
By default, the configuration space name,
\code
L"foo\\bar"
\endcode
is taken to mean the configuration space \a bar which is a
subspace of \a foo. If ::KCONF_FLAG_NOPARSENAME is set, then this
is taken to mean configuration space \a foo\\bar.
*/
#define KCONF_FLAG_NOPARSENAME 0x00000040
/*! \brief Maximum number of allowed characters (including terminating NULL) in a name
\note This is a hard limit in Windows, since we are mapping
configuration spaces to registry keys.
*/
#define KCONF_MAXCCH_NAME 256
/*! \brief Maximum number of allowed bytes (including terminating NULL) in a name */
#define KCONF_MAXCB_NAME (KCONF_MAXCCH_NAME * sizeof(wchar_t))
/*! \brief Maximum level of nesting for configuration spaces
*/
#define KCONF_MAX_DEPTH 16
/*! \brief Maximum number of allowed characters (including terminating NULL) in a configuration path */
#define KCONF_MAXCCH_PATH (KCONF_MAXCCH_NAME * KCONF_MAX_DEPTH)
/*! \brief Maximum number of allowed bytes (including terminating NULL) in a configuration path */
#define KCONF_MAXCB_PATH (KCONF_MAXCCH_PATH * sizeof(wchar_t))
/*! \brief Maximum number of allowed characters (including terminating NULL) in a string */
#define KCONF_MAXCCH_STRING KHM_MAXCCH_STRING
/*! \brief Maximum number of allowed bytes (including terminating NULL) in a string */
#define KCONF_MAXCB_STRING (KCONF_MAXCCH_STRING * sizeof(wchar_t))
/*! \brief Open a configuration space
Opens the configuration space specified by \a cspace. By default,
the opened space includes user,machine and schema configuration
stores. However, you can specify a subset of these.
If the configuration space does not exist and the \a flags specify
KHM_FLAG_CREATE, then the configuration space is created. The
stores that are affected by the create operation depend on \a
flags. If the \a flags only specifies ::KCONF_FLAG_MACHINE, then
the configuration space is created in the machine store. If \a
flags specifies any combination of stores including \a
::KCONF_FLAG_USER, then the configuration space is created in the
user store. Note that ::KCONF_FLAG_SCHEMA is readonly.
Once opened, use khc_close_space() to close the configuration
space.
\param[in] parent The parent configuration space. The path
specified in \a cspace is relative to the parent. Set this to
NULL to indicate the root configuration space.
\param[in] cspace The confiuration path. This can be up to
::KCONF_MAXCCH_PATH characters in length. Use either
backslashes or forward slashes to specify hiearchy. Set this
to NULL to reopen the parent configuration space.
\param[in] flags Flags. This can be a combination of KCONF_FLAG_*
constants and KHM_FLAG_CREATE. If none of ::KCONF_FLAG_USER,
::KCONF_FLAG_MACHINE or ::KCONF_FLAG_SCHEMA is specified, then
it defaults to all three.
\param[out] result Pointer to a handle which receives the handle
to the opened configuration space if the call succeeds.
\note You can re-open a configuration space with different flags
such as ::KCONF_FLAG_MACHINE by specifying NULL for \a cspace
and settings \a flags to the required flags.
*/
KHMEXP khm_int32 KHMAPI
khc_open_space(khm_handle parent, const wchar_t * cspace, khm_int32 flags,
khm_handle * result);
/*! \brief Set the shadow space for a configuration handle
The handle specified by \a lower becomes a shadow for the handle
specified by \a upper. Any configuration value that is queried in
\a upper that does not exist in \a upper will be queried in \a
lower.
If \a upper already had a shadow handle, that handle will be
replaced by \a lower. The handle \a lower still needs to be
closed by a call to khc_close_space(). However, closing \a lower
will not affect \a upper which will still treat the configuration
space pointed to by \a lower to be it's shadow.
Shadows are specific to handles and not configuration spaces.
Shadowing a configuration space using one handle does not affect
any other handles which may be obtained for the same configuration
space.
Specify NULL for \a lower to remove any prior shadow.
*/
KHMEXP khm_int32 KHMAPI
khc_shadow_space(khm_handle upper, khm_handle lower);
/*! \brief Close a handle opened with khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_close_space(khm_handle conf);
/*! \brief Read a string value from a configuration space
The \a value_name parameter specifies the value to read from the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to access the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
- Otherwise, if KCONF_FLAG_SCHEMA was specified, the the schema
store.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three.
If the value is not found in the configuration space and any
shadowed configuration spaces, the function returns \a
KHM_ERROR_NOT_FOUND. In this case, the buffer is left unmodified.
\param[in] buf Buffer to copy the string to. Specify NULL to just
retrieve the number of required bytes.
\param[in,out] bufsize On entry, specifies the number of bytes of
space available at the location specified by \a buf. On exit
specifies the number of bytes actually copied or the size of
the required buffer if \a buf is NULL or insufficient.
\retval KHM_ERROR_NOT_READY The configuration provider has not started
\retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid
\retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string
\retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient. The required size is in bufsize.
\retval KHM_ERROR_SUCCESS Success. The number of bytes copied is in bufsize.
\retval KHM_ERROR_NOT_FOUND The value was not found.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_read_string(khm_handle conf,
const wchar_t * value_name,
wchar_t * buf,
khm_size * bufsize);
/*! \brief Read a multi-string value from a configuration space
The \a value_name parameter specifies the value to read from the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to access the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
- Otherwise, if KCONF_FLAG_SCHEMA was specified, the the schema
store.
A multi-string is a pseudo data type. The value in the
configuration store should contain a CSV string. Each comma
separated value in the CSV string is considered to be a separate
value. Empty values are not allowed. The buffer pointed to by \a
buf will receive these values in the form of a series of NULL
terminated strings terminated by an empty string (or equivalently,
the last string will be terminated by a double NULL).
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three.
If the value is not found in the configuration space and any
shadowed configuration spaces, the function returns \a
KHM_ERROR_NOT_FOUND. In this case, the buffer is left unmodified.
\param[in] buf Buffer to copy the multi-string to. Specify NULL
to just retrieve the number of required bytes.
\param[in,out] bufsize On entry, specifies the number of bytes of
space available at the location specified by \a buf. On exit
specifies the number of bytes actually copied or the size of
the required buffer if \a buf is NULL or insufficient.
\retval KHM_ERROR_NOT_READY The configuration provider has not started
\retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid
\retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string
\retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient. The required size is in bufsize.
\retval KHM_ERROR_SUCCESS Success. The number of bytes copied is in bufsize.
\retval KHM_ERROR_NOT_FOUND The value was not found.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_read_multi_string(khm_handle conf,
const wchar_t * value_name,
wchar_t * buf,
khm_size * bufsize);
/*! \brief Read a 32 bit integer value from a configuration space
The \a value_name parameter specifies the value to read from the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to access the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
- Otherwise, if KCONF_FLAG_SCHEMA was specified, the the schema
store.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three.
If the value is not found in the configuration space and any
shadowed configuration spaces, the function returns \a
KHM_ERROR_NOT_FOUND. In this case, the buffer is left unmodified.
\param[in] conf Handle to a configuration space
\param[in] value The value to query
\param[out] buf The buffer to receive the value
\retval KHM_ERROR_NOT_READY The configuration provider has not started.
\retval KHM_ERROR_SUCCESS Success. The value that was read was placed in \a buf
\retval KHM_ERROR_NOT_FOUND The specified value was not found
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid
\retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not of the correct type.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_read_int32(khm_handle conf,
const wchar_t * value_name,
khm_int32 * buf);
/*! \brief Read a 64 bit integer value from a configuration space
The \a value_name parameter specifies the value to read from the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to access the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
- Otherwise, if KCONF_FLAG_SCHEMA was specified, the the schema
store.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three.
If the value is not found in the configuration space and any
shadowed configuration spaces, the function returns \a
KHM_ERROR_NOT_FOUND. In this case, the buffer is left unmodified.
\param[in] conf Handle to a configuration space
\param[in] value_name The value to query
\param[out] buf The buffer to receive the value
\retval KHM_ERROR_NOT_READY The configuration provider has not started
\retval KHM_ERROR_SUCCESS Success. The value that was read was placed in \a buf
\retval KHM_ERROR_NOT_FOUND The specified value was not found
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid
\retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not the correct data type.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_read_int64(khm_handle conf,
const wchar_t * value_name,
khm_int64 * buf);
/*! \brief Read a binary value from a configuration space
The \a value_name parameter specifies the value to read from the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to access the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) does
not support binary values.
If the value is not found in the configuration space and any
shadowed configuration spaces, the function returns \a
KHM_ERROR_NOT_FOUND. In this case, the buffer is left unmodified.
\param[in] buf Buffer to copy the string to. Specify NULL to just
retrieve the number of required bytes.
\param[in,out] bufsize On entry, specifies the number of bytes of
space available at the location specified by \a buf. On exit
specifies the number of bytes actually copied or the size of
the required buffer if \a buf is NULL or insufficient.
\retval KHM_ERROR_SUCCESS Success. The data was copied to \a buf. The number of bytes copied is stored in \a bufsize
\retval KHM_ERROR_NOT_FOUND The specified value was not found
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_read_binary(khm_handle conf,
const wchar_t * value_name,
void * buf,
khm_size * bufsize);
/*! \brief Write a string value to a configuration space
The \a value_name parameter specifies the value to write to the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to write the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If \a KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if \a KCONF_FLAG_MACHINE was specified, then the
machine configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) is
readonly.
If the \a KCONF_FLAG_WRITEIFMOD flag is specified in the call to
khc_open_space() for obtaining the configuration handle, the
specified string will only be written if it is different from the
value being read from the handle.
If the \a KCONF_FLAG_IFMODCI flag is specified along with the \a
KCONF_FLAG_WRITEIFMOD flag, then the string comparison used will
be case insensitive.
\param[in] conf Handle to a configuration space
\param[in] value_name Name of value to write
\param[in] buf A NULL terminated unicode string not exceeding KCONF_MAXCCH_STRING in characters including terminating NULL
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_write_string(khm_handle conf,
const wchar_t * value_name,
wchar_t * buf);
/*! \brief Write a multi-string value to a configuration space
The \a value_name parameter specifies the value to write to the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to write the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
A multi-string is a pseudo data type. The buffer pointed to by \a
buf should contain a sequence of NULL terminated strings
terminated by an empty string (or equivalently, the last string
should terminate with a double NULL). This will be stored in the
value as a CSV string.
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) is
readonly.
If the \a KCONF_FLAG_WRITEIFMOD flag is specified in the call to
khc_open_space() for obtaining the configuration handle, the
specified string will only be written if it is different from the
value being read from the handle.
If the \a KCONF_FLAG_IFMODCI flag is specified along with the \a
KCONF_FLAG_WRITEIFMOD flag, then the string comparison used will
be case insensitive.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_write_multi_string(khm_handle conf,
const wchar_t * value_name,
wchar_t * buf);
/*! \brief Write a 32 bit integer value to a configuration space
The \a value_name parameter specifies the value to write to the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to write the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) is
readonly.
If the \a KCONF_FLAG_WRITEIFMOD flag is specified in the call to
khc_open_space() for obtaining the configuration handle, the
specified string will only be written if it is different from the
value being read from the handle.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_write_int32(khm_handle conf,
const wchar_t * value_name,
khm_int32 buf);
/*! \brief Write a 64 bit integer value to a configuration space
The \a value_name parameter specifies the value to write to the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to write the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) is
readonly.
If the \a KCONF_FLAG_WRITEIFMOD flag is specified in the call to
khc_open_space() for obtaining the configuration handle, the
specified string will only be written if it is different from the
value being read from the handle.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_write_int64(khm_handle conf,
const wchar_t * value_name,
khm_int64 buf);
/*! \brief Write a binary value to a configuration space
The \a value_name parameter specifies the value to write to the
configuration space. This can be either a value name or a value
path consisting of a series nested configuration space names
followed by the value name all separated by backslashes or forward
slashes.
For example: If \a conf is a handle to the configuration space \c
'A/B/C', then the value name \c 'D/E/v' refers to the value named
\c 'v' in the configuration space \c 'A/B/C/D/E'.
The specific configuration store that is used to write the value
depends on the flags that were specified in the call to
khc_open_space(). The precedence of configuration stores are as
follows:
- If KCONF_FLAG_USER was specified, then the user configuration
space.
- Otherwise, if KCONF_FLAG_MACHINE was specified, then the machine
configuration space.
Note that not specifying any of the configuration store specifiers
in the call to khc_open_space() is equivalent to specifying all
three. Also note that the schema store (KCONF_FLAG_SCHEMA) is
readonly.
\see khc_open_space()
*/
KHMEXP khm_int32 KHMAPI
khc_write_binary(khm_handle conf,
const wchar_t * value_name,
void * buf,
khm_size bufsize);
/*! \brief Get the type of a value in a configuration space
\return The return value is the type of the specified value, or
KC_NONE if the value does not exist.
*/
KHMEXP khm_int32 KHMAPI
khc_get_type(khm_handle conf, const wchar_t * value_name);
/*! \brief Check which configuration stores contain a specific value.
Each value in a configuration space can be contained in zero or
more configuration stores. Use this function to determine which
configuration stores contain the specific value.
The returned bitmask always indicates a subset of the
configuration stores that were specified when opening the
configuration space corresponding to \a conf.
\return A combination of ::KCONF_FLAG_MACHINE, ::KCONF_FLAG_USER
and ::KCONF_FLAG_SCHEMA indicating which stores contain the
value.
*/
KHMEXP khm_int32 KHMAPI
khc_value_exists(khm_handle conf, const wchar_t * value);
/*! \brief Remove a value from a configuration space
Removes a value from one or more configuration stores.
A value can exist in multiple configuration stores. Only the
values that are stored in writable stores can be removed. When
the function searches for values to remove, it will only look in
configuration stores that are specified in the handle. In
addition, the configuration stores affected can be further
narrowed by specifying them in the \a flags parameter. If \a
flags is zero, then all the stores visible to the handle are
searched. If \a flags specifies ::KCONF_FLAG_USER or
::KCONF_FLAG_MACHINE or both, then only the specified stores are
searched, provided that the stores are visible to the handle.
This function only operates on the topmost configuration space
visible to the handle. If the configuration handle is shadowed,
the shadowed configuration spaces are unaffected by the removal.
\param[in] conf Handle to configuration space to remove value from
\param[in] value_name Value to remove
\param[in] flags Specifies which configuration stores will be
affected by the removal. See above.
\retval KHM_ERROR_SUCCESS The value was removed from all the
specified configuration stores.
\retval KHM_ERROR_NOT_FOUND The value was not found.
\retval KHM_ERROR_UNKNOWN An unknown error occurred while trying
to remove the value.
\retval KHM_ERROR_PARTIAL The value was successfully removed from
one or more stores, but the operation failed on one or more
other stores.
*/
KHMEXP khm_int32 KHMAPI
khc_remove_value(khm_handle conf, const wchar_t * value_name, khm_int32 flags);
/*! \brief Get the name of a configuration space
\param[in] conf Handle to a configuration space
\param[out] buf The buffer to receive the name. Set to NULL if
only the size of the buffer is required.
\param[in,out] bufsize On entry, holds the size of the buffer
pointed to by \a buf. On exit, holds the number of bytes
copied into the buffer including the NULL terminator.
*/
KHMEXP khm_int32 KHMAPI
khc_get_config_space_name(khm_handle conf,
wchar_t * buf,
khm_size * bufsize);
/*! \brief Get a handle to the parent space
\param[in] conf Handle to a configuration space
\param[out] parent Handle to the parent configuration space if the
call succeeds. Receives NULL otherwise. The returned handle
must be closed using khc_close_space()
*/
KHMEXP khm_int32 KHMAPI
khc_get_config_space_parent(khm_handle conf,
khm_handle * parent);
/*! \brief Load a configuration schema into the specified configuration space
\param[in] conf Handle to a configuration space or NULL to use the
root configuration space.
\param[in] schema The schema to load. The schema is assumed to be
well formed.
\see khc_unload_schema()
*/
KHMEXP khm_int32 KHMAPI
khc_load_schema(khm_handle conf,
const kconf_schema * schema);
/*! \brief Unload a schema from a configuration space
*/
KHMEXP khm_int32 KHMAPI
khc_unload_schema(khm_handle conf,
const kconf_schema * schema);
/*! \brief Enumerate the subspaces of a configuration space
Prepares a configuration space for enumeration and returns the
child spaces in no particular order.
\param[in] conf The configuration space to enumerate child spaces
\param[in] prev The previous configuration space returned by
khc_enum_subspaces() or NULL if this is the first call. If
this is not NULL, then the handle passed in \a prev will be
freed.
\param[out] next If \a prev was NULL, receives the first sub space
found in \a conf. You must \b either call
khc_enum_subspaces() again with the returned handle or call
khc_close_space() to free the returned handle if no more
subspaces are required. \a next can point to the same handle
specified in \a prev.
\retval KHM_ERROR_SUCCESS The call succeeded. There is a valid
handle to a configuration space in \a first_subspace.
\retval KHM_ERROR_INVALID_PARAM Either \a conf or \a prev was not a
valid configuration space handle or \a first_subspace is NULL.
Note that \a prev can be NULL.
\retval KHM_ERROR_NOT_FOUND There were no subspaces in the
configuration space pointed to by \a conf.
\note The configuration spaces that are enumerated directly belong
to the configuration space given by \a conf. This function
does not enumerate subspaces of shadowed configuration spaces
(see khc_shadow_space()). Even if \a conf was obtained on a
restricted domain (i.e. you specified one or more
configuration stores when you openend the handle and didn't
include all the configuration stores. See khc_open_space()),
the subspaces that are returned are the union of all
configuration spaces in all the configuration stores. This is
not a bug. This is a feature. In NetIDMgr, a configuartion
space exists if some configuration store defines it (or it was
created with a call to khc_open_space() even if no
configuration store defines it yet). This is the tradeoff you
make when using a layered configuration system.
However, the returned handle has the same domain restrictions
as \a conf.
*/
KHMEXP khm_int32 KHMAPI
khc_enum_subspaces(khm_handle conf,
khm_handle prev,
khm_handle * next);
/*! \brief Remove a configuration space
The configuration space will be marked for removal. Once all the
handles for the space have been released, it will be deleted. The
configuration stores that will be affected are the write enabled
configuration stores for the handle.
*/
KHMEXP khm_int32 KHMAPI
khc_remove_space(khm_handle conf);
/*@}*/
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,160 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_ACTIONDEF_H
#define __KHIMAIRA_ACTIONDEF_H
/*! \ingroup khui_actions
@{*/
/*! \defgroup khui_std_actions Standard Actions
@{ */
/*!\name Standard actions
@{*/
#define KHUI_ACTION_BASE 50000
#define KHUI_ACTION_PROPERTIES (KHUI_ACTION_BASE + 0)
#define KHUI_ACTION_EXIT (KHUI_ACTION_BASE + 1)
#define KHUI_ACTION_SET_DEF_ID (KHUI_ACTION_BASE + 3)
#define KHUI_ACTION_SET_SRCH_ID (KHUI_ACTION_BASE + 4)
#define KHUI_ACTION_PASSWD_ID (KHUI_ACTION_BASE + 7)
#define KHUI_ACTION_NEW_CRED (KHUI_ACTION_BASE + 8)
#define KHUI_ACTION_DEBUG_WINDOW (KHUI_ACTION_BASE + 10)
#define KHUI_ACTION_VIEW_REFRESH (KHUI_ACTION_BASE + 11)
#define KHUI_ACTION_LAYOUT_ID (KHUI_ACTION_BASE + 12)
#define KHUI_ACTION_LAYOUT_TYPE (KHUI_ACTION_BASE + 13)
#define KHUI_ACTION_LAYOUT_LOC (KHUI_ACTION_BASE + 14)
#define KHUI_ACTION_TB_STANDARD (KHUI_ACTION_BASE + 15)
#define KHUI_ACTION_OPT_KHIM (KHUI_ACTION_BASE + 16)
#define KHUI_ACTION_OPT_IDENTS (KHUI_ACTION_BASE + 17)
#define KHUI_ACTION_OPT_NOTIF (KHUI_ACTION_BASE + 18)
#define KHUI_ACTION_HELP_CTX (KHUI_ACTION_BASE + 19)
#define KHUI_ACTION_HELP_CONTENTS (KHUI_ACTION_BASE + 20)
#define KHUI_ACTION_HELP_INDEX (KHUI_ACTION_BASE + 21)
#define KHUI_ACTION_HELP_ABOUT (KHUI_ACTION_BASE + 22)
#define KHUI_ACTION_DESTROY_CRED (KHUI_ACTION_BASE + 23)
#define KHUI_ACTION_RENEW_CRED (KHUI_ACTION_BASE + 24)
#define KHUI_ACTION_OPEN_APP (KHUI_ACTION_BASE + 25)
#define KHUI_ACTION_MENU_ACTIVATE (KHUI_ACTION_BASE + 26)
#define KHUI_ACTION_CLOSE_APP (KHUI_ACTION_BASE + 27)
#define KHUI_ACTION_IMPORT (KHUI_ACTION_BASE + 28)
#define KHUI_ACTION_OPT_PLUGINS (KHUI_ACTION_BASE + 29)
#define KHUI_ACTION_LAYOUT_CUST (KHUI_ACTION_BASE + 30)
#define KHUI_ACTION_OPT_APPEAR (KHUI_ACTION_BASE + 31)
#define KHUI_ACTION_LAYOUT_RELOAD (KHUI_ACTION_BASE + 32)
/*@}*/
/*! \name Pseudo actions
Pseudo actions do not trigger any specific function, but acts as a
signal of some generic event which will be interpreted based on
context.
@{*/
#define KHUI_PACTION_BASE (KHUI_ACTION_BASE + 500)
#define KHUI_PACTION_MENU (KHUI_PACTION_BASE + 0)
#define KHUI_PACTION_UP (KHUI_PACTION_BASE + 1)
#define KHUI_PACTION_DOWN (KHUI_PACTION_BASE + 2)
#define KHUI_PACTION_LEFT (KHUI_PACTION_BASE + 3)
#define KHUI_PACTION_RIGHT (KHUI_PACTION_BASE + 4)
#define KHUI_PACTION_ENTER (KHUI_PACTION_BASE + 5)
#define KHUI_PACTION_ESC (KHUI_PACTION_BASE + 6)
#define KHUI_PACTION_OK (KHUI_PACTION_BASE + 7)
#define KHUI_PACTION_CANCEL (KHUI_PACTION_BASE + 8)
#define KHUI_PACTION_CLOSE (KHUI_PACTION_BASE + 9)
#define KHUI_PACTION_DELETE (KHUI_PACTION_BASE + 10)
#define KHUI_PACTION_UP_EXTEND (KHUI_PACTION_BASE + 11)
#define KHUI_PACTION_UP_TOGGLE (KHUI_PACTION_BASE + 12)
#define KHUI_PACTION_DOWN_EXTEND (KHUI_PACTION_BASE + 13)
#define KHUI_PACTION_DOWN_TOGGLE (KHUI_PACTION_BASE + 14)
#define KHUI_PACTION_BLANK (KHUI_PACTION_BASE + 15)
#define KHUI_PACTION_NEXT (KHUI_PACTION_BASE + 16)
#define KHUI_PACTION_SELALL (KHUI_PACTION_BASE + 17)
#define KHUI_PACTION_YES (KHUI_PACTION_BASE + 18)
#define KHUI_PACTION_NO (KHUI_PACTION_BASE + 19)
#define KHUI_PACTION_YESALL (KHUI_PACTION_BASE + 20)
#define KHUI_PACTION_NOALL (KHUI_PACTION_BASE + 21)
#define KHUI_PACTION_REMOVE (KHUI_PACTION_BASE + 22)
#define KHUI_PACTION_KEEP (KHUI_PACTION_BASE + 23)
#define KHUI_PACTION_DISCARD (KHUI_PACTION_BASE + 24)
#define KHUI_PACTION_PGDN (KHUI_PACTION_BASE + 25)
#define KHUI_PACTION_PGUP (KHUI_PACTION_BASE + 26)
#define KHUI_PACTION_PGUP_EXTEND (KHUI_PACTION_BASE + 27)
#define KHUI_PACTION_PGDN_EXTEND (KHUI_PACTION_BASE + 28)
/*@}*/
/*! \name Menus
Stock menus.
@{*/
#define KHUI_MENU_BASE (KHUI_ACTION_BASE + 1000)
#define KHUI_MENU_MAIN (KHUI_MENU_BASE + 0)
#define KHUI_MENU_FILE (KHUI_MENU_BASE + 1)
#define KHUI_MENU_CRED (KHUI_MENU_BASE + 2)
#define KHUI_MENU_VIEW (KHUI_MENU_BASE + 3)
#define KHUI_MENU_OPTIONS (KHUI_MENU_BASE + 4)
#define KHUI_MENU_HELP (KHUI_MENU_BASE + 5)
#define KHUI_MENU_LAYOUT (KHUI_MENU_BASE + 6)
#define KHUI_MENU_TOOLBARS (KHUI_MENU_BASE + 7)
#define KHUI_MENU_IDENT_CTX (KHUI_MENU_BASE + 8)
#define KHUI_MENU_TOK_CTX (KHUI_MENU_BASE + 9)
#define KHUI_MENU_ICO_CTX_MIN (KHUI_MENU_BASE + 12)
#define KHUI_MENU_ICO_CTX_NORMAL (KHUI_MENU_BASE + 13)
#define KHUI_MENU_CWHEADER_CTX (KHUI_MENU_BASE + 14)
#define KHUI_MENU_COLUMNS (KHUI_MENU_BASE + 15)
#define KHUI_PMENU_TOK_SEL (KHUI_MENU_BASE + 10)
#define KHUI_PMENU_ID_SEL (KHUI_MENU_BASE + 11)
/* Next menu: 14 */
/*@}*/
/*! \name Toolbars
@{*/
#define KHUI_TOOLBAR_BASE (KHUI_ACTION_BASE + 2000)
#define KHUI_TOOLBAR_STANDARD (KHUI_TOOLBAR_BASE + 0)
/*@}*/
/*! \brief Base for user actions
When creating new actions, the UI library will allocate command
identifiers starting with this one.
*/
#define KHUI_USERACTION_BASE (KHUI_ACTION_BASE + 10000)
/*! \brief Does this command represent a user action? */
#define IS_USERACTION(cmd) ((cmd) >= KHUI_USERACTION_BASE)
/*@}*/
/*@}*/
#endif

View File

@ -0,0 +1,398 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHALERTS_H
#define __KHIMAIRA_KHALERTS_H
/*********************************************************************
Alerter and error reporting
**********************************************************************/
/*! \addtogroup khui
@{ */
/*!\defgroup khui_alert Alerter and Error Reporting
@{*/
#define KHUI_MAX_ALERT_COMMANDS 4
/*! \brief An alert
Describes an alert message that will be shown to the user in a
variety of ways depending on the state of the NetIDMgr
application.
*/
typedef struct tag_khui_alert {
khm_int32 magic; /*!< Magic number. Always set to
KHUI_ALERT_MAGIC */
khm_int32 severity; /*!< The severity of the alert. One
of KHERR_ERROR, KHERR_WARNING or
KHERR_INFO. The default is
KHERR_INFO. Do not set directly.
Use khui_alert_set_severity(). */
khm_int32 alert_commands[KHUI_MAX_ALERT_COMMANDS];
/*!< The command buttons associated
with the alert. Use
khui_alert_add_command() to add a
command. The buttons will appear in
the order in which they were added.
The first button will be the
default. Each command should be a
known action identifier. */
khm_int32 n_alert_commands;
wchar_t * title; /*!< The title of the alert. Subject
to ::KHUI_MAXCCH_TITLE. Use
khui_alert_set_title() to set. Do
not modify directly. */
wchar_t * message; /*!< The main message of the alert.
Subject to ::KHUI_MAXCCH_MESSAGE.
Use khui_alert_set_message() to
set. Do not modify direcly. */
wchar_t * suggestion; /*!< A suggestion. Appears below
the message text. Use
khui_alert_set_suggestion() to
set. Do not modify directly. */
#ifdef _WIN32
POINT target;
#endif
khm_int32 flags; /*!< combination of
::khui_alert_flags. Do not modify
directly. */
kherr_context * err_context;
/*!< If non-NULL at the time the alert
window is shown, this indicates that
the alert window should provide an
error viewer for the given error
context. */
kherr_event * err_event;
/*!< If non-NULL at the time the alert
window is shown, this indicates that
the alert window should provide an
error viewer for the given error
event. If an \a err_context is also
given, the error viewer for the
context will be below this error. */
khm_int32 response;
/*!< Once the alert is displayed to
the user, when the user clicks one
of the command buttons, the command
ID will be assigned here. */
int refcount; /* internal */
LDCL(struct tag_khui_alert); /* internal */
} khui_alert;
#define KHUI_ALERT_MAGIC 0x48c39ce9
/*! \brief Maximum number of characters in title including terminating NULL
*/
#define KHUI_MAXCCH_TITLE 256
/*! \brief Maximum number of bytes in title including terminating NULL
*/
#define KHUI_MAXCB_TITLE (KHUI_MAXCCH_TITLE * sizeof(wchar_t))
/*! \brief Maximum number of characters in message including terminating NULL
*/
#define KHUI_MAXCCH_MESSAGE 1024
/*! \brief Maximum number of bytes in message including terminating NULL
*/
#define KHUI_MAXCB_MESSAGE (KHUI_MAXCCH_MESSAGE * sizeof(wchar_t))
/*! \brief Maxumum number of characters in a suggestion including terminating NULL */
#define KHUI_MAXCCH_SUGGESTION 1024
/*! \brief Maximum number of bytes in a suggestion, including terminating NULL */
#define KHUI_MAXCB_SUGGESTION (KHUI_MAXCCH_SUGGESTION * sizeof(wchar_t))
/*! \brief Flags for an alert */
enum khui_alert_flags {
KHUI_ALERT_FLAG_FREE_STRUCT =0x00000001,
/*!< Internal. Free the structure once the alert is done. */
KHUI_ALERT_FLAG_FREE_TITLE =0x00000002,
/*!< Internal. Free the \a title field when the alert is done.*/
KHUI_ALERT_FLAG_FREE_MESSAGE =0x00000004,
/*!< Internal. Free the \a message field when the alert is done. */
KHUI_ALERT_FLAG_FREE_SUGGEST =0x00000008,
/*!< Internal. Free the \a suggest field when the alert is done */
KHUI_ALERT_FLAG_DEFACTION =0x00000010,
/*!< If the message is displayed as a balloon prompt, then perform
the default action when it is clicked. The default action is
the first action added to the alert. Cannot be used if there
are no actions or if ::KHUI_ALERT_FLAG_REQUEST_WINDOW is
specified.*/
KHUI_ALERT_FLAG_VALID_TARGET =0x00010000,
/*!< There is a valid target for the alert */
KHUI_ALERT_FLAG_VALID_ERROR =0x00020000,
/*!< There is a valid error context associated with the alert */
KHUI_ALERT_FLAG_DISPLAY_WINDOW =0x01000000,
/*!< The alert has been displayed in a window */
KHUI_ALERT_FLAG_DISPLAY_BALLOON =0x02000000,
/*!< The alert has been displayed in a ballon */
KHUI_ALERT_FLAG_REQUEST_WINDOW =0x04000000,
/*!< The alert should be displayed in a window */
KHUI_ALERT_FLAG_REQUEST_BALLOON =0x08000000,
/*!< The alert should be displayed in a balloon */
KHUI_ALERT_FLAG_MODAL =0x10000000,
/*!< Modal alert. Do not set direclty. */
KHUI_ALERT_FLAGMASK_RDWR =0x0C000010,
/*!< Bit mask of flags that can be set by khui_alert_set_flags() */
};
/*! \brief Create an empty alert object
The returned result is a held pointer to a ::khui_alert object.
Use khui_alert_release() to release the object.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_create_empty(khui_alert ** result);
/*! \brief Create a simple alert object
The returned result is a held pointer to a ::khui_alert object.
Use khui_alert_release() to release the object.
\param[in] title The title of the alert. (Required, Localized)
Limited by ::KHUI_MAXCCH_TITLE.
\param[in] message The message. (Required. Localized). Limited
by ::KHUI_MAXCCH_MESSAGE.
\param[in] severity One of ::tag_kherr_severity
\param[out] result Receives a held pointer to a ::khui_alert
object upon successful completion.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_create_simple(const wchar_t * title,
const wchar_t * message,
khm_int32 severity,
khui_alert ** result);
/*! \brief Set the title of an alert object
The title is limited by ::KHUI_MAXCCH_TITLE.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_set_title(khui_alert * alert,
const wchar_t * title);
/*! \brief Set the message of an alert object
The message is limited by ::KHUI_MAXCCH_MESSAGE.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_set_message(khui_alert * alert,
const wchar_t * message);
/*! \brief Set the suggestion of an alert object
The suggestion is limited by ::KHUI_MAXCCH_SUGGESTION
*/
KHMEXP khm_int32 KHMAPI
khui_alert_set_suggestion(khui_alert * alert,
const wchar_t * suggestion);
/*! \brief Set the severity of the alert object
The severity value is one of ::tag_kherr_severity
*/
KHMEXP khm_int32 KHMAPI
khui_alert_set_severity(khui_alert * alert,
khm_int32 severity);
/*! \brief Sets the flags of the alert
The flags are as defined in ::khui_alert_flags. The bits that are
on in \a mask will be set to the corresponding values in \a flags.
Only the bits specified in ::KHUI_ALERT_FLAGMASK_RDWR can be
specified in \a mask.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_set_flags(khui_alert * alert, khm_int32 mask, khm_int32 flags);
/*! \brief Clear all the commands from an alert object
\see khui_alert_add_command()
*/
KHMEXP khm_int32 KHMAPI
khui_alert_clear_commands(khui_alert * alert);
/*! \brief Add a command to an alert object
The command ID should be a valid registered command.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_add_command(khui_alert * alert,
khm_int32 command_id);
/*! \brief Display an alert
The alert must have a valid \a severity, \a title and a \a message
to be displayed. Otherwise the function immediately returns with
a failure code.
The method used to display the alert is as follows:
- A balloon alert will be shown if one of the following is true:
- The NetIDMgr application is minimized or in the background.
- ::KHUI_ALERT_FLAG_REQUEST_BALLOON is specified in \a flags.
- Otherwise an alert window will be shown.
If the message, title of the alert is too long to fit in a balloon
prompt, there's a suggestion or if there are custom commands then
a placeholder balloon prompt will be shown which when clicked on,
shows the actual alert in an alert window.
An exception is when ::KHUI_ALERT_FLAG_DEFACTION is specified in
flags. In this case instead of a placeholder balloon prompt, one
will be shown with the actual title and message (truncated if
necessary). Clicking on the balloon will have the same effect as
choosing the first command in the action.
The placeholder balloon prompt will have a title derived from the
first 63 characters of the \a title field in the alert and a
message notifying the user that they should click the balloon
prompt for more information.
To this end, it is beneficial to limit the length of the title to
63 characters (64 counting the terminating NULL). This limit is
enforced on Windows. Also, try to make the title descriptive.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_show(khui_alert * alert);
/*! \brief Display a modal alert
Similar to khui_alert_show(), but shows a modal alert dialog. The
function does not return until the user has closed the alert.
This function always opens an alert window (never shows a
balloon).
\note Should only be called from the UI thread.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_show_modal(khui_alert * alert);
/*! \brief Queue an alert
Instead of displaying the alert immediately, the alert is queued
and the status bar updated to notify the user that there is a
pending alert. Once the user activates the pending alert, it will
be displayed as if khui_alert_show() was called.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_queue(khui_alert * alert);
/*! \brief Display a simple alert
\see khui_alert_show()
*/
KHMEXP khm_int32 KHMAPI
khui_alert_show_simple(const wchar_t * title,
const wchar_t * message,
khm_int32 severity);
/*! \brief Obtain a hold on the alert
An alert structure is only considered valid for the duration that
there is a hold on it.
Use khui_alert_release() to release the hold.
*/
KHMEXP khm_int32 KHMAPI
khui_alert_hold(khui_alert * alert);
/*! \brief Release the hold on the alert
Holds obtained on an alert using any of the functions that either
return a held pointer to an alert or implicitly obtains a hold on
it need to be undone through a call to khui_alert_release().
*/
KHMEXP khm_int32 KHMAPI
khui_alert_release(khui_alert * alert);
/*! \brief Lock an alert
Locking an alert disallows any other thread from accessing the
alert at the same time. NetIDMgr keeps a global list of all alert
objects and the user interface may access any of them at various
points in time. Locking the alert allows a thread to modify an
alert without causing another thread to be exposed to an
inconsistent state.
Once a thread obtains a lock on the alert, it must call
khui_alert_unlock() to unlock it. Otherwise no other thread will
be able to access the alert.
\note Currently the alert lock is global. Locking one alert
disallows access to all other alerts as well.
\note Calling khui_alert_lock() is only necessary if you are
modifying the ::khui_alert structure directly. Calling any of
the khui_alert_* functions to modify the alert does not
require obtaining a lock, as they perform synchronization
internally.
*/
KHMEXP void KHMAPI
khui_alert_lock(khui_alert * alert);
/*! \brief Unlock an alert
\see khui_alert_lock()
*/
KHMEXP void KHMAPI
khui_alert_unlock(khui_alert * alert);
/*!@}*/
/*!@}*/
#endif

View File

@ -0,0 +1,616 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHCONFIGUI_H
#define __KHIMAIRA_KHCONFIGUI_H
/*! \addtogroup khui
@{ */
/*! \defgroup khui_cfg Configuration Panels
Configuration panels are the primary means from which the user is
presented with an interface to change NetIDMgr and plugin
configuration.
@{ */
/*! \brief Configuration window notification message
This is the message that will be used to notify dialog panels.
The format of the message is :
- uMsg : KHUI_WM_CFG_NOTIFY
- HIWORD(wParam) : one of ::khui_wm_cfg_notifications
\note This is the same as ::KHUI_WM_NC_NOTIFY
*/
#define KHUI_WM_CFG_NOTIFY (WM_APP + 0x101)
/*! \brief Configuration notifications
These are sent thorugh a ::KHUI_WM_CFG_NOTIFY message.
The format of the message is :
- uMsg : KHUI_WM_CFG_NOTIFY
- HIWORD(wParam) : one of ::khui_wm_cfg_notifications
*/
enum khui_wm_cfg_notifications {
WMCFG_SHOW_NODE = 1,
/*!< Sent to the configuration dialog to request that the panel
for the specified node be shown. The \a lParam message
parameter will contain a held ::khui_config_node handle. The
sender of the mssage is responsible for releasing the handle.*/
WMCFG_UPDATE_STATE = 2,
/*!< Sent to the configuration dialog to indicate that the state
flags for the specified configuration node have changed.
- LOWORD(wParam) : new flags
- lParam : ::khui_config_node for the node*/
WMCFG_APPLY = 3,
/*!< Sent to all the configuration panels when the user clicks the
'Apply' button or the 'Ok' button. The panels are responsible
for applying the configuration changes and updating their flags
using khui_cfg_set_flags(). */
WMCFG_SYNC_NODE_LIST = 4,
/*!< Sent from the UI library to the configuration window to
notify the window that the node list has changed. This message
is sent synchronously before the node is removed. */
};
/*! \brief Registration information for a configuration node
\see khui_cfg_register_node()
*/
typedef struct tag_khui_config_node_reg {
const wchar_t * name; /*!< Internal identifier
(not-localized, required). The name
is required to be unique among
sibling nodes. However it is not
required to be unique globally. The
size of the name is constrained by
::KHUI_MAXCCH_NAME*/
const wchar_t * short_desc; /*!< Short description (Localized,
required). This is the name which
identifies the node within a
collection of siblings. The size of
the string is constrained by
::KHUI_MAXCCH_SHORT_DESC*/
const wchar_t * long_desc; /*!< Global name of the node.
(Localized, required). This
uniquely identifies the node in the
collection of all configuration
nodes. The size of the string is
constrained by
::KHUI_MAXCCH_LONG_DESC.*/
HMODULE h_module; /*!< Module which contains the dialog
resource specified in \a
dlg_template */
LPWSTR dlg_template; /*!< Dialog template for the
configuration window */
DLGPROC dlg_proc; /*!< Dialog procedure */
khm_int32 flags; /*!< Flags. Can be a combination of
::KHUI_CNFLAG_SORT_CHILDREN and
::KHUI_CNFLAG_SUBPANEL*/
} khui_config_node_reg;
/*! \brief Sort the child nodes by short description */
#define KHUI_CNFLAG_SORT_CHILDREN 0x0001
/*! \brief Is a subpanel */
#define KHUI_CNFLAG_SUBPANEL 0x0002
/*! \brief Node represents a panel that is replicated for all child nodes */
#define KHUI_CNFLAG_PLURAL 0x0004
/*! \brief System node
\note For internal use by the NetIDMgr application. Do not use.
*/
#define KHUI_CNFLAG_SYSTEM 0x0010
#define KHUI_CNFLAG_MODIFIED 0x0100
#define KHUI_CNFLAG_APPLIED 0x0200
#define KHUI_CNFLAGMASK_STATIC 0x00ff
#define KHUI_CNFLAGMASK_DYNAMIC 0x0f00
/*! \brief Maximum length of the name in characters
The length includes the terminating NULL
*/
#define KHUI_MAXCCH_NAME 256
/*! \brief Maximum length of the name in bytes
The length includes the terminating NULL
*/
#define KHUI_MAXCB_NAME (KHUI_MAXCCH_NAME * sizeof(wchar_t))
/*! \brief Maximum length of the long description in characters
The length includes the terminating NULL
*/
#define KHUI_MAXCCH_LONG_DESC 1024
/*! \brief Maximum length of the long description in bytes
The length includes the terminating NULL
*/
#define KHUI_MAXCB_LONG_DESC (KHUI_MAXCCH_LONG_DESC * sizeof(wchar_t))
/*! \brief Maximum length of the short description in chracters
The length includes the terminating NULL
*/
#define KHUI_MAXCCH_SHORT_DESC 256
/*! \brief Maximum length of the short description in bytes
The length includes the terminating NULL
*/
#define KHUI_MAXCB_SHORT_DESC (KHUI_MAXCCH_SHORT_DESC * sizeof(wchar_t))
/*! \brief Width of a configuration dialog in dialog units
::CFGDLG_WIDTH and ::CFGDLG_HEIGHT specify the dimensions of a
configuration dialog width and height in dialog units. The dialog
will be created as a child of the configuration dialog and placed
within it.
*/
#define CFGDLG_WIDTH 255
/*! \brief Height of a configuration dialog in dialog units
\see ::CFGDLG_WIDTH
*/
#define CFGDLG_HEIGHT 182
/*! \brief Width of a configuration tab dialog in dialog units
::CFGDLG_TAB_WIDTH and ::CFGDLG_TAB_HEIGHT specify the dimensions
(in dialog units) of a dialog that will be placed within a tab
control for dialogs where multiple display panels need to be
shown.
*/
#define CFGDLG_TAB_WIDTH 235
/*! \brief Height of configuration tab dialog in dialog units
\see ::CFGDLG_TAB_WIDTH
*/
#define CFGDLG_TAB_HEIGHT 151
/*! \brief A handle to a configuration node
\see khui_cfg_open_node(), khui_cfg_close_node()
*/
typedef khm_handle khui_config_node;
/*! \brief Initialization data passed in to a subpanel
When creating a subpanel, a pointer to the following strucutred
will be passed in as the creation parameter for the dialog.
*/
typedef struct tag_khui_config_init_data {
khui_config_node ctx_node; /*!< The node under which the current
dialog subpanel is being created. */
khui_config_node this_node; /*!< The node which provided the
registration information for the
creation of the subpanel. */
khui_config_node ref_node; /*!< The parent node of the subpanel
node. In nodes which have the
::KHUI_CNFLAG_PLURAL, this would be
different from the \a node. This is
the node under which the subpanel
was registered. */
} khui_config_init_data;
/*! \brief Register a configuration node
The caller fills the registration information in the
::khui_config_node_reg structre. If the call succeeds, the
function will return KHM_ERROR_SUCCESS.
\param[in] parent Parent of the node to be registered. Set to
NULL if the parent is the root node.
\param[in] reg Registration information
\param[out] new_id Receives the new unique identifier of the
configuration node. Pass in NULL if the new identifier is not
required.
\retval KHM_ERROR_SUCCESS Success
\retval KHM_ERROR_INVALID_PARAM One or more parameters, or fields
of reg were invalid
\retval KHM_ERROR_DUPLICATE A node with the same name exists as a
child of the specified parent node.
\note The name (not the short or long description) of the node can
not be the same as the name of a custom action. See
khui_action_create().
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_register(khui_config_node parent,
const khui_config_node_reg * reg);
/*!\brief Open a configuration node by name
If successful, the \a result parameter will receive a handle to
the configuration node. Use khui_cfg_release() to release
the handle.
\param[in] parent Parent node. Set to NULL to specify root node.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_open(khui_config_node parent,
const wchar_t * name,
khui_config_node * result);
/*! \brief Remove a configuration node
Marks a configuration node as deleted. Once all the handles,
including the handle specified in \a node have been released, it
will be deleted.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_remove(khui_config_node node);
/*! \brief Hold a handle to a configuration node
Obtains an additional hold on the handle specified by \a node.
The hold must be released with a call to \a
khui_cfg_release()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_hold(khui_config_node node);
/*! \brief Release a handle to a configuration node
\see khui_cfg_hold()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_release(khui_config_node node);
/*! \brief Get the parent of a node
Returns a held handle to the parent of the node, or NULL if the
current node is a top level node. The returned handle must be
released with khui_cfg_release().
\retval KHM_ERROR_SUCCESS The handle to the parent node is in \a result
\retval KHM_ERROR_NOT_FOUND The node is a top level node
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_parent(khui_config_node vnode,
khui_config_node * result);
/*! \brief Get a handle to the first child node
If the call is successful, \a result will receieve a handle to the
first child node of the specified node. The returned handle must
be released with a call to khui_cfg_release()
If \a parent does not have any child nodes, the function will
return KHM_ERROR_NOT_FOUND and set \a result to NULL.
\param[in] parent Parent node. Set to NULL to specify root node.
\param[out] result Receives a held handle to the first child node.
\see khui_cfg_get_next()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_first_child(khui_config_node parent,
khui_config_node * result);
/*! \brief Get a handle to the first subpanel
If the call is successful, \a result will receieve a handle to the
first subpanel node of the specified node. The returned handle
must be released with a call to khui_cfg_release()
If \a parent does not have any subpanels, the function will return
KHM_ERROR_NOT_FOUND and set \a result to NULL.
A subpanel node is a node which has the ::KHUI_CNFLAG_SUBPANEL
flag set.
\param[in] parent Parent node. Set to NULL to specify root node.
\param[out] result Receives a held handle to the first subpanel node.
\see khui_cfg_get_next()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_first_subpanel(khui_config_node vparent,
khui_config_node * result);
/*! \brief Get a handle to the next sibling node
If the call is successful, \a result will receive a held handle to
the next sibling node. The returned handle must be released with
a call to khui_cfg_release().
If there are no more sibling nodes, then the function return
KHM_ERROR_NOT_FOUND and set \a result to NULL.
This function can be used to traverse a list of child nodes as
well as a list of subpanel nodes.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_next(khui_config_node node,
khui_config_node * result);
/*! \brief Get a handle to the next sibling node
Similar to khui_cfg_get_next(), but implicitly releases the handle
that was supplied. Equivalent to doing :
\code
khui_cfg_get_next(node, &next);
khui_cfg_release(node);
node = next;
\endcode
\param[in,out] node On entry, specifies the node whose sibling
needs to be fetched. On exit, will have either NULL or a held
handle to the sibling node. The handle which was supplied to
the function is released.
\retval KHM_ERROR_SUCCESS The next node is now in \a node
\retval KHM_ERROR_INVALID_PARAM \a node was not a valid handle
\retval KHM_ERROR_NOT_FOUND There are no more siblings. \a node
is set to NULL.
\note Even if there are no more siblings, the handle specified in
\a node on entry is released.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_next_release(khui_config_node * node);
/*! \brief Get the name of a configuration node
Gets the name (not the short description or the long description)
of the given configuration node.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_name(khui_config_node node,
wchar_t * buf,
khm_size * cb_buf);
/*! \brief Get registration information for a node
The registration information that is returned is a shallow copy of
the data kept by NetIDMgr. In particular, the strings that will
be returned actually point to internal buffers and should not be
modified.
No further action is necessary to release the information.
However, the returned data ceases to be valid when \a node is
released with a call to khui_cfg_release().
\param[in] node Node for which information is requested. Can be NULL if requesting information about the root node.
\param[out] reg Pointer to a ::khui_config_node_reg structure.
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_reg(khui_config_node node,
khui_config_node_reg * reg);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP HWND KHMAPI
khui_cfg_get_hwnd_inst(khui_config_node node,
khui_config_node noderef);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP LPARAM KHMAPI
khui_cfg_get_param_inst(khui_config_node node,
khui_config_node noderef);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_set_hwnd_inst(khui_config_node node,
khui_config_node noderef,
HWND hwnd);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_set_param_inst(khui_config_node node,
khui_config_node noderef,
LPARAM param);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP HWND KHMAPI
khui_cfg_get_hwnd(khui_config_node node);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP LPARAM KHMAPI
khui_cfg_get_param(khui_config_node node);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_set_hwnd(khui_config_node node, HWND hwnd);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_set_param(khui_config_node node, LPARAM param);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_clear_params(void);
/*! \brief Internal use
This function is used internally by NetIDMgr. Do not use.
*/
KHMEXP void KHMAPI
khui_cfg_set_configui_handle(HWND hwnd);
/*! \brief Update the state for the specified node
\param[in] node ::khui_config_node handle for the configuration node.
\param[in] flags New flags. Combination of ::KHUI_CNFLAG_APPLIED and ::KHUI_CNFLAG_MODIFIED
\param[in] mask Valid bits in \a flags
\note Should only be called from within the dialog procedure for
the configuration node.
*/
KHMEXP void KHMAPI
khui_cfg_set_flags(khui_config_node vnode, khm_int32 flags, khm_int32 mask);
/*! \brief Retrieve the state flags for the configuration node
\see khui_cfg_set_flags()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_flags(khui_config_node vnode);
/*! \brief Utility function: Initialize dialog box window data
This function initializes the dialog box window data using the
::khui_config_init_data that was passed into the WM_INITDIALOG
message.
A new block of memory will be alocated to store the dialog data as
well as any extra space specified. A pointer to this memory block
will be stored in the \a DWLP_USER slot in the dialog box.
The allocated block of memory must be freed by a call to
khui_cfg_free_dialog_data(). While handling other messages, the
dialog data can be retrieved using khui_cfg_get_dialog_data().
\param[in] hwnd_dlg Handle to the dialog box
\param[in] data Pointer to the ::khui_config_init_data that was
passed in to WM_INITDIALOG (this is the value of \a lParam)
\param[in] cb_extra Number of extra bytes to allocate, along with
the space required to store the contents of
::khui_config_init_data. The extra space will be initialized
to zero.
\param[out] new_data Receives a pointer to the copy of the
initialization data that was allocated. Optional. Pass in
NULL if this value is not required.
\param[out] extra Receives a pointer to the block of extra memory
allocated as specified in \a cb_extra. If \a cb_extra is 0,
then this receives a NULL.
\see khui_cfg_get_dialog_data(), khui_cfg_free_dialog_data()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_init_dialog_data(HWND hwnd_dlg,
const khui_config_init_data * data,
khm_size cb_extra,
khui_config_init_data ** new_data,
void ** extra);
/*! \brief Utility function: Retrieves dialog data
Retrieves the dialog data previoulsy stored using
khui_cfg_init_dialog_data().
\param[in] hwnd_dlg Handle to the dialog box
\param[out] data Receives a pointer to the ::khui_config_init_data
block.
\param[out] extra Receives a pointer to the extra memory
allocated. Optional (set to NULL if this value is not needed).
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_get_dialog_data(HWND hwnd_dlg,
khui_config_init_data ** data,
void ** extra);
/*! \brief Utility function: Free dialog data
Deallocates the memory allcated in a previous call to
khui_cfg_init_dialog_data()
*/
KHMEXP khm_int32 KHMAPI
khui_cfg_free_dialog_data(HWND hwnd_dlg);
/*! \brief Sets the instance flags for a subpanel
Since there can be more than one subpanel in a configuration
panel, they shouldn't modify the flags of the configuration node
directly. Instead, they should call this function to set the
instance flags.
The instance flags will be merged with the flags for the
configuration node automatically.
*/
KHMEXP void KHMAPI
khui_cfg_set_flags_inst(khui_config_init_data * d,
khm_int32 flags,
khm_int32 mask);
/*!@} */
/*!@} */
#endif

View File

@ -0,0 +1,235 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHDEFS_H__
#define __KHIMAIRA_KHDEFS_H__
/*! \defgroup khdef Core definitions
Key type definitions used throughout NetIDMgr.
*/
/*@{*/
#include<stddef.h>
#include<limits.h>
#include<wchar.h>
/*!\typedef khm_octet
\brief A byte (8 bit unsigned)*/
/*!\typedef khm_int16
\brief A signed 16 bit quantity */
/*!\typedef khm_ui_2
\brief An unsigned 16 bit quantity */
/*!\typedef khm_int32
\brief A signed 32 bit quantity */
/*!\typedef khm_ui_4
\brief An unsigned 32 bit quantity */
/*!\typedef khm_int64
\brief A signed 64 bit quantity */
/*!\typedef khm_ui_8
\brief An unsigned 64 bit quantity */
typedef unsigned __int8 khm_octet;
typedef __int16 khm_int16;
typedef unsigned __int16 khm_ui_2;
typedef __int32 khm_int32;
typedef unsigned __int32 khm_ui_4;
typedef __int64 khm_int64;
typedef unsigned __int64 khm_ui_8;
#define VALID_INT_BITS INT_MAX
#define VALID_UINT_BITS UINT_MAX
#define KHM_UINT32_MAX 4294967295
#define KHM_INT32_MAX 2147483647
/* this strange form is necessary since - is a unary operator, not a sign
indicator */
#define KHM_INT32_MIN (-KHM_INT32_MAX-1)
#define KHM_UINT16_MAX 65535
#define KHM_INT16_MAX 32767
/* this strange form is necessary since - is a unary operator, not a sign
indicator */
#define KHM_INT16_MIN (-KHM_INT16_MAX-1)
/*! \brief Generic handle type.
Handles in NetIDMgr are generic pointers.
*/
typedef void * khm_handle;
/*! \brief The invalid handle
Just used to indicate that this handle does not point to anything useful.
Usually returned by a function that returns a handle as a signal that the
operation failed.
*/
#define KHM_INVALID_HANDLE ((khm_handle) NULL)
/*! \brief Boolean.
*/
typedef khm_int32 khm_boolean;
/*! \brief A size
*/
typedef size_t khm_size;
/*! \typedef ssize_t
\brief Signed size specifier
Just a signed version of size_t
*/
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
typedef ssize_t khm_ssize;
#if defined(_WIN64)
typedef unsigned __int64 khm_wparm;
/*TODO: is this enough? */
typedef unsigned __int64 khm_lparm;
#elif defined(_WIN32)
typedef unsigned __int32 khm_wparm;
typedef unsigned __int64 khm_lparm;
#else
#error khm_wparm and khm_lparm need to be defined for this platform
#endif
/*!\def KHMAPI
\brief Calling convention for NetIDMgr exported functions
The caling convention for all NetIDMgr exported functions is \b
__stdcall , unless otherwise noted.
*/
/*!\def KHMEXP
\brief Export prefix for NetIDMgr exported functions
When compiling source that exports functions, those exported
function declarations will be done as follows:
\code
__declspec(dllexport) khm_int32 __stdcall function_name(arguments...);
\endcode
This eliminates the need for a separate exports definition file.
However, it doesn't preserve ordinals, but we aren't guaranteeing
that anyway.
On the other hand, if a particular function is going to be imported
from a DLL, it should declared as follows:
\code
__declspec(dllimport) khm_int32 __stdcall function_name(arguments...);
\endcode
This allows the compiler to properly instrument the import. If the
function is not declared this way, there will be a stub function
generated that will just jump to the proper import, generating
redundant instructions and wasting execution time.
This macro encapsulates the proper declaration specifier.
*/
#ifdef _WIN32
#define KHMAPI __stdcall
#define KHMEXP_EXP __declspec(dllexport)
#define KHMEXP_IMP __declspec(dllimport)
#define KHMEXP KHMEXP_EXP
#endif
/* Generic permission values */
/*! \brief Generic read permission or request */
#define KHM_PERM_READ 0x100
/*! \brief Generic write permission or request */
#define KHM_PERM_WRITE 0x200
/* Generic flags */
/*! \brief Generic create request
For most lookup functions, specifying this flag indicates that if
the requested object is not found it should be created.
*/
#define KHM_FLAG_CREATE 0x1000
/*! \brief Wrap to DWORD boundary
Returns the smallest integer greater than or equal to the
parameter that is a multiple of 4.
\note Only use with positive integers. */
#define UBOUND32(d) ((((d)-1)&~3) + 4)
/*! \brief Offset a pointer by a number of bytes
Given a pointer, returns a void pointer that is a given number of
bytes offset from the pointer.
*/
#define BYTEOFFSET(p,off) ((void *)(((char *) (p)) + (off)))
/*! \brief Check for powers of 2
Return TRUE if the operand is a positive power of 2 or 0*/
#define IS_POW2(d) ((d)>=0 && !((d) & ((d) - 1)))
/*! \brief Wrap to upper bound based on start and step size
Return the smallest element in the series <tt>s, s+t, s+2*t,
s+3*t, ...</tt> that is greater than or equal to \c v.
*/
#define UBOUNDSS(v,start,step) (((v)<=(start))?(start):(start)+((((v)-((start)+1))/(step))+1)*(step))
/* \brief Length of an array
*/
#define ARRAYLENGTH(x) (sizeof(x)/sizeof(x[0]))
/*! \brief Generic version type*/
typedef struct tag_khm_version {
khm_ui_2 major; /*!< Major version number */
khm_ui_2 minor; /*!< Minor version number */
khm_ui_2 patch; /*!< Patch level */
khm_ui_2 aux; /*!< Auxilary level (usually carries a build number) */
} khm_version;
/*@}*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
/* Exported */
#ifndef __KHIMAIRA_KHERROR_H
#define __KHIMAIRA_KHERROR_H
/*! \defgroup kherror NetIDMgr errors
@{*/
/*! \brief Base for error codes
NetIDMgr errors range from \a KHM_ERROR_BASE to KHM_ERROR_BASE +
KHM_ERROR_RANGE, with the exception of KHM_ERROR_SUCCESS and
KHM_ERROR_NONE.
*/
#define KHM_ERROR_BASE 0x40000000L
/*! \brief Range for error codes
NetIDMgr errors range from \a KHM_ERROR_BASE to
KHM_ERROR_BASE + KHM_ERROR_RANGE.
*/
#define KHM_ERROR_RANGE 256L
/*! \defgroup kherror_codes Error codes
@{*/
/*! \brief No error */
#define KHM_ERROR_NONE 0x00000000L
/*! \brief Success. Same as \a KHM_ERROR_NONE */
#define KHM_ERROR_SUCCESS KHM_ERROR_NONE
/*! \brief The supplied name was invalid */
#define KHM_ERROR_INVALID_NAME (KHM_ERROR_BASE + 1)
/*! \brief Too much data
A supplied buffer was invalid, was of insufficient size, or a
buffer was of a larger size than expected
*/
#define KHM_ERROR_TOO_LONG (KHM_ERROR_BASE + 2)
/*! \brief One or more parameters supplied to a function were invalid */
#define KHM_ERROR_INVALID_PARAM (KHM_ERROR_BASE + 3)
/*! \brief A duplicate.
Usually means that something that should have been unique was
found to be not.
*/
#define KHM_ERROR_DUPLICATE (KHM_ERROR_BASE + 4)
/*! \brief An object was not found
An object referenced in a parameter was not found.
*/
#define KHM_ERROR_NOT_FOUND (KHM_ERROR_BASE + 5)
/*! \brief The relevant subsystem is not ready
Indicates that initialization has not been completed for a
subsystem.
*/
#define KHM_ERROR_NOT_READY (KHM_ERROR_BASE + 6)
/*! \brief No more resources
A limited resource has been exhausted.
*/
#define KHM_ERROR_NO_RESOURCES (KHM_ERROR_BASE + 7)
/*! \brief Type mismatch
*/
#define KHM_ERROR_TYPE_MISMATCH (KHM_ERROR_BASE + 8)
/*! \brief Already exists
Usually indicates that an exclusive create operation failed due to
the existence of a similar object. Subtly different from
::KHM_ERROR_DUPLICATE
*/
#define KHM_ERROR_EXISTS (KHM_ERROR_BASE + 9)
/*! \brief Operation timed out
*/
#define KHM_ERROR_TIMEOUT (KHM_ERROR_BASE + 10)
/*! \brief An EXIT message was received
*/
#define KHM_ERROR_EXIT (KHM_ERROR_BASE + 11)
/*! \brief Unknown or unspecified error
*/
#define KHM_ERROR_UNKNOWN (KHM_ERROR_BASE + 12)
/*! \brief General error
*/
#define KHM_ERROR_GENERAL KHM_ERROR_UNKNOWN
/*! \brief An index was out of bounds
*/
#define KHM_ERROR_OUT_OF_BOUNDS (KHM_ERROR_BASE + 13)
/*! \brief Object already deleted
One or more objects that were referenced were found to have been
already deleted.
*/
#define KHM_ERROR_DELETED (KHM_ERROR_BASE + 14)
/*! \brief Invalid operation
The operation was not permitted to continue for some reason.
Usually because the necessary conditions for the operation haven't
been met yet or the operation can only be performed at certain
times during the execution of NetIDMgr.
*/
#define KHM_ERROR_INVALID_OPERATION (KHM_ERROR_BASE + 15)
/*! \brief Signature check failed
*/
#define KHM_ERROR_INVALID_SIGNATURE (KHM_ERROR_BASE + 16)
/*! \brief Not implemented yet
The operation that was attempted involved invoking functionality
that has not been implemented yet.
*/
#define KHM_ERROR_NOT_IMPLEMENTED (KHM_ERROR_BASE + 17)
/*! \brief The objects were equivalent
*/
#define KHM_ERROR_EQUIVALENT (KHM_ERROR_BASE + 18)
/*! \brief No provider exists to service the request
*/
#define KHM_ERROR_NO_PROVIDER (KHM_ERROR_BASE + 19)
/*! \brief The operation succeeded, but with errors
*/
#define KHM_ERROR_PARTIAL (KHM_ERROR_BASE + 20)
/*! \brief An incompatibility was found */
#define KHM_ERROR_INCOMPATIBLE (KHM_ERROR_BASE + 21)
/*@}*/ /*kherror_codes*/
/*! \brief Tests whether a return value indicates success */
#define KHM_SUCCEEDED(rv) ((rv)==KHM_ERROR_NONE)
/*! \brief Tests whether a return value indicates failure */
#define KHM_FAILED(rv) ((rv)!=KHM_ERROR_NONE)
/*@}*/
#endif

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHHTLINK_H
#define __KHIMAIRA_KHHTLINK_H
/*! \addtogroup khui
@{ */
/*! \defgroup khui_hyperlink Hyperlink
@{*/
/*! \brief A hyperlink
When a link in a hypertext window is clicked, this structure is
passed along with the message.
The link text fields do to point to NULL terminated strings.
Instead, the length fields should be used to extract the string.
*/
typedef struct tag_khui_htwnd_link {
RECT r;
wchar_t * id;
int id_len;
wchar_t * param;
int param_len;
} khui_htwnd_link;
#define KHUI_MAXCCH_HTLINK_FIELD 256
#define KHUI_MAXCB_HTLINK_FIELD (KHUI_MAXCCH_HTLINK_FIELD * sizeof(wchar_t))
/*!@}*/
/*!@}*/
#endif

View File

@ -0,0 +1,173 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
/* Not exported */
#ifndef _KHIMAIRA_KHLIST_H
#define _KHIMAIRA_KHLIST_H
/* Note that most of these are "unsafe" macros. Not for general use */
/* LIFO lists */
#define LDCL(type) \
type * next; \
type * prev
#define LINIT(pe) \
do { \
(pe)->next = NULL; \
(pe)->prev = NULL; } while(0)
#define LPUSH(pph,pe) \
do { \
(pe)->next = *pph; \
(pe)->prev = NULL; \
if(*(pph)) (*(pph))->prev = (pe); \
(*(pph)) = (pe); } while(0)
#define LPOP(pph,ppe) \
do { \
*(ppe) = *(pph); \
if(*(pph)) *(pph) = (*(pph))->next; \
if(*(pph)) (*(pph))->prev = NULL; \
if(*(ppe)) (*(ppe))->next = NULL; \
} while(0)
#define LDELETE(pph,pe) \
do { \
if((pe)->prev) (pe)->prev->next = (pe)->next; \
if((pe)->next) (pe)->next->prev = (pe)->prev; \
if(*(pph) == (pe)) *(pph) = (pe)->next; \
(pe)->next = (pe)->prev = NULL; \
} while(0)
#define LEMPTY(pph) (*(pph) == NULL)
#define LNEXT(pe) ((pe)?(pe)->next:NULL)
#define LPREV(pe) ((pe)?(pe)->prev:NULL)
/* Trees with LIFO child lists */
#define TDCL(type) \
LDCL(type); \
type * children; \
type * parent
#define TINIT(pe) \
do { \
(pe)->children = NULL; \
(pe)->parent = NULL; } while(0)
#define TADDCHILD(pt,pe) \
do { \
LPUSH(&((pt)->children),(pe)); \
(pe)->parent = (pt); } while(0)
#define TFIRSTCHILD(pt) ((pt)?(pt)->children:NULL)
#define TPOPCHILD(pt, ppe) \
do { \
LPOP(&((pt)->children), ppe); \
if(*(ppe)) (*(ppe))->parent = NULL; \
} while(0)
#define TDELCHILD(pt, pe) \
do { \
LDELETE(&((pt)->children), (pe)); \
(pe)->parent = NULL; } while(0)
#define TPARENT(pe) ((pe)?(pe)->parent:NULL)
/* FIFO lists */
#define QDCL(type) \
type * head; \
type * tail
#define QINIT(pq) \
do { \
(pq)->head = (pq)->tail = NULL; \
} while(0)
#define QPUT(pq, pe) \
do { \
LPUSH(&(pq)->tail, (pe)); \
if(!(pq)->head) (pq)->head = (pe); \
} while(0)
#define QGET(pq, ppe) \
do { \
*(ppe) = (pq)->head; \
if(*(ppe)) { \
(pq)->head = (*(ppe))->prev; \
if( (*(ppe))->prev ) (*(ppe))->prev->next = NULL; \
(*(ppe))->prev = NULL; \
if( (pq)->tail == *(ppe)) (pq)->tail = NULL; \
} \
} while(0)
#define QDEL(pq, pe) \
do { \
if((pq)->head == (pe)) (pq)->head = LPREV(pe); \
LDELETE(&((pq)->tail), (pe)); \
} while(0)
#define QGETT(pq,ppe) \
do { \
*(ppe) = (pq)->tail; \
if(*(ppe)) { \
(pq)->tail = (*(ppe))->next; \
if( (*(ppe))->next ) (*(ppe))->next->prev = NULL; \
(*(ppe))->next = NULL; \
if( (pq)->head == *(ppe)) (pq)->head = NULL; \
} \
} while(0)
#define QTOP(pq) ((pq)->head)
#define QBOTTOM(pq) ((pq)->tail)
#define QNEXT(pe) ((pe)->prev)
#define QPREV(pe) ((pe)->next)
/* Trees with FIFO child lists */
#define TQDCL(type) \
LDCL(type); \
QDCL(type); \
type * parent
#define TQINIT(pe) \
do { \
QINIT(pe); \
(pe)->parent = NULL; } while(0)
#define TQADDCHILD(pt,pe) \
do { \
QPUT((pt), (pe)); \
(pe)->parent = (pt); } while(0)
#define TQFIRSTCHILD(pt) ((pt)?QTOP(pt):NULL)
#define TQPARENT(pe) ((pe)?(pe)->parent:NULL)
#endif

View File

@ -0,0 +1,800 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHMSGTYPES_H
#define __KHIMAIRA_KHMSGTYPES_H
/*! \addtogroup kmq
@{*/
/*! \defgroup kmq_msg Message Types
@{*/
/*! \name Global message types
@{*/
/*! \brief System messages.
All subscribers are subscribed to the system message class by default.
\see \ref kmq_msg_system
*/
#define KMSG_SYSTEM 0
/*! \brief Ad-hoc messages.
These are messages that are sent through add hoc publishers and
subscribers.
*/
#define KMSG_ADHOC 1
/*! \brief NetIDMgr Credentials Database messages
These messages notify subscribers of events related to the
credentials database, such as the registration, unregistration and
modification of identities, attributes, attribute types and
credential types. It also provides notifications of changes to
the root crednetial set.
\see \ref kmq_msg_kcdb
*/
#define KMSG_KCDB 2
/*! \brief NetIDMgr Module Manager messages
\see \ref kmq_msg_kmm
*/
#define KMSG_KMM 3
/*! \brief NetIDMgr Credential messages
Notifications of crednetial events. These are the most important
events that a credentials provider should respond to. The
notifications provide co-oridination between credential providers
for performing basic credentials management tasks such as
obtaining new credentials for an identity, deleting credentials
for an identity, obtaining or deleting credentials of a particular
type for an identity etc.
\see \ref cred_msgs
\see \ref kmq_msg_cred
*/
#define KMSG_CRED 4
/*! \brief Action list messages
Notifications of changes in action state and firing of custom
actions.
\see \ref kmq_msg_act
*/
#define KMSG_ACT 5
/*! \brief Alert messages
Notifier is the component which displays alerts and error messages
when the NetIDMgr window is normally in operation and which
displays balloon prompts when the window is minimized to alert the
user to important messages such as credentials expiring etc.
\note This is an internal message class. Components that are not
the notifier should not be subscribing to alert messages.
\see \ref kmq_msg_alert
*/
#define KMSG_ALERT 6
/*! \brief Identity messages
These are messages that are sent to the identity provider. These
are generally dispatched through a specific subscription object
and are not broadcast.
\see \ref kmq_msg_ident
*/
#define KMSG_IDENT 7
/*! \brief Base message type ID for customized message types
*/
#define KMSGBASE_USER 16
/*@}*/
/*! \defgroup kmq_msg_system KMSG_SYSTEM subtypes
@{*/
/*! \brief Generic initialization message
This message is used by specific components to signal that the
recipient is to perform initialization tasks. As a convention,
the recipient should return KHM_ERROR_SUCCESS if it successfully
performed the initlization tasks or some other value if it failed
to do so. Failure to successfully initialize is usually taken to
mean that the recipient component is not able to perform its
function.
Usually this is the first message to be received by the recipient.
\see \ref pi_pt_cred_init
*/
#define KMSG_SYSTEM_INIT 1
/*! \brief Generic uninitialization message
Used by specific components to signal that the recipient should
perform uninitilization tasks in preparation of termination. The
return value of this message is not used.
Usually this is the last message to be received by the recipient.
\see \ref pi_pt_cred_exit
*/
#define KMSG_SYSTEM_EXIT 2
/*! \brief Message completion
This is an internal message
*/
#define KMSG_SYSTEM_COMPLETION 3
/*@}*/
/*! \defgroup kmq_msg_kcdb KMSG_KCDB subtypes
@{*/
#define KMSG_KCDB_IDENT 1
#define KMSG_KCDB_CREDTYPE 2
#define KMSG_KCDB_ATTRIB 3
#define KMSG_KCDB_TYPE 4
/*! \brief Generic credentials request
\see ::kcdb_cred_request for more information
*/
#define KMSG_KCDB_REQUEST 256
/*@}*/
/*! \defgroup kmq_msg_kmm KMSG_KMM subtypes
@{*/
#define KMSG_KMM_I_REG 1
#define KMSG_KMM_I_DONE 2
/*@}*/
/*! \defgroup kmq_msg_act KMSG_ACT subtypes
@{*/
/*! \brief One or more actions changed state
This message is sent in response to a call to
khui_enable_actions() or khui_enable_action() and indicates that
one or more actions have changed their state.
*/
#define KMSG_ACT_ENABLE 1
/*! \brief One or more actions changed check state
Sent in response to khui_check_radio_action() or
khui_check_action() and indicates that one or more actions have
either been checked or unchecked.
*/
#define KMSG_ACT_CHECK 2
/*! \brief Refresh action states
Sent after a batch of modifications were made to action states.
*/
#define KMSG_ACT_REFRESH 3
/*! \brief A new action was created
Sent when a new custom action was created. The \a uparam
parameter of the message contains the identifier of the newly
created action.
*/
#define KMSG_ACT_NEW 4
/*! \brief A custom action was deleted
Sent after a custom action is deleted. The \a uparam parameter of
the message contains the identifier of the deleted action.
*/
#define KMSG_ACT_DELETE 5
/*! \brief A custom action has been activated
When a custom action is activated, then the listener of that
custom action receives this message. Note that only the listener
for that custom action will receive this notification.
\a uparam of the message is set to the identifier of the custom
action.
*/
#define KMSG_ACT_ACTIVATE 6
/*! \brief Internal */
#define KMSG_ACT_BEGIN_CMDLINE 128
/*! \brief Internal */
#define KMSG_ACT_CONTINUE_CMDLINE 129
/*! \brief Internal */
#define KMSG_ACT_SYNC_CFG 130
/*@}*/
/*! \defgroup kmq_msg_cred KMSG_CRED subtypes
@{*/
/*! \brief Root credential set changed
This message is issued when the root credential set successfully
collected credentials from another credential set.
\a uparam of the message is set to a bitmask indicating the change
that occured. It is a combination of ::KCDB_DELTA_ADD,
::KCDB_DELTA_DEL and ::KCDB_DELTA_MODIFY.
*/
#define KMSG_CRED_ROOTDELTA 1
/*! \brief Re-enumerate credentials
A notice to all credential providers to re-enumerate their
respective credentials.
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_REFRESH 2
/*! \brief Change the password
This message notifies credentials providers that a password change
request has been received.
A plug-in handling this message that wishes to participate in the
password change operation is expected to add a
::khui_new_creds_by_type to the list of participants in the
::khui_new_creds structure by calling khui_cw_add_type().
The password change operation requires user interaction. Any
plug-ins that are participating in the operation need to provide a
user-interface.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\see khui_cw_add_type(), ::khui_new_creds, ::khui_new_creds_by_type
*/
#define KMSG_CRED_PASSWORD 16
/*! \brief Initiate the process of obtaining new credentials
The UI sends this message to start the process of obtaining new
credentials. See \ref cred_acq for more information about
handling this message.
A plug-in handling this message that wishes to participate in the
new credentials acquisition operation is expected to add a
::khui_new_creds_by_type to hte list of participants in the
::khui_new_creds structure by calling khui_cw_add_type().
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\see \ref cred_acq, khui_cw_add_type(), ::khui_new_creds,
::khui_new_creds_by_type
*/
#define KMSG_CRED_NEW_CREDS 17
/*! \brief Renew credentials
This is a notification sent to individual credentials providers
that a specified identity's credentials should be renewed.
A plug-in handling this message that wishes to participate in the
renew credentials operation is expected to add a
::khui_new_creds_by_type to the list of participants in the
::khui_new_creds structure by calling khui_cw_add_type().
Message parameters:
- \b vparam : Pointer to a khui_new_creds object
\see khui_cw_add_type(), ::khui_new_creds,
::khui_new_creds_by_type
*/
#define KMSG_CRED_RENEW_CREDS 18
/*! \brief Dialog setup
Once ::KMSG_CRED_NEW_CREDS has been responded to by all the
credential types, the UI creates the dialog windows using the data
supplied in the ::khui_new_creds_by_type structures and issues
this message. Each credentials provider is expected to respond by
finalizing dialog creation operations.
Message parameters:
- \b vparam : poitner to a ::khui_new_creds structure
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_DIALOG_SETUP 19
/*! \brief Dialog pre-start
Sent after all the credentials providers have responded to
::KMSG_CRED_DIALOG_SETUP and all the initialization has been
completed. Credentials providers are expected to respond to this
message by loading any default data into the dialog controls for
each credential type.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_DIALOG_PRESTART 20
/*! \brief Dialog start
A notification that the dialog is now in progress.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_DIALOG_START 21
/*! \brief The primary identity of the new credentials dialog has changed
This message is not sent out by the UI, but is reserved here for
use by individual credentials providers. The message may be sent
from the dialog procedure to the plugin.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note Be careful when sending this message. All messages that are
not sent by the system should not be sent via broadcast.
Instead, create a subscription using kmq_create_subscription()
for the individual plugin that you want to send the message
and use one of the per-subscription message functions to send
the actual message.
*/
#define KMSG_CRED_DIALOG_NEW_IDENTITY 22
/*! \brief New credentials options have changed.
This message is not sent out by the UI, but is reserved here for
use by individual credentials providers. The message may be sent
from the dialog procedure to the plugin.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note Be careful when sending this message. All messages that are
not sent by the system should not be sent via broadcast.
Instead, create a subscription using kmq_create_subscription()
for the individual plugin that you want to send the message
and use one of the per-subscription message functions to send
the actual message.
*/
#define KMSG_CRED_DIALOG_NEW_OPTIONS 23
/*! \brief Process dialog
Sent to all the credential providers to look at the contents of
the given ::khui_new_creds structure and do any required
processing.
If the \a result field in the structure is set to
::KHUI_NC_RESULT_PROCESS, then new credentials should be
obtained using the given data.
Set the \a response field in the structure to indicate how the UI
should proceed from here.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_PROCESS 24
/*! \brief End a credentials acquisition operation
A notification that the credentials acquisition operation has
ended.
Message parameters:
- \b vparam : pointer to a ::khui_new_creds structure
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_END 25
/*! \brief Import credentials from the operating system
Notification to all credentials providers to import any available
credentials from the operating system.
Message parameters:
- This message does not have any parameters
*/
#define KMSG_CRED_IMPORT 26
/*! \brief Destroy credentials
Notification that the specified credentials should be destroyed.
Once this message has completed processing a ::KMSG_CRED_REFRESH
message will be issued.
The credentials that should be destroyed are specified by a
::khui_action_context structure. The context that should be used
is the selection context. Hence, the credentials that must be
destroyed are the ones lised in the credential set (\a credset).
Message parameters:
- \b upram : Unused. Zero.
- \b vparam : pointer to a ::khui_action_context structure which
describes which credentials need to be destroyed.
*/
#define KMSG_CRED_DESTROY_CREDS 32
#if 0
/*! \brief Parse an identity
\note May be sent to individual credential subscriptions.
*/
#define KMSG_CRED_IDENT_PARSE 65
#endif
/*! \brief A property page is being launced
Message parameters:
- \b vparam : pointer to a ::khui_property_sheet structure
*/
#define KMSG_CRED_PP_BEGIN 128
/*! \brief A property page is about to be created
Message parameters:
- \b vparam : pointer to a ::khui_property_sheet structure
\note This message is merely a notification that the property
sheet is being created. Handlers should not modify the state
of the property sheet or pages at this time.
*/
#define KMSG_CRED_PP_PRECREATE 129
/*! \brief A property page has finished processing
Message parameters:
- \b vparam : pointer to a ::khui_property_sheet structure
*/
#define KMSG_CRED_PP_END 130
/*! \brief A property page has been destroyed
Message parameters:
- \b vparam : pointer to a ::khui_property_sheet structure
*/
#define KMSG_CRED_PP_DESTROY 131
/*! \brief An IP address change occurred
There are no parameters for this message. The NetIDMgr
application handles this message and depending on configuration,
posts message for the individual credentials providers to either
obtain new credentials or renew old ones.
*/
#define KMSG_CRED_ADDR_CHANGE 140
/*! \brief Check if a KMSG_CRED subtype is a credentials acquisition message
Dialog messages are those that deal with the new or initial
credentials acquisition dialog, from initial announcement to
dialog completion.
Currently, the dialog messages are:
- ::KMSG_CRED_NEW_CREDS
- ::KMSG_CRED_RENEW_CREDS
- ::KMSG_CRED_DIALOG_SETUP
- ::KMSG_CRED_DIALOG_PRESTART
- ::KMSG_CRED_DIALOG_START
- ::KMSG_CRED_DIALOG_NEW_IDENTITY
- ::KMSG_CRED_DIALOG_NEW_OPTIONS
- ::KMSG_CRED_PROCESS
- ::KMSG_CRED_END
All dialog message numbers are allocated in a contigous block.
Note that while ::KMSG_CRED_PROCESS and ::KMSG_CRED_END are not
specific to dialogs, they are still included in this predicate
because they are also part of the dialog message sequence.
*/
#define IS_CRED_ACQ_MSG(msg) ((msg) >= 16 && (msg) <=31)
/*@}*/ /* /KMSG_CRED subtypes */
/*! \defgroup kmq_msg_alert KMSG_ALERT Subtypes
@{*/
/*! \brief Show an alert
Message parameters:
- \b vparam : held pointer to a ::khui_alert object
\note The ::khui_alert object will be released when the processing
of this message completes.
*/
#define KMSG_ALERT_SHOW 1
/*! \brief Add an alert to the alert queue
Message parameters:
- \b vparam : held pointer to a ::khui_alert object
\note the ::khui_alert object will be released when the queued
messages are displayed.
*/
#define KMSG_ALERT_QUEUE 2
/*! \brief Show the next queued alert
There are no message parameters
*/
#define KMSG_ALERT_SHOW_QUEUED 3
/*! \brief Check if there are any queued messages and, if so, update the statusbar
There are no message parameters
*/
#define KMSG_ALERT_CHECK_QUEUE 4
/*! \brief Show a modal alert
Message parameters:
- \b vparam : held pointer to a ::khui_alert object.
\note the ::khui_alert object will be released when the queued
messages are displayed.
*/
#define KMSG_ALERT_SHOW_MODAL 5
/*@}*/
/*! \defgroup kmq_msg_ident KMSG_IDENT Subtypes
@{*/
/*! \brief Initialize and start the identity provider
Sent by the KCDB to notify the identity provider that it is now
the current identity provider.
Note that unlike regular plugins, an identity provider can be
loaded and inert (not provide any services). Also, the user may
switch between multiple identity providers on the fly.
*/
#define KMSG_IDENT_INIT 1
/*! \brief Stop the identity provider
Sent by the KCDB as notificaton that the identity provider is no
longer the current provider.
*/
#define KMSG_IDENT_EXIT 2
/*! \brief Check if an identity name is valid
This message is sent to the identity provider to verify the syntax
of an identity name. Note that only the syntax of the name is to
be verfied and not the actual physical existence of said identity.
Message parameters:
- \b vparam : pointer to ::kcdb_ident_name_xfer object. The
name to be validated will be in the \a name_src member. The
buffer will be NULL terminated with a maximum limit of
KCDB_IDENT_MAXCCH_NAME characters including the terminating
NULL, consisting only of characters in KCDB_IDENT_VALID_CHARS
The \a result member should be set to one of the following
depending on the result of the validation:
- KHM_ERROR_SUCCESS : The name was valid
- KHM_ERROR_INVALID_NAME : The name was invalid
*/
#define KMSG_IDENT_VALIDATE_NAME 3
/*! \brief Check if an identity is valid
Sent to the identity provider to verify the validity of the given
identity. The provider should verify that the identity exists and
is in a state where it can be actively used.
Depending on the result of the validation, the flags of the
identity should be updated.
Message parameters:
- \b vparam : Handle to an identity cast as a void pointer.
*/
#define KMSG_IDENT_VALIDATE_IDENTITY 4
/*! \brief Canonicalize identity name
The identity provider will be given a name, which it should put in
canonical form, adjusting case and any character replacement or
doing any relevant expansions if applicable, and place it in the
supplied buffer.
Message parameters:
- \b vparam : Pointer to a ::kcdb_ident_name_xfer structure
which provides the identity name to canonicalize in the \a
name_src member, and the buffer to store the canonical name
in the \a name_dest member. The \a name_dest buffer is
guaranteed to be at least KCDB_IDENT_MAXCCH_NAME characters
in size.
If the name cannot be canonicalized for some reason, the
destination buffer should be set to a zero-length string and the
\a result member of the ::kcdb_ident_name_xfer structure should be
set to the error code. If the destination buffer is set to a
zero-length string and \a result is KHM_ERROR_SUCCESS, then the
original name provided in \a name_src is assumed to be already in
canonical form.
*/
#define KMSG_IDENT_CANON_NAME 5
/*! \brief Compare names
Compare two identity names. The names that are given aren't
guaranteed to be in canonical form. The return value should be
akin to strcmp().
Message parameters:
- \b vparam : A pointer to a ::kcdb_ident_name_xfer structure.
The \a name_src member points at the first name, and the \a
name_alt member specifies the second name. The result of the
comparison should be place in \a result.
*/
#define KMSG_IDENT_COMPARE_NAME 6
/*! \brief Set the default identity
Set or unset the default identity. To set the default identity,
the \a uparam parameter will be set to a non-zero value and a
handle to the identity will be specified in \a vparam. To unset
the default identity (i.e. not have a default identity), a zero
value will be specified in \a uparam and no identities will be
specified in \a vparam.
When setting a default identity, the identity provider will
receive this message prior to the ::KCDB_IDENT_FLAG_DEFAULT bit
being set or reset on any identity. It should return
KHM_ERROR_SUCCESS if the requested operation can be performed.
Returning any other value will abort the operation and will leave
the default identity unchanged.
When resetting the default identity, this message should be
treated only as a notification.
Message parameters:
- \a uparam : Is non-zero if an identity is being made default. If
this is zero, then identity should be the default.
- \a vparam : A handle to the identity to be made default if \a
uparam is non-zero. NULL otherwise.
Return value:
- KHM_ERROR_SUCCESS : The identity should be marked as default
- Any other value : The identity should not be marked as default
*/
#define KMSG_IDENT_SET_DEFAULT 7
/*! \brief Set an identity as searchable
Set or reset the searchable bit on an identity. If the \a uparam
parameter is non-zero, then the searchable bit is being set.
Otherwise it is being reset. The identity provider should return
KHM_ERROR_SUCCESS in order to indicate that the identity should be
marked as searchable. Any other value will result in the
searchable bit being reset on the identity.
Message parameters:
- \a uparam : Is non-zero if the searchable bit is being set. Zero
otherwise.
- \a vparam : Handle to the identity
Return value:
- KHM_ERROR_SUCCESS: The identity should be marked as searchable
- Any other value : The identity should not be marked as default
*/
#define KMSG_IDENT_SET_SEARCHABLE 8
/*! \brief Get information about an identity
*/
#define KMSG_IDENT_GET_INFO 9
/*! \brief Enumerate known and accessible identities
*/
#define KMSG_IDENT_ENUM_KNOWN 10
/*! \brief Update information about an identity
*/
#define KMSG_IDENT_UPDATE 11
/*! \brief Retrieve the user interface callback function
When obtaining new credentials, the user interface needs to obtain
a callback function which will provide identity selection
controls.
Message parameters:
- \a uparam : Not used
- \a vparam : pointer to a ::khui_ident_new_creds_cb which will
receive the call back.
*/
#define KMSG_IDENT_GET_UI_CALLBACK 12
/*! \brief Notification of the creation of an identity
This should be considered just a notification. The identit
provider does not have an opportunity to veto the creation of an
identity whose name has been found to be valid. However, when
handing this notification, the identity provider can:
- Change the flags of the identity and/or marking the identity as
invalid.
- Change the default identity.
Note that this notification is sent before the general :;KMSG_KCDB
notification of the identity creation is sent.
Message parameters:
- \a uparam : Not used.
- \p vparam : handle to the identity
*/
#define KMSG_IDENT_NOTIFY_CREATE 13
/*@}*/ /* /KMSG_IDENT subtypes */
/*@}*/ /* / message types */
/*@}*/ /* / kmq */
#endif

View File

@ -0,0 +1,975 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHNEWCRED_H
#define __KHIMAIRA_KHNEWCRED_H
/********************************************************************
New credentials windows
*********************************************************************/
/*! \addtogroup khui
@{ */
/*! \defgroup khui_cred Credentials acquisition
Declarations associated with credentials acquisition.
@{ */
/*! \brief Window message sent to credentials type panels
This message is sent to the child windows.
The format of the message is :
- uMsg : KHUI_WM_NC_NOTIFY
- HIWORD(wParam) : one of ::khui_wm_nc_notifications
- LPARAM : pointer to the ::khui_new_creds structure
*/
#define KHUI_WM_NC_NOTIFY (WM_APP + 0x101)
/*! \brief The first control ID that may be used by an identity provider */
#define KHUI_CW_ID_MIN 8016
/*! \brief The maximum number of controls that may be created by an identity provider*/
#define KHUI_CW_MAX_CTRLS 8
/*! \brief The maximum control ID that may be used by an identity provider */
#define KHUI_CW_ID_MAX (KHUI_CW_ID_MIN + KHUI_CW_MAX_CTRLS - 1)
/*! \brief Credentials dialog notifications
These notifications will be sent to the individual dialog
procedures of the credential type panels as a ::KHUI_WM_NC_NOTIFY
message.
*/
enum khui_wm_nc_notifications {
WMNC_DIALOG_EXPAND = 1,
/*!< The dialog is getting expanded.
This message is sent to the new creds dialog to set the dialog
to expanded mode. In expanded mode, all credentials type panels
are visible as opposed to the compressed mode where they are not
visible. The message is not sent to credentials type panels.*/
WMNC_DIALOG_SETUP,
/*!< Sent by NetIDMgr to the new creds window to notify it that
the dialog should create all the type configuration panels.
Until this message is issued, none of the credentials type
panels exist. The credentials type panels will receive
WM_INITDIALOG etc as per the normal dialog creation process. */
WMNC_DIALOG_ACTIVATE,
/*!< Sent by NetIDMgr to the new creds window to notify it that
the dialog should do final initialization work and activate. */
WMNC_DIALOG_MOVE,
/*!< Sent by the new creds widnow to all the panels notifying them
that the NC window is moving. */
WMNC_DIALOG_SWITCH_PANEL,
/*!< Sent to the new creds window to cause it to switch to the
panel identified by LOWORD(wParam).
Does nothing if the specified panel is already the current
panel. If the dialog is in compact mode and making the
specified panel visible requires switching to expanded mode, the
dialog will do so. */
WMNC_UPDATE_CREDTEXT,
/*!< Sent to all the credential type panels for a credentials
window to request them to update the credential text.
When sent to the new credentials window, causes it to send the
WMNC_UPDATE_CREDTEXT message to all the credential type panels
and update the cred text window.*/
WMNC_CREDTEXT_LINK,
/*!< Sent to a panel dialog proc when a user clicks a credtext
embedded link that belongs to that panel */
WMNC_IDENTITY_CHANGE,
/*!< The primary identity has changed */
WMNC_CLEAR_PROMPTS,
/*!< Sent to the new creds window to clear any custom prompts */
WMNC_SET_PROMPTS,
/*!< Sent to the new creds window to set custom prompts */
WMNC_DIALOG_PREPROCESS,
/*!< Sent to all the credentials type panels to notify them that
the dialog is about to be processed */
WMNC_DIALOG_PROCESS,
/*!< Process the dialog and signal whether to exit the dialog or
not */
WMNC_DIALOG_PROCESS_COMPLETE,
/*!< Sent to the new creds window to indicate that the all the
threads have completed processing.*/
WMNC_TYPE_STATE,
/*!< Sent to the new creds window as notification that a
particular credentials type has changed state from enabled to
disabled or vice versa. The LPARAM member of the message
specifies the credentials type identifier for the changed
type */
WMNC_ADD_CONTROL_ROW,
/*!< Add a row of controls to a new cred dialog. This is an
internal message. */
};
/*! \brief Plugins can use WMNC_NOTIFY message codes from here on up
\see ::KHUI_WM_NC_NOTIFY
*/
#define WMNC_USER 2048
/*! \brief Notifications to the identity provider
These notifications are sent through to the identity provider's UI
callback that was obtained using a ::KMSG_IDENT_GET_UI_CB message.
The callback routine is called from the context of the UI thread
and is expected to not make any blocking calls. One of the
following commands will be passed in as the \a cmd parameter to
the callback.
*/
enum khui_wm_nc_ident_notify {
WMNC_IDENT_INIT,
/*!< Initialize an identity selector for a new credentials
dialog. The \a lParam parameter contains a handle to the
dialog window which will contain the identity selector
controls. The identity provider may make use of the \a
ident_aux field of the ::khui_new_creds structure to hold any
data pertaining to the credentials acquisition dialog.*/
WMNC_IDENT_WMSG,
/*!< Windows message. Presumably sent from one of the controls
that was created by the identity provider. The callback is
expected to return TRUE if it processed the message or FALSE
if it did not. The \a uMsg, \a wParam and \a lParam
parameters are set to the values passed in by Windows. */
WMNC_IDENT_EXIT,
/*!< Terminate a credentials acquisition dialog. Sent just before
the dialog is terminated. */
};
/*! \name Standard credtext link IDs
@{*/
/*! \brief Switch the panel
The \a id attribute of the link specifies the ordinal of the panel
to switch to.
*/
#define CTLINKID_SWITCH_PANEL L"SwitchPanel"
/*@}*/
/*forward dcl*/
struct tag_khui_new_creds_by_type;
typedef struct tag_khui_new_creds_by_type khui_new_creds_by_type;
struct tag_khui_new_creds_prompt;
typedef struct tag_khui_new_creds_prompt khui_new_creds_prompt;
struct tag_khui_new_creds;
typedef struct tag_khui_new_creds khui_new_creds;
typedef LRESULT
(KHMAPI *khui_ident_new_creds_cb)(khui_new_creds * nc,
UINT cmd,
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
/*! \brief New credentials acquisition blob
A pointer to an object of this type is passed in along with the
credentials acquisition messages.
\see \ref cred_acq for more information
*/
typedef struct tag_khui_new_creds {
khm_int32 magic;
khm_int32 subtype; /*!< Subtype of the request that is
being handled through this object.
One of ::KMSG_CRED_INITIAL_CREDS,
::KMSG_CRED_NEW_CREDS or
::KMSG_CRED_RENEW_CREDS */
CRITICAL_SECTION cs;
khm_boolean set_default; /*!< After a successfull credentials
acquisition, set the primary
identity as the default. */
khm_handle *identities; /*!< The list of identities associated
with this request. The first
identity in this list (\a
identities[0]) is the primary
identity. */
khm_size n_identities; /*!< Number of identities in the list
\a identities */
khm_size nc_identities; /*!< Internal use */
khui_action_context ctx; /*!< An action context specifying the
context in which the credentials
acquisition operation was
launced. */
khm_int32 mode; /*!< The mode of the user interface.
One of ::KHUI_NC_MODE_MINI or
::KHUI_NC_MODE_EXPANDED. */
HWND hwnd; /*!< Handle to the new credentials
window. */
struct tag_khui_new_creds_by_type **types;
/*!< Internal use */
khm_handle *type_subs; /*!< Internal use */
khm_size n_types; /*!< Internal use */
khm_size nc_types; /*!< Internal use */
khm_int32 result; /*!< One of ::KHUI_NC_RESULT_CANCEL or
::KHUI_NC_RESULT_PROCESS indicating
the result of the dialog with the
user */
khm_int32 response; /*!< Response. See individual message
documentation for info on what to do
with this field */
wchar_t *password; /*!< Not set until the dialog ends */
/* UI stuff */
wchar_t *banner; /*!< Internal use */
wchar_t *pname; /*!< Internal use */
khm_size n_prompts; /*!< Internal use */
khm_size nc_prompts; /*!< Internal use */
struct tag_khui_new_creds_prompt ** prompts; /*!< Internal use */
khui_ident_new_creds_cb ident_cb; /*!< Internal use */
wchar_t *window_title; /*!< Internal use */
LPARAM ident_aux; /*!< Auxilliary field which is
reserved for use by the identity
provider during the course of
conducting this dialog. */
} khui_new_creds;
#define KHUI_NC_MAGIC 0x84270427
/*!\name Result values for khui_new_creds_t::result
@{*/
#define KHUI_NC_RESULT_PROCESS 0
#define KHUI_NC_RESULT_CANCEL 1
/*@}*/
/*!\name Mode values for khui_new_creds_t::mode
@{*/
#define KHUI_NC_MODE_MINI 0
#define KHUI_NC_MODE_EXPANDED 1
/*@}*/
/*!\name Response values for khui_new_creds_t::response
@{*/
/*!\brief No known response */
#define KHUI_NC_RESPONSE_NONE 0
/*!\brief It is okay to exit the dialog now
This is the default, which is why it has a value of zero. In
order to prevent the dialog from exiting, set the
KHUI_NC_RESPONSE_NOEXIT response bit. */
#define KHUI_NC_RESPONSE_EXIT 0
/*!\brief It is NOT okay to exit the dialog now
Used to indicate that further user-interaction is necessary to
process the dialog. Usually this is accompanied by setting
necessary custom prompts and notifications so the user knows why
the dialog is prompting for more information.
*/
#define KHUI_NC_RESPONSE_NOEXIT 0x00000002
/*!\brief The dialog was processed successfully
Since this is the default response, the value is zero. Use one of
KHUI_NC_RESPONSE_FAILED or KHUI_NC_RESPONSE_PENDING to indicate an
error or pending status.
*/
#define KHUI_NC_RESPONSE_SUCCESS 0
/*!\brief The processing of the dialog failed
Self explanatory. More information about the failure should have
been reported using the khlog API, however, this response value
indicates to other credential types that depend on this credential
type that whatever it was that this credential type was supposed
to do didn't happen.
*/
#define KHUI_NC_RESPONSE_FAILED 0x00000008
/*!\brief Further interaction required
Set along with KHUI_NC_RESPONSE_NOEXIT although it is not
required. Setting this bit will automatically add the
KHUI_NC_RESPONSE_NOEXIT.
If this bit is set, all dependent plugins will be set on hold
until another round of processing clears the pending bit.
*/
#define KHUI_NC_RESPONSE_PENDING 0x00000010
/*! \brief Completed
This is automatically set if the plugin sets a response which does
not indicate either KHUI_NC_RESPONSE_NOEXIT or
KHUI_NC_RESPONSE_PENDING, which is considered to mean that the
plugin is completed processing.
This flag cannot be explicitly specified in a response.
*/
#define KHUI_NC_RESPONSE_COMPLETED 0x00000020
/*! \brief Processing
This is an internal flag set while the credentials acquisition
process is executing.
*/
#define KHUI_NC_RESPONSE_PROCESSING 0x00010000
#define KHUI_NCMASK_RESPONSE (KHUI_NC_RESPONSE_EXIT|KHUI_NC_RESPONSE_NOEXIT)
#define KHUI_NCMASK_RESULT (KHUI_NC_RESPONSE_SUCCESS|KHUI_NC_RESPONSE_FAILED|KHUI_NC_RESPONSE_PENDING)
/*@}*/
/*!\brief Maximum number of dependencies for a credentials type */
#define KHUI_MAX_TYPE_DEPS 8
/*!\brief Maximum number of credential types for a new creds window */
#define KHUI_MAX_NCTYPES 16
/*!\brief Maximum number of characters in a password
Length includes the termininating NULL
*/
#define KHUI_MAXCCH_PASSWORD 512
/*! \brief Maximum number of bytes in a password
Includes terminating NULL
*/
#define KHUI_MAXCB_PASSWORD (KHUI_MAXCCH_PASSWORD * sizeof(wchar_t))
/*! \brief Maximum number of characters in a custom banner
Length includes terminating NULL
*/
#define KHUI_MAXCCH_BANNER 256
/*! \brief Maximum number of bytes in a custom banner
Length includes terminating NULL
*/
#define KHUI_MAXCB_BANNER (KHUI_MAXCCH_BANNER * sizeof(wchar_t))
/*! \brief Maximum number of characters in a panel name
Length includes terminating NULL
*/
#define KHUI_MAXCCH_PNAME 256
/*! \brief Maximum number of bytes in a panel name
Length includes terminating NULL
*/
#define KHUI_MAXCB_PNAME (KHUI_MAXCCH_PNAME * sizeof(wchar_t))
/*! \brief A descriptor of a panel in the new credentials acquisition tab
When processing certain credentials messages such as
::KMSG_CRED_PASSWORD, ::KMSG_CRED_NEW_CREDS,
::KMSG_CRED_RENEW_CREDS, a pointer to a ::khui_new_creds structure
will be passed in to the message handler. If the handler of the
message needs to add one or more credentials types as participants
of the operation, the handler will need to call khui_cw_add_type()
and specify a ::khui_new_creds_by_type structure.
Note that the memory address passed in to the call to
khui_cw_add_type() will not be copied. Therefore, the block of
memory should remain as-is for the lifetime of the
::khui_new_creds structure or until it is removed with a call to
khui_cw_del_type().
Some of the credentials messages that require specifying a
::khui_new_creds_by_type structure require providing a
user-interface. In these cases, the fields marked for providing a
UI may be required to hold valid values. If the message does not
require providing a UI, these fields will be ignored.
*/
typedef struct tag_khui_new_creds_by_type {
khui_new_creds * nc; /*!< Internal use. Do not set */
khm_int32 flags; /*!< Internal use. Do not set */
khm_int32 type; /*!< The identifier of the credentials
type. This is a credentials type
identifier allocated with a call to
kcdb_credtype_register(). */
khm_int32 type_deps[KHUI_MAX_TYPE_DEPS];
/*!< credentials types that this
credential type depends on. Each
element defines a credentials type
identifier that this type depends
on for this operation. The number
of valid values in this array
should be specified in the \a
n_type_deps field. */
khm_size n_type_deps; /*!< Number of dependencies listed
above. Should be between 0 and
::KHUI_MAX_TYPE_DEPS. Specify 0 if
there are no dependencies. */
khm_size ordinal; /*!< The requested ordinal. The UI
would attempt to place this panel at
the reqested order in the list of
panels. Set to -1 if the order does
not matter. Once the dialog is
activated this field will be updated
to reflect the actual ordinal of the
panel. */
wchar_t *name; /*!< Name of the panel (localized,
optional). If NULL, the localized
name of the credentials type is
used. Only used if providing a
user-interface. */
HICON icon; /*!< Icon for the panel (optional).
Only used if providing a
user-interface. */
wchar_t *tooltip; /*!< Tooltip for the panel (localized,
optional). If NULL, no tooltip will
be assigned for the panel. Only
used if providing a
user-interface. */
HMODULE h_module; /*!< Handle to the module containing
the dialog resource. Only used if
providing a user-interface. */
LPWSTR dlg_template; /*!< The dialog resource. Only used
if providing a user-interface. */
DLGPROC dlg_proc; /*!< The dialog procedure. Only used
if providing a user-interface. */
HWND hwnd_panel; /*!< The dialog window. Once the
dialog panel is created, a handle to
the panel will be assigned here.
Note that the handle is assigned
after a successful call to
CreateDialogParam and hence would
not be available when handling the
WM_INITDIALOG message from the
dialog procedure. Only used of
providing a user-interface. */
HWND hwnd_tc; /*!< Internal use. Do not set */
wchar_t *credtext; /*!< A brief description of the
current state of this cred
type. (localized, optional). Only
used if providing a
user-interface. */
LPARAM aux; /*!< auxilliary field. For use by the
plug-in. */
} khui_new_creds_by_type;
/*!\name Flags for khui_new_creds_by_type
Note that KHUI_NC_RESPONSE_SUCCESS, KHUI_NC_RESPONSE_FAILED,
KHUI_NC_RESPONSE_PENDING are also stored in the flags.
@{*/
#define KHUI_NCT_FLAG_PROCESSED 1024
#define KHUI_NCT_FLAG_DISABLED 2048
/*@}*/
/*! \brief Width of a new creds dialog panel in dialog units*/
#define NCDLG_WIDTH 300
/*! \brief Height of a new creds dialog panel in dialog units*/
#define NCDLG_HEIGHT 166
/*! \brief Width of the button bar in dialog units */
#define NCDLG_BBAR_WIDTH 60
/*! \brief Height of a tab button in dialog units */
#define NCDLG_TAB_HEIGHT 15
/*! \brief Width of a tab button in dialog units */
#define NCDLG_TAB_WIDTH 60
/*! \brief A custom prompt */
typedef struct tag_khui_new_creds_prompt {
khm_size index; /*!< Set to the zero based index
of this prompt. */
khm_int32 type; /*!< one of KHUI_NCPROMPT_TYPE_* */
wchar_t * prompt; /*!< prompt string. Cannot exceed
KHUI_MAXCCH_PROMPT */
wchar_t * def; /*!< default value. Cannot exceed
KHUI_MAXCCH_PROMPT_VALUE */
wchar_t * value; /*!< On completion, this is set to the
value that the user entered. Will
not exceed
KHUI_MAXCCH_PROMPT_VALUE */
khm_int32 flags; /*!< Combination of
KHUI_NCPROMPT_FLAG_* */
HWND hwnd_static; /* internal use */
HWND hwnd_edit; /* internal use */
} khui_new_creds_prompt;
/*! \brief The prompt input is hidden
The input is hidden for prompts which accept passwords. The
control which represents the input will display an asterisk or a
small circle corresponding to each character typed in, but will
not show the actual character.
*/
#define KHUI_NCPROMPT_FLAG_HIDDEN 1
/*! \brief Internal use */
#define KHUI_NCPROMPT_FLAG_STOCK 2
/*! \brief Maximum number of characters in a prompt
Refers to the prompt text that accompanies an input control. THe
length includes the terminating NULL.
*/
#define KHUI_MAXCCH_PROMPT 256
/*! \brief Maximum number of bytes in a prompt
Refers to the prompt text that accompanies an input control. THe
length includes the terminating NULL.
*/
#define KHUI_MAXCB_PROMPT (KHUI_MAXCCH_PROMPT * sizeof(wchar_t))
/*! \brief Maximum number of characters that can be entered in an input control
Refers to the input control of a prompt. The length includes the
terminating NULL.
*/
#define KHUI_MAXCCH_PROMPT_VALUE 256
/*! \brief Maximum number of bytes that can be entered in an input control
Refers to the input control of a prompt. The length includes the
terminating NULL.
*/
#define KHUI_MAXCB_PROMPT_VALUE (KHUI_MAXCCH_PROMPT_VALUE * sizeof(wchar_t))
/* from krb5.h. Redefining here because we don't want to depend on
krb5.h for all credential types */
/*! \brief A password control */
#define KHUI_NCPROMPT_TYPE_PASSWORD 1
/*! \brief New password control
Used when changing the password
*/
#define KHUI_NCPROMPT_TYPE_NEW_PASSWORD 2
/*! \brief New password again control
Used when changing the password
*/
#define KHUI_NCPROMPT_TYPE_NEW_PASSWORD_AGAIN 3
/*! \brief Preauthentication (reserved) */
#define KHUI_NCPROMPT_TYPE_PREAUTH 4
/*! \brief Control sizes */
typedef enum tag_khui_control_size {
KHUI_CTRLSIZE_SMALL,
/*!< A small control fits in about 1/5 the width of the new
credentials panel */
KHUI_CTRLSIZE_HALF,
/*!< Half size controls fit in 1/2 the width of the new
credentials panel */
KHUI_CTRLSIZE_FULL,
/*!< Takes up the whole width of the crednetials panel */
} khui_control_size;
/*! \brief Internal use */
typedef struct tag_khui_control_row {
HWND label;
HWND input;
khui_control_size size;
} khui_control_row;
/*! \brief Create a ::khui_new_creds object
Creates and initializes a ::khui_new_creds object. The created
object must be destroyed using the khui_cw_destroy_cred_blob()
function.
\note Plugins should not call this function directly. The
necessary ::khui_new_creds objects will be created by
NetIDMgr.
\see khui_cw_destroy_cred_blob()
*/
KHMEXP khm_int32 KHMAPI
khui_cw_create_cred_blob(khui_new_creds ** c);
/*! \brief Destroy a ::khui_new_creds object
Destroys a ::khui_new_creds object that was fomerly created using
a call to khui_cw_create_cred_blob().
\note Plugins should not call this function directly. The
necessary ::khui_new_creds objects will be created by
NetIDMgr.
\see khui_cw_create_cred_blob()
*/
KHMEXP khm_int32 KHMAPI
khui_cw_destroy_cred_blob(khui_new_creds *c);
/*! \brief Lock the new_creds object
When a plugin is accessing the fields of a ::khui_new_creds
object, it must first obtain a lock on the object so that other
threads will not modify the fields at the same time. Locking the
object ensures that the fields of the object will be consistent.
Use khui_cw_unlock_nc() to undo the lock obtained through a call
to khui_cw_lock_nc().
It is not necessary to lock a new credentials object when
modifying it using the NetIDMgr API.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_lock_nc(khui_new_creds * c);
/*! \brief Unlock a new_creds object
\see khui_cw_lock_nc()
*/
KHMEXP khm_int32 KHMAPI
khui_cw_unlock_nc(khui_new_creds * c);
/*! \brief Add a new panel to a new credentials acquisition window
See the description of ::khui_new_cred_panel for information on
how to populate it to describe a credentials type panel.
Note that the structure pointed to by \a t is added by reference.
The memory pointed to by \a t is not copied. Hence, the block of
memory and any other blocks pointed to by the
::khui_new_creds_by_type structure located there should remain
intact for the lifetime of the ::khui_new_creds structure pointed
to by \a c or until the credentials type panel is removed from the
::khui_new_creds structure with a call to khui_cw_del_type().
Generally, a plug-in that calls this function should allocate a
block of memory to contain the ::khui_new_creds_by_type structure,
fill it in and then pass in the address in a call to
khui_cw_add_type() while handling a ::KMSG_CRED_PASSWORD,
::KMSG_CRED_NEW_CREDS or ::KMSG_CRED_RENEW_CREDS message. Then
the plug-in should remove the reference with a call to
khui_cw_del_type() while processing ::KMSG_CRED_END.
\see khui_cw_del_type()
\see \ref cred_acq_panel_spec
\see ::khui_new_cred_panel
\see ::khui_new_creds
*/
KHMEXP khm_int32 KHMAPI
khui_cw_add_type(khui_new_creds * c,
khui_new_creds_by_type * t);
/*! \brief Remove a panel from a new credentials acquisition window
\see khui_cw_add_type()
*/
KHMEXP khm_int32 KHMAPI
khui_cw_del_type(khui_new_creds * c,
khm_int32 type);
/*! \brief Find the panel belonging to a particular credentials type
This panel would have been added to the new credentials window
using khui_cw_add_type().
\see khui_cw_add_type()
*/
KHMEXP khm_int32 KHMAPI
khui_cw_find_type(khui_new_creds * c,
khm_int32 type,
khui_new_creds_by_type **t);
/*! \brief Enable/disable a particular credentials type
Enables or disables the panel associated with a particular
credentials type. Does not preclude the credentials type from
participating in the new credentials acquisition. However, the
user will be prevented from interacting with the specific panel.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_enable_type(khui_new_creds * c,
khm_int32 type,
khm_boolean enable);
/*! \brief Set the primary identity in a new credentials acuisition
The primary identity dictates many of the defaults and the
semantics associated with the credentials acquision process.
Setting the primary identity also triggers the
::WMNC_IDENTITY_CHANGE notification which will be sent to all the
credentials type panels.
Has no effect if the primary identity is already the same as the
one specified in \a id. Specify NULL for \a id if the current
primary identity is to be cleared.
If the primary identity is changed, then all the additional
identities associated with the new credentials acquisition dialog
will also be discarded.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_set_primary_id(khui_new_creds * c,
khm_handle id);
/*! \brief Add an additional identity to the new credentials acquisition
Individual plugins are free to decide how to handle additional
identities. Generally, they would attempt to obtain credentials
for the primary and additional identities, but would not consider
it an error if an additional identity failed to obtain
credentials.
Calling this function with \a id of NULL does nothing.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_add_identity(khui_new_creds * c,
khm_handle id);
/*! \brief Clear all custom prompts
Removes all the custom prompts from the new credentials dialog.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_clear_prompts(khui_new_creds * c);
/*! \brief Synchronize custom prompt values
It is important to synchronize the values before accessing their
values. The controls associated with custom prompts update the
values in the ::khui_new_creds object periodically. However, the
values may lose sync intermittently.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_sync_prompt_values(khui_new_creds * c);
/*! \brief Begin custom prompting
Begins the process of defining custom prompts. Implicity removes
all the custom prompts that are currently being displayed. The \a
banner and \a name will be displayed in separate controls above
the set of new custom prompts.
The controls associated with the prompts will not actually be
created until all the prompts have been added using
khui_cw_add_prompt(). The number of promtps that can be added
will be exactly \a n_prompts.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_begin_custom_prompts(khui_new_creds * c,
khm_size n_prompts,
wchar_t * banner,
wchar_t * name);
/*! \brief Add a custom prompt
After khui_cw_begin_custom_prompts() is called, the plugin should
call khui_cw_add_prompt() to add the actual prompts. The number
of prompts that can be added is the \a n_prompts value specified
in the earlier call to \a khui_cw_begin_custom_prompts().
Once \a n_prompts prompts have been added, the new prompts will
automatically be created and shown in the user interface.
However, if less than that prompts are added, nothing is displayed
to the user.
\param[in] c Pointer to ::khui_new_creds structure
\param[in] type Type of prompt. One of
::KHUI_NCPROMPT_TYPE_PREAUTH, ::KHUI_NCPROMPT_TYPE_PASSWORD,
::KHUI_NCPROMPT_TYPE_NEW_PASSWORD,
::KHUI_NCPROMPT_TYPE_NEW_PASSWORD_AGAIN
\param[in] prompt Text of the prompt. Constrained by
::KHUI_MAXCCH_PROMPT. (Localized, required)
\param[in] def Default value. (optional). Constrained by
::KHUI_MAXCCH_PROMPT_VALUE. Set to NULL if not provided.
\param[in] flags Flags. Combination of
::KHUI_NCPROMPT_FLAG_HIDDEN
*/
KHMEXP khm_int32 KHMAPI
khui_cw_add_prompt(khui_new_creds * c,
khm_int32 type,
wchar_t * prompt,
wchar_t * def,
khm_int32 flags);
/*! \brief Retrieve a custom prompt
Retrieves an individual prompt. The \a idx parameter is a
zero-based index of the prompt to retrieve. The ordering is the
same as the order in which khui_cw_add_prompt() was called.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_get_prompt(khui_new_creds * c,
khm_size idx,
khui_new_creds_prompt ** prompt);
/*! \brief Get the number of custom prompts
Retrieves the number of custom prompts currently displayed. If
this function is called between calling
khui_cw_begin_custom_prompts() and adding all the prompts, the
number returned will be the number of prompts that is expected to
be registered (i.e. the \a n_prompts parameter passed to
khui_cw_begin_custom_prompts()).
*/
KHMEXP khm_int32 KHMAPI
khui_cw_get_prompt_count(khui_new_creds * c,
khm_size * np);
/*! \brief Get the value of a custom prompt
Retrieve the value of a specific prompt. The value is the string
that was typed into the input control associated with a custom
prompt. The \a idx parameter is the zero-based index of the
prompt from which to retrieve the value from. The ordering is the
same as the order in which khui_cw_add_prompt() was called.
It is important to call khui_cw_sync_prompt_values() before
starting to call khui_cw_get_prompt_value() so that the values
returned are up-to-date.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_get_prompt_value(khui_new_creds * c,
khm_size idx,
wchar_t * buf,
khm_size *cbbuf);
/*! \brief Set the response for a plugin
When handling ::KMSG_CRED_DIALOG_PROCESS from within the plugin
thread, it is important to set the response by calling this
function. The response can be used to signal whether the plugin
successfully obtained credentials or whether further interaction
is required, or the credentials acquisition failed.
The response is a combination of :
- ::KHUI_NC_RESPONSE_PENDING
- ::KHUI_NC_RESPONSE_FAILED
- ::KHUI_NC_RESPONSE_PENDING
- ::KHUI_NC_RESPONSE_SUCCESS
- ::KHUI_NC_RESPONSE_NOEXIT
- ::KHUI_NC_RESPONSE_EXIT
*/
KHMEXP khm_int32 KHMAPI
khui_cw_set_response(khui_new_creds * c,
khm_int32 type,
khm_int32 response);
/*! \brief Check whether a specified credential type panel succeeded
This is called during the processing of KMSG_CRED_DIALOG_PROCESS
to determine whether a specified credential type succeeded in
obtaining credentials. The credential type that is being queried
should have also been listed as a dependency when adding the
current credentials type, otherwise the type queried may not have
been invoked yet.
\return TRUE iff the queried type has reported that it successfully
completed the credentials acquision operation.
*/
KHMEXP khm_boolean KHMAPI
khui_cw_type_succeeded(khui_new_creds * c,
khm_int32 type);
/*! \brief Add a row of controls to the identity specifier area
Only for use by identity provider callbacks that wish to add an
identity selector control. A row of controls consist of a label
control and some input control.
When the ::WMNC_IDENT_INIT message is sent to the identity
provider, it receives a handle to the dialog panel in the \a
lParam parameter which should be the parent window of both the
windows specified here. The control ID for any controls created
must fall within the ::KHUI_CW_ID_MIN and ::KHUI_CW_ID_MAX range.
Both controls will be resized to fit in the row.
If \a long_label is TRUE then the size of the label will be larger
than normal and will accomodate more text.
*/
KHMEXP khm_int32 KHMAPI
khui_cw_add_control_row(khui_new_creds * c,
HWND label,
HWND input,
khui_control_size size);
/*!@}*/ /* Credentials acquisition */
/*!@}*/
#endif

View File

@ -0,0 +1,207 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHPROPS_H
#define __KHIMAIRA_KHPROPS_H
/*********************************************************************
Property sheets
**********************************************************************/
/*! \addtogroup khui
@{*/
/*!\defgroup khui_pp Property sheets
@{*/
/* forward dcl */
struct tag_khui_property_page;
/*! \brief A property sheet
*/
typedef struct tag_khui_property_sheet {
PROPSHEETHEADER header; /*!< property sheet header */
khm_int32 status; /*!< status of property sheet. One of
::KHUI_PS_STATUS_NONE,
::KHUI_PS_STATUS_RUNNING or
::KHUI_PS_STATUS_DONE */
HWND hwnd; /*!< handle to the property sheet window.
Only valid when \a status is NOT
::KHUI_PS_STATUS_NONE */
HWND hwnd_page; /*!< handle to the current page in the
property sheet. Only valid when \a
status is ::KHUI_PS_STATUS_RUNNING */
khui_action_context ctx; /*!< Context for the property sheet. See
documentation for
::khui_action_context */
khm_handle identity; /*!< Handle to the associated identity,
if applicable */
khm_int32 credtype; /*!< Type ID of the credentials type, if
applicable */
khm_handle cred; /*!< Handle to the associated credential,
if applicable */
khm_int32 n_pages; /*!< Number of property pages.
Upperbound of ::KHUI_PS_MAX_PSP */
QDCL(struct tag_khui_property_page);
} khui_property_sheet;
/*! \brief The property sheet hasn't been created yet */
#define KHUI_PS_STATUS_NONE 0
/*! \brief The property sheet is visible and running */
#define KHUI_PS_STATUS_RUNNING 1
/*! \brief The property sheet has completed running.
At this point, it is safe to call khui_ps_destroy_sheet() to
destroy the property sheet.
*/
#define KHUI_PS_STATUS_DONE 2
/*! \brief The property sheet is in the process of being destroyed
*/
#define KHUI_PS_STATUS_DESTROY 3
/*! \brief Maximum number of property sheet pages in a property sheet */
#define KHUI_PS_MAX_PSP 16
/*! \brief A property sheet page
*/
typedef struct tag_khui_property_page {
HPROPSHEETPAGE h_page;
LPPROPSHEETPAGE p_page;
HWND hwnd;
khm_int32 credtype;
khm_int32 ordinal;
LDCL(struct tag_khui_property_page);
} khui_property_page;
/*! \brief Special pseudo credtype for identity page
*/
#define KHUI_PPCT_IDENTITY (-8)
/*! \brief Special pseudo credtype for credential page
*/
#define KHUI_PPCT_CREDENTIAL (-9)
/*! \brief Create a property sheet
\note Only called by the NetIDMgr application.
*/
KHMEXP khm_int32 KHMAPI
khui_ps_create_sheet(khui_property_sheet ** sheet);
/*! \brief Add a page to a property sheet
Called by a plugin or the NetIDMgr application to add a page to a
property sheet.
Pages can only be added before the property sheet is made visible
to the user.
\param[in] sheet The property sheet to add the page to
\param[in] credtype The credentials type ID of the owner of the
property page. This should be set to ::KCDB_CREDTYPE_INVALID
if the type is not relevant.
\param[in] ordinal Requested ordinal. A positive integer which is
used to order the pages in a property sheet. The pages are
ordered based on ordinal first and then alphabetically by
credentials type name. If the type is unavailable, then the
ordering is undefined. Ordinals for credential type property
pages can be in the range from 0 to 127. Ordinals 128 and
above are reserved. Passing in 0 will work for credentials
providers unless they provide more than one property page per
credential, in which case the ordinal should be used to
enforce an order.
\param[in] ppage Pointer to structure that will be passed to
CreatePropertySheetPage() to create the property page. The
structure is not managed by NetIDMgr at all, and must exist
until the status of the property sheet changes to
::KHUI_PS_STATUS_RUNNING. The same pointer will be found in
the \a p_page member of the ::khui_property_page structure.
\param[out] page A pointer will be returned here that will point
to the newly created khui_property_page structure. Specify
NULL if this value is not required. You can use
khui_ps_find_page() to retrieve a pointer to the structure
later.
*/
KHMEXP khm_int32 KHMAPI
khui_ps_add_page(khui_property_sheet * sheet,
khm_int32 credtype,
khm_int32 ordinal,
LPPROPSHEETPAGE ppage,
khui_property_page ** page);
/*! \brief Retrieve a property page structure from a property sheet
*/
KHMEXP khm_int32 KHMAPI
khui_ps_find_page(khui_property_sheet * sheet,
khm_int32 credtype,
khui_property_page ** page);
/*! \brief Display the property sheet
\note Only called by the NetIDMgr application
*/
KHMEXP HWND KHMAPI
khui_ps_show_sheet(HWND parent,
khui_property_sheet * sheet);
/*! \brief Check if the given message belongs to the property sheet
\note Only called by the NetIDMgr application
*/
KHMEXP LRESULT KHMAPI
khui_ps_check_message(khui_property_sheet * sheet,
PMSG msg);
/*! \brief Destroy a property sheet and all associated data structures.
\note Only called by the NetIDMgr application.
*/
KHMEXP khm_int32 KHMAPI
khui_ps_destroy_sheet(khui_property_sheet * sheet);
KHMEXP khm_int32 KHMAPI
khui_property_wnd_set_record(HWND hwnd_pwnd, khm_handle record);
/*!@}*/
/*!@}*/
#endif

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_REMOTE_H
#define __KHIMAIRA_REMOTE_H
/*! \addtogroup khui
@{*/
/*! \defgroup khui_remote Connecting to NetIDMgr from another process
@{*/
/* Leash compatibility */
#define ID_OBTAIN_TGT_WITH_LPARAM 32810
#define KHUI_REQDAEMONWND_CLASS L"IDMgrRequestDaemonCls"
#define KHUI_REQDAEMONWND_NAME L"IDMgrRequestDaemon"
#define KHUI_REQD_MAPPING_FORMAT L"Local\\NetIDMgr_DlgInfo_%lu"
#define NETID_USERNAME_SZ 128
#define NETID_REALM_SZ 192
#define NETID_TITLE_SZ 256
#define NETID_CCACHE_NAME_SZ 264
#define NETID_DLGTYPE_TGT 0
#define NETID_DLGTYPE_CHPASSWD 1
typedef struct {
DWORD size;
DWORD dlgtype;
// Tells whether dialog box is in change pwd mode or init ticket mode
struct {
WCHAR title[NETID_TITLE_SZ];
WCHAR username[NETID_USERNAME_SZ];
WCHAR realm[NETID_REALM_SZ];
WCHAR ccache[NETID_CCACHE_NAME_SZ];
DWORD use_defaults;
DWORD forwardable;
DWORD noaddresses;
DWORD lifetime;
DWORD renew_till;
DWORD proxiable;
DWORD publicip;
DWORD must_use_specified_principal;
} in;
struct {
WCHAR username[NETID_USERNAME_SZ];
WCHAR realm[NETID_REALM_SZ];
WCHAR ccache[NETID_CCACHE_NAME_SZ];
} out;
// Version 1 of this structure ends here
} NETID_DLGINFO, *LPNETID_DLGINFO;
#define NETID_DLGINFO_V1_SZ (10 * sizeof(DWORD) \
+ sizeof(WCHAR) * (NETID_TITLE_SZ + \
2 * NETID_USERNAME_SZ + 2 * NETID_REALM_SZ + \
2 * NETID_CCACHE_NAME_SZ))
/*!@} */
/*!@} */
#endif

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_RESCACHE_H
#define __KHIMAIRA_RESCACHE_H
#include<khdefs.h>
KHMEXP void KHMAPI
khui_init_rescache(void);
KHMEXP void KHMAPI
khui_exit_rescache(void);
KHMEXP void KHMAPI
khui_cache_bitmap(UINT id, HBITMAP hbm);
KHMEXP HBITMAP KHMAPI
khui_get_cached_bitmap(UINT id);
typedef struct khui_ilist_t {
int cx;
int cy;
int n;
int ng;
int nused;
HBITMAP img;
HBITMAP mask;
int *idlist;
} khui_ilist;
typedef struct khui_bitmap_t {
HBITMAP hbmp;
int cx;
int cy;
} khui_bitmap;
KHMEXP void KHMAPI
khui_bitmap_from_hbmp(khui_bitmap * kbm, HBITMAP hbm);
KHMEXP void KHMAPI
khui_delete_bitmap(khui_bitmap * kbm);
KHMEXP void KHMAPI
khui_draw_bitmap(HDC hdc, int x, int y, khui_bitmap * kbm);
/* image lists */
KHMEXP khui_ilist * KHMAPI
khui_create_ilist(int cx, int cy, int n, int ng, int opt);
KHMEXP BOOL KHMAPI
khui_delete_ilist(khui_ilist * il);
KHMEXP int KHMAPI
khui_ilist_add_masked(khui_ilist * il, HBITMAP hbm, COLORREF cbkg);
KHMEXP int KHMAPI
khui_ilist_add_masked_id(khui_ilist *il, HBITMAP hbm,
COLORREF cbkg, int id);
KHMEXP int KHMAPI
khui_ilist_lookup_id(khui_ilist *il, int id);
KHMEXP void KHMAPI
khui_ilist_draw(khui_ilist * il, int idx, HDC dc, int x, int y, int opt);
KHMEXP void KHMAPI
khui_ilist_draw_bg(khui_ilist * il, int idx, HDC dc, int x, int y,
int opt, COLORREF bgcolor);
#define khui_ilist_draw_id(il, id, dc, x, y, opt) \
khui_ilist_draw((il),khui_ilist_lookup_id((il),(id)),(dc),(x),(y),(opt))
#define KHUI_SMICON_CX 16
#define KHUI_SMICON_CY 16
#endif

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_TRACKERWND_H
#define __KHIMAIRA_TRACKERWND_H
#include<time.h>
/*! \addtogroup khui
@{ */
/*!\defgroup khui_trk Duration sliders
The duration sliders in the UI are pseudo-log-scaled. This is based
on the assumption that people don't really need 1 minute accuracy when
setting a duration that's several hours long. As a result, it is
easier to hone in on the duration that you want without having
wizardly mouse maneuvering skillz.
Following are the duration ranges and the granularity that is offered
in each range:
<table>
<tr><td> Range </td><td> Increment</td></tr>
<tr><td> 0..5m </td><td> 1 min </td></tr>
<tr><td> 5m..1hr </td><td> 5 min </td></tr>
<tr><td> 1hr..4hr </td><td> 15 min </td></tr>
<tr><td> 4hr..10hr </td><td> 30 min </td></tr>
<tr><td> 10hr..24hr</td><td> 1 hr </td></tr>
<tr><td> 24hr..4d </td><td> 6 hr </td></tr>
<tr><td> 4d.. </td><td> 1 day </td></tr>
</table>
We don't really adjust for durations over 4 days. The ranges we are
concerned with don't get much larger.
For the purpose of writing this piece of code, I have chosen the term
"tick" to refer to a period of granularity. The number of periods of
granularity (inclusive) within a certain duration interval is referred
to as the number of ticks in the interval. For example, there are 4
ticks between the interval of 3 minutes to 10 minutes. Each occuring
at the start of 3min, 4, 5 and 10mins. And thusly the slider control
will display 4 ticks if it is displaying the interval 3-10mins.
@{*/
/*! \brief Tracker data */
typedef struct tag_khui_tracker {
WNDPROC fn_edit;
WNDPROC fn_tracker;
HWND hw_slider;
HWND hw_edit;
int lbl_y;
int lbl_lx;
int lbl_rx;
DWORD act_time;
time_t current; /*!< Current selection */
time_t min; /*!< Minimum (inclusive) */
time_t max; /*!< Maximum (inclusive) */
} khui_tracker;
/*! \brief Install a tracker into an edit control
Once installed, the edit control becomes a duration editor. The
tracker data structure that is supplied should remain as is for
the lifetime of the edit control.
The tracker strucutre should have been initialized with a call to
khui_tracker_initialize() and should have valid values in the \a
min, \a max and \a current fields.
*/
KHMEXP void KHMAPI
khui_tracker_install(HWND hwnd_edit, khui_tracker * tc);
KHMEXP void KHMAPI
khui_tracker_reposition(khui_tracker * tc);
KHMEXP void KHMAPI
khui_tracker_initialize(khui_tracker * tc);
KHMEXP void KHMAPI
khui_tracker_refresh(khui_tracker * tc);
KHMEXP void KHMAPI
khui_tracker_kill_controls(khui_tracker * tc);
/*!@}*/
/*!@}*/
#endif

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KHUIDEFS_H
#define __KHIMAIRA_KHUIDEFS_H
#include<windows.h>
#include<kmq.h>
#include<kcreddb.h>
#include<kherror.h>
#include<kherr.h>
#include<khmsgtypes.h>
#include<khaction.h>
#include<khactiondef.h>
#include<khrescache.h>
#include<khhtlink.h>
#include<khnewcred.h>
#include<khprops.h>
#include<khalerts.h>
#include<khconfigui.h>
#include<khtracker.h>
#include<khremote.h>
/*! \internal */
KHMEXP void KHMAPI
khm_version_init(void);
/*! \defgroup khui User Interface
Functions and data structures for interacting with the user
interface.
@{*/
/*! \brief Get the version of the NetIDMgr library
\param[out] libver Receives the version of the library.
\param[out] apiver Receives the API version of the library.
Optional. Set to NULL if this value is not required.
\note When the NetIDMgr framework loads a plugin, it checks the
version information of the plugin against the version of the
library to determine if the plugin is compatible.
*/
KHMEXP void KHMAPI
khm_get_lib_version(khm_version * libver, khm_ui_4 * apiver);
/*! \brief Return the version of Common Control library
Can be used to check the version of the Windows Common Control
library that is currently loaded. The return value of the
function is the packed version value obatained by the macro :
\code
MAKELONG(vesion->dwMinorVersion, version->dwMajorVersion);
\endcode
The \a pdvi parameter is optional. Specify NULL if this is not
required.
*/
KHMEXP khm_ui_4 KHMAPI
khm_get_commctl_version(khm_version * pdvi);
/*!@}*/
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,764 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KMQ_H__
#define __KHIMAIRA_KMQ_H__
/*! \defgroup kmq NetIDMgr Message Queue */
/*@{*/
#include<khdefs.h>
#include<khlist.h>
#include<kherr.h>
/* general */
#ifdef _WIN32
typedef DWORD kmq_thread_id;
typedef DWORD kmq_timer;
#endif
#ifdef _WIN32
/*! \brief Window message for kmq
This message is sent to the window procedure of a window if that
window is a subscriber to KMQ messages.
\see kmq_subscribe_hwnd() for more information about handling this
window message
*/
#define KMQ_WM_DISPATCH (WM_APP+0x100)
#endif
/* callback */
/*! \brief A message callback
Should return TRUE if the message is properly handled. Otherwise
return FALSE */
typedef khm_int32 (KHMAPI *kmq_callback_t)(khm_int32 msg_type,
khm_int32 msg_sub_type,
khm_ui_4 uparam,
void * vparam);
/* message */
/*! \brief A single response.
Certain broadcast messages may user scatter-gather type
notification and result gathering. Individual subscribers to a
message attach their individual responses to a ::kmq_response
object and attach that to the message which can later be read by
the sender of the message.
*/
typedef struct tag_kmq_response {
kmq_thread_id thread;
void * response;
LDCL(struct tag_kmq_response);
} kmq_response;
/*! \brief A single message
*/
typedef struct tag_kmq_message {
khm_int32 type; /*!< Type of message */
khm_int32 subtype; /*!< Subtype of message */
khm_ui_4 uparam; /*!< Integer parameter */
void * vparam; /*!< Pointer to parameter blob */
khm_int32 nSent; /*!< Number of instances of message
sent (for broadcast messages) */
khm_int32 nCompleted; /*!< Number of instances that have
completed processing (for broadcast
messages) */
khm_int32 nFailed; /*!< Number of instances that failed
to process (for broadcast
messages) */
kmq_response * responses; /*!< List of responses */
HANDLE wait_o; /*!< Event to wait on (only valid if
the publisher of the message
requested a handle to the call) */
kmq_timer timeSent; /*!< Time at which the message was
sent */
kmq_timer timeExpire; /*!< Time at which the message
expires */
kherr_context * err_ctx; /*!< Error context for the message */
khm_int32 refcount;
LDCL(struct tag_kmq_message);
} kmq_message;
/*! \brief A handle to a call
*/
typedef kmq_message *kmq_call;
/*! \brief Message reference */
typedef struct tag_kmq_message_ref {
kmq_message * msg; /*!< Message that we are referring
to */
kmq_callback_t recipient; /*!< The recipient of the message */
LDCL(struct tag_kmq_message_ref);
} kmq_message_ref;
/*! \brief Message queue
Each thread gets its own message queue. When a message is
broadcast to which there is a subscriber in a particular thread, a
reference to the message is placed in the message queue of the
thread. The dispatch procedure then dispatches the message as
described in the message reference.
*/
typedef struct tag_kmq_queue {
kmq_thread_id thread; /*!< The thread id */
CRITICAL_SECTION cs;
HANDLE wait_o;
khm_int32 load; /*!< Number of messages waiting to be
processed on this message queue. */
kmq_timer last_post; /*!< Time the last message was
received */
khm_int32 flags; /*!< Flags. Currently, it's just KMQ_QUEUE_FLAG_DELETED */
/*Q*/
QDCL(kmq_message_ref); /*!< Queue of message references */
/*Lnode*/
LDCL(struct tag_kmq_queue);
} kmq_queue;
#define KMQ_QUEUE_FLAG_DELETED 0x0008
/*! \brief Message subscription
A subscription binds a recipient with a message type. These are
specific to a thread. I.e. a subscription that was made in one
thread will not receive messages in the context of another thread.
*/
typedef struct tag_kmq_msg_subscription {
khm_int32 magic; /*!< Magic number. Should always be
::KMQ_MSG_SUB_MAGIC */
khm_int32 type; /*!< Type of message */
khm_int32 rcpt_type; /*!< Type of recipient. One of
::KMQ_RCPTTYPE_CB or
::KMQ_RCPTTYPE_HWND */
union {
kmq_callback_t cb; /*!< Callback if the subscription is
of callback type */
HWND hwnd; /*!< Window handle if the subscription
is a windows message type */
} recipient;
kmq_queue * queue; /*!< Associated queue */
/*lnode*/
LDCL(struct tag_kmq_msg_subscription);
} kmq_msg_subscription;
#define KMQ_MSG_SUB_MAGIC 0x3821b58e
/*! \brief Callback recipient type
The recipient is a callback function */
#define KMQ_RCPTTYPE_CB 1
/*! \brief Windows recipient type
The recipient is a window */
#define KMQ_RCPTTYPE_HWND 2
/* publishers */
/*! \brief A completion handler for a message
Each message type can have a completion handler. Once a message
of this a specific type has been broadcast and handled by all the
subscripbers, the message will be passed down to the completion
handler before the associated data structures are freed. This
allows applications that define message type to also define clean
up for each message. For example, the completion handler can
initiate another message if the messages form a sequence or free
up blocks of memory that was passed as the parameter to the
message.
*/
typedef void (KHMAPI *kmq_msg_completion_handler)(kmq_message *);
/*! \brief A message type
*/
typedef struct tag_kmq_msg_type {
khm_int32 id; /*!< Identifier for the message
type. */
kmq_msg_subscription * subs; /*!< The list of subscriptions */
kmq_msg_completion_handler completion_handler; /*!< Completion
handler for the message type */
wchar_t * name; /*!< Name of the message type for
named types. Message type names are
language independant. */
/*Lnode*/
LDCL(struct tag_kmq_msg_type);
} kmq_msg_type;
/*! \brief The maximum number of message types
*/
#define KMQ_MSG_TYPE_MAX 255
/*! \brief Maximum number of characters in a message type name
The count includes the terminating NULL
*/
#define KMQ_MAXCCH_TYPE_NAME 256
/*! \brief Maximum number of bytes in a message type name
Type count includes the terminating NULL
*/
#define KMQ_MAXCB_TYPE_NAME (KMQ_MAXCCH_TYPE_NAME * sizeof(wchar_t))
KHMEXP khm_int32 KHMAPI kmq_init(void);
KHMEXP khm_int32 KHMAPI kmq_exit(void);
/*! \brief Register a message type
Registers a custom message type. The \a name parameter specifies
a language independent name for the message type and must be
unique and must be less than ::KMQ_MAXCCH_TYPE_NAME characters.
\param[in] name Name of the message type. Upto
::KMQ_MAXCCH_TYPE_NAME characters including terminating NULL.
The \a name cannot be a zero length string.
\param[out] new_id Receives the new message type ID. Specify NULL
if the new message type is not required.
\see kmq_find_type() and kmq_unregister_type()
\retval KHM_ERROR_INVALID_PARAM The \a name parameter was invalid.
\retval KHM_ERROR_EXISTS A message type with that name already exists.
\retval KHM_ERROR_NO_RESOURCES Can't register any more message types.
\retval KHM_ERROR_SUCCESS The operation succeeded.
*/
KHMEXP khm_int32 KHMAPI kmq_register_type(wchar_t * name, khm_int32 * new_id);
/*! \brief Find a message type
Find the message type with the given name. If found, the type ID
is returned in \a id.
\retval KHM_ERROR_SUCCESS A message type with the given name was
found.
\retval KHM_ERROR_NOT_FOUND A message type with the given name was
not found.
*/
KHMEXP khm_int32 KHMAPI kmq_find_type(wchar_t * name, khm_int32 * id);
/*! \brief Unregister a message type
Unregisters a message type that was registered using
kmq_register_type().
\retval KHM_ERROR_SUCCESS The specified message type was
successfully unregistered.
\retval KHM_ERROR_NOT_FOUND The message type was not found.
*/
KHMEXP khm_int32 KHMAPI kmq_unregister_type(khm_int32 id);
/*! \brief Subscribte to a message type.
Adds a subscription to messages of type \a type. Subscriptions
are managed per thread. Therefore the subscription is actually
added to the subscription list for the current thread (the thread
which calls kmq_subscribe()).
When a message of type \a type is received by the thread, it is
dispatched to the callback function identified by \a cb within the
context of this thread.
\note Calling kmq_subscribe() from within multiple threads with
the same \a type and \a cb will result in multiple
subscriptions.
\see kmq_unsubscribe()
\see kmq_dispatch()
*/
KHMEXP khm_int32 KHMAPI kmq_subscribe(khm_int32 type, kmq_callback_t cb);
/*! \brief Subscribe a window to a message type
Adds the window specified by \a hwnd to the subscription list for
the message type \a type. When a message of this type is posted,
then the window procedure of the window \a hwnd receives a message
::KMQ_WM_DISPATCH.
When a window receives a ::KMQ_WM_DISPATCH message, it means that
a message has been posted which is of a type that the window has
subscribed for. Because of the way Windows handles window
messages and the way NetIDMgr message queues work, a thread which
has a window (or thread) procedure can not call kmq_dispatch() to
handle these messages. For threads that have window or thread
message loops, they must call kmq_subscribe_hwnd() to subscribe a
particular window (for thread message loops, this would be the
HWND of the message window for the thread) to NetIDMgr messages.
There are two supported ways of handling the ::KMQ_WM_DISPATCH
message. Examples of both are provided below.
Handling the message inline:
\code
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
kmq_message * m;
khm_int32 rv;
...
switch(uMsg) {
case WM_CREATE:
...
kmq_subscribe_hwnd(KMSG_CRED, hwnd);
...
break;
case WM_DESTROY:
...
kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);
...
break;
...
case KMQ_WM_DISPATCH:
kmq_wm_begin(lParam,&m);
if(m->type == KMSG_CRED && m->subtype == KMSG_CRED_ROOTDELTA) {
// do something
rv = KHM_ERROR_SUCCESS;
}
return kmq_wm_end(m, rv);
...
};
...
}
\endcode
The other method is to dispatch the ::KMQ_WM_DISPATCH message to a
secondary callback function:
\code
khm_int32 msg_handler(khm_int32 t, khm_int32 st, khm_ui_4 up, void * pb) {
khm_int32 rv = KHM_ERROR_SUCCESS;
//handle message
return rv;
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
kmq_message * m;
khm_int32 rv;
...
switch(uMsg) {
...
case WM_CREATE:
...
kmq_subscribe_hwnd(KMSG_CRED, hwnd);
...
break;
case WM_DESTROY:
...
kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);
...
break;
...
case KMQ_WM_DISPATCH:
return kmq_wm_dispatch(lParam, msg_handler);
...
};
...
}
\endcode
\note Make sure you unsubscribe from the message type when the
window is destroyed.
\see kmq_unsubscribe_hwnd()
\see kmq_wm_begin()
\see kmq_wm_end()
\see kmq_wm_dispatch()
*/
KHMEXP khm_int32 KHMAPI kmq_subscribe_hwnd(khm_int32 type, HWND hwnd);
#ifdef _WIN32
/*! \brief Begins handling a KMQ_WM_DISPATCH message
\return The return value of this function should be ignored.
\see kmq_subscribe_hwnd() for more details about handling ::KMQ_WM_DISPATCH
*/
KHMEXP LRESULT KHMAPI kmq_wm_begin(LPARAM lparm, kmq_message ** m);
/*! \brief Ends handling a KMQ_WM_DISPATCH message
\return The return value of this function should be the return
value of the window procedure. See kmq_subscribe_hwnd()
documentation for example
\see kmq_subscribe_hwnd() for more details about handling ::KMQ_WM_DISPATCH
*/
KHMEXP LRESULT KHMAPI kmq_wm_end(kmq_message *m, khm_int32 rv);
/*! \brief Dispatches a KMQ_WM_DISPATCH message to a callback
\return The return value of this function should be the return
value of the window procedure. See kmq_subscribe_hwnd()
documentation for example.
\see kmq_subscribe_hwnd() for more details about handling ::KMQ_WM_DISPATCH
*/
KHMEXP LRESULT KHMAPI kmq_wm_dispatch(LPARAM lparm, kmq_callback_t cb);
#endif
/*! \brief Unsubscribe a callback from a message type
Removes the subscription for message type \a type for callback
function \a cb from the subscription list for the current thread
(the thread that calls kmq_unsubscribe()).
\note kmq_unsubscribe() can only remove subscriptions for the subscription
list for the current thread.
\see kmq_subscribe()
\see kmq_dispatch()
*/
KHMEXP khm_int32 KHMAPI kmq_unsubscribe(khm_int32 type, kmq_callback_t cb);
/*! \brief Unsubscribe a window from a message type
Removes the specific window from the subsription list for message
type \a type.
\see kmq_subscribe_hwnd()
*/
KHMEXP khm_int32 KHMAPI kmq_unsubscribe_hwnd(khm_int32 type, HWND hwnd);
/*! \brief Create an ad-hoc subscription
An ad-hoc subscription describes a callback point in a thread that
can be dispatched messages to individually without broadcasting.
\see kmq_post_sub_msg(), kmq_post_sub_msg_ex(),
kmq_send_sub_msg(), kmq_post_subs_msg(),
kmq_post_subs_msg_ex(), kmq_send_subs_msg(),
kmq_delete_subscription()
*/
KHMEXP khm_int32 KHMAPI kmq_create_subscription(
kmq_callback_t cb,
khm_handle * result);
/*! \brief Create an ad-hoc subscription for a window
An ad-hoc subscription describes a window that will be dispatched
messages individually without broadcasting.
\see kmq_post_sub_msg(), kmq_post_sub_msg_ex(),
kmq_send_sub_msg(), kmq_post_subs_msg(),
kmq_post_subs_msg_ex(), kmq_send_subs_msg(),
kmq_delete_subscription()
*/
KHMEXP khm_int32 KHMAPI kmq_create_hwnd_subscription(HWND hw,
khm_handle * result);
/*! \brief Delete an ad-hoc subscription
Deletes a subscriptoin that was created using
kmq_create_subscription()
*/
KHMEXP khm_int32 KHMAPI kmq_delete_subscription(khm_handle sub);
/*! \brief Post a message to a subscription
Equivalent of kmq_post_msg() but only posts the message to the
specified subscription.
*/
KHMEXP khm_int32 KHMAPI kmq_post_sub_msg(
khm_handle sub,
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * vparam);
/*! \brief Post a message to a subscription and acquire a handle to the call
*/
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);
/*! \brief Send a synchronous message to a subscription
\retval KHM_ERROR_SUCCESS The call succeeded, and no subscribers reported errors
\retval KHM_ERROR_PARTIAL The call succeeded, but at least one subscriber reported errors
*/
KHMEXP khm_int32 KHMAPI kmq_send_sub_msg(
khm_handle sub,
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * vparam);
/*! \brief Post a message to a group of subscriptions
The block of memory pointed to by \a subs should be an array of
subscriptions. The number of elements in that array should be \a
n_subs. A message as specified by the remaining parameters will
be dispatched to all of the subscription points in the array.
*/
KHMEXP khm_int32 KHMAPI kmq_post_subs_msg(
khm_handle * subs,
khm_size n_subs,
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * vparam);
/*! \brief Post a message to a group of subscriptions and acquire a handle to the call
The block of memory pointed to by \a subs should be an array of
subscriptions. The number of elements in that array should be \a
n_subs. A message as specified by the remaining parameters will
be dispatched to all of the subscription points in the array, and
a handle to the call will be returned in \a call.
The returned \a call will reference all of the dispatches that
were made.
*/
KHMEXP khm_int32 KHMAPI kmq_post_subs_msg_ex(
khm_handle * subs,
khm_int32 n_subs,
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * vparam,
kmq_call * call);
/*! \brief Send a synchronous message to a group of subscriptions
The block of memory pointed to by \a subs should be an array of
subscriptions. The number of elements in that array should be \a
n_subs. A message as specified by the remaining parameters will
be dispatched to all of the subscription points in the array. The
function will not return until all of the calls have succeeded.
\retval KHM_ERROR_SUCCESS The call succeeded, and no subscribers reported errors
\retval KHM_ERROR_PARTIAL The call succeeded, but at least one subscriber reported errors
*/
KHMEXP khm_int32 KHMAPI kmq_send_subs_msg(
khm_handle *subs,
khm_int32 n_subs,
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * vparam);
/*! \brief Dispatch a message for the current thread.
This function opens the message list for the current thread and
dispatches the first message instance that is found. Note that if
multiple callbacks subscribe to the same message type in the same
thread, then when a message of that type is received, multiple
message instances are added to the message queue corresponding to
each subscription.
If no message instances are waiting in the queue, kmq_dispatch()
waits for the \a timeout period for a message.
\param[in] timeout The timeout period in milliseconds. Specify INFINITE for
kmq_dispatch() to wait indefinitely.
\retval KHM_ERROR_SUCCESS A message instance was dispatched
\retval KHM_ERROR_TIMEOUT The timeout period elapsed
\retval KHM_ERROR_EXIT The message found on the queue was <KMSG_SYSTEM,KMSG_SYSTEM_EXIT>
*/
KHMEXP khm_int32 KHMAPI kmq_dispatch(kmq_timer timeout);
/*! \brief Send a message
The specified message will be posted to all the subscribers of the
message type. Then the function will wait for all the subscribers
to finish processing the message before returning.
\param[in] type The type of the message
\param[in] subtype The subtype
\param[in] uparam The khm_ui_4 parameter for the message
\param[in] blob The parameter blob for the message
\note The internal timeout for this function is INFINITE. If you
it is desirable to use a different timeout, use
kmq_post_message_ex() and kmq_wait() functions.
\retval KHM_ERROR_SUCCESS The call succeeded and no subscribers returned errors
\retval KHM_ERROR_PARTIAL The call succeeded but at least one subscriber returned an error
*/
KHMEXP khm_int32 KHMAPI kmq_send_message(
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * blob);
/*! \brief Post a message
The specified message will be posted to all the subscribers of the
message type. The function returns immediately.
If you want to be able to wait for all the subscribers to finish
processing the message, you should use kmq_post_message_ex()
instead.
\param[in] type The type of the message
\param[in] subtype The subtype
\param[in] uparam The khm_ui_4 parameter for the message
\param[in] blob The parameter blob for the message
*/
KHMEXP khm_int32 KHMAPI kmq_post_message(
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * blob);
/*! \brief Post a message and acquire a handle to the call.
The specified message is posted to all the subscribers. In
addition, a handle is obtained for the call which can be used in
subsequent call to kmq_free_call() or kmq_wait().
Call kmq_free_call() to free the handle.
\param[in] type The type of the message
\param[in] subtype The subtype
\param[in] uparam The khm_ui_4 parameter for the message
\param[in] blob The parameter blob for the message
\param[out] call Receives the call handle. Set to NULL if the call handle is not required.
\see kmq_free_call()
*/
KHMEXP khm_int32 KHMAPI kmq_post_message_ex(
khm_int32 type,
khm_int32 subtype,
khm_ui_4 uparam,
void * blob,
kmq_call * call);
/*! \brief Free a handle to a call obtained through kmq_post_message_ex()
All call handles obtained through kmq_post_message_ex() must be
freed via a call to kmq_free_call().
*/
KHMEXP khm_int32 KHMAPI kmq_free_call(kmq_call call);
/*! \brief Sends a <KMSG_SYSTEM,KMSG_SYSTEM_EXIT> message to the specified thread.
The message itself will not be received by any callback function,
however, any kmq_dispatch() function that is currently active of
becomes active will exit with a KHM_ERROR_EXIT code.
kmq_send_thread_quit_message() will wait for this to happen before
returning.
*/
KHMEXP khm_int32 KHMAPI kmq_send_thread_quit_message(
kmq_thread_id thread,
khm_ui_4 uparam);
/*! \brief Post a <KMSG_SYSTEM,KMSG_SYSTEM_EXIT> message to the specified thread.
The message itself will not be received by any callback function,
however, any kmq_dispatch() function that is currently active of
becomes active will exit with a KHM_ERROR_EXIT code.
kmq_post_thread_quit_message() will return immediately.
*/
KHMEXP khm_int32 KHMAPI kmq_post_thread_quit_message(
kmq_thread_id thread,
khm_ui_4 uparam,
kmq_call * call);
KHMEXP khm_int32 KHMAPI kmq_get_next_response(kmq_call call, void ** resp);
/*! \brief Check if a specific call has completed
\return TRUE if the call has completed. FALSE otherwise.
*/
KHMEXP khm_boolean KHMAPI kmq_has_completed(kmq_call call);
/*! \brief Wait for a call to complete.
Waits for the specified call to complete. If the call dispatched
to multiple recipients, the function waits for all dispatches to
complete.
If the call has already completed, then the function returns
immediately.
If more than one thread is waiting for a single message to
complete, then only one of them will be released when the message
compeltes. Each subsequent thread will be released as each
released thread calls kmq_free_call().
\param[in] call A handle to a call.
\param[in] timeout Specifies, in milliseconds, the amount of time
to wait for the call to complete. Specify INFINITE to wait
indefinitely.
\retval KHM_ERROR_SUCCESS The call completed
\retval KHM_ERROR_TIMEOUT The timeout period expired
\retval KHM_ERROR_INVALID_PARAM One of the parameters were invalid.
*/
KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout);
/*! \brief Sets the completion handler for a specified message type.
\note Only one completion handler can exist for one message type.
Calling this function overwrites the previous completion
handler.
*/
KHMEXP khm_int32 KHMAPI kmq_set_completion_handler(
khm_int32 type,
kmq_msg_completion_handler hander);
/*@}*/
#endif

View File

@ -0,0 +1,146 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_KPLUGIN_H
#define __KHIMAIRA_KPLUGIN_H
#include<kmm.h>
#include<kherror.h>
/*! \addtogroup kmm
@{*/
/*! \defgroup kplugin NetIDMgr Plugin Callbacks
See the following related documentation pages for more information
about NetIDMgr plugins.
These are prototypes of functions that must be implemented by a NetIDMgr
plugin.
- \ref plugins
@{*/
/*! \brief Initialize the module
This is the first callback function to be called in a module.
Perform all the required intialization when this is called. As
mentioned in \ref plugins, you should not attempt to call any
NetIDMgr API function from DLLMain or other initialization code
other than this one.
You should use this call back to register the plugins that will be
implemented in this module and to notify the plugin manager of any
resource libraries that this module will use.
Call:
- kmm_set_locale() : to set the notify the plugin manager of the
locale specifc resource libraries that are used by this module.
- kmm_provide_plugin() : to register each plugin that is
implemented in this module.
This function is called in the context of the current user, from
the plug-in manager thread. This same thread is used by the
plug-in manager to load and initialize all the modules for a
session.
The name of the callback must be init_module(). The calling
convention is KHMAPI, which is currently __stdcall.
If this function does not register any plugins, the plugin manager
will immediately call exit_module() and unload the module even if
the init_module() function completes successfully.
\return Return the following values to indicate whether the module
successfully initialized or not.
- KHM_ERROR_SUCCESS : Succeeded. The module manager will call
init_plugin() for each of the registered plugins for the
module.
- any other error code: Signals that the module did not
successfully initialize. The plugin manager will
immediately call exit_module() and then unload the module.
\note This callback is required.
*/
KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module);
/*! \brief Type for init_module() */
typedef khm_int32 (KHMAPI *init_module_t)(kmm_module);
#if defined(_WIN64)
#define EXP_INIT_MODULE "init_module"
#elif defined(_WIN32)
#define EXP_INIT_MODULE "_init_module@4"
#else
#error EXP_INIT_MODULE not defined for platform
#endif
/*! \brief Plugin procedure
This is the message processor for a plugin. See \ref pi_fw_pnm_p
for more information.
Essentially, this is a message subscriber for KMQ messages.
*/
KHMEXP khm_int32 KHMAPI _plugin_proc(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);
/*! \brief Type for init_plugin() */
typedef kmq_callback_t _plugin_proc_t;
/*! \brief Exit a module
This is the last callback function that the NetIDMgr module
manager calls before unloading the module. When this function is
called, all of the plugins for the module have already been
stopped. However, any localization libraries that were loaded as
a result of init_module() calling kmm_set_locale_info() will still
be loaded. These localization libraries will be unloaded
immediately after this callback returns.
Use this callback to perform any required cleanup tasks. However,
it is advisable that each plugin perform its own cleanup tasks,
since each plugin may be stopped independently of others.
\return The return value of this function is ignored.
\note This callback is not required.
*/
KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module);
/*! \brief Type for exit_module() */
typedef khm_int32 (KHMAPI *exit_module_t)(kmm_module);
#if defined(_WIN64)
#define EXP_EXIT_MODULE "exit_module"
#elif defined(_WIN32)
#define EXP_EXIT_MODULE "_exit_module@4"
#else
#error EXP_EXIT_MODULE not defined for platform
#endif
/*@}*/
/*@}*/
#endif

View File

@ -0,0 +1,361 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_MSTRING_H
#define __KHIMAIRA_MSTRING_H
#include<khdefs.h>
/*! \addtogroup util
@{ */
/*! \defgroup util_mstring Multi String and CSV functions
@{*/
#define KHM_PREFIX 8
#define KHM_CASE_SENSITIVE 16
#define KHM_MAXCCH_STRING 16384
#define KHM_MAXCB_STRING (KHM_MAXCCH_STRING * sizeof(wchar_t))
/*! \brief Initialize a multi-string
*/
KHMEXP khm_int32 KHMAPI
multi_string_init(wchar_t * ms,
khm_size cb_ms);
/*! \brief Prepend a string to a multi string
Adds the string \a str to the beginning of multi-string \a ms.
\param[in,out] ms The multi-string to be modified.
\param[in,out] pcb_ms A pointer to the size of the multistring.
On entry this specifies the size of the buffer pointed to by
\a ms. If the call is successful, on exit this will receive
the new size of the multi string in bytes. If the buffer is
insufficient, the function will return KHM_ERROR_TOO_LONG and
set this to the required size of the buffer in bytes.
\param[in] str The string to prepend to \a ms. This cannot be
longer than KHM_MAXCCH_STRING in characters including the
terminating NULL.
*/
KHMEXP khm_int32 KHMAPI
multi_string_prepend(wchar_t * ms,
khm_size * pcb_ms,
const wchar_t * str);
/*! \brief Append a string to a multi-string
Appends the string specified by \a str to the multi string
specified by \a ms. The size of the multi string in characters
including terminating NULLs after appending \a str can not exceed
KHM_MAXCCH_STRING.
\param[in] ms The buffer containing the multi string
\param[in,out] pcb_ms Points to a khm_int32 indicating the size of
the buffer pointed to by \a ms. On entry this contains the
size (in bytes) of the buffer pointed to by \a ms. On exit,
contains the new size of the multi string in bytes.
\param[in] str The string to append to the multi string. This
string cannot be NULL or an empty (zero length) string. The
length of \a str cannot exceed KHM_MAXCCH_STRING in
characters including terminating NULL.
\retval KHM_ERROR_SUCCESS The string was appended to the multi string
\retval KHM_ERROR_TOO_LONG The buffer pointed to by \a ms was
insufficient. The required size of the buffer is in \a pcb_ms
\retval KHM_ERROR_INVALID_PARAM One of more of the parameters were invalid.
*/
KHMEXP khm_int32 KHMAPI
multi_string_append(wchar_t * ms,
khm_size * pcb_ms,
const wchar_t * str);
/*! \brief Deletes a string from a multi string
Deletes the string specified by \a str from the multi string
specified by \a ms. How the string is matched to the strings in
\a ms is determined by \a flags. If more than one match is found,
then only the first match is deleted.
\param[in] ms The multi string to modify. The length of the multi
string in characters cannot exceed KHM_MAXCCH_STRING.
\param[in] str The string to search for
\param[in] flags How \a str is to be matched to existing strings
in \a ms. This could be a combination of KHM_PREFIX and
KHM_CASE_SENSITIVE. If KHM_PREFIX is used, then \a ms is
searched for a string that begins with \a str. Otherwise, \a
str must match the an entire string in the multi string. If
KHM_CASE_SENSITIVE is specified, then a case sensitive match
is performed. The defualt is to use a case insensitive
search.
\retval KHM_ERROR_SUCCESS A string was matched and deleted from \a ms
\retval KHM_ERROR_NOT_FOUND No matches were found
\retval KHM_ERROR_INVALID_PARAM One or more parameters were incorrect.
\note The search for the existing string is done with
multi_string_find()
*/
KHMEXP khm_int32 KHMAPI
multi_string_delete(wchar_t * ms,
const wchar_t * str,
const khm_int32 flags);
/*! \brief Search a multi string for a string
Searches the string specified by \a ms for a string that matches
\a str. How the match is performed is determined by \a flags.
Returns a poitner to the start of the matched string in \a ms. If
more than one string in \a ms matches \a str, then only the first
match is returned.
\param[in] ms The multi string to search in. The length of the
multi string cannot exceed KHM_MAXCCH_STRING in characters.
\param[in] str The string to search for
\param[in] flags How \a str is to be matched to existing strings
in \a ms. This could be a combination of KHM_PREFIX and
KHM_CASE_SENSITIVE. If KHM_PREFIX is used, then \a ms is
searched for a string that begins with \a str. Otherwise, \a
str must match the an entire string in the multi string. If
KHM_CASE_SENSITIVE is specified, then a case sensitive match
is performed. The defualt is to use a case insensitive
search.
\return A pointer to the start of the first matched string or
NULL if no matches were found.
*/
KHMEXP wchar_t * KHMAPI
multi_string_find(const wchar_t * ms,
const wchar_t * str,
const khm_int32 flags);
/*! \brief Convert a multi string to CSV
Converts a multi string to a comma separated value string based on
the following rules.
- Each string in the multi string is treated an individual field
- A field is quoted if it has double quotes or commas
- Double quotes within quoted fields are escaped by two
consecutive double quotes.
For example:
\code
multi_string = L"foo\0bar\0baz,quux\0ab\"cd\0";
csv_string = L"foo,bar,\"baz,quux\",\"ab\"\"cd\"";
\endcode
If multi_string_to_csv() is called on \a multi_string above,
you would obtain \a csv_string.
\param[out] csvbuf The buffer to place the CSV string in. Can be
NULL if only teh size of the needed buffer is required.
\param[in,out] pcb_csvbuf On entry, points to a khm_int32 that
holds the size of the buffer pointed to by \a csvbuf. On
exit, gets the number of bytes writted to \a csvbuf or the
required size of \a csvbuf if the buffer is too small or \a
csvbuf is NULL.
\param[in] ms The mutli string to convert to a CSV.
\retval KHM_ERROR_SUCCESS The multi string was successfully
converted to a CSV string. The number of bytes written is in
\a pcb_csvbuf. The count includes the terminating NULL.
\retval KHM_ERROR_TOO_LONG The buffer was too small or \a csvbuf
was NULL. The required number of bytes in the buffer is in \a
pcb_csvbuf.
\retval KHM_ERROR_INVALID_PARAM One or more parameters were ivnalid.
\see csv_to_multi_string()
*/
KHMEXP khm_int32 KHMAPI
multi_string_to_csv(wchar_t * csvbuf,
khm_size * pcb_csvbuf,
const wchar_t * ms);
/*! \brief Converts a CSV to a multi string
Undoes what multi_string_to_csv() does.
\param[out] ms The buffer that recieves the multi string. This
can be NULL if only the size of the buffer is requried.
\param[in,out] pcb_ms On entry contains the number of bytes ni the
buffer poitned to by \a ms. On exit contains the number of
bytes that were copied to \a ms including terminating NULLs,
or if the buffer was too small or \a ms was NULL, holds the
size in bytes of the requied buffer.
\param[in] csv The CSV string.
\retval KHM_ERROR_SUCCESS The CSV string was successfully
converted. The number of bytes written is in \a pcb_ms.
\retval KHM_ERROR_TOO_LONG The provided buffer was too small or \a
ms was NULL. The required size of the buffer in bytes is in \a
pcb_ms.
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.
*/
KHMEXP khm_int32 KHMAPI
csv_to_multi_string(wchar_t * ms,
khm_size * pcb_ms,
const wchar_t * csv);
/*! \brief Get the next string in a multi string
When \a str is pointing to a string that is in a multi string,
this function returns a pointer to the next string in the multi
string.
Typically, one would start by having \a str point to the start of
the multi string (which is the first string in the multi string),
and then call this function repeatedly, until it returns NULL, at
which point the end of the multi string has been reached.
\param[in] str Pointer to a string in a multi string. Each string
in a multi string cannot exceed KHM_MAXCCH_STRING in charaters
including the terminating NULL.
\return A pointer to the start of the next string in the multi
string or NULL if there is no more strings.
*/
KHMEXP wchar_t * KHMAPI
multi_string_next(const wchar_t * str);
/*! \brief Get the length of a multi string in bytes
The returned length includes the trailing double \a NULL and any
other \a NULL inbetween.
\param[in] str Pointer to a multi string.
\param[in] max_cb Maximum size that the str can be. This can not
be larger than KHM_MAXCB_STRING.
\param[out] len_cb The length of the string in bytes if the call
is successful.
\retval KHM_ERROR_SUCCESS The length of the string is in \a len_cb
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid
\retval KHM_ERROR_TOO_LONG The multi string is longer than \a
max_cb bytes.
*/
KHMEXP khm_int32 KHMAPI
multi_string_length_cb(const wchar_t * str,
khm_size max_cb,
khm_size * len_cb);
/*! \brief Get the length of a multi string in characters
The returned length includes the trailing double \a NULL and any
other \a NULL inbetween.
\param[in] str Pointer to a multi string.
\param[in] max_cch Maximum size that the str can be. This can not
be larger than KHM_MAXCCH_STRING.
\param[out] len_cch The length of the string in characters if the call
is successful.
\retval KHM_ERROR_SUCCESS The length of the string is in \a len_cch
\retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid
\retval KHM_ERROR_TOO_LONG The multi string is longer than \a
max_cch characters.
*/
KHMEXP khm_int32 KHMAPI
multi_string_length_cch(const wchar_t * str,
khm_size max_cch,
khm_size * len_cch);
/*! \brief Get the number of strings in a multi string
*/
KHMEXP khm_size KHMAPI
multi_string_length_n(const wchar_t * str);
/*! \brief Copy a multi string with byte counts
Copy a multi string from one location to another.
\param[out] s_dest Receives a copy of the multi string
\param[in] max_cb_dest Number of bytes in the buffer pointed to by
\a s_dest.
\param[in] src The source multi string
\retval KHM_ERROR_SUCCESS The multi string was copied successfully
\retval KHM_ERROR_INVALID_PARAM One or more parameters were
invalid.
\retval KHM_ERROR_TOO_LONG The size of the destination buffer was
insufficient.
*/
KHMEXP khm_int32 KHMAPI
multi_string_copy_cb(wchar_t * s_dest,
khm_size max_cb_dest,
const wchar_t * src);
/*! \brief Copy a multi string with character count
Copy a multi string from one location to another.
\param[out] s_dest Receives a copy of the multi string
\param[in] max_cb_dest Number of characters in the buffer pointed
to by \a s_dest.
\param[in] src The source multi string
\retval KHM_ERROR_SUCCESS The multi string was copied successfully
\retval KHM_ERROR_INVALID_PARAM One or more parameters were
invalid.
\retval KHM_ERROR_TOO_LONG The size of the destination buffer was
insufficient.
*/
KHMEXP khm_int32 KHMAPI
multi_string_copy_cch(wchar_t * s_dest,
khm_size max_cch_dest,
const wchar_t * src);
/*@}*/
#endif

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __NETIDMGR_H
#define __NETIDMGR_H
#include "khdefs.h"
#include "utils.h"
#include "khuidefs.h"
#include "kmq.h"
#include "khmsgtypes.h"
#include "kcreddb.h"
#include "kherr.h"
#include "kherror.h"
#include "kconfig.h"
#include "kmm.h"
#include "kplugin.h"
#endif

View File

@ -0,0 +1,59 @@
/* Copyright (c) 2004 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#ifndef __NETIDMGR_VERSION_H
#define __NETIDMGR_VERSION_H
#include<windows.h>
/* Version number macros */
#define KH_VERSION_MAJOR 1
#define KH_VERSION_MINOR 1
#define KH_VERSION_PATCH 0
#define KH_VERSION_AUX 1
#define KH_VERSION_API 5
#define KH_VERSION_API_MINCOMPAT 5
#define KH_VERSION_LIST 1,1,0,1
#define KH_VERSION_STRING "1.1.0.1"
#define KH_VERSION_STRINGW L"1.1.0.1"
#define KH_VERSION_STRINGC "1,1,0,1"
#define KH_VERSION_STRINGCW L"1,1,0,1"
#define KH_VERSION_STRINGAPI "5"
/* Version definition macros */
#define KH_VER_FILEFLAGMASK 0x17L
#define KH_VER_FILEFLAGS 0
#define KH_VER_FILEOS VOS_NT_WINDOWS32
#define KH_VER_FILETYPEDLL VFT_DLL
#define KH_VER_FILETYPEAPP VFT_APP
/* Special macros for NetIDMgr special string resources */
#define NIMV_MODULE "NIDM_Module"
#define NIMV_PLUGINS "NIDM_Plugins"
#define NIMV_APIVER "NIDM_APIVers"
#define NIMV_SUPPORT "NIDM_Support"
#endif

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_PERFSTAT_H
#define __KHIMAIRA_PERFSTAT_H
#include<khdefs.h>
#ifdef DEBUG
#define PMALLOC(s) perf_malloc(__FILE__,__LINE__,s)
#define PCALLOC(n,s) perf_calloc(__FILE__,__LINE__,n,s)
#define PREALLOC(d,s) perf_realloc(__FILE__,__LINE__,d,s)
#define PFREE(p) perf_free(p)
#define PDUMP(f) perf_dump(f)
#define PWCSDUP(s) perf_wcsdup(__FILE__,__LINE__,s)
#define PSTRDUP(s) perf_strdup(__FILE__,__LINE__,s)
#else
#define PMALLOC(s) malloc(s)
#define PCALLOC(n,s) calloc(n,s)
#define PREALLOC(d,s) realloc(d,s)
#define PFREE(p) free(p)
#define PDUMP(f) ((void) 0)
#define PWCSDUP(s) wcsdup(s)
#define PSTRDUP(s) strdup(s)
#endif
KHMEXP void *
perf_malloc(char * file, int line, size_t s);
KHMEXP void *
perf_realloc(char * file, int line, void * data, size_t s);
KHMEXP void
perf_free (void * b);
KHMEXP void
perf_dump (char * filename);
KHMEXP wchar_t *
perf_wcsdup(char * file, int line, const wchar_t * str);
KHMEXP char *
perf_strdup(char * file, int line, const char * str);
KHMEXP void *
perf_calloc(char * file, int line, size_t num, size_t size);
#endif

View File

@ -0,0 +1,128 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_SYNC_H
#define __KHIMAIRA_SYNC_H
#include<khdefs.h>
/*! \addtogroup util
@{ */
/*! \defgroup util_sync Synchronization
@{*/
/*! \brief A read/write lock
A classic read/write lock. Allows multiple readers or a single
writer to access a protected object. Readers will wait for any
pending writer to release the lock, while a writer will wait for
any pending readers to release the lock.
*/
typedef struct tag_rwlock {
int locks;
int status;
CRITICAL_SECTION cs;
HANDLE readwx;
HANDLE writewx;
DWORD writer; /* TID of writer thread */
} rw_lock_t;
typedef rw_lock_t RWLOCK, *PRWLOCK;
/*! \brief Initialize a read/write lock.
A lock <b>must</b> be initialized before it can be used.
Initializing the lock does not grant the caller any locks on the
object.
*/
KHMEXP void KHMAPI InitializeRwLock(PRWLOCK pLock);
/*! \brief Delete a read/write lock
Once the application is done using the read/write lock, it must be
deleted with a call to DeleteRwLock()
*/
KHMEXP void KHMAPI DeleteRwLock(PRWLOCK pLock);
/*! \brief Obtains a read lock on the read/write lock
Multiple readers can obtain read locks on the same r/w lock.
However, if any thread attempts to obtain a write lock on the
object, it will wait until all readers have released the read
locks.
Call LockReleaseRead() to release the read lock. While the same
thread may obtain multiple read locks on the same object, each
call to LockObtainRead() must have a corresponding call to
LockReleaseRead() to properly relinquish the lock.
\see LockReleaseRead()
*/
KHMEXP void KHMAPI LockObtainRead(PRWLOCK pLock);
/*! \brief Relase a read lock obtained on a read/write lock
Each call to LockObtainRead() must have a corresponding call to
LockReleaseRead(). Once all read locks are released, any threads
waiting on write locks on the object will be woken and assigned a
write lock.
\see LockObtainRead()
*/
KHMEXP void KHMAPI LockReleaseRead(PRWLOCK pLock);
/*! \brief Obtains a write lock on the read/write lock
Only a single writer is allowed to lock a single r/w lock.
However, if any thread attempts to obtain a read lock on the
object, it will wait until the writer has released the lock.
Call LockReleaseWrite() to release the write lock. While the same
thread may obtain multiple write locks on the same object, each
call to LockObtainWrite() must have a corresponding call to
LockReleaseWrite() to properly relinquish the lock.
\see LockReleaseWrite()
*/
KHMEXP void KHMAPI LockObtainWrite(PRWLOCK pLock);
/*! \brief Relase a write lock obtained on a read/write lock
Each call to LockObtainWrite() must have a corresponding call to
LockReleaseWrite(). Once the write lock is released, any threads
waiting for read or write locks on the object will be woken and
assigned the proper lock.
\see LockObtainWrite()
*/
KHMEXP void KHMAPI LockReleaseWrite(PRWLOCK pLock);
/*@}*/
/*@}*/
#endif

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* $Id$ */
#ifndef __KHIMAIRA_UTIL_H
#define __KHIMAIRA_UTIL_H
/*! \defgroup util Utilities
*/
#include<hashtable.h>
#include<sync.h>
#include<mstring.h>
#include<perfstat.h>
#endif

View File

@ -1,122 +1,214 @@
/* This file contains definitions for use by the Hesiod name service and
* applications.
/*! \file hesiod.h
* WSHelper DNS/Hesiod Library
*
* @doc
*
* @module hesiod.h |
* For copying and distribution information, see the file
* <gt> mit-copyright.h <lt>.
*
* Original version by Steve Dyer, IBM/Project Athena.
*
*/
/* Configuration information. */
* This file contains the function declaration for: \n
* hes_to_bind() \n
* hes_resolve() \n
* hes_error() \n
* hes_free() \n
* hes_getmailhost() \n
* hes_getservbyname() \n
* hes_getpwnam() \n
* hes_getpwuid() \n
*/
#ifndef _HESIOD_
#define _HESIOD_
#if defined(_WINDOWS) || defined(_WIN32)
#include <windows.h>
#endif
#if defined(_WINDOWS) || defined(_WIN32)
#define HESIOD_CONF "c:\\net\\tcp\\hesiod.cfg"
#else
#define HESIOD_CONF "/etc/hesiod.conf" /* Configuration file. */
#endif
#define DEF_RHS ".Athena.MIT.EDU" /* Defaults if HESIOD_CONF */
#define DEF_LHS ".ns" /* file is not present. */
/* @doc ERROR
/* Error codes. */
/*
@type HES_ER_UNINIT | -1 uninitialized
@type HES_ER_OK | 0 no error
@type HES_ER_NOTFOUND | 1 Hesiod name not found by server
@type HES_ER_CONFIG | 2 local problem (no config file?)
@type HES_ER_NET | 3 network problem
/*! \def HESIOD_CONF
* name of the hesiod configuration file. We will look at the file to determine the RHS AND LHS value before using the default.
* Here is a sample hesiod.cfg file: \n
* lhs .ns \n
* rhs .ATHENA.MIT.EDU \n
*/
#define HESIOD_CONF "c:\\net\\tcp\\hesiod.cfg"
#define HES_ER_UNINIT -1 /* uninitialized */
#define HES_ER_OK 0 /* no error */
#define HES_ER_NOTFOUND 1 /* Hesiod name not found by server */
#define HES_ER_CONFIG 2 /* local problem (no config file?) */
#define HES_ER_NET 3 /* network problem */
/*! \def DEF_RHS
* default RHS value is the hesiod configuration file is not present
*/
#define DEF_RHS ".Athena.MIT.EDU"
/*! \def DEF_LHS
* default LHS value is the hesiod configuration file is not present
*/
#define DEF_LHS ".ns"
/*! \def HES_ER_UNINIT
* HES error code: uninitialized
*/
#define HES_ER_UNINIT -1
/*! \def HES_ER_OK
* HES error code: no error
*/
#define HES_ER_OK 0
/*! \def HES_ER_NOTFOUND
* HES error code: Hesiod name not found by server
*/
#define HES_ER_NOTFOUND 1
/*! \def HES_ER_CONFIG
* HES error code: local problem (no config file?)
*/
#define HES_ER_CONFIG 2
/*! \def HES_ER_NET
* HES error code: network problem
*/
#define HES_ER_NET 3
/* Declaration of routines */
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WINDOWS) || defined(_WIN32)
/*! \fn LPSTR WINAPI hes_to_bind(LPSTR HesiodName, LPSTR HesiodNameType)
* hes_to_bind function use the LHS and RHS values and
* binds them with the parameters so that a well formed DNS query may
* be performed.
*
* defined in hesiod.c
*
* \param[in] HesiodName The Hesiod name such as a username or service name
* \param[in] HesiodNameType The Hesiod name type such as pobox, passwd, or sloc
* \retval Returns NULL if there was an error. Otherwise the pointer to a string containing a valid query is returned.
*
*/
LPSTR WINAPI
hes_to_bind(
LPSTR HesiodName,
LPSTR HesiodNameType
);
/*! \fn LPSTR * WINAPI hes_resolve(LPSTR HesiodName, LPSTR HesiodNameType)
* This function calls hes_to_bind to form a valid hesiod query, then queries the dns database.
*
* defined in hesiod.c
*
* \param[in] HesiodName The Hesiod name such as a username or service name
* \param[in] HesiodNameType The Hesiod name type such as pobox, passwd, or sloc
* \retval returns a NULL terminated vector of strings (a la argv),
* one for each resource record containing Hesiod data, or NULL if
* there is any error. If there is an error call hes_error() to get
* further information. You will need to call hes_free to free the result
*
*/
LPSTR * WINAPI
hes_resolve(
LPSTR HesiodName,
LPSTR HesiodNameType
);
/*! \fn int WINAPI hes_error(void)
* The function hes_error may be called to determine the
* source of the error. It does not take an argument.
*
* defined in hesiod.c
*
* \retval return one of the HES_ER_* codes defined in hesiod.h.
*/
int WINAPI
hes_error(
void
);
#else
char *hes_to_bind(const char *name, const char *type);
char **hes_resolve(const char *name, const char *type);
int hes_error(void);
#endif /* WINDOWS */
/*
* @doc
/*! \fn void WINAPI hes_free(LPSTR* hesinfo)
* The function hes_free should be called to free up memeory returned by hes_resolve
*
* @struct hes_postoffice | For use in getting post-office information.
*
* @field LPSTR | po_type | The post office type, e.g. POP, IMAP
* @field LPSTR | po_host | The post office host, e.g. PO10.MIT.EDU
* @field LPSTR | po_name | The account name on the post office, e.g. tom
* defined in hesiod.c
*
* \param[in] hesinfo a NULL terminiated array of strings returned by hes_resolve
*/
void WINAPI
hes_free(
LPSTR* hesinfo
);
/*! \struct hes_postoffice
* For use in getting post-office information.
*/
#if defined(_WINDOWS) || defined(_WIN32)
struct hes_postoffice {
/*! The post office type, e.g. POP, IMAP */
LPSTR po_type;
/*! The post office host, e.g. PO10.MIT.EDU */
LPSTR po_host;
/*! The account name on the post office, e.g. tom */
LPSTR po_name;
};
#else
struct hes_postoffice {
char *po_type;
char *po_host;
char *po_name;
};
#endif
/* Other routines */
/*! \fn struct hes_postoffice * WINAPI hes_getmailhost(LPSTR user)
* This call is used to obtain a user's type of mail account and the location of that
* account. E.g. POP PO10.MIT.EDU or IMAP IMAP-TEST.MIT.EDU
*
* defined in hesmailh.c
*
* \param[in] user The username to be used when querying for the Hesiod Name Type POBOX.
* \retval NULL if there was an error or if there was no entry for the
* username. Otherwise a pointer to a hes_postoffice structure is
* returned. The caller must never attempt to modify this structure or to free
* any of its components. Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another getmailhost call
*/
struct hes_postoffice * WINAPI hes_getmailhost(LPSTR user);
#if defined(_WINDOWS) || defined(_WIN32)
struct hes_postoffice FAR * WINAPI hes_getmailhost(LPSTR user);
struct servent FAR * WINAPI hes_getservbyname(LPSTR name,
LPSTR proto);
struct passwd FAR * WINAPI hes_getpwnam(LPSTR nam);
struct passwd FAR * WINAPI hes_getpwuid(int uid);
#else
struct hes_postoffice *hes_getmailhost();
struct servent *hes_getservbyname();
struct passwd *hes_getpwnam();
struct passwd *hes_getpwuid();
#endif
/*! \fn struct servent * WINAPI hes_getservbyname(LPSTR name, LPSTR proto)
* This function will query a Hesiod server for a servent structure given
* a service name and protocol. This is a replacement for the Winsock
* getservbyname function which normally just uses a local services
* file. This allows a site to use a centralized database for adding new
* services.
*
* defined in hesservb.c
*
* \param[in] name pointer to the official name of the service, eg "POP3".
* \param[in] proto pointer to the protocol to use when contacting the service, e.g. "TCP"
* \retval NULL if there was an error or a pointer to a servent structure. The caller must
* never attempt to modify this structure or to free any of its components.
* Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another hes_getservbyname call
*
*/
struct servent * WINAPI hes_getservbyname(LPSTR name,
LPSTR proto);
/*! \fn struct passwd * WINAPI hes_getpwnam(LPSTR nam)
* Given a username this function will return the pwd information, eg
* username, uid, gid, fullname, office location, phone number, home
* directory, and default shell
*
* defined in hespwnam.c
*
* \param nam a pointer to the username
* \retval NULL if there was an error or a pointer to the passwd structure. The caller must
* never attempt to modify this structure or to free any of its components.
* Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another hes_getpwnam call
*
*/
struct passwd * WINAPI hes_getpwnam(LPSTR nam);
/*! struct passwd * WINAPI hes_getpwuid(int uid)
* Given a UID this function will return the pwd information, eg username, uid,
* gid, fullname, office location, phone number, home directory, and default shell
*
* defined in hespwnam.c
*
* \param uid The user ID
* \retval NULL if there was an error or a pointer to the passwd structure. The caller must
* never attempt to modify this structure or to free any of its components.
* Furthermore, only one copy of this structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another hes_getpwuid call
*/
struct passwd * WINAPI hes_getpwuid(int uid);
#ifdef __cplusplus
}

View File

@ -1,14 +1,8 @@
/*
@doc
@module mitwhich.h |
some defines so that we can figure out which MS OS and subsystem an
application is running under. Also support for finding out which
TCP/IP stack is being used. This is useful when you need to find out
about the domain or the nameservers.
/*! \file mitwhich.h
* some defines so that we can figure out which MS OS and subsystem an
* application is running under. Also support for finding out which
* TCP/IP stack is being used. This is useful when you need to find out
* about the domain or the nameservers.
*/
#if !defined( __MIT_WHICH_H )
@ -51,12 +45,12 @@ about the domain or the nameservers.
should change these defaults to their own defaults either by
editing this file and recompiling or by editing the string tables
of the binaries. Don't use App Studio to edit the .RC files.
<nl>
#define DNS1 "18.70.0.160" <nl>
#define DNS2 "18.71.0.151" <nl>
#define DNS3 "18.72.0.3" <nl>
<nl>
#define DEFAULT_DOMAIN "mit.edu" <nl>
\n
#define DNS1 "18.70.0.160" \n
#define DNS2 "18.71.0.151" \n
#define DNS3 "18.72.0.3" \n
\n
#define DEFAULT_DOMAIN "mit.edu" \n
*/
#define DNS1 "18.70.0.160"
@ -86,71 +80,5 @@ about the domain or the nameservers.
#define W95_DOMAIN_KEY "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP\\Domain"
#define W95_NS_KEY "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP\\NameServer"
/*
@comm Notes on different Winsock stack configuration files.<nl>
The Microsoft stacks for Windows95 and NT 3.x, 4.x use the registry
to store the default domain and the IP addresses of the DNS
servers. The wshelper and wshelp32 will use the registry information
when possible.<nl>
Novell's LAN WorkPlace stack and the much older Excelan products use
a resolv.cfg file to store this information. The resolv.cfg file
could be located in a number of places over the years. Our DLL will
try to search for it in:<nl><nl>
C:\etc\resolv.cfg<nl>
C:\excelan\tcp\resolv.cfg<nl>
C:\net\tcp\resolv.cfg<nl>
%NDIR%\etc\resolv.cfg<nl>
%NDIR%\tcp\resolv.cfg<nl><nl>
where %NDIR% is the expansion of the local environment variable
NDIR. So setting NDIR to be N:\COMMON\NET would mean that we would
also look in N:\common\net\etc\resolv.cfg and
N:\common\net\tcp\resolv.cfg for the domain and nameserver
information.<nl><nl>
Here is a sample resolv.cfg file<nl>
; LAN WorkPlace resolver configuration file<nl>
domain mit.edu<nl>
nameserver 18.70.0.160<nl>
nameserver 18.71.0.151<nl>
nameserver 18.72.0.3<nl>
; end of file<nl><nl>
The TRUMPET Winsock stack uses a TRUMPETWSK.INI file to store the
domain and nameserver configuration information. The section tag is
[Trumpet Winsock]. The domain information is identified by domain=
and the nameserver information is identified by a single name, dns=,
multiple nameservers may be specified on the same line and they
should be space delimited.<nl><nl>
trupwsk.ini<nl>
[Trumpet Winsock]<nl>
dns=18.71.0.151 18.70.0.160 18.72.0.3<nl>
domain=mit.edu<nl><nl>
Core Internet-Connect uses a CORE.INI file, nameservers are comma
delimited.<nl>
[winsock]<nl>
domainname=mit.edu<nl>
nameservers=18.71.0.151, 18.70.0.160, 18.72.0.3<nl><nl>
FTP software uses a PCTCP.INI file. This file may be located by use
of the environment variable PCTCP.<nl>
[pctcp general]<nl>
domain=mit.edu<nl>
[pctcp addresses]<nl>
domain-name-server=18.70.0.160<nl>
domain-name-server=18.71.0.151<nl>
domain-name-server=18.72.0.3<nl>
*/
#endif // __MIT_WHICH_H

View File

@ -1,126 +1,145 @@
/*
@doc
@module resolv.h |
* Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
* All rights reserved. <nl>
Structure definitions for resolver functions and #define statements
/*! \file resolv.h
* WSHelper DNS/Hesiod Library header
* This file contains the function declaration for:\n
* res_init() \n
* res_search() \n
* dn_comp() \n
* rdn_expand() \n \n
* and unsupported functions: \n
* res_setopts() \n
* res_getopts() \n
* res_querydomain() \n
* res_mkquery() \n
* res_send() \n
*/
/*
* Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)resolv.h 5.15 (Berkeley) 4/3/91
*/
#ifndef _RESOLV_H_
#define _RESOLV_H_
#if defined(_WINDOWS) || defined(_WIN32)
#include <windows.h>
#endif
/*
* Resolver configuration file.
* Normally not present, but may contain the address of the
* inital name server(s) to query and the domain search list.
*/
#ifndef _PATH_RESCONF
#if defined(_WINDOWS) || defined(_WIN32)
#define _PATH_RESCONF "c:\\net\\tcp\\resolv.cfg"
#else
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
#endif
#ifndef MAXDNAME
#include <arpa/nameser.h>
#endif
/*
* Global defines and variables for resolver stub.
/*! \def MAXNS
* max # name servers we'll track
*/
#define MAXNS 3 /* max # name servers we'll track */
#define MAXDFLSRCH 3 /* # default domain levels to try */
#define MAXDNSRCH 6 /* max # domains in search path */
#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
#define MAXNS 3
#define RES_TIMEOUT 5 /* min. seconds between retries */
/*! \def MAXDFLSRCH
* # default domain levels to try
*/
#define MAXDFLSRCH 3
// new
/*! \def MAXDNSRCH
* max # domains in search path
*/
#define MAXDNSRCH 6
/*! \def LOCALDOMAINPARTS
* min levels in name that is "local"
*/
#define LOCALDOMAINPARTS 2
/*! \def RES_TIMEOUT
* min. seconds between retries
*/
#define RES_TIMEOUT 5
/*! \def MAXMXRECS
* number of records in the preference array in the MX record
*/
#define MAXMXRECS 8
/*! \struct mxent
* structure to hold the MX record
*/
struct mxent {
/*! number of records in the preference field */
int numrecs;
/*! holds a 16 bit integer which specifies the preference given to this RR */
u_short pref[MAXMXRECS];
char FAR * FAR * hostname;
/*! a host willing to act as a mail exchange */
char ** hostname;
};
/*
@struct state | This structure holds the state for the resolver query
/*! \struct state
* This structure holds the state for the resolver query
*/
struct state {
int retrans; /* @field retransmition time interval */
int retry; /* @field number of times to retransmit */
long options; /* @field option flags - see below. */
int nscount; /* @field number of name servers */
struct sockaddr_in nsaddr_list[MAXNS]; /* @field address of name server */
#define nsaddr nsaddr_list[0] /* @field for backward compatibility */
u_short id; /* @field current packet id */
char defdname[MAXDNAME]; /* @field default domain */
char *dnsrch[MAXDNSRCH+1]; /* @field components of domain to search */
/*! retransmition time interval */
int retrans;
/*! number of times to retransmit */
int retry;
/*! field option flags - see below. */
long options;
/*! field number of name servers */
int nscount;
/*! address of name server */
struct sockaddr_in nsaddr_list[MAXNS];
#define nsaddr nsaddr_list[0]
/*! current packet id */
u_short id;
/*! field default domain */
char defdname[MAXDNAME];
/*! field components of domain to search */
char *dnsrch[MAXDNSRCH+1];
};
/*
* Resolver options
/*! \def RES_INIT
* resolver option: address initialized
*/
#define RES_INIT 0x0001 /* address initialized */
#define RES_DEBUG 0x0002 /* print debug messages */
#define RES_AAONLY 0x0004 /* authoritative answers only */
#define RES_USEVC 0x0008 /* use virtual circuit */
#define RES_PRIMARY 0x0010 /* query primary server only */
#define RES_IGNTC 0x0020 /* ignore trucation errors */
#define RES_RECURSE 0x0040 /* recursion desired */
#define RES_DEFNAMES 0x0080 /* use default domain name */
#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
#define RES_DNSRCH 0x0200 /* search up local domain tree */
#define RES_INIT 0x0001
/*! \def RES_DEBUG
* resolver option: print debug messages
*/
#define RES_DEBUG 0x0002
/*! \def RES_AAONLY
* resolver option: authoritative answers only
*/
#define RES_AAONLY 0x0004
/*! \def RES_USEVC
* resolver option: use virtual circuit
*/
#define RES_USEVC 0x0008
/*! \def RES_PRIMARY
* resolver option: query primary server only
*/
#define RES_PRIMARY 0x0010
/*! \def RES_IGNTC
* resolver option: ignore trucation errors
*/
#define RES_IGNTC 0x0020
/*! \def RES_RECURSE
* resolver option: recursion desired
*/
#define RES_RECURSE 0x0040
/*! \def RES_DEFNAMES
* resolver option: use default domain name
*/
#define RES_DEFNAMES 0x0080
/*! \def RES_STAYOPEN
* resolver option: Keep TCP socket ope
*/
#define RES_STAYOPEN 0x0100
/*! \def RES_DNSRCH
* resolver option: search up local domain tree
*/
#define RES_DNSRCH 0x0200
/*! \def RES_DEFAULT
* resolver option: Default RES options (RES_RECURSE + RES_DEFNAMES + RES_DNSRCH)
*/
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
extern struct state _res;
@ -128,7 +147,6 @@ extern struct state _res;
#include <stdio.h>
/* Private routines shared between libc/net, named, nslookup and others. */
#define dn_skipname __dn_skipname
#define fp_query __fp_query
#define hostalias __hostalias
#define putlong __putlong
@ -137,65 +155,130 @@ extern struct state _res;
#define p_time __p_time
#define p_type __p_type
#if defined(_WINDOWS) || defined(_WIN32)
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn int WINAPI res_init()
* \brief retrieves the default domain name and search order. It will look to see if an environment variable LOCALDOMAIN is defined. Otherwise,
* the domain associated with the local host is used. Otherwise, it will try to find the domain name from the registry
*
* defined in res_init.c
*
* \retval The return value is 0 if the operation was successful. Otherwise the value -1 is returned.
*/
int WINAPI res_init();
void WINAPI res_setopts(long opts);
long WINAPI res_getopts(void);
int WINAPI res_mkquery(int op, const char FAR *dname,
int qclass, int type,
const char FAR *data, int datalen,
const struct rrec FAR *newrr,
char FAR *buf, int buflen);
int WINAPI res_send(const char FAR *msg, int msglen,
char FAR *answer, int anslen);
int WINAPI res_querydomain(const char FAR *name,
const char FAR *domain,
int qclass, int type,
u_char FAR *answer, int anslen);
int WINAPI res_search(const char FAR *name,
int qclass, int type,
u_char FAR *answer, int anslen);
int WINAPI dn_comp(const u_char FAR *exp_dn,
u_char FAR *comp_dn,
int length, u_char FAR * FAR *dnptrs,
u_char FAR * FAR *lastdnptr);
int WINAPI rdn_expand(const u_char FAR *msg,
const u_char FAR *eomorig,
const u_char FAR *comp_dn,
u_char FAR *exp_dn,
/*! \fn int WINAPI res_search(const char* name, int qclass, int type, u_char* answer, int anslen)
* \brief a generic query interface to the DNS name space. The query is performed with the dnsapi and
* the answer buffer is populated based on the returned RR set.
*
* defined in res_quer.c
* \param[in] name domain name
* \param[in] qclass class of query(such as DNS_CLASS_INTERNET, DNS_CLASS_CSNET, DNS_CLASS_CHAOS,
* DNS_CLASS_HESIOD. Defined in windns.h)
* \param[in] type type of query(such as DNS_TYPE_A, DNS_TYPE_NS, DNS_TYPE_MX, DNS_TYPE_SRV. Defined in
* windns.h)
* \param[in] answer buffer to put answer in
* \param[in] anslen size of the answer buffer. compare the anslen with the return value, if the return
* value is bigger than anslen, it means the answer buffer doesn't contain the complete
* response. You will need to call this function again with a bigger answer buffer if
* you care about the complete response
*
* \retval return the size of the response on success, -1 on error
*
*/
int WINAPI res_search(const char *name,
int qclass, int type,
u_char *answer, int anslen);
/*! \fn int WINAPI dn_comp(const u_char* exp_dn, u_char* comp_dn, int length, u_char** dnptrs, u_char** lastdnptr)
* \brief Compress domain name 'exp_dn' into 'comp_dn'
*
* defined in res_comp.c
*
* \param[in] exp_dn name to compress
* \param[in, out] comp_dn result of the compression
* \param[in] length the size of the array pointed to by 'comp_dn'.
* \param[in, out] dnptrs a list of pointers to previous compressed names. dnptrs[0]
* is a pointer to the beginning of the message. The list ends with NULL.
* \param[in] lastdnptr a pointer to the end of the arrary pointed to by 'dnptrs'. Side effect
* is to update the list of pointers for labels inserted into the
* message as we compress the name. If 'dnptr' is NULL, we don't try to
* compress names. If 'lastdnptr' is NULL, we don't update the list.
* \retval Return the size of the compressed name or -1
*/
int WINAPI dn_comp(const u_char *exp_dn,
u_char *comp_dn,
int length, u_char **dnptrs,
u_char * *lastdnptr);
/*! \fn int WINAPI rdn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, u_char *exp_dn,
int length);
* \brief replacement for dn_expand called rdn_expand. Older versions of the DLL used to this as dn_expand
* but this has caused some conflict with more recent versions of the MSDEV libraries. rdn_expand()
* expands the compressed domain name comp_dn to a full domain name. Expanded names are converted to upper case.
*
* defined in res_comp.c
*
* \param[in] msg msg is a pointer to the beginning of the message
* \param[in] eomorig
* \param[in] comp_dn the compressed domain name.
* \param[in, out] exp_dn a pointer to the result buffer
* \param[in] length size of the result in expn_dn
* \retval the size of compressed name is returned or -1 if there was an error.
*/
int WINAPI rdn_expand(const u_char *msg,
const u_char *eomorig,
const u_char *comp_dn,
u_char *exp_dn,
int length);
/* Microsoft includes an implementation of dn_expand() in winsock */
/* Make sure we do not use it. jaltman@columbia.edu */
#define dn_expand(a,b,c,d,e) rdn_expand(a,b,c,d,e)
/*! \fn void WINAPI res_setopts(long opts)
* unsupported
*/
void WINAPI res_setopts(long opts);
/*! \fn long WINAPI res_getopts(void)
* unsupported
*/
long WINAPI res_getopts(void);
/*! \fn int WINAPI res_mkquery(int op, const char *dname, int qclass, int type, const char *data, int datalen,
* const struct rrec *newrr, char *buf, int buflen)
* unsupported
*/
int WINAPI res_mkquery(int op, const char *dname,
int qclass, int type,
const char *data, int datalen,
const struct rrec *newrr,
char *buf, int buflen);
/*! \fn int WINAPI res_send(const char *msg, int msglen, char *answer, int anslen)
* unsupported
*/
int WINAPI res_send(const char *msg, int msglen,
char *answer, int anslen);
/*! \fn int WINAPI res_querydomain(const char *name, const char *domain, int qclass, int type,
u_char *answer, int anslen);
* unsupported
*/
int WINAPI res_querydomain(const char *name,
const char *domain,
int qclass, int type,
u_char *answer, int anslen);
#ifdef __cplusplus
}
#endif
#else
__BEGIN_DECLS
int __dn_skipname __P((const u_char *, const u_char *));
void __fp_query __P((char *, FILE *));
char *__hostalias __P((const char *));
void __putlong __P((u_long, u_char *));
void __putshort __P((u_short, u_char *));
char *__p_class __P((int));
char *__p_time __P((u_long));
char *__p_type __P((int));
int dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **));
int rdn_expand __P((const u_char *, const u_char *, const u_char *,
u_char *, int));
int res_init __P((void));
int res_mkquery __P((int, const char *, int, int, const char *, int,
const struct rrec *, char *, int));
int res_send __P((const char *, int, char *, int));
__END_DECLS
#endif /* _WINDOWS || _WIN32 */
#endif /* !_RESOLV_H_ */

View File

@ -1,53 +1,144 @@
/*
WSHelper DNS/Hesiod Library for WINSOCK
wshelper.h
*/
/*! \file wshelper.h
* WSHelper DNS/Hesiod Library
*
* This file contains the function declaration for: \n
* rgethostbyname() \n
* rgethostbyaddr() \n
* rgetservbyname() \n
* inet_aton() \n
* wsh_gethostname() \n
* wsh_getdomainname() \n \n
* and unsupported functions: \n
* gethinfobyname() \n
* getmxbyname() \n
* getrecordbyname() \n
* rrhost() \n
*/
#ifndef _WSHELPER_
#define _WSHELPER_
#include <winsock.h>
#include <mitwhich.h>
#include <resolv.h>
#include <hesiod.h>
#ifdef __cplusplus
extern "C" {
#endif
/*! \fn struct hostent * WINAPI rgethostbyname(char *name)
* retrieves host information corresponding to a host name in the DNS database
*
* defined in gethna.c
*
* \param[in] name Pointer to the null-terminated name of the host to resolve. It can be a fully qualified host name such as x.mit.edu
* or it can be a simple host name such as x. If it is a simple host name, the default domain name is
* appended to do the search.
* \retval a pointer to the structure hostent. a structure allocated by the library. The hostent structure contains
* the results of a successful search for the host specified in the name parameter. The caller must never
* attempt to modify this structure or to free any of its components. Furthermore, only one copy of this
* structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another rgethostbyname.
* NULL if the search has failed
*
*/
struct hostent * WINAPI rgethostbyname(char *name);
struct hostent FAR* WINAPI rgethostbyname(char FAR *name);
struct hostent FAR* WINAPI rgethostbyaddr(char FAR *addr,
int len, int type);
struct servent FAR* WINAPI rgetservbyname(LPSTR name,
LPSTR proto);
/*! \fn struct hostent * WINAPI rgethostbyaddr(char *addr, int len, int type)
* retrieves the host information corresponding to a network address in the DNS database
*
* defined in gethna.c
*
* \param[in] addr Pointer to an address in network byte order
* \param[in] len Length of the address, in bytes
* \param[in] type Type of the address, such as the AF_INET address family type (defined as TCP,
* UDP, and other associated Internet protocols). Address family types and their corresponding
* values are defined in the Winsock2.h header file.
* \retval returns a pointer to the hostent structure that contains the name and address corresponding
* to the given network address. The structure is allocated by the library. The caller must never
* attempt to modify this structure or to free any of its components. Furthermore, only one copy of this
* structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another rgethostbyaddr.
* NULL if the search has failed
*
*/
struct hostent * WINAPI rgethostbyaddr(char *addr, int len, int type);
/*! \fn struct servent * WINAPI rgetservbyname(LPSTR name, LPSTR proto)
* retrieves service information corresponding to a service name and protocol.
*
* defined in gethna.c
*
* \param[in] name Pointer to a null-terminated service name.
* \param[in] proto pointer to a null-terminated protocol name. getservbyname should match both
* the name and the proto.
* \retval a pointer to the servent structure containing the name(s) and service number that match the name and proto
* parameters. The structure is allocated by the library. The caller must never
* attempt to modify this structure or to free any of its components. Furthermore, only one copy of this
* structure is allocated per call per thread, so the application should copy any information it needs before
* issuing another rgetservbyname.
* NULL if the search has failed
*
*/
struct servent * WINAPI rgetservbyname(LPSTR name, LPSTR proto);
/*! \fn LPSTR WINAPI gethinfobyname(LPSTR name)
* unsupported
*/
LPSTR WINAPI gethinfobyname(LPSTR name);
/*! \fn LPSTR WINAPI getmxbyname(LPSTR name)
* unsupported
*/
LPSTR WINAPI getmxbyname(LPSTR name);
/*! \fn LPSTR WINAPI getrecordbyname(LPSTR name, int rectype)
* unsupported
*/
LPSTR WINAPI getrecordbyname(LPSTR name, int rectype);
/*! \fn DWORD WINAPI rrhost( LPSTR lpHost )
* unsupported
*/
DWORD WINAPI rrhost( LPSTR lpHost );
unsigned long WINAPI inet_aton(register const char *cp,
struct in_addr *addr);
/*! \fn unsigned long WINAPI inet_aton(register const char *cp, struct in_addr *addr)
* converts a string containing an (Ipv4) Internet Protocol dotted address into a proper address for the in_addr structure
*
* defined in inetaton.c
*
* \param[in] cp Null-terminated character string representing a number expressed in the
* Internet standard ".'' (dotted) notation.
* \param[in, out] addr pointer to the in_addr structure. The s_addr memeber will be populated
* \retval Returns 1 if the address is valid, 0 if not.
*/
unsigned long WINAPI inet_aton(register const char *cp, struct in_addr *addr);
DWORD WhichOS( DWORD *check);
#ifdef _WIN32
/*! \fn int WINAPI wsh_gethostname(char* name, int size)
* Gets the base part of the hostname
*
* defined in res_init.c
*
* \param[in, out] name pointer to a buffer that receives a null-terminated string containing the computer name
* \param[in] size specifies the size of the buffer, in chars (must be large
* enough to hold NULL-terminated host name)
* \retval return 0 ifsuccess, -1 on error.
*/
int WINAPI wsh_gethostname(char* name, int size);
/*! \fn int WINAPI wsh_getdomainname(char* name, int size)
* Gets the machine's domain name
*
* defined in res_init.c
*
* \param[in, out] name pointer to a buffer that receives a null-terminated string containing the domain name
* \param[in] size specifies the size of the buffer, in chars (must be large
* enough to hold NULL-terminated domain name)
*
* \retval return 0 ifsuccess, -1 on error.
*/
int WINAPI wsh_getdomainname(char* name, int size);
LONG FAR WSHGetHostID();
#endif
/* some definitions to determine which OS were using and which subsystem */
#if !defined( STACK_UNKNOWN )
#define STACK_UNKNOWN -1
#define MS_NT_32 1
#define MS_NT_16 2
#define MS_95_32 3
#define MS_95_16 4
#define NOVELL_LWP_16 5
#endif /* STACK_UNKNOWN */
#ifdef __cplusplus

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.