Guardtime KSI c SDK
tlv.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 KSI_TLV_H_
21 #define KSI_TLV_H_
22 
23 #include "types.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
63  int KSI_TLV_new(KSI_CTX *ctx, unsigned tag, int isLenient, int isForward, KSI_TLV **tlv);
64 
78  int KSI_TLV_fromString(KSI_CTX *ctx, unsigned tag, int isLenient, int isForward, char *str, KSI_TLV **tlv);
79 
90  int KSI_TLV_parseBlob(KSI_CTX *ctx, const unsigned char *data, size_t data_length, KSI_TLV **tlv);
91 
103  int KSI_TLV_parseBlob2(KSI_CTX *ctx, unsigned char *data, size_t data_length, int ownMemory, KSI_TLV **tlv);
104 
114  int KSI_TLV_getRawValue(KSI_TLV *tlv, const unsigned char **buf, size_t *len);
115 
124  int KSI_TLV_getInteger(KSI_TLV *tlv, KSI_Integer **value);
125 
134  int KSI_TLV_getUInt64Value(const KSI_TLV *tlv, KSI_uint64_t *val);
135 
146  int KSI_TLV_getNestedList(KSI_TLV *tlv, KSI_LIST(KSI_TLV) **list);
151  void KSI_TLV_free(KSI_TLV *tlv);
152 
160  int KSI_TLV_isNonCritical(const KSI_TLV *tlv);
161 
169  int KSI_TLV_isForward(const KSI_TLV *tlv);
170 
178  unsigned KSI_TLV_getTag(const KSI_TLV *tlv);
179 
190  int KSI_TLV_serialize_ex(const KSI_TLV *tlv, unsigned char *buf, size_t buf_size, size_t *len);
191 
200  int KSI_TLV_serialize(const KSI_TLV *tlv, unsigned char **buf, size_t *buf_len);
201 
212  int KSI_TLV_serializePayload(const KSI_TLV *tlv, unsigned char *buf, size_t *len);
213 
222  int KSI_TLV_replaceNestedTlv(KSI_TLV *parentTlv, KSI_TLV *oldTlv, KSI_TLV *newTlv);
223 
230  int KSI_TLV_appendNestedTlv(KSI_TLV *target, KSI_TLV *tlv);
231 
232  int KSI_TLV_writeBytes(const KSI_TLV *tlv, unsigned char *buf, size_t buf_size, size_t *buf_len, int opt);
233 
243  char *KSI_TLV_toString(const KSI_TLV *tlv, char *buffer, size_t buffer_len);
244 
254  int KSI_TLV_clone(const KSI_TLV *tlv, KSI_TLV **clone);
255 
264  int KSI_TLV_setRawValue(KSI_TLV *tlv, const void *data, size_t data_len);
265 
273  size_t KSI_TLV_getAbsoluteOffset(const KSI_TLV *tlv);
274 
283  size_t KSI_TLV_getRelativeOffset(const KSI_TLV *tlv);
284 
286 
291 #ifdef __cplusplus
292 }
293 #endif
294 
295 #endif /* KSI_TLV_H_ */
int KSI_TLV_serialize_ex(const KSI_TLV *tlv, unsigned char *buf, size_t buf_size, size_t *len)
#define KSI_uint64_t
Definition: types_base.h:105
struct KSI_Integer_st KSI_Integer
Definition: types_base.h:140
int KSI_TLV_appendNestedTlv(KSI_TLV *target, KSI_TLV *tlv)
size_t KSI_TLV_getAbsoluteOffset(const KSI_TLV *tlv)
int KSI_TLV_fromString(KSI_CTX *ctx, unsigned tag, int isLenient, int isForward, char *str, KSI_TLV **tlv)
int KSI_TLV_parseBlob2(KSI_CTX *ctx, unsigned char *data, size_t data_length, int ownMemory, KSI_TLV **tlv)
int KSI_TLV_getNestedList(KSI_TLV *tlv, KSI_LIST(KSI_TLV)**list)
int KSI_TLV_getInteger(KSI_TLV *tlv, KSI_Integer **value)
unsigned KSI_TLV_getTag(const KSI_TLV *tlv)
int KSI_TLV_getRawValue(KSI_TLV *tlv, const unsigned char **buf, size_t *len)
KSI_DEFINE_GET_CTX(KSI_TLV)
int KSI_TLV_new(KSI_CTX *ctx, unsigned tag, int isLenient, int isForward, KSI_TLV **tlv)
int KSI_TLV_writeBytes(const KSI_TLV *tlv, unsigned char *buf, size_t buf_size, size_t *buf_len, int opt)
int KSI_TLV_isNonCritical(const KSI_TLV *tlv)
int KSI_TLV_serialize(const KSI_TLV *tlv, unsigned char **buf, size_t *buf_len)
int KSI_TLV_setRawValue(KSI_TLV *tlv, const void *data, size_t data_len)
int KSI_TLV_getUInt64Value(const KSI_TLV *tlv, KSI_uint64_t *val)
char * KSI_TLV_toString(const KSI_TLV *tlv, char *buffer, size_t buffer_len)
struct KSI_CTX_st KSI_CTX
Definition: types_base.h:124
int KSI_TLV_replaceNestedTlv(KSI_TLV *parentTlv, KSI_TLV *oldTlv, KSI_TLV *newTlv)
struct KSI_TLV_st KSI_TLV
Definition: types_base.h:129
int KSI_TLV_serializePayload(const KSI_TLV *tlv, unsigned char *buf, size_t *len)
size_t KSI_TLV_getRelativeOffset(const KSI_TLV *tlv)
void KSI_TLV_free(KSI_TLV *tlv)
int KSI_TLV_isForward(const KSI_TLV *tlv)
int KSI_TLV_clone(const KSI_TLV *tlv, KSI_TLV **clone)
#define KSI_LIST(type)
Definition: list.h:44
int KSI_TLV_parseBlob(KSI_CTX *ctx, const unsigned char *data, size_t data_length, KSI_TLV **tlv)