/src/libfwevt/libfvalue/libfvalue_filetime.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Filetime functions |
3 | | * |
4 | | * Copyright (C) 2010-2024, Joachim Metz <joachim.metz@gmail.com> |
5 | | * |
6 | | * Refer to AUTHORS for acknowledgements. |
7 | | * |
8 | | * This program 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 program 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 program. If not, see <https://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include <common.h> |
23 | | #include <types.h> |
24 | | |
25 | | #include "libfvalue_definitions.h" |
26 | | #include "libfvalue_filetime.h" |
27 | | #include "libfvalue_libcerror.h" |
28 | | #include "libfvalue_libfdatetime.h" |
29 | | |
30 | | #if defined( HAVE_LIBFDATETIME ) || defined( HAVE_LOCAL_LIBFDATETIME ) |
31 | | |
32 | | /* Copies the filetime from an integer value |
33 | | * Returns 1 if successful or -1 on error |
34 | | */ |
35 | | int libfvalue_filetime_copy_from_integer( |
36 | | libfdatetime_filetime_t *filetime, |
37 | | uint64_t integer_value, |
38 | | size_t integer_value_size, |
39 | | libcerror_error_t **error ) |
40 | 0 | { |
41 | 0 | static char *function = "libfvalue_filetime_copy_from_integer"; |
42 | |
|
43 | 0 | if( integer_value_size != 64 ) |
44 | 0 | { |
45 | 0 | libcerror_error_set( |
46 | 0 | error, |
47 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
48 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
49 | 0 | "%s: unsupported integer value size.", |
50 | 0 | function ); |
51 | |
|
52 | 0 | return( -1 ); |
53 | 0 | } |
54 | 0 | if( libfdatetime_filetime_copy_from_64bit( |
55 | 0 | filetime, |
56 | 0 | integer_value, |
57 | 0 | error ) != 1 ) |
58 | 0 | { |
59 | 0 | libcerror_error_set( |
60 | 0 | error, |
61 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
62 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
63 | 0 | "%s: unable to copy filetime from 64-bit value.", |
64 | 0 | function ); |
65 | |
|
66 | 0 | return( -1 ); |
67 | 0 | } |
68 | 0 | return( 1 ); |
69 | 0 | } |
70 | | |
71 | | /* Copies the filetime to an integer value |
72 | | * Returns 1 if successful or -1 on error |
73 | | */ |
74 | | int libfvalue_filetime_copy_to_integer( |
75 | | libfdatetime_filetime_t *filetime, |
76 | | uint64_t *integer_value, |
77 | | size_t *integer_value_size, |
78 | | libcerror_error_t **error ) |
79 | 0 | { |
80 | 0 | static char *function = "libfvalue_filetime_copy_to_integer"; |
81 | |
|
82 | 0 | if( integer_value_size == NULL ) |
83 | 0 | { |
84 | 0 | libcerror_error_set( |
85 | 0 | error, |
86 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
87 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
88 | 0 | "%s: invalid integer value size.", |
89 | 0 | function ); |
90 | |
|
91 | 0 | return( -1 ); |
92 | 0 | } |
93 | 0 | if( libfdatetime_filetime_copy_to_64bit( |
94 | 0 | filetime, |
95 | 0 | integer_value, |
96 | 0 | error ) != 1 ) |
97 | 0 | { |
98 | 0 | libcerror_error_set( |
99 | 0 | error, |
100 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
101 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
102 | 0 | "%s: unable to copy filetime to 64-bit value.", |
103 | 0 | function ); |
104 | |
|
105 | 0 | return( -1 ); |
106 | 0 | } |
107 | 0 | *integer_value_size = 64; |
108 | |
|
109 | 0 | return( 1 ); |
110 | 0 | } |
111 | | |
112 | | #endif /* defined( HAVE_LIBFDATETIME ) || defined( HAVE_LOCAL_LIBFDATETIME ) */ |
113 | | |