-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathzen_time.h
More file actions
51 lines (42 loc) · 1.83 KB
/
Copy pathzen_time.h
File metadata and controls
51 lines (42 loc) · 1.83 KB
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
50
51
/* This file is part of Zenroom (https://zenroom.dyne.org)
*
* Copyright (C) 2017-2026 Dyne.org foundation
* designed, written and maintained by Denis Roio <jaromil@dyne.org>
*
* 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_TIME_H__
#define __ZEN_TIME_H__
#include <stdint.h>
/*
* Conservative heuristic window used by TIME.detect_time_value().
* Keep autodetection narrow on purpose: it should catch modern Unix
* timestamps used in credential-expiry style payloads without treating
* arbitrary small integers as TIME values.
*/
#define AUTODETECTED_TIME_MIN 1500000000LL
#define AUTODETECTED_TIME_MAX 4102444800LL
/* Canonical TIME domain: signed 64-bit Unix seconds. */
typedef int64_t ztime_t;
/* Creates a fresh userdata-backed TIME value and pushes it onto the Lua stack. */
HEDLEY_RETURNS_NON_NULL
ztime_t* time_new(lua_State *L);
/* Clones an existing TIME value into fresh userdata and pushes the clone. */
ztime_t* time_dup(lua_State *L, ztime_t *c);
/* Returns a heap-owned TIME clone for userdata, strings, or numbers. */
ztime_t* time_arg(lua_State *L, int n);
/* Converts TIME to octet using the compatibility policy in zen_time.c. */
octet *new_octet_from_time(lua_State *L, ztime_t c);
#endif