1 /*
2 * Date and time functions
3 *
4 * Copyright (C) 2010-2017, Joachim Metz <joachim.metz@gmail.com>
5 *
6 * Refer to AUTHORS for acknowledgements.
7 *
8 * This software is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This software is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this software. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include <common.h>
23
24 #if defined( TIME_WITH_SYS_TIME )
25 #include <sys/time.h>
26 #include <time.h>
27 #elif defined( HAVE_SYS_TIME_H )
28 #include <sys/time.h>
29 #else
30 #include <time.h>
31 #endif
32
33 #include "libfcache_date_time.h"
34 #include "libfcache_libcerror.h"
35 #include "libfcache_types.h"
36
37 /* Retrieves the cache value timestamp
38 * Returns 1 if successful or -1 on error
39 */
libfcache_date_time_get_timestamp(time_t * timestamp,libcerror_error_t ** error)40 int libfcache_date_time_get_timestamp(
41 time_t *timestamp,
42 libcerror_error_t **error )
43 {
44 static char *function = "libfcache_date_time_get_timestamp";
45
46 if( timestamp == NULL )
47 {
48 libcerror_error_set(
49 error,
50 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
51 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
52 "%s: invalid timestamp.",
53 function );
54
55 return( -1 );
56 }
57 *timestamp = time( NULL );
58
59 return( 1 );
60 }
61
62