*
* NAME
*
- * typedef unsigned char SilcAttribute;
+ * typedef SilcUInt8 SilcAttribute;
*
* DESCRIPTION
*
*
* SOURCE
*/
-typedef unsigned char SilcAttribute;
+typedef SilcUInt8 SilcAttribute;
/* All defined attributes. See the specs for detailed information. The
comment is the structure or data type that must be used with the
#define SILC_ATTRIBUTE_STATUS_MESSAGE 5 /* SilcAttributeObjMime */
#define SILC_ATTRIBUTE_PREFERRED_LANGUAGE 6 /* char * (UTF-8 string) */
#define SILC_ATTRIBUTE_PREFERRED_CONTACT 7 /* SilcAttributeContact */
-#define SILC_ATTRIBUTE_TIMEZONE 8 /* char * (UTF-8 string */
+#define SILC_ATTRIBUTE_TIMEZONE 8 /* char * (UTF-8 string) */
#define SILC_ATTRIBUTE_GEOLOCATION 9 /* SilcAttributeObjGeo */
#define SILC_ATTRIBUTE_DEVICE_INFO 10 /* SilcAttributeObjDevice */
#define SILC_ATTRIBUTE_EXTENSION 11 /* SilcAttributeObjMime */
*
* NAME
*
- * typedef unsigned char SilcAttributeFlags;
+ * typedef SilcUInt8 SilcAttributeFlags;
*
* DESCRIPTION
*
*
* SOURCE
*/
-typedef unsigned char SilcAttributeFlags;
+typedef SilcUInt8 SilcAttributeFlags;
/* All defined flags */
#define SILC_ATTRIBUTE_FLAG_NONE 0x00 /* No flags */
*
* Parses one attribute payload sent as argument and saves it to
* SilcAttributePayload context. The new allocated context is returned.
+ *
***/
SilcAttributePayload
silc_attribute_payload_parse(const unsigned char *payload,
*
* SYNOPSIS
*
- * SilcBuffer silc_attribute_payload_encode(SilcAttribute attribute,
+ * SilcBuffer silc_attribute_payload_encode(SilcBuffer attrs,
+ * SilcAttribute attribute,
* SilcAttributeFlags flags,
- * const unsigned char *data,
- * SilcUInt32 data_len);
+ * void *object,
+ * SilcUInt32 object_size);
*
* DESCRIPTION
*
- * Encodes one attribute payload and returns allocated buffer. The
- * `attributes' is the attribute type with `flags' and the actual
- * attribute data indicated by `data' and `data_len'.
+ * Encodes one attribute payload into the `attrs' buffer and returns
+ * pointer to the buffer, which may be different in case the buffer
+ * was reallocated. If `attrs' is NULL for first attribute this
+ * allocates the buffer and returns it. This can be called multiple
+ * times to add multiple attributes to the `attrs' buffer. The `flags'
+ * indicates the validity of the added attribute.
+ *
+ * The `object' must always be the same data type as defined with
+ * SilcAttribute (see the comments) for all attributes.
*
***/
-SilcBuffer silc_attribute_payload_encode(SilcAttribute attribute,
+SilcBuffer silc_attribute_payload_encode(SilcBuffer attrs,
+ SilcAttribute attribute,
SilcAttributeFlags flags,
- const unsigned char *data,
- SilcUInt32 data_len);
+ void *object,
+ SilcUInt32 object_size);
/****f* silccore/SilcAttributesAPI/silc_attribute_payload_parse_list
*
* Parses list of Attribute payloads returning list of payloads. This
* is equivalent to the silc_attribute_payload_parse except that the
* `buffer' now includes multiple Attribute Payloads one after the other.
- * You can produce such a list with silc_attribute_payload_encode_list
+ * You can produce such a list with silc_attribute_payload_encode
* function.
*
***/
SilcDList silc_attribute_payload_parse_list(const unsigned char *payload,
SilcUInt32 payload_len);
-/****f* silccore/SilcAttributesAPI/silc_attribute_payload_encode_list
- *
- * SYNOPSIS
- *
- * SilcBuffer silc_attribute_payload_encode(SilcUInt32 num_attrs, ...);
- *
- * DESCRIPTION
- *
- * Encodes a list of Attribute payloads. The `num_attrs' indicates the
- * number of attributes sent as argument. The variable argument list
- * sent as argument includes the attribute, attribute flags, attribute
- * data and attribute data length. One attribute is one of these
- * { attribute, attribute flags, data and data length } arguments.
- * Returns the attribute payloads in data buffer one after the other.
- * You can parse such list with silc_attribute_payload_parse_list
- * function.
- *
- ***/
-SilcBuffer silc_attribute_payload_encode_list(SilcUInt32 num_attrs, ...);
-
/****f* silccore/SilcAttributesAPI/silc_attribute_payload_free
*
* SYNOPSIS
*
* DESCRIPTION
*
- * Data type for MIME object as attribute. Caller must free the
- * MIME data buffer inside the structure.
+ * Data type for MIME object as attribute. The data in the structure
+ * is valid as long as the payload structure is valid.
*
* SOURCE
*/
typedef struct {
- unsigned char *mime; /* allocated MIME buffer */
- SilcUInt32 mime_len; /* length of the allocated MIME buffer */
+ const unsigned char *mime; /* MIME buffer */
+ SilcUInt32 mime_len; /* length of the MIME buffer */
} SilcAttributeObjMime;
/***/
*
* bool silc_attribute_get_object(SilcAttributePayload payload,
* SilcAttribute attribute,
- * const void **object,
+ * void **object,
* SilcUInt32 object_size);
*
* DESCRIPTION
* Returns TRUE if the `attribute' attribute was found and FALSE
* if such attribute is not present in the `payload', or the `object_size'
* is not sufficient. See the definition of SilcAttribute for the
- * list attributes and the required object types for attributes.
+ * list of attributes and the required object types for attributes.
*
***/
bool silc_attribute_get_object(SilcAttributePayload payload,