Guardtime KSI c SDK
Loading...
Searching...
No Matches
tlv_element.h
Go to the documentation of this file.
1/*
2 * Copyright 2013-2015 Guardtime, Inc.
3 *
4 * This file is part of the Guardtime client SDK.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License").
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
13 * express or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 * "Guardtime" and "KSI" are trademarks or registered trademarks of
16 * Guardtime, Inc., and no license to trademarks is granted; Guardtime
17 * reserves and retains all trademark rights.
18 */
19
20#ifndef TLV_ELEMENT_H_
21#define TLV_ELEMENT_H_
22
23#include "ksi.h"
24#include "fast_tlv.h"
25#include "list.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
32
34#define KSI_TlvElementList_append(lst, o) KSI_APPLY_TO_NOT_NULL((lst), append, ((lst), (o)))
35#define KSI_TlvElementList_remove(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), removeElement, ((lst), (pos), (o)))
36#define KSI_TlvElementList_indexOf(lst, o, i) KSI_APPLY_TO_NOT_NULL((lst), indexOf, ((lst), (o), (i)))
37#define KSI_TlvElementList_insertAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), insertAt, ((lst), (pos), (o)))
38#define KSI_TlvElementList_replaceAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), replaceAt, ((lst), (pos), (o)))
39#define KSI_TlvElementList_elementAt(lst, pos, o) KSI_APPLY_TO_NOT_NULL((lst), elementAt, ((lst), (pos), (o)))
40#define KSI_TlvElementList_length(lst) (((lst) != NULL && (lst)->length != NULL) ? (lst)->length((lst)) : 0)
41#define KSI_TlvElementList_sort(lst, cmp) KSI_APPLY_TO_NOT_NULL((lst), sort, ((lst), (cmp)))
42#define KSI_TlvElementList_foldl(lst, foldCtx, foldFn) (((lst) != NULL) ? (((lst)->foldl != NULL) ? ((lst)->foldl((lst), (foldCtx), (foldFn))) : KSI_INVALID_STATE) : KSI_OK)
43#define KSI_TlvElementList_find(lst, o,f, i) KSI_APPLY_TO_NOT_NULL((lst), find, ((lst), (o), (f), (i)))
44
46
53 size_t ref;
57 unsigned char *ptr;
62 };
63
70
81 int KSI_TlvElement_parse(unsigned char *dat, size_t dat_len, KSI_TlvElement **out);
82
91
97
109 int KSI_TlvElement_serialize(const KSI_TlvElement *element, unsigned char *buf, size_t buf_size, size_t *len, int opt);
110
118
128
140
151
162 int KSI_TlvElement_getUtf8String(KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Utf8String **out);
163
175
186 int KSI_TlvElement_getInteger(KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Integer **out);
187
198
209
219 int KSI_TlvElement_setInteger(KSI_TlvElement *parent, unsigned tag, KSI_Integer *value);
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif /* TLV_ELEMENT_H_ */
struct fast_tlv_s KSI_FTLV
Definition fast_tlv.h:29
struct KSI_Integer_st KSI_Integer
Definition types_base.h:94
struct KSI_OctetString_st KSI_OctetString
Definition types_base.h:99
struct KSI_CTX_st KSI_CTX
Definition types_base.h:78
struct KSI_Utf8String_st KSI_Utf8String
Definition types_base.h:104
#define KSI_DEFINE_LIST(type)
Definition list.h:96
Definition tlv_element.h:51
unsigned char * ptr
Definition tlv_element.h:57
size_t ref
Definition tlv_element.h:53
int ptr_own
Definition tlv_element.h:59
KSI_LIST(KSI_TlvElement) *subList
KSI_FTLV ftlv
Definition tlv_element.h:55
int KSI_TlvElement_parse(unsigned char *dat, size_t dat_len, KSI_TlvElement **out)
int KSI_TlvElement_setElement(KSI_TlvElement *parent, KSI_TlvElement *child)
void KSI_TlvElement_free(KSI_TlvElement *t)
int KSI_TlvElement_new(KSI_TlvElement **out)
int KSI_TlvElement_getInteger(KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Integer **out)
int KSI_TlvElement_setOctetString(KSI_TlvElement *parent, unsigned tag, KSI_OctetString *value)
int KSI_TlvElement_serialize(const KSI_TlvElement *element, unsigned char *buf, size_t buf_size, size_t *len, int opt)
int KSI_TlvElement_getElement(KSI_TlvElement *parent, unsigned tag, KSI_TlvElement **el)
int KSI_TlvElement_getUtf8String(KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_Utf8String **out)
int KSI_TlvElement_appendElement(KSI_TlvElement *parent, KSI_TlvElement *child)
struct KSI_TlvElement_st KSI_TlvElement
Definition tlv_element.h:31
int KSI_TlvElement_detach(KSI_TlvElement *el)
int KSI_TlvElement_setUtf8String(KSI_TlvElement *parent, unsigned tag, KSI_Utf8String *value)
int KSI_TlvElement_removeElement(KSI_TlvElement *parent, unsigned tag, KSI_TlvElement **el)
int KSI_TlvElement_getOctetString(KSI_TlvElement *parent, KSI_CTX *ctx, unsigned tag, KSI_OctetString **out)
int KSI_TlvElement_setInteger(KSI_TlvElement *parent, unsigned tag, KSI_Integer *value)
#define KSI_DEFINE_REF(typ)
Definition types_base.h:39