|
OpenVAS Scanner 23.32.3
|
Implementation of an API for ISOTIME values. More...
#include "nasl_isotime.h"#include "nasl_debug.h"#include "nasl_global_ctxt.h"#include "nasl_lex_ctxt.h"#include "nasl_tree.h"#include "nasl_var.h"#include <ctype.h>#include <glib.h>#include <glib/gstdio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | G_LOG_DOMAIN "lib nasl" |
| GLib logging domain. | |
| #define | DIM(v) |
| #define | DIMof(type, member) |
| #define | ISOTIME_SIZE 16 |
| #define | JD_DIFF 1721060L |
| #define | spacep(p) |
| #define | digitp(p) |
| #define | atoi_1(p) |
| #define | atoi_2(p) |
| #define | atoi_4(p) |
Typedefs | |
| typedef char | my_isotime_t[ISOTIME_SIZE] |
Functions | |
| static void | epoch2isotime (my_isotime_t timebuf, time_t atime) |
| static void | get_current_isotime (my_isotime_t timebuf) |
| static int | check_isotime (const my_isotime_t atime) |
| static int | isotime_p (const char *string) |
| static int | isotime_human_p (const char *string) |
| static int | string2isotime (my_isotime_t atime, const char *string) |
| static int | days_per_year (int y) |
| static int | days_per_month (int y, int m) |
| static unsigned long | date2jd (int year, int month, int day) |
| static int | jd2date (unsigned long jd, int *year, int *month, int *day) |
| static int | add_seconds_to_isotime (my_isotime_t atime, int nseconds) |
| static int | add_days_to_isotime (my_isotime_t atime, int ndays) |
| static int | add_years_to_isotime (my_isotime_t atime, int nyears) |
| tree_cell * | nasl_isotime_now (lex_ctxt *lexic) |
| Return the current time in ISO format. | |
| tree_cell * | nasl_isotime_is_valid (lex_ctxt *lexic) |
| Check whether an ISO time string is valid. | |
| tree_cell * | nasl_isotime_scan (lex_ctxt *lexic) |
| Convert a string into an ISO time string. | |
| tree_cell * | nasl_isotime_print (lex_ctxt *lexic) |
| Convert an SIO time string into a better readable string. | |
| tree_cell * | nasl_isotime_add (lex_ctxt *lexic) |
| Add days or seconds to an ISO time string. | |
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 | ) |
Definition at line 75 of file nasl_isotime.c.
| #define atoi_2 | ( | p | ) |
Definition at line 76 of file nasl_isotime.c.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), add_years_to_isotime(), and isotime_human_p().
| #define atoi_4 | ( | p | ) |
Definition at line 77 of file nasl_isotime.c.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), and add_years_to_isotime().
| #define digitp | ( | p | ) |
Definition at line 72 of file nasl_isotime.c.
Referenced by check_isotime(), isotime_human_p(), and isotime_p().
| #define DIM | ( | v | ) |
Definition at line 58 of file nasl_isotime.c.
Referenced by nasl_ssh_close_hook(), nasl_ssh_connect(), and verify_session_id().
| #define DIMof | ( | type, | |
| member ) |
Definition at line 59 of file nasl_isotime.c.
| #define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 55 of file nasl_isotime.c.
| #define ISOTIME_SIZE 16 |
Definition at line 64 of file nasl_isotime.c.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), add_years_to_isotime(), epoch2isotime(), nasl_isotime_add(), nasl_isotime_is_valid(), and nasl_isotime_scan().
| #define JD_DIFF 1721060L |
Definition at line 68 of file nasl_isotime.c.
| #define spacep | ( | p | ) |
Definition at line 71 of file nasl_isotime.c.
Referenced by isotime_human_p(), and string2isotime().
| typedef char my_isotime_t[ISOTIME_SIZE] |
Definition at line 65 of file nasl_isotime.c.
|
static |
Definition at line 452 of file nasl_isotime.c.
References atoi_2, atoi_4, check_isotime(), date2jd(), ISOTIME_SIZE, and jd2date().
Referenced by nasl_isotime_add().


|
static |
Definition at line 405 of file nasl_isotime.c.
References atoi_2, atoi_4, check_isotime(), date2jd(), ISOTIME_SIZE, and jd2date().
Referenced by nasl_isotime_add().


|
static |
Definition at line 490 of file nasl_isotime.c.
References atoi_2, atoi_4, check_isotime(), date2jd(), ISOTIME_SIZE, and jd2date().
Referenced by nasl_isotime_add().


|
static |
Definition at line 113 of file nasl_isotime.c.
References digitp.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), add_years_to_isotime(), nasl_isotime_add(), and nasl_isotime_print().

|
static |
Definition at line 335 of file nasl_isotime.c.
References JD_DIFF.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), add_years_to_isotime(), and jd2date().

|
static |
Definition at line 302 of file nasl_isotime.c.
Referenced by jd2date().

|
static |
Definition at line 289 of file nasl_isotime.c.
Referenced by jd2date().

|
static |
Definition at line 81 of file nasl_isotime.c.
References ISOTIME_SIZE.
Referenced by get_current_isotime().

|
static |
Definition at line 103 of file nasl_isotime.c.
References epoch2isotime().
Referenced by nasl_isotime_now().


|
static |
Definition at line 163 of file nasl_isotime.c.
References atoi_2, digitp, and spacep.
Referenced by nasl_isotime_is_valid(), and string2isotime().

|
static |
Definition at line 137 of file nasl_isotime.c.
References digitp.
Referenced by nasl_isotime_is_valid(), and string2isotime().

|
static |
Definition at line 355 of file nasl_isotime.c.
References date2jd(), days_per_month(), days_per_year(), and JD_DIFF.
Referenced by add_days_to_isotime(), add_seconds_to_isotime(), and add_years_to_isotime().


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 727 of file nasl_isotime.c.
References add_days_to_isotime(), add_seconds_to_isotime(), add_years_to_isotime(), alloc_typed_cell(), check_isotime(), CONST_STR, get_int_var_by_name(), get_str_var_by_num(), get_var_size_by_num(), ISOTIME_SIZE, TC::size, TC::str_val, and TC::x.

Check whether an ISO time string is valid.
| [in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 575 of file nasl_isotime.c.
References alloc_typed_cell(), CONST_INT, get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), TC::i_val, isotime_human_p(), isotime_p(), ISOTIME_SIZE, VAR2_DATA, VAR2_STRING, and TC::x.

Return the current time in ISO format.
| [in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 543 of file nasl_isotime.c.
References alloc_typed_cell(), CONST_STR, get_current_isotime(), TC::size, TC::str_val, and TC::x.

Convert an SIO time string into a better readable string.
| [in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 677 of file nasl_isotime.c.
References alloc_typed_cell(), check_isotime(), CONST_STR, get_str_var_by_num(), get_var_size_by_num(), TC::size, TC::str_val, and TC::x.

Convert a string into an ISO time string.
| [in] | lexic | Lexical context of the NASL interpreter. |
Definition at line 626 of file nasl_isotime.c.
References alloc_typed_cell(), CONST_STR, get_str_var_by_num(), get_var_size_by_num(), get_var_type_by_num(), ISOTIME_SIZE, TC::size, TC::str_val, string2isotime(), VAR2_DATA, VAR2_STRING, and TC::x.

|
static |
Definition at line 234 of file nasl_isotime.c.
References isotime_human_p(), isotime_p(), and spacep.
Referenced by nasl_isotime_scan().

