Loading...
Searching...
No Matches
as_cdt_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2023 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/******************************************************************************
28 * MACROS
29 *****************************************************************************/
30
31#define as_cdt_begin() \
32 {0};\
33 while (true) {
34
35#define as_cdt_end(pk) \
36 if (!(pk)->buffer) {\
37 (pk)->buffer = cf_malloc((pk)->offset);\
38 (pk)->capacity = (pk)->offset;\
39 (pk)->offset = 0;\
40 (pk)->head = NULL;\
41 (pk)->tail = NULL;\
42 continue;\
43 }\
44 break;\
45 }
46
47/******************************************************************************
48 * FUNCTIONS
49 *****************************************************************************/
50
51void
52as_cdt_pack_header(as_packer* pk, as_cdt_ctx* ctx, uint16_t command, uint32_t count);
53
54void
55as_cdt_pack_header_flag(as_packer* pk, as_cdt_ctx* ctx, uint16_t command, uint32_t count, uint32_t flag);
56
57void
59
60uint32_t
62
63bool
64as_cdt_add_packed(as_packer* pk, as_operations* ops, const char* name, as_operator op_type);
65
66bool
68
69static inline void
70as_pack_string(as_packer* pk, const char* s)
71{
72 uint32_t len = (uint32_t)strlen(s);
73 as_pack_str(pk, (uint8_t*)s, len);
74}
75
76static inline void
77as_pack_byte_string(as_packer* pk, const uint8_t* b, uint32_t len)
78{
79 as_pack_str(pk, b, len);
80}
81
82bool
83as_unpack_str_init(as_unpacker* pk, char* str, uint32_t max);
84
85bool
86as_unpack_str_new(as_unpacker* pk, char** str, uint32_t max);
87
88bool
89as_unpack_bytes_init(as_unpacker* pk, uint8_t* b, uint32_t max);
90
91bool
92as_unpack_bytes_new(as_unpacker* pk, uint8_t** bytes, uint32_t* bytes_size, uint32_t max);
93
94#define as_cmp_error() \
95 printf("Line %d\n", __LINE__);\
96 return false;
97
98bool
100
101#ifdef __cplusplus
102} // end extern "C"
103#endif
bool as_unpack_str_init(as_unpacker *pk, char *str, uint32_t max)
bool as_val_compare(as_val *v1, as_val *v2)
void as_cdt_pack_header_flag(as_packer *pk, as_cdt_ctx *ctx, uint16_t command, uint32_t count, uint32_t flag)
void as_cdt_pack_ctx(as_packer *pk, as_cdt_ctx *ctx)
uint32_t as_cdt_ctx_pack(const as_cdt_ctx *ctx, as_packer *pk)
bool as_cdt_add_packed(as_packer *pk, as_operations *ops, const char *name, as_operator op_type)
void as_cdt_pack_header(as_packer *pk, as_cdt_ctx *ctx, uint16_t command, uint32_t count)
bool as_cdt_ctx_from_unpacker(as_cdt_ctx *ctx, as_unpacker *pk)
bool as_unpack_bytes_init(as_unpacker *pk, uint8_t *b, uint32_t max)
bool as_unpack_str_new(as_unpacker *pk, char **str, uint32_t max)
bool as_unpack_bytes_new(as_unpacker *pk, uint8_t **bytes, uint32_t *bytes_size, uint32_t max)
static void as_pack_byte_string(as_packer *pk, const uint8_t *b, uint32_t len)
static void as_pack_string(as_packer *pk, const char *s)
int as_pack_str(as_packer *pk, const uint8_t *buf, uint32_t sz)
as_operator