summaryrefslogtreecommitdiffstats
path: root/src/windows/identity/kcreddb/attrib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/identity/kcreddb/attrib.c')
-rw-r--r--src/windows/identity/kcreddb/attrib.c114
1 files changed, 63 insertions, 51 deletions
diff --git a/src/windows/identity/kcreddb/attrib.c b/src/windows/identity/kcreddb/attrib.c
index e43540dc5..badfb2b49 100644
--- a/src/windows/identity/kcreddb/attrib.c
+++ b/src/windows/identity/kcreddb/attrib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 Massachusetts Institute of Technology
+ * 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
@@ -33,27 +33,31 @@ kcdb_attrib_i ** kcdb_attrib_tbl = NULL;
kcdb_attrib_i ** kcdb_property_tbl = NULL;
kcdb_attrib_i * kcdb_attribs = NULL;
-void kcdb_attrib_add_ref_func(const void * key, void * va)
+void
+kcdb_attrib_add_ref_func(const void * key, void * va)
{
kcdb_attrib_hold((kcdb_attrib_i *) va);
}
-void kcdb_attrib_del_ref_func(const void * key, void * va)
+void
+kcdb_attrib_del_ref_func(const void * key, void * va)
{
kcdb_attrib_release((kcdb_attrib_i *) va);
}
-void kcdb_attrib_msg_completion(kmq_message * m)
+void
+kcdb_attrib_msg_completion(kmq_message * m)
{
if(m && m->vparam) {
kcdb_attrib_release((kcdb_attrib_i *) m->vparam);
}
}
-khm_int32 kcdb_attrib_hold(kcdb_attrib_i * ai)
+khm_int32
+kcdb_attrib_hold(kcdb_attrib_i * ai)
{
if(!ai)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
ai->refcount++;
@@ -61,10 +65,11 @@ khm_int32 kcdb_attrib_hold(kcdb_attrib_i * ai)
return KHM_ERROR_SUCCESS;
}
-khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai)
+khm_int32
+kcdb_attrib_release(kcdb_attrib_i * ai)
{
if(!ai)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
ai->refcount--;
@@ -72,16 +77,18 @@ khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai)
return KHM_ERROR_SUCCESS;
}
-void kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)
+void
+kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)
{
kcdb_attrib_hold(ai);
kmq_post_message(KMSG_KCDB, KMSG_KCDB_ATTRIB, op, (void *) ai);
}
-khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle vcred,
- khm_int32 attr,
- void * buf,
- khm_size * pcb_buf)
+khm_int32 KHMAPI
+kcdb_attr_sys_cb(khm_handle vcred,
+ khm_int32 attr,
+ void * buf,
+ khm_size * pcb_buf)
{
kcdb_cred * c;
@@ -192,27 +199,28 @@ khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle vcred,
}
}
-void kcdb_attrib_init(void)
+void
+kcdb_attrib_init(void)
{
kcdb_attrib attrib;
wchar_t sbuf[256];
InitializeCriticalSection(&cs_attrib);
- kcdb_attrib_namemap = hash_new_hashtable(
- KCDB_ATTRIB_HASH_SIZE,
- hash_string,
- hash_string_comp,
- kcdb_attrib_add_ref_func,
- kcdb_attrib_del_ref_func);
+ kcdb_attrib_namemap =
+ hash_new_hashtable(KCDB_ATTRIB_HASH_SIZE,
+ hash_string,
+ hash_string_comp,
+ kcdb_attrib_add_ref_func,
+ kcdb_attrib_del_ref_func);
kcdb_attrib_tbl =
- malloc(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));
+ PMALLOC(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));
assert(kcdb_attrib_tbl != NULL);
ZeroMemory(kcdb_attrib_tbl,
sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));
kcdb_property_tbl =
- malloc(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);
+ PMALLOC(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);
assert(kcdb_property_tbl != NULL);
ZeroMemory(kcdb_property_tbl,
sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);
@@ -468,23 +476,25 @@ void kcdb_attrib_init(void)
kcdb_attrib_register(&attrib, NULL);
}
-void kcdb_attrib_exit(void)
+void
+kcdb_attrib_exit(void)
{
DeleteCriticalSection(&cs_attrib);
if(kcdb_attrib_tbl)
- free(kcdb_attrib_tbl);
+ PFREE(kcdb_attrib_tbl);
if(kcdb_property_tbl)
- free(kcdb_property_tbl);
+ PFREE(kcdb_property_tbl);
}
-KHMEXP khm_int32 KHMAPI kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)
+KHMEXP khm_int32 KHMAPI
+kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)
{
kcdb_attrib_i * ai;
if(!name)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
ai = hash_lookup(kcdb_attrib_namemap, (void *) name);
@@ -499,7 +509,8 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)
}
}
-KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)
+KHMEXP khm_int32 KHMAPI
+kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)
{
kcdb_attrib_i * ai;
size_t cb_name;
@@ -511,7 +522,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
if(!attrib ||
KHM_FAILED(kcdb_type_get_info(attrib->type, NULL)) ||
!attrib->name)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
if(FAILED(StringCbLength(attrib->name, KCDB_MAXCB_NAME, &cb_name)))
return KHM_ERROR_TOO_LONG;
@@ -535,50 +546,51 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
(!attrib->compute_cb ||
attrib->compute_min_cbsize <= 0 ||
attrib->compute_max_cbsize < attrib->compute_min_cbsize))
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
if ((attrib->flags & KCDB_ATTR_FLAG_ALTVIEW) &&
KHM_FAILED(kcdb_attrib_get_info(attrib->alt_id,
NULL)))
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
prop = !!(attrib->flags & KCDB_ATTR_FLAG_PROPERTY);
EnterCriticalSection(&cs_attrib);
- if(
- !prop &&
- (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID))
+ if(!prop &&
+ (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID))
{
if(KHM_FAILED(kcdb_attrib_next_free_id(&attr_id))) {
LeaveCriticalSection(&cs_attrib);
return KHM_ERROR_NO_RESOURCES;
}
- } else if (
- prop &&
- (attrib->id < KCDB_ATTR_MIN_PROP_ID || attrib->id > KCDB_ATTR_MAX_PROP_ID))
- {
+ } else if (prop &&
+ (attrib->id < KCDB_ATTR_MIN_PROP_ID ||
+ attrib->id > KCDB_ATTR_MAX_PROP_ID)) {
+
if(KHM_FAILED(kcdb_attrib_next_free_prop_id(&attr_id))) {
LeaveCriticalSection(&cs_attrib);
return KHM_ERROR_NO_RESOURCES;
}
+
} else {
attr_id = attrib->id;
}
#ifdef DEBUG
assert(!prop || (attr_id >= KCDB_ATTR_MIN_PROP_ID && attr_id <= KCDB_ATTR_MAX_PROP_ID));
- assert(prop || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));
+ assert(prop || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));
#endif
if((!prop && kcdb_attrib_tbl[attr_id]) ||
- (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID]))
- {
+ (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID])) {
+
LeaveCriticalSection(&cs_attrib);
return KHM_ERROR_DUPLICATE;
+
}
- ai = malloc(sizeof(kcdb_attrib_i));
+ ai = PMALLOC(sizeof(kcdb_attrib_i));
ZeroMemory(ai, sizeof(kcdb_attrib_i));
ai->attr.type = attrib->type;
@@ -588,14 +600,14 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * n
ai->attr.compute_cb = attrib->compute_cb;
ai->attr.compute_max_cbsize = attrib->compute_max_cbsize;
ai->attr.compute_min_cbsize = attrib->compute_min_cbsize;
- ai->attr.name = malloc(cb_name);
+ ai->attr.name = PMALLOC(cb_name);
StringCbCopy(ai->attr.name, cb_name, attrib->name);
if(cb_short_desc) {
- ai->attr.short_desc = malloc(cb_short_desc);
+ ai->attr.short_desc = PMALLOC(cb_short_desc);
StringCbCopy(ai->attr.short_desc, cb_short_desc, attrib->short_desc);
}
if(cb_long_desc) {
- ai->attr.long_desc = malloc(cb_long_desc);
+ ai->attr.long_desc = PMALLOC(cb_long_desc);
StringCbCopy(ai->attr.long_desc, cb_long_desc, attrib->long_desc);
}
@@ -632,7 +644,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_info(
else if(id >= KCDB_ATTR_MIN_PROP_ID && id <= KCDB_ATTR_MAX_PROP_ID)
prop = TRUE;
else
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
if(prop)
@@ -679,7 +691,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_describe(
khm_boolean prop;
if(!cbsize)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
if(id >= 0 && id <= KCDB_ATTR_MAX_ID)
prop = FALSE;
@@ -734,7 +746,7 @@ khm_int32 kcdb_attrib_next_free_prop_id(khm_int32 * id)
int i;
if(!id)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
for(i=0;i < KCDB_ATTR_MAX_PROPS; i++) {
@@ -757,7 +769,7 @@ khm_int32 kcdb_attrib_next_free_id(khm_int32 * id)
int i;
if(!id)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
EnterCriticalSection(&cs_attrib);
for(i=0;i<= KCDB_ATTR_MAX_ID; i++) {
@@ -785,7 +797,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_count(
int i;
if(pcount == NULL)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
eq_flags &= and_flags;
@@ -819,7 +831,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_get_ids(
int i;
if(plist == NULL || pcsize == NULL)
- return KHM_ERROR_INVALID_PARM;
+ return KHM_ERROR_INVALID_PARAM;
eq_flags &= and_flags;