OpenVAS Libraries
9.0.3
|
Implementation of an API for ISOTIME values. More...
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "nasl_tree.h"
#include "nasl_global_ctxt.h"
#include "nasl_var.h"
#include "nasl_lex_ctxt.h"
#include "nasl_debug.h"
#include "nasl_isotime.h"
Go to the source code of this file.
Macros | |
#define | DIM(v) (sizeof(v)/sizeof((v)[0])) |
#define | DIMof(type, member) DIM(((type *)0)->member) |
#define | ISOTIME_SIZE 16 |
#define | JD_DIFF 1721060L |
#define | spacep(p) (*(p) == ' ' || *(p) == '\t') |
#define | digitp(p) (*(p) >= '0' && *(p) <= '9') |
#define | atoi_1(p) (*(p) - '0' ) |
#define | atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) |
#define | atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2)) |
Typedefs | |
typedef char | my_isotime_t[ISOTIME_SIZE] |
Functions | |
tree_cell * | nasl_isotime_now (lex_ctxt *lexic) |
Return the current time in ISO format. More... | |
tree_cell * | nasl_isotime_is_valid (lex_ctxt *lexic) |
Check whether an ISO time string is valid. More... | |
tree_cell * | nasl_isotime_scan (lex_ctxt *lexic) |
Convert a string into an ISO time string. More... | |
tree_cell * | nasl_isotime_print (lex_ctxt *lexic) |
Convert an SIO time string into a better readable string. More... | |
tree_cell * | nasl_isotime_add (lex_ctxt *lexic) |
Add days or seconds to an ISO time string. More... | |
Implementation of an API for ISOTIME values.
This file contains the implementation of the isotime_* NASL builtin functions.
Most 32 bit systems use a signed 32 bit time_t to represent the system time. The problem is that in 2038 this time type will overflow. However, we sometimes need to compute dates in the future; for example some certificates are (for whatever reasons) valid for 30 years. To solve this problem in a platform independent way, we represent the time as a string and provide functions to work with them. This is not an elegant solution, but all proposed new time APIs have never been implemented on main stream systems - we can't expect that this will happen any time soon.
Definition in file nasl_isotime.c.
#define atoi_1 | ( | p | ) | (*(p) - '0' ) |
Definition at line 89 of file nasl_isotime.c.
Definition at line 90 of file nasl_isotime.c.
Definition at line 91 of file nasl_isotime.c.
#define digitp | ( | p | ) | (*(p) >= '0' && *(p) <= '9') |
Definition at line 86 of file nasl_isotime.c.
#define DIM | ( | v | ) | (sizeof(v)/sizeof((v)[0])) |
Definition at line 72 of file nasl_isotime.c.
#define DIMof | ( | type, | |
member | |||
) | DIM(((type *)0)->member) |
Definition at line 73 of file nasl_isotime.c.
#define ISOTIME_SIZE 16 |
Definition at line 78 of file nasl_isotime.c.
#define JD_DIFF 1721060L |
Definition at line 82 of file nasl_isotime.c.
#define spacep | ( | p | ) | (*(p) == ' ' || *(p) == '\t') |
Definition at line 85 of file nasl_isotime.c.
typedef char my_isotime_t[ISOTIME_SIZE] |
Definition at line 79 of file nasl_isotime.c.
Add days or seconds to an ISO time string.
This function adds days or seconds to an ISO time string and returns the resulting time string. The number of days or seconds are given using the named parameters; if none are given nothing is added; if both are given both additions are performed. This function won't work for dates before the Gregorian calendar switch.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 776 of file nasl_isotime.c.
References get_str_var_by_num(), get_var_size_by_num(), and ISOTIME_SIZE.
Check whether an ISO time string is valid.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 620 of file nasl_isotime.c.
References get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), ISOTIME_SIZE, VAR2_DATA, and VAR2_STRING.
Return the current time in ISO format.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 588 of file nasl_isotime.c.
Convert an SIO time string into a better readable string.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 724 of file nasl_isotime.c.
References get_str_var_by_num(), and get_var_size_by_num().
Convert a string into an ISO time string.
[in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 672 of file nasl_isotime.c.
References get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), ISOTIME_SIZE, VAR2_DATA, and VAR2_STRING.