diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2019-10-13 23:24:57 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2019-10-13 23:24:57 (GMT) | 
| commit | f439711a77e0719e7f1dcf4b5c5511157986c918 (patch) | |
| tree | cac0cf37be2676fcf2dc958f9d9fd2fadea20653 /src/analysis/db/misc/timestamp.c | |
| parent | 986125d4c2d8b049017b6d0770f16b9058076165 (diff) | |
Retrieved the current snapshot identifier from servers.
Diffstat (limited to 'src/analysis/db/misc/timestamp.c')
| -rw-r--r-- | src/analysis/db/misc/timestamp.c | 71 | 
1 files changed, 67 insertions, 4 deletions
| diff --git a/src/analysis/db/misc/timestamp.c b/src/analysis/db/misc/timestamp.c index 12299eb..dfc6f25 100644 --- a/src/analysis/db/misc/timestamp.c +++ b/src/analysis/db/misc/timestamp.c @@ -29,6 +29,9 @@  #include <time.h> +#include "../../../core/logs.h" + +  /******************************************************************************  *                                                                             * @@ -36,19 +39,59 @@  *                                                                             *  *  Description : Obtient un horodatage initialisé au moment même.             *  *                                                                             * -*  Retour      : -                                                            * +*  Retour      : Bilan de l'opération.                                        *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -void init_timestamp(timestamp_t *timestamp) +bool init_timestamp(timestamp_t *timestamp)  { +    bool result;                            /* Bilan à retourner           */      struct timespec info;                   /* Détails sur l'époque        */ +    int ret;                                /* Bilan de la récupération    */ + +    ret = clock_gettime(CLOCK_REALTIME, &info); -    clock_gettime(CLOCK_REALTIME, &info); +    if (ret != 0) +    { +        LOG_ERROR_N("clock_gettime"); +        result = false; +    } -    *timestamp = info.tv_sec * 1000000 + info.tv_nsec / 1000; +    else +    { +        *timestamp = info.tv_sec * 1000000 + info.tv_nsec / 1000; +        result = true; +    } + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : timestamp = horodatage à initialiser. [OUT]                  * +*                value     = valeur d'initialisation.                         * +*                                                                             * +*  Description : Obtient un horodatage initialisé avec une valeur donnée.     * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool init_timestamp_from_value(timestamp_t *timestamp, uint64_t value) +{ +    bool result;                            /* Bilan à retourner           */ + +    result = true; + +    *timestamp = value; + +    return result;  } @@ -79,6 +122,26 @@ bool timestamp_is_younger(timestamp_t stamp, timestamp_t limit)  /******************************************************************************  *                                                                             * +*  Paramètres  : dest = destination de la copie d'horodatage. [OUT]           * +*                src  = source de l'horodatage à copier.                      * +*                                                                             * +*  Description : Effectue une copie d'horodatage.                             * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void copy_timestamp(timestamp_t *dest, const timestamp_t *src) +{ +    *dest = *src; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : t1 = premier horodatage à comparer.                          *  *                t2 = second horodatage à comparer.                           *  *                                                                             * | 
