1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* CMetrics 4 * ======== 5 * Copyright 2021 Eduardo Silva <eduardo@calyptia.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 21 #ifndef CMT_DECODE_MSGPACK_H 22 #define CMT_DECODE_MSGPACK_H 23 24 #include <cmetrics/cmetrics.h> 25 #include <cmetrics/cmt_mpack_utils_defs.h> 26 27 #define CMT_DECODE_MSGPACK_SUCCESS CMT_MPACK_SUCCESS 28 #define CMT_DECODE_MSGPACK_INSUFFICIENT_DATA CMT_MPACK_INSUFFICIENT_DATA 29 #define CMT_DECODE_MSGPACK_INVALID_ARGUMENT_ERROR CMT_MPACK_INVALID_ARGUMENT_ERROR 30 #define CMT_DECODE_MSGPACK_ALLOCATION_ERROR CMT_MPACK_ALLOCATION_ERROR 31 #define CMT_DECODE_MSGPACK_CORRUPT_INPUT_DATA_ERROR CMT_MPACK_CORRUPT_INPUT_DATA_ERROR 32 #define CMT_DECODE_MSGPACK_CONSUME_ERROR CMT_MPACK_CONSUME_ERROR 33 #define CMT_DECODE_MSGPACK_ENGINE_ERROR CMT_MPACK_ENGINE_ERROR 34 #define CMT_DECODE_MSGPACK_PENDING_MAP_ENTRIES CMT_MPACK_PENDING_MAP_ENTRIES 35 #define CMT_DECODE_MSGPACK_PENDING_ARRAY_ENTRIES CMT_MPACK_PENDING_ARRAY_ENTRIES 36 #define CMT_DECODE_MSGPACK_UNEXPECTED_KEY_ERROR CMT_MPACK_UNEXPECTED_KEY_ERROR 37 #define CMT_DECODE_MSGPACK_UNEXPECTED_DATA_TYPE_ERROR CMT_MPACK_UNEXPECTED_DATA_TYPE_ERROR 38 39 #define CMT_DECODE_MSGPACK_DICTIONARY_LOOKUP_ERROR CMT_MPACK_ERROR_CUTOFF + 1 40 #define CMT_DECODE_MSGPACK_VERSION_ERROR CMT_MPACK_ERROR_CUTOFF + 2 41 42 struct cmt_msgpack_decode_context { 43 struct cmt *cmt; 44 struct cmt_map *map; 45 struct cmt_metric *metric; 46 struct mk_list unique_label_list; 47 int static_labels_unpacked; 48 }; 49 50 int cmt_decode_msgpack_create(struct cmt **out_cmt, char *in_buf, size_t in_size, 51 size_t *offset); 52 void cmt_decode_msgpack_destroy(struct cmt *cmt); 53 54 #endif 55