/*
- client_attrs.c
+ client_attrs.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002 Pekka Riikonen
+ Copyright (C) 2002 - 2004 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static void silc_client_attributes_process_foreach(void *key, void *context,
void *user_context)
{
- SilcAttribute attribute = (SilcAttribute)(SilcUInt32)key;
+ SilcAttribute attribute = (SilcAttribute)SILC_PTR_TO_32(key);
SilcAttributePayload attr = context;
SilcAttrForeach *f = user_context;
const unsigned char *data;
SILC_LOG_DEBUG(("Attribute %d found", attribute));
data = silc_attribute_get_data(attr, &data_len);
+#if 0
/* We replace the TIMEZONE with valid value here */
if (attribute == SILC_ATTRIBUTE_TIMEZONE) {
data = (const unsigned char *)silc_get_time(0);
(void *)data, data_len);
return;
}
+#endif
f->buffer = silc_attribute_payload_encode_data(f->buffer, attribute,
SILC_ATTRIBUTE_FLAG_VALID,
SilcAttribute attribute;
SilcAttributePayload attr;
SilcAttributeObjPk pk;
- unsigned char sign[2048];
+ unsigned char sign[2048 + 1];
SilcUInt32 sign_len;
SILC_LOG_DEBUG(("Process Requested Attributes"));
/* If nothing is set by application assume that we don't want to use
attributes, ignore the request. */
- if (!conn->attrs)
+ if (!conn->internal->attrs)
return NULL;
/* Always put our public key. */
if (attribute == SILC_ATTRIBUTE_USER_DIGITAL_SIGNATURE)
continue;
- silc_hash_table_find_foreach(conn->attrs, (void *)(SilcUInt32)attribute,
+ silc_hash_table_find_foreach(conn->internal->attrs,
+ SILC_32_TO_PTR(attribute),
silc_client_attributes_process_foreach,
&f);
}
if (!attr)
return NULL;
- if (!conn->attrs)
- conn->attrs = silc_hash_table_alloc(0, silc_hash_ptr, NULL, NULL,
- NULL, silc_client_attribute_destruct,
- NULL, TRUE);
- silc_hash_table_add(conn->attrs, (void *)(SilcUInt32)attribute, attr);
+ if (!conn->internal->attrs)
+ conn->internal->attrs =
+ silc_hash_table_alloc(0, silc_hash_ptr, NULL, NULL,
+ NULL, silc_client_attribute_destruct,
+ NULL, TRUE);
+ silc_hash_table_add(conn->internal->attrs,
+ SILC_32_TO_PTR(attribute), attr);
return attr;
}
if (!attr)
return;
attribute = silc_attribute_get_attribute(attr);
- silc_hash_table_del_by_context(conn->attrs,
- (void *)(SilcUInt32)attribute, attr);
+ silc_hash_table_del_by_context(conn->internal->attrs,
+ SILC_32_TO_PTR(attribute), attr);
}
/* Delete one attribute */
{
bool ret;
- if (!conn->attrs)
+ if (!conn->internal->attrs)
return FALSE;
if (attr) {
attribute = silc_attribute_get_attribute(attr);
- ret = silc_hash_table_del_by_context(conn->attrs,
- (void *)(SilcUInt32)attribute, attr);
+ ret = silc_hash_table_del_by_context(conn->internal->attrs,
+ SILC_32_TO_PTR(attribute), attr);
} else if (attribute) {
- silc_hash_table_find_foreach(conn->attrs, (void *)(SilcUInt32)attribute,
+ silc_hash_table_find_foreach(conn->internal->attrs,
+ SILC_32_TO_PTR(attribute),
silc_client_attribute_del_foreach, conn);
ret = TRUE;
} else{
}
if (ret)
- if (!silc_hash_table_count(conn->attrs)) {
- silc_hash_table_free(conn->attrs);
- conn->attrs = NULL;
+ if (!silc_hash_table_count(conn->internal->attrs)) {
+ silc_hash_table_free(conn->internal->attrs);
+ conn->internal->attrs = NULL;
}
return ret;
/* Return all attributes */
-const SilcHashTable silc_client_attributes_get(SilcClient client,
- SilcClientConnection conn)
+SilcHashTable silc_client_attributes_get(SilcClient client,
+ SilcClientConnection conn)
{
- return (const SilcHashTable)conn->attrs;
+ return conn->internal->attrs;
}
/* Construct a Requested Attributes buffer. If the `attribute' is zero (0)