-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
zen_octet.h
50 lines (40 loc) · 1.7 KB
/
zen_octet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* This file is part of Zenroom (https://zenroom.dyne.org)
*
* Copyright (C) 2017-2020 Dyne.org foundation
* designed, written and maintained by Denis Roio <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef __ZEN_OCTET_H__
#define __ZEN_OCTET_H__
#include <amcl.h>
// tracing wrappers for all C->Lua functions
#define BEGIN() trace(L, "vv begin %s",__func__)
#define END(n) trace(L, "^^ end %s",__func__); return(n)
#define THROW(ERR) \
lerror(L, "fatal %s: %s", __func__, (ERR)); \
lua_pushnil(L)
// REMEMBER: o_new and o_dup push a new object in lua's stack
octet* o_new(lua_State *L, const int size);
octet *o_dup(lua_State *L, octet *o);
// REMEMBER: o_arg returns a new allocated octet to be freed with o_free
octet* o_arg(lua_State *L, int n);
// These functions are internal and not exposed to lua's stack
// to make an octet visible to lua can be done using o_dup
octet *o_alloc(lua_State *L, int size);
void o_free(lua_State *L,octet *o);
void push_octet_to_hex_string(lua_State *L, octet *o);
void push_buffer_to_octet(lua_State *L, char *p, size_t len);
#endif