1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
|
/*
* Date and time elements functions
*
* Copyright (C) 2013-2017, Joachim Metz <joachim.metz@gmail.com>
*
* Refer to AUTHORS for acknowledgements.
*
* This software is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined( _LIBCDATETIME_INTERNAL_ELEMENTS_H )
#define _LIBCDATETIME_INTERNAL_ELEMENTS_H
#include <common.h>
#include <types.h>
#if !defined( WINAPI )
#if defined( TIME_WITH_SYS_TIME )
#include <sys/time.h>
#include <time.h>
#elif defined( HAVE_SYS_TIME_H )
#include <sys/time.h>
#else
#include <time.h>
#endif
#endif
#include "libcdatetime_extern.h"
#include "libcdatetime_libcerror.h"
#include "libcdatetime_types.h"
#if defined( __cplusplus )
extern "C" {
#endif
enum LIBCDATETIME_ELEMENTS_MODES
{
LIBCDATETIME_ELEMENTS_MODE_DATE_TIME_IN_UTC,
LIBCDATETIME_ELEMENTS_MODE_DATE_TIME_IN_LOCALTIME,
LIBCDATETIME_ELEMENTS_MODE_DURATION,
};
typedef struct libcdatetime_internal_elements libcdatetime_internal_elements_t;
struct libcdatetime_internal_elements
{
#if defined( WINAPI ) && ( WINVER >= 0x0500 )
/* The filetime
*/
FILETIME filetime;
/* The systemtime
*/
SYSTEMTIME systemtime;
#elif defined( WINAPI )
/* TODO */
#error WINAPI date and time elements type for Windows NT4 or earlier NOT implemented yet
#else
/* The time
*/
time_t time;
/* The struct tm
*/
struct tm tm;
#endif /* defined( WINAPI ) && ( WINVER >= 0x0500 ) */
/* Value to indicate how the time elements are used
* e.g. to store a date time in UCT or localtime or a duration
*/
uint8_t mode;
};
LIBCDATETIME_EXTERN \
int libcdatetime_elements_initialize(
libcdatetime_elements_t **elements,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_free(
libcdatetime_elements_t **elements,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_copy(
libcdatetime_elements_t *destination_elements,
const libcdatetime_elements_t *source_elements,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_year(
libcdatetime_elements_t *elements,
uint16_t *year,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_day_of_year(
libcdatetime_elements_t *elements,
uint16_t *day_of_year,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_month(
libcdatetime_elements_t *elements,
uint8_t *month,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_day_of_month(
libcdatetime_elements_t *elements,
uint8_t *day_of_month,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_date_values(
libcdatetime_elements_t *elements,
uint16_t *year,
uint8_t *month,
uint8_t *day_of_month,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_hours(
libcdatetime_elements_t *elements,
uint8_t *hours,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_minutes(
libcdatetime_elements_t *elements,
uint8_t *minutes,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_seconds(
libcdatetime_elements_t *elements,
uint8_t *seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_milli_seconds(
libcdatetime_elements_t *elements,
uint16_t *milli_seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_micro_seconds(
libcdatetime_elements_t *elements,
uint16_t *micro_seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_nano_seconds(
libcdatetime_elements_t *elements,
uint16_t *nano_seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_time_values(
libcdatetime_elements_t *elements,
uint8_t *hours,
uint8_t *minutes,
uint8_t *seconds,
libcerror_error_t **error );
int libcdatetime_elements_set_date_and_time_values(
libcdatetime_elements_t *elements,
uint16_t year,
uint8_t month,
uint8_t day_of_month,
uint8_t hours,
uint8_t minutes,
uint8_t seconds,
libcerror_error_t **error );
#if defined( WINAPI ) && ( WINVER >= 0x0500 )
int libcdatetime_internal_elements_set_from_filetime_utc(
libcdatetime_internal_elements_t *internal_elements,
FILETIME *filetime,
libcerror_error_t **error );
#endif /* defined( WINAPI ) && ( WINVER >= 0x0500 ) */
#if !defined( WINAPI ) && defined( HAVE_TIME ) && ( defined( HAVE_GMTIME ) || defined( HAVE_GMTIME_R ) )
int libcdatetime_internal_elements_set_from_time_utc(
libcdatetime_internal_elements_t *internal_elements,
time_t *time,
libcerror_error_t **error );
#endif /* !defined( WINAPI ) && defined( HAVE_TIME ) && ( defined( HAVE_GMTIME ) || defined( HAVE_GMTIME_R ) ) */
#if !defined( WINAPI ) && defined( HAVE_TIME ) && ( defined( HAVE_LOCALTIME ) || defined( HAVE_LOCALTIME_R ) )
int libcdatetime_internal_elements_set_from_time_localtime(
libcdatetime_internal_elements_t *internal_elements,
time_t *time,
libcerror_error_t **error );
#endif /* !defined( WINAPI ) && defined( HAVE_TIME ) && ( defined( HAVE_LOCALTIME ) || defined( HAVE_LOCALTIME_R ) ) */
LIBCDATETIME_EXTERN \
int libcdatetime_elements_set_current_time_utc(
libcdatetime_elements_t *elements,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_set_current_time_localtime(
libcdatetime_elements_t *elements,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_delta_in_seconds(
libcdatetime_elements_t *first_elements,
libcdatetime_elements_t *second_elements,
int64_t *number_of_seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_set_from_delta_in_seconds(
libcdatetime_elements_t *elements,
int64_t number_of_seconds,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_get_string_size(
libcdatetime_elements_t *elements,
size_t *string_size,
uint32_t string_format_flags,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_copy_to_string(
libcdatetime_elements_t *elements,
uint8_t *string,
size_t string_size,
uint32_t string_format_flags,
libcerror_error_t **error );
LIBCDATETIME_EXTERN \
int libcdatetime_elements_copy_to_string_with_index(
libcdatetime_elements_t *elements,
uint8_t *string,
size_t string_size,
size_t *string_index,
uint32_t string_format_flags,
libcerror_error_t **error );
#if defined( __cplusplus )
}
#endif
#endif /* !defined( _LIBCDATETIME_INTERNAL_ELEMENTS_H ) */
|