| 1 | /* |
|---|
| 2 | * MessagePack unpacking routine |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2008 FURUHASHI Sadayuki |
|---|
| 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 | * |
|---|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 11 | * |
|---|
| 12 | * Unless required by applicable law or agreed to in writing, software |
|---|
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 15 | * See the License for the specific language governing permissions and |
|---|
| 16 | * limitations under the License. |
|---|
| 17 | */ |
|---|
| 18 | #ifndef MSGPACK_UNPACK_INLINE_CONTEXT_H__ |
|---|
| 19 | #define MSGPACK_UNPACK_INLINE_CONTEXT_H__ |
|---|
| 20 | |
|---|
| 21 | #include <stddef.h> |
|---|
| 22 | #include <stdint.h> |
|---|
| 23 | |
|---|
| 24 | #ifndef MSG_STACK_SIZE |
|---|
| 25 | #define MSG_STACK_SIZE 16 |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | #ifdef __cplusplus |
|---|
| 29 | extern "C" { |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | typedef struct { |
|---|
| 33 | msgpack_object obj; |
|---|
| 34 | size_t count; |
|---|
| 35 | unsigned int ct; |
|---|
| 36 | union { |
|---|
| 37 | /*const unsigned char* terminal_trail_start;*/ |
|---|
| 38 | msgpack_object map_key; |
|---|
| 39 | } tmp; |
|---|
| 40 | } msgpack_unpacker_stack; |
|---|
| 41 | |
|---|
| 42 | typedef struct { |
|---|
| 43 | msgpack_unpack_context user; // must be first |
|---|
| 44 | unsigned int cs; |
|---|
| 45 | size_t trail; |
|---|
| 46 | unsigned int top; |
|---|
| 47 | msgpack_unpacker_stack stack[MSG_STACK_SIZE]; |
|---|
| 48 | } msgpack_unpacker; |
|---|
| 49 | |
|---|
| 50 | void msgpack_unpacker_init(msgpack_unpacker* ctx); |
|---|
| 51 | int msgpack_unpacker_execute(msgpack_unpacker* ctx, const char* data, size_t len, size_t* off); |
|---|
| 52 | #define msgpack_unpacker_data(unpacker) (unpacker)->stack[0].obj |
|---|
| 53 | |
|---|
| 54 | #ifdef __cplusplus |
|---|
| 55 | } |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | #endif /* msgpack/unpack/inline_context.h */ |
|---|
| 59 | |
|---|