LCOV - code coverage report
Current view: top level - lib/formats - timestamp.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2015-09-30 14:09:30 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  This file is part of rmlint.
       3             :  *
       4             :  *  rmlint is free software: you can redistribute it and/or modify
       5             :  *  it under the terms of the GNU General Public License as published by
       6             :  *  the Free Software Foundation, either version 3 of the License, or
       7             :  *  (at your option) any later version.
       8             :  *
       9             :  *  rmlint is distributed in the hope that it will be useful,
      10             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *  GNU General Public License for more details.
      13             :  *
      14             :  *  You should have received a copy of the GNU General Public License
      15             :  *  along with rmlint.  If not, see <http://www.gnu.org/licenses/>.
      16             :  *
      17             :  * Authors:
      18             :  *
      19             :  *  - Christopher <sahib> Pahl 2010-2015 (https://github.com/sahib)
      20             :  *  - Daniel <SeeSpotRun> T.   2014-2015 (https://github.com/SeeSpotRun)
      21             :  *
      22             :  * Hosted on http://github.com/sahib/rmlint
      23             :  *
      24             :  */
      25             : 
      26             : #include "../formats.h"
      27             : 
      28             : #include <glib.h>
      29             : #include <stdio.h>
      30             : #include <string.h>
      31             : #include <time.h>
      32             : 
      33             : typedef struct RmFmtHandlerTimestamp {
      34             :     /* must be first */
      35             :     RmFmtHandler parent;
      36             : } RmFmtHandlerSummary;
      37             : 
      38         924 : static void rm_fmt_prog(RmSession *session,
      39             :                         _U RmFmtHandler *parent,
      40             :                         _U FILE *out,
      41             :                         RmFmtProgressState state) {
      42         924 :     if(state != RM_PROGRESS_STATE_INIT) {
      43         863 :         return;
      44             :     }
      45             : 
      46          61 :     if(rm_fmt_get_config_value(session->formats, "stamp", "iso8601")) {
      47             :         char time_buf[256];
      48           2 :         memset(time_buf, 0, sizeof(time_buf));
      49           2 :         rm_iso8601_format(time(NULL), time_buf, sizeof(time_buf));
      50           2 :         fprintf(out, "%s", time_buf);
      51             :     } else {
      52             :         /* Just write out current time */
      53          59 :         fprintf(out, "%" LLU "", (guint64)time(NULL));
      54             :     }
      55             : }
      56             : 
      57             : static RmFmtHandlerSummary TIMESTAMP_HANDLER_IMPL = {
      58             :     /* Initialize parent */
      59             :     .parent =
      60             :         {
      61             :          .size = sizeof(TIMESTAMP_HANDLER_IMPL),
      62             :          .name = "stamp",
      63             :          .head = NULL,
      64             :          .elem = NULL,
      65             :          .prog = rm_fmt_prog,
      66             :          .foot = NULL,
      67             :          .valid_keys = {"iso8601", NULL},
      68             :         },
      69             : };
      70             : 
      71             : RmFmtHandler *TIMESTAMP_HANDLER = (RmFmtHandler *)&TIMESTAMP_HANDLER_IMPL;

Generated by: LCOV version 1.11