1 /*
2  * POSIX time functions
3  *
4  * Copyright (C) 2009-2018, 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 #if !defined( _LIBFDATETIME_INTERNAL_POSIX_TIME_H )
23 #define _LIBFDATETIME_INTERNAL_POSIX_TIME_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "libfdatetime_extern.h"
29 #include "libfdatetime_libcerror.h"
30 #include "libfdatetime_types.h"
31 
32 #if defined( __cplusplus )
33 extern "C" {
34 #endif
35 
36 typedef struct libfdatetime_internal_posix_time libfdatetime_internal_posix_time_t;
37 
38 /* Contains a value representing the number of seconds since January 1, 1970 (UTC)
39  * Normally this value is a 32-bit signed integer where negative numbers predate
40  * the epoch, but different variations exists
41  */
42 struct libfdatetime_internal_posix_time
43 {
44 	/* The timestamp
45 	 */
46 	uint64_t timestamp;
47 
48 	/* The value type
49 	 */
50 	uint8_t value_type;
51 };
52 
53 LIBFDATETIME_EXTERN \
54 int libfdatetime_posix_time_initialize(
55      libfdatetime_posix_time_t **posix_time,
56      libcerror_error_t **error );
57 
58 LIBFDATETIME_EXTERN \
59 int libfdatetime_posix_time_free(
60      libfdatetime_posix_time_t **posix_time,
61      libcerror_error_t **error );
62 
63 LIBFDATETIME_EXTERN \
64 int libfdatetime_posix_time_copy_from_byte_stream(
65      libfdatetime_posix_time_t *posix_time,
66      const uint8_t *byte_stream,
67      size_t byte_stream_size,
68      int byte_order,
69      uint8_t value_type,
70      libcerror_error_t **error );
71 
72 LIBFDATETIME_EXTERN \
73 int libfdatetime_posix_time_copy_from_32bit(
74      libfdatetime_posix_time_t *posix_time,
75      uint32_t value_32bit,
76      uint8_t value_type,
77      libcerror_error_t **error );
78 
79 LIBFDATETIME_EXTERN \
80 int libfdatetime_posix_time_copy_to_32bit(
81      libfdatetime_posix_time_t *posix_time,
82      uint32_t *value_32bit,
83      uint8_t *value_type,
84      libcerror_error_t **error );
85 
86 LIBFDATETIME_EXTERN \
87 int libfdatetime_posix_time_copy_from_64bit(
88      libfdatetime_posix_time_t *posix_time,
89      uint64_t value_64bit,
90      uint8_t value_type,
91      libcerror_error_t **error );
92 
93 LIBFDATETIME_EXTERN \
94 int libfdatetime_posix_time_copy_to_64bit(
95      libfdatetime_posix_time_t *posix_time,
96      uint64_t *value_64bit,
97      uint8_t *value_type,
98      libcerror_error_t **error );
99 
100 int libfdatetime_posix_time_copy_to_date_time_values(
101      libfdatetime_internal_posix_time_t *internal_posix_time,
102      libfdatetime_date_time_values_t *date_time_values,
103      libcerror_error_t **error );
104 
105 LIBFDATETIME_EXTERN \
106 int libfdatetime_posix_time_get_string_size(
107      libfdatetime_posix_time_t *posix_time,
108      size_t *string_size,
109      uint32_t string_format_flags,
110      libcerror_error_t **error );
111 
112 LIBFDATETIME_EXTERN \
113 int libfdatetime_posix_time_copy_to_utf8_string(
114      libfdatetime_posix_time_t *posix_time,
115      uint8_t *utf8_string,
116      size_t utf8_string_size,
117      uint32_t string_format_flags,
118      libcerror_error_t **error );
119 
120 LIBFDATETIME_EXTERN \
121 int libfdatetime_posix_time_copy_to_utf8_string_with_index(
122      libfdatetime_posix_time_t *posix_time,
123      uint8_t *utf8_string,
124      size_t utf8_string_size,
125      size_t *utf8_string_index,
126      uint32_t string_format_flags,
127      libcerror_error_t **error );
128 
129 LIBFDATETIME_EXTERN \
130 int libfdatetime_posix_time_copy_to_utf16_string(
131      libfdatetime_posix_time_t *posix_time,
132      uint16_t *utf16_string,
133      size_t utf16_string_size,
134      uint32_t string_format_flags,
135      libcerror_error_t **error );
136 
137 LIBFDATETIME_EXTERN \
138 int libfdatetime_posix_time_copy_to_utf16_string_with_index(
139      libfdatetime_posix_time_t *posix_time,
140      uint16_t *utf16_string,
141      size_t utf16_string_size,
142      size_t *utf16_string_index,
143      uint32_t string_format_flags,
144      libcerror_error_t **error );
145 
146 LIBFDATETIME_EXTERN \
147 int libfdatetime_posix_time_copy_to_utf32_string(
148      libfdatetime_posix_time_t *posix_time,
149      uint32_t *utf32_string,
150      size_t utf32_string_size,
151      uint32_t string_format_flags,
152      libcerror_error_t **error );
153 
154 LIBFDATETIME_EXTERN \
155 int libfdatetime_posix_time_copy_to_utf32_string_with_index(
156      libfdatetime_posix_time_t *posix_time,
157      uint32_t *utf32_string,
158      size_t utf32_string_size,
159      size_t *utf32_string_index,
160      uint32_t string_format_flags,
161      libcerror_error_t **error );
162 
163 #if defined( __cplusplus )
164 }
165 #endif
166 
167 #endif /* !defined( _LIBFDATETIME_INTERNAL_POSIX_TIME_H ) */
168 
169