/src/libfplist/libfguid/libfguid_identifier.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * GUID 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 <byte_stream.h>  | 
24  |  | #include <memory.h>  | 
25  |  | #include <types.h>  | 
26  |  |  | 
27  |  | #include "libfguid_definitions.h"  | 
28  |  | #include "libfguid_identifier.h"  | 
29  |  | #include "libfguid_libcerror.h"  | 
30  |  | #include "libfguid_types.h"  | 
31  |  |  | 
32  |  | /* Creates an identifier  | 
33  |  |  * Make sure the value identifier is referencing, is set to NULL  | 
34  |  |  * Returns 1 if successful or -1 on error  | 
35  |  |  */  | 
36  |  | int libfguid_identifier_initialize(  | 
37  |  |      libfguid_identifier_t **identifier,  | 
38  |  |      libcerror_error_t **error )  | 
39  | 16.3k  | { | 
40  | 16.3k  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
41  | 16.3k  |   static char *function                               = "libfguid_identifier_initialize";  | 
42  |  |  | 
43  | 16.3k  |   if( identifier == NULL )  | 
44  | 0  |   { | 
45  | 0  |     libcerror_error_set(  | 
46  | 0  |      error,  | 
47  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
48  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
49  | 0  |      "%s: invalid identifier.",  | 
50  | 0  |      function );  | 
51  |  | 
  | 
52  | 0  |     return( -1 );  | 
53  | 0  |   }  | 
54  | 16.3k  |   if( *identifier != NULL )  | 
55  | 0  |   { | 
56  | 0  |     libcerror_error_set(  | 
57  | 0  |      error,  | 
58  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
59  | 0  |      LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,  | 
60  | 0  |      "%s: invalid identifier value already set.",  | 
61  | 0  |      function );  | 
62  |  | 
  | 
63  | 0  |     return( -1 );  | 
64  | 0  |   }  | 
65  | 16.3k  |   internal_identifier = memory_allocate_structure(  | 
66  | 16.3k  |                          libfguid_internal_identifier_t );  | 
67  |  |  | 
68  | 16.3k  |   if( internal_identifier == NULL )  | 
69  | 0  |   { | 
70  | 0  |     libcerror_error_set(  | 
71  | 0  |      error,  | 
72  | 0  |      LIBCERROR_ERROR_DOMAIN_MEMORY,  | 
73  | 0  |      LIBCERROR_MEMORY_ERROR_INSUFFICIENT,  | 
74  | 0  |      "%s: unable to create identifier.",  | 
75  | 0  |      function );  | 
76  |  | 
  | 
77  | 0  |     goto on_error;  | 
78  | 0  |   }  | 
79  | 16.3k  |   if( memory_set(  | 
80  | 16.3k  |        internal_identifier,  | 
81  | 16.3k  |        0,  | 
82  | 16.3k  |        sizeof( libfguid_internal_identifier_t ) ) == NULL )  | 
83  | 0  |   { | 
84  | 0  |     libcerror_error_set(  | 
85  | 0  |      error,  | 
86  | 0  |      LIBCERROR_ERROR_DOMAIN_MEMORY,  | 
87  | 0  |      LIBCERROR_MEMORY_ERROR_SET_FAILED,  | 
88  | 0  |      "%s: unable to clear identifier.",  | 
89  | 0  |      function );  | 
90  |  | 
  | 
91  | 0  |     goto on_error;  | 
92  | 0  |   }  | 
93  | 16.3k  |   *identifier = (libfguid_identifier_t *) internal_identifier;  | 
94  |  |  | 
95  | 16.3k  |   return( 1 );  | 
96  |  |  | 
97  | 0  | on_error:  | 
98  | 0  |   if( internal_identifier != NULL )  | 
99  | 0  |   { | 
100  | 0  |     memory_free(  | 
101  | 0  |      internal_identifier );  | 
102  | 0  |   }  | 
103  | 0  |   return( -1 );  | 
104  | 16.3k  | }  | 
105  |  |  | 
106  |  | /* Frees an identifier  | 
107  |  |  * Returns 1 if successful or -1 on error  | 
108  |  |  */  | 
109  |  | int libfguid_identifier_free(  | 
110  |  |      libfguid_identifier_t **identifier,  | 
111  |  |      libcerror_error_t **error )  | 
112  | 16.3k  | { | 
113  | 16.3k  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
114  | 16.3k  |   static char *function                               = "libfguid_identifier_free";  | 
115  |  |  | 
116  | 16.3k  |   if( identifier == NULL )  | 
117  | 0  |   { | 
118  | 0  |     libcerror_error_set(  | 
119  | 0  |      error,  | 
120  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
121  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
122  | 0  |      "%s: invalid identifier.",  | 
123  | 0  |      function );  | 
124  |  | 
  | 
125  | 0  |     return( -1 );  | 
126  | 0  |   }  | 
127  | 16.3k  |   if( *identifier != NULL )  | 
128  | 16.3k  |   { | 
129  | 16.3k  |     internal_identifier = (libfguid_internal_identifier_t *) *identifier;  | 
130  | 16.3k  |     *identifier         = NULL;  | 
131  |  |  | 
132  | 16.3k  |     memory_free(  | 
133  | 16.3k  |      internal_identifier );  | 
134  | 16.3k  |   }  | 
135  | 16.3k  |   return( 1 );  | 
136  | 16.3k  | }  | 
137  |  |  | 
138  |  | /* Copies the identifier from a byte stream  | 
139  |  |  * Returns 1 if successful or -1 on error  | 
140  |  |  */  | 
141  |  | int libfguid_identifier_copy_from_byte_stream(  | 
142  |  |      libfguid_identifier_t *identifier,  | 
143  |  |      const uint8_t *byte_stream,  | 
144  |  |      size_t byte_stream_size,  | 
145  |  |      int byte_order,  | 
146  |  |      libcerror_error_t **error )  | 
147  | 0  | { | 
148  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
149  | 0  |   static char *function                               = "libfguid_identifier_copy_from_byte_stream";  | 
150  |  | 
  | 
151  | 0  |   if( identifier == NULL )  | 
152  | 0  |   { | 
153  | 0  |     libcerror_error_set(  | 
154  | 0  |      error,  | 
155  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
156  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
157  | 0  |      "%s: invalid identifier.",  | 
158  | 0  |      function );  | 
159  |  | 
  | 
160  | 0  |     return( -1 );  | 
161  | 0  |   }  | 
162  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
163  |  | 
  | 
164  | 0  |   if( byte_stream == NULL )  | 
165  | 0  |   { | 
166  | 0  |     libcerror_error_set(  | 
167  | 0  |      error,  | 
168  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
169  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
170  | 0  |      "%s: invalid byte stream.",  | 
171  | 0  |      function );  | 
172  |  | 
  | 
173  | 0  |     return( -1 );  | 
174  | 0  |   }  | 
175  | 0  |   if( byte_stream_size < 16 )  | 
176  | 0  |   { | 
177  | 0  |     libcerror_error_set(  | 
178  | 0  |      error,  | 
179  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
180  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
181  | 0  |      "%s: byte stream too small.",  | 
182  | 0  |      function );  | 
183  |  | 
  | 
184  | 0  |     return( -1 );  | 
185  | 0  |   }  | 
186  | 0  |   if( byte_stream_size > (size_t) SSIZE_MAX )  | 
187  | 0  |   { | 
188  | 0  |     libcerror_error_set(  | 
189  | 0  |      error,  | 
190  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
191  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
192  | 0  |      "%s: byte stream size exceeds maximum.",  | 
193  | 0  |      function );  | 
194  |  | 
  | 
195  | 0  |     return( -1 );  | 
196  | 0  |   }  | 
197  | 0  |   if( ( byte_order != LIBFGUID_ENDIAN_BIG )  | 
198  | 0  |    && ( byte_order != LIBFGUID_ENDIAN_LITTLE ) )  | 
199  | 0  |   { | 
200  | 0  |     libcerror_error_set(  | 
201  | 0  |      error,  | 
202  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
203  | 0  |      LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,  | 
204  | 0  |      "%s: unsupported byte order.",  | 
205  | 0  |      function );  | 
206  |  | 
  | 
207  | 0  |     return( -1 );  | 
208  | 0  |   }  | 
209  | 0  |   if( byte_order == LIBFGUID_ENDIAN_LITTLE )  | 
210  | 0  |   { | 
211  | 0  |     byte_stream_copy_to_uint32_little_endian(  | 
212  | 0  |      byte_stream,  | 
213  | 0  |      internal_identifier->time.lower );  | 
214  |  | 
  | 
215  | 0  |     byte_stream += 4;  | 
216  |  | 
  | 
217  | 0  |     byte_stream_copy_to_uint16_little_endian(  | 
218  | 0  |      byte_stream,  | 
219  | 0  |      internal_identifier->time.middle );  | 
220  |  | 
  | 
221  | 0  |     byte_stream += 2;  | 
222  |  | 
  | 
223  | 0  |     byte_stream_copy_to_uint16_little_endian(  | 
224  | 0  |      byte_stream,  | 
225  | 0  |      internal_identifier->time.upper );  | 
226  |  | 
  | 
227  | 0  |     byte_stream += 2;  | 
228  | 0  |   }  | 
229  | 0  |   else if( byte_order == LIBFGUID_ENDIAN_BIG )  | 
230  | 0  |   { | 
231  | 0  |     byte_stream_copy_to_uint32_big_endian(  | 
232  | 0  |      byte_stream,  | 
233  | 0  |      internal_identifier->time.lower );  | 
234  |  | 
  | 
235  | 0  |     byte_stream += 4;  | 
236  |  | 
  | 
237  | 0  |     byte_stream_copy_to_uint16_big_endian(  | 
238  | 0  |      byte_stream,  | 
239  | 0  |      internal_identifier->time.middle );  | 
240  |  | 
  | 
241  | 0  |     byte_stream += 2;  | 
242  |  | 
  | 
243  | 0  |     byte_stream_copy_to_uint16_big_endian(  | 
244  | 0  |      byte_stream,  | 
245  | 0  |      internal_identifier->time.upper );  | 
246  |  | 
  | 
247  | 0  |     byte_stream += 2;  | 
248  | 0  |   }  | 
249  | 0  |   internal_identifier->clock_sequence.upper = byte_stream[ 0 ];  | 
250  | 0  |   internal_identifier->clock_sequence.lower = byte_stream[ 1 ];  | 
251  | 0  |   internal_identifier->node[ 0 ]            = byte_stream[ 2 ];  | 
252  | 0  |   internal_identifier->node[ 1 ]            = byte_stream[ 3 ];  | 
253  | 0  |   internal_identifier->node[ 2 ]            = byte_stream[ 4 ];  | 
254  | 0  |   internal_identifier->node[ 3 ]            = byte_stream[ 5 ];  | 
255  | 0  |   internal_identifier->node[ 4 ]            = byte_stream[ 6 ];  | 
256  | 0  |   internal_identifier->node[ 5 ]            = byte_stream[ 7 ];  | 
257  |  | 
  | 
258  | 0  |   return( 1 );  | 
259  | 0  | }  | 
260  |  |  | 
261  |  | /* Copies the identifier to a byte stream  | 
262  |  |  * Returns 1 if successful or -1 on error  | 
263  |  |  */  | 
264  |  | int libfguid_identifier_copy_to_byte_stream(  | 
265  |  |      libfguid_identifier_t *identifier,  | 
266  |  |      uint8_t *byte_stream,  | 
267  |  |      size_t byte_stream_size,  | 
268  |  |      int byte_order,  | 
269  |  |      libcerror_error_t **error )  | 
270  | 15.9k  | { | 
271  | 15.9k  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
272  | 15.9k  |   static char *function                               = "libfguid_identifier_copy_to_byte_stream";  | 
273  |  |  | 
274  | 15.9k  |   if( identifier == NULL )  | 
275  | 0  |   { | 
276  | 0  |     libcerror_error_set(  | 
277  | 0  |      error,  | 
278  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
279  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
280  | 0  |      "%s: invalid identifier.",  | 
281  | 0  |      function );  | 
282  |  | 
  | 
283  | 0  |     return( -1 );  | 
284  | 0  |   }  | 
285  | 15.9k  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
286  |  |  | 
287  | 15.9k  |   if( byte_stream == NULL )  | 
288  | 0  |   { | 
289  | 0  |     libcerror_error_set(  | 
290  | 0  |      error,  | 
291  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
292  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
293  | 0  |      "%s: invalid byte stream.",  | 
294  | 0  |      function );  | 
295  |  | 
  | 
296  | 0  |     return( -1 );  | 
297  | 0  |   }  | 
298  | 15.9k  |   if( byte_stream_size < 16 )  | 
299  | 0  |   { | 
300  | 0  |     libcerror_error_set(  | 
301  | 0  |      error,  | 
302  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
303  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
304  | 0  |      "%s: byte stream too small.",  | 
305  | 0  |      function );  | 
306  |  | 
  | 
307  | 0  |     return( -1 );  | 
308  | 0  |   }  | 
309  | 15.9k  |   if( byte_stream_size > (size_t) SSIZE_MAX )  | 
310  | 0  |   { | 
311  | 0  |     libcerror_error_set(  | 
312  | 0  |      error,  | 
313  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
314  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
315  | 0  |      "%s: byte stream size exceeds maximum.",  | 
316  | 0  |      function );  | 
317  |  | 
  | 
318  | 0  |     return( -1 );  | 
319  | 0  |   }  | 
320  | 15.9k  |   if( ( byte_order != LIBFGUID_ENDIAN_BIG )  | 
321  | 15.9k  |    && ( byte_order != LIBFGUID_ENDIAN_LITTLE ) )  | 
322  | 0  |   { | 
323  | 0  |     libcerror_error_set(  | 
324  | 0  |      error,  | 
325  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
326  | 0  |      LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,  | 
327  | 0  |      "%s: unsupported byte order.",  | 
328  | 0  |      function );  | 
329  |  | 
  | 
330  | 0  |     return( -1 );  | 
331  | 0  |   }  | 
332  | 15.9k  |   if( byte_order == LIBFGUID_ENDIAN_LITTLE )  | 
333  | 0  |   { | 
334  | 0  |     byte_stream_copy_from_uint32_little_endian(  | 
335  | 0  |      byte_stream,  | 
336  | 0  |      internal_identifier->time.lower );  | 
337  |  | 
  | 
338  | 0  |     byte_stream += 4;  | 
339  |  | 
  | 
340  | 0  |     byte_stream_copy_from_uint16_little_endian(  | 
341  | 0  |      byte_stream,  | 
342  | 0  |      internal_identifier->time.middle );  | 
343  |  | 
  | 
344  | 0  |     byte_stream += 2;  | 
345  |  | 
  | 
346  | 0  |     byte_stream_copy_from_uint16_little_endian(  | 
347  | 0  |      byte_stream,  | 
348  | 0  |      internal_identifier->time.upper );  | 
349  |  | 
  | 
350  | 0  |     byte_stream += 2;  | 
351  | 0  |   }  | 
352  | 15.9k  |   else if( byte_order == LIBFGUID_ENDIAN_BIG )  | 
353  | 15.9k  |   { | 
354  | 15.9k  |     byte_stream_copy_from_uint32_big_endian(  | 
355  | 15.9k  |      byte_stream,  | 
356  | 15.9k  |      internal_identifier->time.lower );  | 
357  |  |  | 
358  | 15.9k  |     byte_stream += 4;  | 
359  |  |  | 
360  | 15.9k  |     byte_stream_copy_from_uint16_big_endian(  | 
361  | 15.9k  |      byte_stream,  | 
362  | 15.9k  |      internal_identifier->time.middle );  | 
363  |  |  | 
364  | 15.9k  |     byte_stream += 2;  | 
365  |  |  | 
366  | 15.9k  |     byte_stream_copy_from_uint16_big_endian(  | 
367  | 15.9k  |      byte_stream,  | 
368  | 15.9k  |      internal_identifier->time.upper );  | 
369  |  |  | 
370  | 15.9k  |     byte_stream += 2;  | 
371  | 15.9k  |   }  | 
372  | 15.9k  |   byte_stream[ 0 ] = internal_identifier->clock_sequence.upper;  | 
373  | 15.9k  |   byte_stream[ 1 ] = internal_identifier->clock_sequence.lower;  | 
374  | 15.9k  |   byte_stream[ 2 ] = internal_identifier->node[ 0 ];  | 
375  | 15.9k  |   byte_stream[ 3 ] = internal_identifier->node[ 1 ];  | 
376  | 15.9k  |   byte_stream[ 4 ] = internal_identifier->node[ 2 ];  | 
377  | 15.9k  |   byte_stream[ 5 ] = internal_identifier->node[ 3 ];  | 
378  | 15.9k  |   byte_stream[ 6 ] = internal_identifier->node[ 4 ];  | 
379  | 15.9k  |   byte_stream[ 7 ] = internal_identifier->node[ 5 ];  | 
380  |  |  | 
381  | 15.9k  |   return( 1 );  | 
382  | 15.9k  | }  | 
383  |  |  | 
384  |  | /* Retrieves the size of an UTF-8 encoded string of the identifier  | 
385  |  |  * The string size includes the end of string character  | 
386  |  |  * Returns 1 if successful or -1 on error  | 
387  |  |  */  | 
388  |  | int libfguid_identifier_get_string_size(  | 
389  |  |      libfguid_identifier_t *identifier,  | 
390  |  |      size_t *string_size,  | 
391  |  |      uint32_t string_format_flags,  | 
392  |  |      libcerror_error_t **error )  | 
393  | 0  | { | 
394  | 0  |   static char *function    = "libfguid_identifier_get_string_size";  | 
395  | 0  |   uint32_t required_flags  = 0;  | 
396  | 0  |   uint32_t supported_flags = 0;  | 
397  |  | 
  | 
398  | 0  |   if( identifier == NULL )  | 
399  | 0  |   { | 
400  | 0  |     libcerror_error_set(  | 
401  | 0  |      error,  | 
402  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
403  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
404  | 0  |      "%s: invalid identifier.",  | 
405  | 0  |      function );  | 
406  |  | 
  | 
407  | 0  |     return( -1 );  | 
408  | 0  |   }  | 
409  | 0  |   if( string_size == NULL )  | 
410  | 0  |   { | 
411  | 0  |     libcerror_error_set(  | 
412  | 0  |      error,  | 
413  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
414  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
415  | 0  |      "%s: invalid string size.",  | 
416  | 0  |      function );  | 
417  |  | 
  | 
418  | 0  |     return( -1 );  | 
419  | 0  |   }  | 
420  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
421  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
422  |  | 
  | 
423  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
424  | 0  |   { | 
425  | 0  |     libcerror_error_set(  | 
426  | 0  |      error,  | 
427  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
428  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
429  | 0  |      "%s: missing string format flags.",  | 
430  | 0  |      function );  | 
431  |  | 
  | 
432  | 0  |     return( -1 );  | 
433  | 0  |   }  | 
434  | 0  |   supported_flags = required_flags  | 
435  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
436  |  | 
  | 
437  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
438  | 0  |   { | 
439  | 0  |     libcerror_error_set(  | 
440  | 0  |      error,  | 
441  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
442  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
443  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
444  | 0  |      function,  | 
445  | 0  |      string_format_flags );  | 
446  |  | 
  | 
447  | 0  |     return( -1 );  | 
448  | 0  |   }  | 
449  | 0  |   *string_size = 37;  | 
450  |  | 
  | 
451  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
452  | 0  |   { | 
453  | 0  |     *string_size += 2;  | 
454  | 0  |   }  | 
455  | 0  |   return( 1 );  | 
456  | 0  | }  | 
457  |  |  | 
458  |  | /* Copies the identifier from an UTF-8 encoded string  | 
459  |  |  * Returns 1 if successful or -1 on error  | 
460  |  |  */  | 
461  |  | int libfguid_identifier_copy_from_utf8_string(  | 
462  |  |      libfguid_identifier_t *identifier,  | 
463  |  |      const uint8_t *utf8_string,  | 
464  |  |      size_t utf8_string_size,  | 
465  |  |      uint32_t string_format_flags,  | 
466  |  |      libcerror_error_t **error )  | 
467  | 16.3k  | { | 
468  | 16.3k  |   static char *function    = "libfguid_identifier_copy_from_utf8_string";  | 
469  | 16.3k  |   size_t utf8_string_index = 0;  | 
470  |  |  | 
471  | 16.3k  |   if( libfguid_identifier_copy_from_utf8_string_with_index(  | 
472  | 16.3k  |        identifier,  | 
473  | 16.3k  |        utf8_string,  | 
474  | 16.3k  |        utf8_string_size,  | 
475  | 16.3k  |        &utf8_string_index,  | 
476  | 16.3k  |        string_format_flags,  | 
477  | 16.3k  |        error ) != 1 )  | 
478  | 347  |   { | 
479  | 347  |     libcerror_error_set(  | 
480  | 347  |      error,  | 
481  | 347  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
482  | 347  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
483  | 347  |      "%s: unable to copy identifier from UTF-8 string.",  | 
484  | 347  |      function );  | 
485  |  |  | 
486  | 347  |     return( -1 );  | 
487  | 347  |   }  | 
488  | 15.9k  |   return( 1 );  | 
489  | 16.3k  | }  | 
490  |  |  | 
491  |  | /* Copies the identifier from an UTF-8 encoded string  | 
492  |  |  * Returns 1 if successful or -1 on error  | 
493  |  |  */  | 
494  |  | int libfguid_identifier_copy_from_utf8_string_with_index(  | 
495  |  |      libfguid_identifier_t *identifier,  | 
496  |  |      const uint8_t *utf8_string,  | 
497  |  |      size_t utf8_string_length,  | 
498  |  |      size_t *utf8_string_index,  | 
499  |  |      uint32_t string_format_flags,  | 
500  |  |      libcerror_error_t **error )  | 
501  | 16.3k  | { | 
502  | 16.3k  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
503  | 16.3k  |   static char *function                               = "libfguid_identifier_copy_from_utf8_string_with_index";  | 
504  | 16.3k  |   size_t byte_index                                   = 0;  | 
505  | 16.3k  |   size_t node_index                                   = 0;  | 
506  | 16.3k  |   size_t string_index                                 = 0;  | 
507  | 16.3k  |   size_t string_length                                = 0;  | 
508  | 16.3k  |   uint32_t required_flags                             = 0;  | 
509  | 16.3k  |   uint32_t supported_flags                            = 0;  | 
510  |  |  | 
511  | 16.3k  |   if( identifier == NULL )  | 
512  | 0  |   { | 
513  | 0  |     libcerror_error_set(  | 
514  | 0  |      error,  | 
515  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
516  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
517  | 0  |      "%s: invalid identifier.",  | 
518  | 0  |      function );  | 
519  |  | 
  | 
520  | 0  |     return( -1 );  | 
521  | 0  |   }  | 
522  | 16.3k  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
523  |  |  | 
524  | 16.3k  |   if( utf8_string == NULL )  | 
525  | 0  |   { | 
526  | 0  |     libcerror_error_set(  | 
527  | 0  |      error,  | 
528  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
529  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
530  | 0  |      "%s: invalid UTF-8 string.",  | 
531  | 0  |      function );  | 
532  |  | 
  | 
533  | 0  |     return( -1 );  | 
534  | 0  |   }  | 
535  | 16.3k  |   if( utf8_string_length > (size_t) SSIZE_MAX )  | 
536  | 0  |   { | 
537  | 0  |     libcerror_error_set(  | 
538  | 0  |      error,  | 
539  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
540  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
541  | 0  |      "%s: invalid UTF-8 string size value exceeds maximum.",  | 
542  | 0  |      function );  | 
543  |  | 
  | 
544  | 0  |     return( -1 );  | 
545  | 0  |   }  | 
546  | 16.3k  |   if( utf8_string_index == NULL )  | 
547  | 0  |   { | 
548  | 0  |     libcerror_error_set(  | 
549  | 0  |      error,  | 
550  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
551  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
552  | 0  |      "%s: invalid UTF-8 index.",  | 
553  | 0  |      function );  | 
554  |  | 
  | 
555  | 0  |     return( -1 );  | 
556  | 0  |   }  | 
557  | 16.3k  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
558  | 16.3k  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
559  |  |  | 
560  | 16.3k  |   if( ( string_format_flags & required_flags ) == 0 )  | 
561  | 0  |   { | 
562  | 0  |     libcerror_error_set(  | 
563  | 0  |      error,  | 
564  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
565  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
566  | 0  |      "%s: missing string format flags.",  | 
567  | 0  |      function );  | 
568  |  | 
  | 
569  | 0  |     return( -1 );  | 
570  | 0  |   }  | 
571  | 16.3k  |   supported_flags = required_flags  | 
572  | 16.3k  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
573  |  |  | 
574  | 16.3k  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
575  | 0  |   { | 
576  | 0  |     libcerror_error_set(  | 
577  | 0  |      error,  | 
578  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
579  | 0  |      LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,  | 
580  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
581  | 0  |      function,  | 
582  | 0  |      string_format_flags );  | 
583  |  | 
  | 
584  | 0  |     return( -1 );  | 
585  | 0  |   }  | 
586  | 16.3k  |   string_length = 36;  | 
587  |  |  | 
588  | 16.3k  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
589  | 0  |   { | 
590  | 0  |     string_length += 2;  | 
591  | 0  |   }  | 
592  | 16.3k  |   string_index = *utf8_string_index;  | 
593  |  |  | 
594  | 16.3k  |   if( ( string_index + string_length ) > utf8_string_length )  | 
595  | 6  |   { | 
596  | 6  |     libcerror_error_set(  | 
597  | 6  |      error,  | 
598  | 6  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
599  | 6  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
600  | 6  |      "%s: UTF-8 string is too small.",  | 
601  | 6  |      function );  | 
602  |  |  | 
603  | 6  |     return( -1 );  | 
604  | 6  |   }  | 
605  | 16.3k  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
606  | 0  |   { | 
607  | 0  |     if( utf8_string[ string_index ] != (uint8_t) '{' ) | 
608  | 0  |     { | 
609  | 0  |       goto on_error;  | 
610  | 0  |     }  | 
611  | 0  |     string_index++;  | 
612  | 0  |   }  | 
613  | 16.3k  |   for( byte_index = 0;  | 
614  | 146k  |        byte_index < 8;  | 
615  | 130k  |        byte_index++ )  | 
616  | 130k  |   { | 
617  | 130k  |     internal_identifier->time.lower <<= 4;  | 
618  |  |  | 
619  | 130k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
620  | 130k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
621  | 53.3k  |     { | 
622  | 53.3k  |       internal_identifier->time.lower |= utf8_string[ string_index ] - (uint8_t) '0';  | 
623  | 53.3k  |     }  | 
624  | 76.9k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
625  | 76.9k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
626  | 76.9k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
627  | 2.59k  |     { | 
628  | 2.59k  |       internal_identifier->time.lower |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
629  | 2.59k  |     }  | 
630  | 74.4k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
631  | 74.4k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
632  | 74.4k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
633  | 74.3k  |     { | 
634  | 74.3k  |       internal_identifier->time.lower |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
635  | 74.3k  |     }  | 
636  | 52  |     else  | 
637  | 52  |     { | 
638  | 52  |       goto on_error;  | 
639  | 52  |     }  | 
640  | 130k  |     string_index++;  | 
641  | 130k  |   }  | 
642  | 16.2k  |   if( utf8_string[ string_index ] != (uint8_t) '-' )  | 
643  | 23  |   { | 
644  | 23  |     goto on_error;  | 
645  | 23  |   }  | 
646  | 16.2k  |   string_index++;  | 
647  |  |  | 
648  | 16.2k  |   for( byte_index = 0;  | 
649  | 81.1k  |        byte_index < 4;  | 
650  | 64.8k  |        byte_index++ )  | 
651  | 64.9k  |   { | 
652  | 64.9k  |     internal_identifier->time.middle <<= 4;  | 
653  |  |  | 
654  | 64.9k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
655  | 64.9k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
656  | 34.5k  |     { | 
657  | 34.5k  |       internal_identifier->time.middle |= utf8_string[ string_index ] - (uint8_t) '0';  | 
658  | 34.5k  |     }  | 
659  | 30.3k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
660  | 30.3k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
661  | 30.3k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
662  | 3.68k  |     { | 
663  | 3.68k  |       internal_identifier->time.middle |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
664  | 3.68k  |     }  | 
665  | 26.7k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
666  | 26.7k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
667  | 26.7k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
668  | 26.6k  |     { | 
669  | 26.6k  |       internal_identifier->time.middle |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
670  | 26.6k  |     }  | 
671  | 47  |     else  | 
672  | 47  |     { | 
673  | 47  |       goto on_error;  | 
674  | 47  |     }  | 
675  | 64.8k  |     string_index++;  | 
676  | 64.8k  |   }  | 
677  | 16.2k  |   if( utf8_string[ string_index ] != (uint8_t) '-' )  | 
678  | 13  |   { | 
679  | 13  |     goto on_error;  | 
680  | 13  |   }  | 
681  | 16.1k  |   string_index++;  | 
682  |  |  | 
683  | 16.1k  |   for( byte_index = 0;  | 
684  | 80.8k  |        byte_index < 4;  | 
685  | 64.7k  |        byte_index++ )  | 
686  | 64.7k  |   { | 
687  | 64.7k  |     internal_identifier->time.upper <<= 4;  | 
688  |  |  | 
689  | 64.7k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
690  | 64.7k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
691  | 43.6k  |     { | 
692  | 43.6k  |       internal_identifier->time.upper |= utf8_string[ string_index ] - (uint8_t) '0';  | 
693  | 43.6k  |     }  | 
694  | 21.0k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
695  | 21.0k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
696  | 21.0k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
697  | 1.48k  |     { | 
698  | 1.48k  |       internal_identifier->time.upper |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
699  | 1.48k  |     }  | 
700  | 19.5k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
701  | 19.5k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
702  | 19.5k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
703  | 19.5k  |     { | 
704  | 19.5k  |       internal_identifier->time.upper |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
705  | 19.5k  |     }  | 
706  | 33  |     else  | 
707  | 33  |     { | 
708  | 33  |       goto on_error;  | 
709  | 33  |     }  | 
710  | 64.7k  |     string_index++;  | 
711  | 64.7k  |   }  | 
712  | 16.1k  |   if( utf8_string[ string_index ] != (uint8_t) '-' )  | 
713  | 18  |   { | 
714  | 18  |     goto on_error;  | 
715  | 18  |   }  | 
716  | 16.1k  |   string_index++;  | 
717  |  |  | 
718  | 16.1k  |   for( byte_index = 0;  | 
719  | 48.3k  |        byte_index < 2;  | 
720  | 32.2k  |        byte_index++ )  | 
721  | 32.2k  |   { | 
722  | 32.2k  |     internal_identifier->clock_sequence.upper <<= 4;  | 
723  |  |  | 
724  | 32.2k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
725  | 32.2k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
726  | 17.7k  |     { | 
727  | 17.7k  |       internal_identifier->clock_sequence.upper |= utf8_string[ string_index ] - (uint8_t) '0';  | 
728  | 17.7k  |     }  | 
729  | 14.4k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
730  | 14.4k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
731  | 14.4k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
732  | 1.10k  |     { | 
733  | 1.10k  |       internal_identifier->clock_sequence.upper |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
734  | 1.10k  |     }  | 
735  | 13.3k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
736  | 13.3k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
737  | 13.3k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
738  | 13.3k  |     { | 
739  | 13.3k  |       internal_identifier->clock_sequence.upper |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
740  | 13.3k  |     }  | 
741  | 44  |     else  | 
742  | 44  |     { | 
743  | 44  |       goto on_error;  | 
744  | 44  |     }  | 
745  | 32.2k  |     string_index++;  | 
746  | 32.2k  |   }  | 
747  | 16.0k  |   for( byte_index = 0;  | 
748  | 48.2k  |        byte_index < 2;  | 
749  | 32.1k  |        byte_index++ )  | 
750  | 32.1k  |   { | 
751  | 32.1k  |     internal_identifier->clock_sequence.lower <<= 4;  | 
752  |  |  | 
753  | 32.1k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
754  | 32.1k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
755  | 27.6k  |     { | 
756  | 27.6k  |       internal_identifier->clock_sequence.lower |= utf8_string[ string_index ] - (uint8_t) '0';  | 
757  | 27.6k  |     }  | 
758  | 4.56k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
759  | 4.56k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
760  | 4.56k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
761  | 1.22k  |     { | 
762  | 1.22k  |       internal_identifier->clock_sequence.lower |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
763  | 1.22k  |     }  | 
764  | 3.34k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
765  | 3.34k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
766  | 3.34k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
767  | 3.29k  |     { | 
768  | 3.29k  |       internal_identifier->clock_sequence.lower |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
769  | 3.29k  |     }  | 
770  | 47  |     else  | 
771  | 47  |     { | 
772  | 47  |       goto on_error;  | 
773  | 47  |     }  | 
774  | 32.1k  |     string_index++;  | 
775  | 32.1k  |   }  | 
776  | 16.0k  |   if( utf8_string[ string_index ] != (uint8_t) '-' )  | 
777  | 11  |   { | 
778  | 11  |     goto on_error;  | 
779  | 11  |   }  | 
780  | 16.0k  |   string_index++;  | 
781  |  |  | 
782  | 16.0k  |   for( byte_index = 0;  | 
783  | 208k  |        byte_index < 12;  | 
784  | 192k  |        byte_index++ )  | 
785  | 192k  |   { | 
786  | 192k  |     node_index = byte_index / 2;  | 
787  |  |  | 
788  | 192k  |     internal_identifier->node[ node_index ] <<= 4;  | 
789  |  |  | 
790  | 192k  |     if( ( utf8_string[ string_index ] >= (uint8_t) '0' )  | 
791  | 192k  |      && ( utf8_string[ string_index ] <= (uint8_t) '9' ) )  | 
792  | 149k  |     { | 
793  | 149k  |       internal_identifier->node[ node_index ] |= utf8_string[ string_index ] - (uint8_t) '0';  | 
794  | 149k  |     }  | 
795  | 42.7k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
796  | 42.7k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'a' )  | 
797  | 42.7k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'f' ) )  | 
798  | 20.1k  |     { | 
799  | 20.1k  |       internal_identifier->node[ node_index ] |= utf8_string[ string_index ] - (uint8_t) 'a' + 10;  | 
800  | 20.1k  |     }  | 
801  | 22.5k  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
802  | 22.5k  |           && ( utf8_string[ string_index ] >= (uint8_t) 'A' )  | 
803  | 22.5k  |           && ( utf8_string[ string_index ] <= (uint8_t) 'F' ) )  | 
804  | 22.5k  |     { | 
805  | 22.5k  |       internal_identifier->node[ node_index ] |= utf8_string[ string_index ] - (uint8_t) 'A' + 10;  | 
806  | 22.5k  |     }  | 
807  | 53  |     else  | 
808  | 53  |     { | 
809  | 53  |       goto on_error;  | 
810  | 53  |     }  | 
811  | 192k  |     string_index++;  | 
812  | 192k  |   }  | 
813  | 15.9k  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
814  | 0  |   { | 
815  | 0  |     if( utf8_string[ string_index ] != (uint8_t) '}' )  | 
816  | 0  |     { | 
817  | 0  |       goto on_error;  | 
818  | 0  |     }  | 
819  | 0  |     string_index++;  | 
820  | 0  |   }  | 
821  | 15.9k  |   *utf8_string_index = string_index;  | 
822  |  |  | 
823  | 15.9k  |   return( 1 );  | 
824  |  |  | 
825  | 341  | on_error:  | 
826  | 341  |   libcerror_error_set(  | 
827  | 341  |    error,  | 
828  | 341  |    LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
829  | 341  |    LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
830  | 341  |    "%s: unsupported character value: 0x%02" PRIx8 " at index: %d.",  | 
831  | 341  |    function,  | 
832  | 341  |    utf8_string[ string_index ],  | 
833  | 341  |    string_index );  | 
834  |  |  | 
835  | 341  |   return( -1 );  | 
836  | 15.9k  | }  | 
837  |  |  | 
838  |  | /* Copies the identifier to an UTF-8 encoded string  | 
839  |  |  * The string size should include the end of string character  | 
840  |  |  * Returns 1 if successful or -1 on error  | 
841  |  |  */  | 
842  |  | int libfguid_identifier_copy_to_utf8_string(  | 
843  |  |      libfguid_identifier_t *identifier,  | 
844  |  |      uint8_t *utf8_string,  | 
845  |  |      size_t utf8_string_size,  | 
846  |  |      uint32_t string_format_flags,  | 
847  |  |      libcerror_error_t **error )  | 
848  | 0  | { | 
849  | 0  |   static char *function    = "libfguid_identifier_copy_to_utf8_string";  | 
850  | 0  |   size_t utf8_string_index = 0;  | 
851  |  | 
  | 
852  | 0  |   if( libfguid_identifier_copy_to_utf8_string_with_index(  | 
853  | 0  |        identifier,  | 
854  | 0  |        utf8_string,  | 
855  | 0  |        utf8_string_size,  | 
856  | 0  |        &utf8_string_index,  | 
857  | 0  |        string_format_flags,  | 
858  | 0  |        error ) != 1 )  | 
859  | 0  |   { | 
860  | 0  |     libcerror_error_set(  | 
861  | 0  |      error,  | 
862  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
863  | 0  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
864  | 0  |      "%s: unable to copy identifier to UTF-8 string.",  | 
865  | 0  |      function );  | 
866  |  | 
  | 
867  | 0  |     return( -1 );  | 
868  | 0  |   }  | 
869  | 0  |   return( 1 );  | 
870  | 0  | }  | 
871  |  |  | 
872  |  | /* Copies the identifier to an UTF-8 encoded string  | 
873  |  |  * The string size should include the end of string character  | 
874  |  |  * Returns 1 if successful or -1 on error  | 
875  |  |  */  | 
876  |  | int libfguid_identifier_copy_to_utf8_string_with_index(  | 
877  |  |      libfguid_identifier_t *identifier,  | 
878  |  |      uint8_t *utf8_string,  | 
879  |  |      size_t utf8_string_size,  | 
880  |  |      size_t *utf8_string_index,  | 
881  |  |      uint32_t string_format_flags,  | 
882  |  |      libcerror_error_t **error )  | 
883  | 0  | { | 
884  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
885  | 0  |   static char *function                               = "libfguid_identifier_copy_to_utf8_string_with_index";  | 
886  | 0  |   size_t string_index                                 = 0;  | 
887  | 0  |   size_t string_size                                  = 0;  | 
888  | 0  |   uint32_t required_flags                             = 0;  | 
889  | 0  |   uint32_t supported_flags                            = 0;  | 
890  | 0  |   uint8_t byte_value                                  = 0;  | 
891  | 0  |   uint8_t node_index                                  = 0;  | 
892  | 0  |   int8_t byte_shift                                   = 0;  | 
893  |  | 
  | 
894  | 0  |   if( identifier == NULL )  | 
895  | 0  |   { | 
896  | 0  |     libcerror_error_set(  | 
897  | 0  |      error,  | 
898  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
899  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
900  | 0  |      "%s: invalid identifier.",  | 
901  | 0  |      function );  | 
902  |  | 
  | 
903  | 0  |     return( -1 );  | 
904  | 0  |   }  | 
905  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
906  |  | 
  | 
907  | 0  |   if( utf8_string == NULL )  | 
908  | 0  |   { | 
909  | 0  |     libcerror_error_set(  | 
910  | 0  |      error,  | 
911  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
912  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
913  | 0  |      "%s: invalid UTF-8.",  | 
914  | 0  |      function );  | 
915  |  | 
  | 
916  | 0  |     return( -1 );  | 
917  | 0  |   }  | 
918  | 0  |   if( utf8_string_size > (size_t) SSIZE_MAX )  | 
919  | 0  |   { | 
920  | 0  |     libcerror_error_set(  | 
921  | 0  |      error,  | 
922  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
923  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
924  | 0  |      "%s: UTF-8 string size exceeds maximum.",  | 
925  | 0  |      function );  | 
926  |  | 
  | 
927  | 0  |     return( -1 );  | 
928  | 0  |   }  | 
929  | 0  |   if( utf8_string_index == NULL )  | 
930  | 0  |   { | 
931  | 0  |     libcerror_error_set(  | 
932  | 0  |      error,  | 
933  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
934  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
935  | 0  |      "%s: invalid UTF-8 index.",  | 
936  | 0  |      function );  | 
937  |  | 
  | 
938  | 0  |     return( -1 );  | 
939  | 0  |   }  | 
940  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
941  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
942  |  | 
  | 
943  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
944  | 0  |   { | 
945  | 0  |     libcerror_error_set(  | 
946  | 0  |      error,  | 
947  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
948  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
949  | 0  |      "%s: missing string format flags.",  | 
950  | 0  |      function );  | 
951  |  | 
  | 
952  | 0  |     return( -1 );  | 
953  | 0  |   }  | 
954  | 0  |   supported_flags = required_flags  | 
955  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
956  |  | 
  | 
957  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
958  | 0  |   { | 
959  | 0  |     libcerror_error_set(  | 
960  | 0  |      error,  | 
961  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
962  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
963  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
964  | 0  |      function,  | 
965  | 0  |      string_format_flags );  | 
966  |  | 
  | 
967  | 0  |     return( -1 );  | 
968  | 0  |   }  | 
969  | 0  |   string_size = 37;  | 
970  |  | 
  | 
971  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
972  | 0  |   { | 
973  | 0  |     string_size += 2;  | 
974  | 0  |   }  | 
975  | 0  |   string_index = *utf8_string_index;  | 
976  |  | 
  | 
977  | 0  |   if( ( string_index + string_size ) > utf8_string_size )  | 
978  | 0  |   { | 
979  | 0  |     libcerror_error_set(  | 
980  | 0  |      error,  | 
981  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
982  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
983  | 0  |      "%s: UTF-8 string is too small.",  | 
984  | 0  |      function );  | 
985  |  | 
  | 
986  | 0  |     return( -1 );  | 
987  | 0  |   }  | 
988  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
989  | 0  |   { | 
990  | 0  |     utf8_string[ string_index++ ] = (uint8_t) '{'; | 
991  | 0  |   }  | 
992  | 0  |   byte_shift = 28;  | 
993  |  | 
  | 
994  | 0  |   do  | 
995  | 0  |   { | 
996  | 0  |     byte_value = ( internal_identifier->time.lower >> byte_shift ) & 0x0f;  | 
997  |  | 
  | 
998  | 0  |     if( byte_value <= 9 )  | 
999  | 0  |     { | 
1000  | 0  |       utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1001  | 0  |     }  | 
1002  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1003  | 0  |     { | 
1004  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1005  | 0  |     }  | 
1006  | 0  |     else  | 
1007  | 0  |     { | 
1008  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1009  | 0  |     }  | 
1010  | 0  |     byte_shift -= 4;  | 
1011  | 0  |   }  | 
1012  | 0  |   while( byte_shift >= 0 );  | 
1013  |  | 
  | 
1014  | 0  |   utf8_string[ string_index++ ] = (uint8_t) '-';  | 
1015  |  | 
  | 
1016  | 0  |   byte_shift = 12;  | 
1017  |  | 
  | 
1018  | 0  |   do  | 
1019  | 0  |   { | 
1020  | 0  |     byte_value = ( internal_identifier->time.middle >> byte_shift ) & 0x0f;  | 
1021  |  | 
  | 
1022  | 0  |     if( byte_value <= 9 )  | 
1023  | 0  |     { | 
1024  | 0  |       utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1025  | 0  |     }  | 
1026  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1027  | 0  |     { | 
1028  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1029  | 0  |     }  | 
1030  | 0  |     else  | 
1031  | 0  |     { | 
1032  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1033  | 0  |     }  | 
1034  | 0  |     byte_shift -= 4;  | 
1035  | 0  |   }  | 
1036  | 0  |   while( byte_shift >= 0 );  | 
1037  |  | 
  | 
1038  | 0  |   utf8_string[ string_index++ ] = (uint8_t) '-';  | 
1039  |  | 
  | 
1040  | 0  |   byte_shift = 12;  | 
1041  |  | 
  | 
1042  | 0  |   do  | 
1043  | 0  |   { | 
1044  | 0  |     byte_value = ( internal_identifier->time.upper >> byte_shift ) & 0x0f;  | 
1045  |  | 
  | 
1046  | 0  |     if( byte_value <= 9 )  | 
1047  | 0  |     { | 
1048  | 0  |       utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1049  | 0  |     }  | 
1050  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1051  | 0  |     { | 
1052  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1053  | 0  |     }  | 
1054  | 0  |     else  | 
1055  | 0  |     { | 
1056  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1057  | 0  |     }  | 
1058  | 0  |     byte_shift -= 4;  | 
1059  | 0  |   }  | 
1060  | 0  |   while( byte_shift >= 0 );  | 
1061  |  | 
  | 
1062  | 0  |   utf8_string[ string_index++ ] = (uint8_t) '-';  | 
1063  |  | 
  | 
1064  | 0  |   byte_shift = 4;  | 
1065  |  | 
  | 
1066  | 0  |   do  | 
1067  | 0  |   { | 
1068  | 0  |     byte_value = ( internal_identifier->clock_sequence.upper >> byte_shift ) & 0x0f;  | 
1069  |  | 
  | 
1070  | 0  |     if( byte_value <= 9 )  | 
1071  | 0  |     { | 
1072  | 0  |       utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1073  | 0  |     }  | 
1074  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1075  | 0  |     { | 
1076  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1077  | 0  |     }  | 
1078  | 0  |     else  | 
1079  | 0  |     { | 
1080  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1081  | 0  |     }  | 
1082  | 0  |     byte_shift -= 4;  | 
1083  | 0  |   }  | 
1084  | 0  |   while( byte_shift >= 0 );  | 
1085  |  | 
  | 
1086  | 0  |   byte_shift = 4;  | 
1087  |  | 
  | 
1088  | 0  |   do  | 
1089  | 0  |   { | 
1090  | 0  |     byte_value = ( internal_identifier->clock_sequence.lower >> byte_shift ) & 0x0f;  | 
1091  |  | 
  | 
1092  | 0  |     if( byte_value <= 9 )  | 
1093  | 0  |     { | 
1094  | 0  |       utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1095  | 0  |     }  | 
1096  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1097  | 0  |     { | 
1098  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1099  | 0  |     }  | 
1100  | 0  |     else  | 
1101  | 0  |     { | 
1102  | 0  |       utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1103  | 0  |     }  | 
1104  | 0  |     byte_shift -= 4;  | 
1105  | 0  |   }  | 
1106  | 0  |   while( byte_shift >= 0 );  | 
1107  |  | 
  | 
1108  | 0  |   utf8_string[ string_index++ ] = (uint8_t) '-';  | 
1109  |  | 
  | 
1110  | 0  |   for( node_index = 0;  | 
1111  | 0  |        node_index < 6;  | 
1112  | 0  |        node_index++ )  | 
1113  | 0  |   { | 
1114  | 0  |     byte_shift = 4;  | 
1115  |  | 
  | 
1116  | 0  |     do  | 
1117  | 0  |     { | 
1118  | 0  |       byte_value = ( internal_identifier->node[ node_index ] >> byte_shift ) & 0x0f;  | 
1119  |  | 
  | 
1120  | 0  |       if( byte_value <= 9 )  | 
1121  | 0  |       { | 
1122  | 0  |         utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;  | 
1123  | 0  |       }  | 
1124  | 0  |       else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1125  | 0  |       { | 
1126  | 0  |         utf8_string[ string_index++ ] = (uint8_t) 'A' + byte_value - 10;  | 
1127  | 0  |       }  | 
1128  | 0  |       else  | 
1129  | 0  |       { | 
1130  | 0  |         utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;  | 
1131  | 0  |       }  | 
1132  | 0  |       byte_shift -= 4;  | 
1133  | 0  |     }  | 
1134  | 0  |     while( byte_shift >= 0 );  | 
1135  | 0  |   }  | 
1136  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1137  | 0  |   { | 
1138  | 0  |     utf8_string[ string_index++ ] = (uint8_t) '}';  | 
1139  | 0  |   }  | 
1140  | 0  |   utf8_string[ string_index++ ] = 0;  | 
1141  |  | 
  | 
1142  | 0  |   *utf8_string_index = string_index;  | 
1143  |  | 
  | 
1144  | 0  |   return( 1 );  | 
1145  | 0  | }  | 
1146  |  |  | 
1147  |  | /* Copies the identifier from an UTF-16 encoded string  | 
1148  |  |  * Returns 1 if successful or -1 on error  | 
1149  |  |  */  | 
1150  |  | int libfguid_identifier_copy_from_utf16_string(  | 
1151  |  |      libfguid_identifier_t *identifier,  | 
1152  |  |      const uint16_t *utf16_string,  | 
1153  |  |      size_t utf16_string_size,  | 
1154  |  |      uint32_t string_format_flags,  | 
1155  |  |      libcerror_error_t **error )  | 
1156  | 0  | { | 
1157  | 0  |   static char *function     = "libfguid_identifier_copy_from_utf16_string";  | 
1158  | 0  |   size_t utf16_string_index = 0;  | 
1159  |  | 
  | 
1160  | 0  |   if( libfguid_identifier_copy_from_utf16_string_with_index(  | 
1161  | 0  |        identifier,  | 
1162  | 0  |        utf16_string,  | 
1163  | 0  |        utf16_string_size,  | 
1164  | 0  |        &utf16_string_index,  | 
1165  | 0  |        string_format_flags,  | 
1166  | 0  |        error ) != 1 )  | 
1167  | 0  |   { | 
1168  | 0  |     libcerror_error_set(  | 
1169  | 0  |      error,  | 
1170  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1171  | 0  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
1172  | 0  |      "%s: unable to copy identifier from UTF-16 string.",  | 
1173  | 0  |      function );  | 
1174  |  | 
  | 
1175  | 0  |     return( -1 );  | 
1176  | 0  |   }  | 
1177  | 0  |   return( 1 );  | 
1178  | 0  | }  | 
1179  |  |  | 
1180  |  | /* Copies the identifier from an UTF-16 encoded string  | 
1181  |  |  * Returns 1 if successful or -1 on error  | 
1182  |  |  */  | 
1183  |  | int libfguid_identifier_copy_from_utf16_string_with_index(  | 
1184  |  |      libfguid_identifier_t *identifier,  | 
1185  |  |      const uint16_t *utf16_string,  | 
1186  |  |      size_t utf16_string_length,  | 
1187  |  |      size_t *utf16_string_index,  | 
1188  |  |      uint32_t string_format_flags,  | 
1189  |  |      libcerror_error_t **error )  | 
1190  | 0  | { | 
1191  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
1192  | 0  |   static char *function                               = "libfguid_identifier_copy_from_utf16_string_with_index";  | 
1193  | 0  |   size_t byte_index                                   = 0;  | 
1194  | 0  |   size_t node_index                                   = 0;  | 
1195  | 0  |   size_t string_index                                 = 0;  | 
1196  | 0  |   size_t string_length                                = 0;  | 
1197  | 0  |   uint32_t required_flags                             = 0;  | 
1198  | 0  |   uint32_t supported_flags                            = 0;  | 
1199  |  | 
  | 
1200  | 0  |   if( identifier == NULL )  | 
1201  | 0  |   { | 
1202  | 0  |     libcerror_error_set(  | 
1203  | 0  |      error,  | 
1204  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1205  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1206  | 0  |      "%s: invalid identifier.",  | 
1207  | 0  |      function );  | 
1208  |  | 
  | 
1209  | 0  |     return( -1 );  | 
1210  | 0  |   }  | 
1211  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
1212  |  | 
  | 
1213  | 0  |   if( utf16_string == NULL )  | 
1214  | 0  |   { | 
1215  | 0  |     libcerror_error_set(  | 
1216  | 0  |      error,  | 
1217  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1218  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1219  | 0  |      "%s: invalid UTF-16 string.",  | 
1220  | 0  |      function );  | 
1221  |  | 
  | 
1222  | 0  |     return( -1 );  | 
1223  | 0  |   }  | 
1224  | 0  |   if( utf16_string_length > (size_t) SSIZE_MAX )  | 
1225  | 0  |   { | 
1226  | 0  |     libcerror_error_set(  | 
1227  | 0  |      error,  | 
1228  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1229  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
1230  | 0  |      "%s: invalid UTF-16 string size value exceeds maximum.",  | 
1231  | 0  |      function );  | 
1232  |  | 
  | 
1233  | 0  |     return( -1 );  | 
1234  | 0  |   }  | 
1235  | 0  |   if( utf16_string_index == NULL )  | 
1236  | 0  |   { | 
1237  | 0  |     libcerror_error_set(  | 
1238  | 0  |      error,  | 
1239  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1240  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1241  | 0  |      "%s: invalid UTF-16 index.",  | 
1242  | 0  |      function );  | 
1243  |  | 
  | 
1244  | 0  |     return( -1 );  | 
1245  | 0  |   }  | 
1246  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
1247  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
1248  |  | 
  | 
1249  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
1250  | 0  |   { | 
1251  | 0  |     libcerror_error_set(  | 
1252  | 0  |      error,  | 
1253  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1254  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
1255  | 0  |      "%s: missing string format flags.",  | 
1256  | 0  |      function );  | 
1257  |  | 
  | 
1258  | 0  |     return( -1 );  | 
1259  | 0  |   }  | 
1260  | 0  |   supported_flags = required_flags  | 
1261  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
1262  |  | 
  | 
1263  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
1264  | 0  |   { | 
1265  | 0  |     libcerror_error_set(  | 
1266  | 0  |      error,  | 
1267  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1268  | 0  |      LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,  | 
1269  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
1270  | 0  |      function,  | 
1271  | 0  |      string_format_flags );  | 
1272  |  | 
  | 
1273  | 0  |     return( -1 );  | 
1274  | 0  |   }  | 
1275  | 0  |   string_length = 36;  | 
1276  |  | 
  | 
1277  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1278  | 0  |   { | 
1279  | 0  |     string_length += 2;  | 
1280  | 0  |   }  | 
1281  | 0  |   string_index = *utf16_string_index;  | 
1282  |  | 
  | 
1283  | 0  |   if( ( string_index + string_length ) > utf16_string_length )  | 
1284  | 0  |   { | 
1285  | 0  |     libcerror_error_set(  | 
1286  | 0  |      error,  | 
1287  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1288  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
1289  | 0  |      "%s: UTF-16 string is too small.",  | 
1290  | 0  |      function );  | 
1291  |  | 
  | 
1292  | 0  |     return( -1 );  | 
1293  | 0  |   }  | 
1294  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1295  | 0  |   { | 
1296  | 0  |     if( utf16_string[ string_index ] != (uint16_t) '{' ) | 
1297  | 0  |     { | 
1298  | 0  |       goto on_error;  | 
1299  | 0  |     }  | 
1300  | 0  |     string_index++;  | 
1301  | 0  |   }  | 
1302  | 0  |   for( byte_index = 0;  | 
1303  | 0  |        byte_index < 8;  | 
1304  | 0  |        byte_index++ )  | 
1305  | 0  |   { | 
1306  | 0  |     internal_identifier->time.lower <<= 4;  | 
1307  |  | 
  | 
1308  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1309  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1310  | 0  |     { | 
1311  | 0  |       internal_identifier->time.lower |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1312  | 0  |     }  | 
1313  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1314  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1315  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1316  | 0  |     { | 
1317  | 0  |       internal_identifier->time.lower |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1318  | 0  |     }  | 
1319  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1320  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1321  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1322  | 0  |     { | 
1323  | 0  |       internal_identifier->time.lower |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1324  | 0  |     }  | 
1325  | 0  |     else  | 
1326  | 0  |     { | 
1327  | 0  |       goto on_error;  | 
1328  | 0  |     }  | 
1329  | 0  |     string_index++;  | 
1330  | 0  |   }  | 
1331  | 0  |   if( utf16_string[ string_index ] != (uint16_t) '-' )  | 
1332  | 0  |   { | 
1333  | 0  |     goto on_error;  | 
1334  | 0  |   }  | 
1335  | 0  |   string_index++;  | 
1336  |  | 
  | 
1337  | 0  |   for( byte_index = 0;  | 
1338  | 0  |        byte_index < 4;  | 
1339  | 0  |        byte_index++ )  | 
1340  | 0  |   { | 
1341  | 0  |     internal_identifier->time.middle <<= 4;  | 
1342  |  | 
  | 
1343  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1344  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1345  | 0  |     { | 
1346  | 0  |       internal_identifier->time.middle |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1347  | 0  |     }  | 
1348  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1349  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1350  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1351  | 0  |     { | 
1352  | 0  |       internal_identifier->time.middle |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1353  | 0  |     }  | 
1354  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1355  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1356  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1357  | 0  |     { | 
1358  | 0  |       internal_identifier->time.middle |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1359  | 0  |     }  | 
1360  | 0  |     else  | 
1361  | 0  |     { | 
1362  | 0  |       goto on_error;  | 
1363  | 0  |     }  | 
1364  | 0  |     string_index++;  | 
1365  | 0  |   }  | 
1366  | 0  |   if( utf16_string[ string_index ] != (uint16_t) '-' )  | 
1367  | 0  |   { | 
1368  | 0  |     goto on_error;  | 
1369  | 0  |   }  | 
1370  | 0  |   string_index++;  | 
1371  |  | 
  | 
1372  | 0  |   for( byte_index = 0;  | 
1373  | 0  |        byte_index < 4;  | 
1374  | 0  |        byte_index++ )  | 
1375  | 0  |   { | 
1376  | 0  |     internal_identifier->time.upper <<= 4;  | 
1377  |  | 
  | 
1378  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1379  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1380  | 0  |     { | 
1381  | 0  |       internal_identifier->time.upper |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1382  | 0  |     }  | 
1383  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1384  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1385  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1386  | 0  |     { | 
1387  | 0  |       internal_identifier->time.upper |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1388  | 0  |     }  | 
1389  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1390  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1391  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1392  | 0  |     { | 
1393  | 0  |       internal_identifier->time.upper |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1394  | 0  |     }  | 
1395  | 0  |     else  | 
1396  | 0  |     { | 
1397  | 0  |       goto on_error;  | 
1398  | 0  |     }  | 
1399  | 0  |     string_index++;  | 
1400  | 0  |   }  | 
1401  | 0  |   if( utf16_string[ string_index ] != (uint16_t) '-' )  | 
1402  | 0  |   { | 
1403  | 0  |     goto on_error;  | 
1404  | 0  |   }  | 
1405  | 0  |   string_index++;  | 
1406  |  | 
  | 
1407  | 0  |   for( byte_index = 0;  | 
1408  | 0  |        byte_index < 2;  | 
1409  | 0  |        byte_index++ )  | 
1410  | 0  |   { | 
1411  | 0  |     internal_identifier->clock_sequence.upper <<= 4;  | 
1412  |  | 
  | 
1413  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1414  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1415  | 0  |     { | 
1416  | 0  |       internal_identifier->clock_sequence.upper |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1417  | 0  |     }  | 
1418  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1419  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1420  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1421  | 0  |     { | 
1422  | 0  |       internal_identifier->clock_sequence.upper |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1423  | 0  |     }  | 
1424  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1425  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1426  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1427  | 0  |     { | 
1428  | 0  |       internal_identifier->clock_sequence.upper |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1429  | 0  |     }  | 
1430  | 0  |     else  | 
1431  | 0  |     { | 
1432  | 0  |       goto on_error;  | 
1433  | 0  |     }  | 
1434  | 0  |     string_index++;  | 
1435  | 0  |   }  | 
1436  | 0  |   for( byte_index = 0;  | 
1437  | 0  |        byte_index < 2;  | 
1438  | 0  |        byte_index++ )  | 
1439  | 0  |   { | 
1440  | 0  |     internal_identifier->clock_sequence.lower <<= 4;  | 
1441  |  | 
  | 
1442  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1443  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1444  | 0  |     { | 
1445  | 0  |       internal_identifier->clock_sequence.lower |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1446  | 0  |     }  | 
1447  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1448  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1449  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1450  | 0  |     { | 
1451  | 0  |       internal_identifier->clock_sequence.lower |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1452  | 0  |     }  | 
1453  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1454  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1455  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1456  | 0  |     { | 
1457  | 0  |       internal_identifier->clock_sequence.lower |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1458  | 0  |     }  | 
1459  | 0  |     else  | 
1460  | 0  |     { | 
1461  | 0  |       goto on_error;  | 
1462  | 0  |     }  | 
1463  | 0  |     string_index++;  | 
1464  | 0  |   }  | 
1465  | 0  |   if( utf16_string[ string_index ] != (uint16_t) '-' )  | 
1466  | 0  |   { | 
1467  | 0  |     goto on_error;  | 
1468  | 0  |   }  | 
1469  | 0  |   string_index++;  | 
1470  |  | 
  | 
1471  | 0  |   for( byte_index = 0;  | 
1472  | 0  |        byte_index < 12;  | 
1473  | 0  |        byte_index++ )  | 
1474  | 0  |   { | 
1475  | 0  |     node_index = byte_index / 2;  | 
1476  |  | 
  | 
1477  | 0  |     internal_identifier->node[ node_index ] <<= 4;  | 
1478  |  | 
  | 
1479  | 0  |     if( ( utf16_string[ string_index ] >= (uint16_t) '0' )  | 
1480  | 0  |      && ( utf16_string[ string_index ] <= (uint16_t) '9' ) )  | 
1481  | 0  |     { | 
1482  | 0  |       internal_identifier->node[ node_index ] |= utf16_string[ string_index ] - (uint16_t) '0';  | 
1483  | 0  |     }  | 
1484  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
1485  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'a' )  | 
1486  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'f' ) )  | 
1487  | 0  |     { | 
1488  | 0  |       internal_identifier->node[ node_index ] |= utf16_string[ string_index ] - (uint16_t) 'a' + 10;  | 
1489  | 0  |     }  | 
1490  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1491  | 0  |           && ( utf16_string[ string_index ] >= (uint16_t) 'A' )  | 
1492  | 0  |           && ( utf16_string[ string_index ] <= (uint16_t) 'F' ) )  | 
1493  | 0  |     { | 
1494  | 0  |       internal_identifier->node[ node_index ] |= utf16_string[ string_index ] - (uint16_t) 'A' + 10;  | 
1495  | 0  |     }  | 
1496  | 0  |     else  | 
1497  | 0  |     { | 
1498  | 0  |       goto on_error;  | 
1499  | 0  |     }  | 
1500  | 0  |     string_index++;  | 
1501  | 0  |   }  | 
1502  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1503  | 0  |   { | 
1504  | 0  |     if( utf16_string[ string_index ] != (uint16_t) '}' )  | 
1505  | 0  |     { | 
1506  | 0  |       goto on_error;  | 
1507  | 0  |     }  | 
1508  | 0  |     string_index++;  | 
1509  | 0  |   }  | 
1510  | 0  |   *utf16_string_index = string_index;  | 
1511  |  | 
  | 
1512  | 0  |   return( 1 );  | 
1513  |  |  | 
1514  | 0  | on_error:  | 
1515  | 0  |   libcerror_error_set(  | 
1516  | 0  |    error,  | 
1517  | 0  |    LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1518  | 0  |    LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
1519  | 0  |    "%s: unsupported character value: 0x%04" PRIx16 " at index: %d.",  | 
1520  | 0  |    function,  | 
1521  | 0  |    utf16_string[ string_index ],  | 
1522  | 0  |    string_index );  | 
1523  |  | 
  | 
1524  | 0  |   return( -1 );  | 
1525  | 0  | }  | 
1526  |  |  | 
1527  |  | /* Copies the identifier to an UTF-16 encoded string  | 
1528  |  |  * The string size should include the end of string character  | 
1529  |  |  * Returns 1 if successful or -1 on error  | 
1530  |  |  */  | 
1531  |  | int libfguid_identifier_copy_to_utf16_string(  | 
1532  |  |      libfguid_identifier_t *identifier,  | 
1533  |  |      uint16_t *utf16_string,  | 
1534  |  |      size_t utf16_string_size,  | 
1535  |  |      uint32_t string_format_flags,  | 
1536  |  |      libcerror_error_t **error )  | 
1537  | 0  | { | 
1538  | 0  |   static char *function     = "libfguid_identifier_copy_to_utf16_string";  | 
1539  | 0  |   size_t utf16_string_index = 0;  | 
1540  |  | 
  | 
1541  | 0  |   if( libfguid_identifier_copy_to_utf16_string_with_index(  | 
1542  | 0  |        identifier,  | 
1543  | 0  |        utf16_string,  | 
1544  | 0  |        utf16_string_size,  | 
1545  | 0  |        &utf16_string_index,  | 
1546  | 0  |        string_format_flags,  | 
1547  | 0  |        error ) != 1 )  | 
1548  | 0  |   { | 
1549  | 0  |     libcerror_error_set(  | 
1550  | 0  |      error,  | 
1551  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1552  | 0  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
1553  | 0  |      "%s: unable to copy identifier to UTF-16 string.",  | 
1554  | 0  |      function );  | 
1555  |  | 
  | 
1556  | 0  |     return( -1 );  | 
1557  | 0  |   }  | 
1558  | 0  |   return( 1 );  | 
1559  | 0  | }  | 
1560  |  |  | 
1561  |  | /* Copies the identifier to an UTF-16 encoded string  | 
1562  |  |  * The string size should include the end of string character  | 
1563  |  |  * Returns 1 if successful or -1 on error  | 
1564  |  |  */  | 
1565  |  | int libfguid_identifier_copy_to_utf16_string_with_index(  | 
1566  |  |      libfguid_identifier_t *identifier,  | 
1567  |  |      uint16_t *utf16_string,  | 
1568  |  |      size_t utf16_string_size,  | 
1569  |  |      size_t *utf16_string_index,  | 
1570  |  |      uint32_t string_format_flags,  | 
1571  |  |      libcerror_error_t **error )  | 
1572  | 0  | { | 
1573  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
1574  | 0  |   static char *function                               = "libfguid_identifier_copy_to_utf16_string_with_index";  | 
1575  | 0  |   size_t string_index                                 = 0;  | 
1576  | 0  |   size_t string_size                                  = 0;  | 
1577  | 0  |   uint32_t required_flags                             = 0;  | 
1578  | 0  |   uint32_t supported_flags                            = 0;  | 
1579  | 0  |   uint8_t byte_value                                  = 0;  | 
1580  | 0  |   uint8_t node_index                                  = 0;  | 
1581  | 0  |   int8_t byte_shift                                   = 0;  | 
1582  |  | 
  | 
1583  | 0  |   if( identifier == NULL )  | 
1584  | 0  |   { | 
1585  | 0  |     libcerror_error_set(  | 
1586  | 0  |      error,  | 
1587  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1588  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1589  | 0  |      "%s: invalid identifier.",  | 
1590  | 0  |      function );  | 
1591  |  | 
  | 
1592  | 0  |     return( -1 );  | 
1593  | 0  |   }  | 
1594  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
1595  |  | 
  | 
1596  | 0  |   if( utf16_string == NULL )  | 
1597  | 0  |   { | 
1598  | 0  |     libcerror_error_set(  | 
1599  | 0  |      error,  | 
1600  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1601  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1602  | 0  |      "%s: invalid UTF-16.",  | 
1603  | 0  |      function );  | 
1604  |  | 
  | 
1605  | 0  |     return( -1 );  | 
1606  | 0  |   }  | 
1607  | 0  |   if( utf16_string_size > (size_t) SSIZE_MAX )  | 
1608  | 0  |   { | 
1609  | 0  |     libcerror_error_set(  | 
1610  | 0  |      error,  | 
1611  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1612  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
1613  | 0  |      "%s: UTF-16 string size exceeds maximum.",  | 
1614  | 0  |      function );  | 
1615  |  | 
  | 
1616  | 0  |     return( -1 );  | 
1617  | 0  |   }  | 
1618  | 0  |   if( utf16_string_index == NULL )  | 
1619  | 0  |   { | 
1620  | 0  |     libcerror_error_set(  | 
1621  | 0  |      error,  | 
1622  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1623  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1624  | 0  |      "%s: invalid UTF-16 index.",  | 
1625  | 0  |      function );  | 
1626  |  | 
  | 
1627  | 0  |     return( -1 );  | 
1628  | 0  |   }  | 
1629  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
1630  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
1631  |  | 
  | 
1632  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
1633  | 0  |   { | 
1634  | 0  |     libcerror_error_set(  | 
1635  | 0  |      error,  | 
1636  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1637  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
1638  | 0  |      "%s: missing string format flags.",  | 
1639  | 0  |      function );  | 
1640  |  | 
  | 
1641  | 0  |     return( -1 );  | 
1642  | 0  |   }  | 
1643  | 0  |   supported_flags = required_flags  | 
1644  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
1645  |  | 
  | 
1646  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
1647  | 0  |   { | 
1648  | 0  |     libcerror_error_set(  | 
1649  | 0  |      error,  | 
1650  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1651  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
1652  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
1653  | 0  |      function,  | 
1654  | 0  |      string_format_flags );  | 
1655  |  | 
  | 
1656  | 0  |     return( -1 );  | 
1657  | 0  |   }  | 
1658  | 0  |   string_size = 37;  | 
1659  |  | 
  | 
1660  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1661  | 0  |   { | 
1662  | 0  |     string_size += 2;  | 
1663  | 0  |   }  | 
1664  | 0  |   string_index = *utf16_string_index;  | 
1665  |  | 
  | 
1666  | 0  |   if( ( string_index + string_size ) > utf16_string_size )  | 
1667  | 0  |   { | 
1668  | 0  |     libcerror_error_set(  | 
1669  | 0  |      error,  | 
1670  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1671  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
1672  | 0  |      "%s: UTF-16 string is too small.",  | 
1673  | 0  |      function );  | 
1674  |  | 
  | 
1675  | 0  |     return( -1 );  | 
1676  | 0  |   }  | 
1677  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1678  | 0  |   { | 
1679  | 0  |     utf16_string[ string_index++ ] = (uint16_t) '{'; | 
1680  | 0  |   }  | 
1681  | 0  |   byte_shift = 28;  | 
1682  |  | 
  | 
1683  | 0  |   do  | 
1684  | 0  |   { | 
1685  | 0  |     byte_value = ( internal_identifier->time.lower >> byte_shift ) & 0x0f;  | 
1686  |  | 
  | 
1687  | 0  |     if( byte_value <= 9 )  | 
1688  | 0  |     { | 
1689  | 0  |       utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1690  | 0  |     }  | 
1691  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1692  | 0  |     { | 
1693  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1694  | 0  |     }  | 
1695  | 0  |     else  | 
1696  | 0  |     { | 
1697  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1698  | 0  |     }  | 
1699  | 0  |     byte_shift -= 4;  | 
1700  | 0  |   }  | 
1701  | 0  |   while( byte_shift >= 0 );  | 
1702  |  | 
  | 
1703  | 0  |   utf16_string[ string_index++ ] = (uint16_t) '-';  | 
1704  |  | 
  | 
1705  | 0  |   byte_shift = 12;  | 
1706  |  | 
  | 
1707  | 0  |   do  | 
1708  | 0  |   { | 
1709  | 0  |     byte_value = ( internal_identifier->time.middle >> byte_shift ) & 0x0f;  | 
1710  |  | 
  | 
1711  | 0  |     if( byte_value <= 9 )  | 
1712  | 0  |     { | 
1713  | 0  |       utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1714  | 0  |     }  | 
1715  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1716  | 0  |     { | 
1717  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1718  | 0  |     }  | 
1719  | 0  |     else  | 
1720  | 0  |     { | 
1721  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1722  | 0  |     }  | 
1723  | 0  |     byte_shift -= 4;  | 
1724  | 0  |   }  | 
1725  | 0  |   while( byte_shift >= 0 );  | 
1726  |  | 
  | 
1727  | 0  |   utf16_string[ string_index++ ] = (uint16_t) '-';  | 
1728  |  | 
  | 
1729  | 0  |   byte_shift = 12;  | 
1730  |  | 
  | 
1731  | 0  |   do  | 
1732  | 0  |   { | 
1733  | 0  |     byte_value = ( internal_identifier->time.upper >> byte_shift ) & 0x0f;  | 
1734  |  | 
  | 
1735  | 0  |     if( byte_value <= 9 )  | 
1736  | 0  |     { | 
1737  | 0  |       utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1738  | 0  |     }  | 
1739  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1740  | 0  |     { | 
1741  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1742  | 0  |     }  | 
1743  | 0  |     else  | 
1744  | 0  |     { | 
1745  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1746  | 0  |     }  | 
1747  | 0  |     byte_shift -= 4;  | 
1748  | 0  |   }  | 
1749  | 0  |   while( byte_shift >= 0 );  | 
1750  |  | 
  | 
1751  | 0  |   utf16_string[ string_index++ ] = (uint16_t) '-';  | 
1752  |  | 
  | 
1753  | 0  |   byte_shift = 4;  | 
1754  |  | 
  | 
1755  | 0  |   do  | 
1756  | 0  |   { | 
1757  | 0  |     byte_value = ( internal_identifier->clock_sequence.upper >> byte_shift ) & 0x0f;  | 
1758  |  | 
  | 
1759  | 0  |     if( byte_value <= 9 )  | 
1760  | 0  |     { | 
1761  | 0  |       utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1762  | 0  |     }  | 
1763  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1764  | 0  |     { | 
1765  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1766  | 0  |     }  | 
1767  | 0  |     else  | 
1768  | 0  |     { | 
1769  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1770  | 0  |     }  | 
1771  | 0  |     byte_shift -= 4;  | 
1772  | 0  |   }  | 
1773  | 0  |   while( byte_shift >= 0 );  | 
1774  |  | 
  | 
1775  | 0  |   byte_shift = 4;  | 
1776  |  | 
  | 
1777  | 0  |   do  | 
1778  | 0  |   { | 
1779  | 0  |     byte_value = ( internal_identifier->clock_sequence.lower >> byte_shift ) & 0x0f;  | 
1780  |  | 
  | 
1781  | 0  |     if( byte_value <= 9 )  | 
1782  | 0  |     { | 
1783  | 0  |       utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1784  | 0  |     }  | 
1785  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1786  | 0  |     { | 
1787  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1788  | 0  |     }  | 
1789  | 0  |     else  | 
1790  | 0  |     { | 
1791  | 0  |       utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1792  | 0  |     }  | 
1793  | 0  |     byte_shift -= 4;  | 
1794  | 0  |   }  | 
1795  | 0  |   while( byte_shift >= 0 );  | 
1796  |  | 
  | 
1797  | 0  |   utf16_string[ string_index++ ] = (uint16_t) '-';  | 
1798  |  | 
  | 
1799  | 0  |   for( node_index = 0;  | 
1800  | 0  |        node_index < 6;  | 
1801  | 0  |        node_index++ )  | 
1802  | 0  |   { | 
1803  | 0  |     byte_shift = 4;  | 
1804  |  | 
  | 
1805  | 0  |     do  | 
1806  | 0  |     { | 
1807  | 0  |       byte_value = ( internal_identifier->node[ node_index ] >> byte_shift ) & 0x0f;  | 
1808  |  | 
  | 
1809  | 0  |       if( byte_value <= 9 )  | 
1810  | 0  |       { | 
1811  | 0  |         utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;  | 
1812  | 0  |       }  | 
1813  | 0  |       else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
1814  | 0  |       { | 
1815  | 0  |         utf16_string[ string_index++ ] = (uint16_t) 'A' + byte_value - 10;  | 
1816  | 0  |       }  | 
1817  | 0  |       else  | 
1818  | 0  |       { | 
1819  | 0  |         utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;  | 
1820  | 0  |       }  | 
1821  | 0  |       byte_shift -= 4;  | 
1822  | 0  |     }  | 
1823  | 0  |     while( byte_shift >= 0 );  | 
1824  | 0  |   }  | 
1825  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1826  | 0  |   { | 
1827  | 0  |     utf16_string[ string_index++ ] = (uint16_t) '}';  | 
1828  | 0  |   }  | 
1829  | 0  |   utf16_string[ string_index++ ] = 0;  | 
1830  |  | 
  | 
1831  | 0  |   *utf16_string_index = string_index;  | 
1832  |  | 
  | 
1833  | 0  |   return( 1 );  | 
1834  | 0  | }  | 
1835  |  |  | 
1836  |  | /* Copies the identifier from an UTF-32 encoded string  | 
1837  |  |  * Returns 1 if successful or -1 on error  | 
1838  |  |  */  | 
1839  |  | int libfguid_identifier_copy_from_utf32_string(  | 
1840  |  |      libfguid_identifier_t *identifier,  | 
1841  |  |      const uint32_t *utf32_string,  | 
1842  |  |      size_t utf32_string_size,  | 
1843  |  |      uint32_t string_format_flags,  | 
1844  |  |      libcerror_error_t **error )  | 
1845  | 0  | { | 
1846  | 0  |   static char *function     = "libfguid_identifier_copy_from_utf32_string";  | 
1847  | 0  |   size_t utf32_string_index = 0;  | 
1848  |  | 
  | 
1849  | 0  |   if( libfguid_identifier_copy_from_utf32_string_with_index(  | 
1850  | 0  |        identifier,  | 
1851  | 0  |        utf32_string,  | 
1852  | 0  |        utf32_string_size,  | 
1853  | 0  |        &utf32_string_index,  | 
1854  | 0  |        string_format_flags,  | 
1855  | 0  |        error ) != 1 )  | 
1856  | 0  |   { | 
1857  | 0  |     libcerror_error_set(  | 
1858  | 0  |      error,  | 
1859  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1860  | 0  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
1861  | 0  |      "%s: unable to copy identifier from UTF-32 string.",  | 
1862  | 0  |      function );  | 
1863  |  | 
  | 
1864  | 0  |     return( -1 );  | 
1865  | 0  |   }  | 
1866  | 0  |   return( 1 );  | 
1867  | 0  | }  | 
1868  |  |  | 
1869  |  | /* Copies the identifier from an UTF-32 encoded string  | 
1870  |  |  * Returns 1 if successful or -1 on error  | 
1871  |  |  */  | 
1872  |  | int libfguid_identifier_copy_from_utf32_string_with_index(  | 
1873  |  |      libfguid_identifier_t *identifier,  | 
1874  |  |      const uint32_t *utf32_string,  | 
1875  |  |      size_t utf32_string_length,  | 
1876  |  |      size_t *utf32_string_index,  | 
1877  |  |      uint32_t string_format_flags,  | 
1878  |  |      libcerror_error_t **error )  | 
1879  | 0  | { | 
1880  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
1881  | 0  |   static char *function                               = "libfguid_identifier_copy_from_utf32_string_with_index";  | 
1882  | 0  |   size_t byte_index                                   = 0;  | 
1883  | 0  |   size_t node_index                                   = 0;  | 
1884  | 0  |   size_t string_index                                 = 0;  | 
1885  | 0  |   size_t string_length                                = 0;  | 
1886  | 0  |   uint32_t required_flags                             = 0;  | 
1887  | 0  |   uint32_t supported_flags                            = 0;  | 
1888  |  | 
  | 
1889  | 0  |   if( identifier == NULL )  | 
1890  | 0  |   { | 
1891  | 0  |     libcerror_error_set(  | 
1892  | 0  |      error,  | 
1893  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1894  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1895  | 0  |      "%s: invalid identifier.",  | 
1896  | 0  |      function );  | 
1897  |  | 
  | 
1898  | 0  |     return( -1 );  | 
1899  | 0  |   }  | 
1900  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
1901  |  | 
  | 
1902  | 0  |   if( utf32_string == NULL )  | 
1903  | 0  |   { | 
1904  | 0  |     libcerror_error_set(  | 
1905  | 0  |      error,  | 
1906  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1907  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1908  | 0  |      "%s: invalid UTF-32 string.",  | 
1909  | 0  |      function );  | 
1910  |  | 
  | 
1911  | 0  |     return( -1 );  | 
1912  | 0  |   }  | 
1913  | 0  |   if( utf32_string_length > (size_t) SSIZE_MAX )  | 
1914  | 0  |   { | 
1915  | 0  |     libcerror_error_set(  | 
1916  | 0  |      error,  | 
1917  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1918  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
1919  | 0  |      "%s: invalid UTF-32 string size value exceeds maximum.",  | 
1920  | 0  |      function );  | 
1921  |  | 
  | 
1922  | 0  |     return( -1 );  | 
1923  | 0  |   }  | 
1924  | 0  |   if( utf32_string_index == NULL )  | 
1925  | 0  |   { | 
1926  | 0  |     libcerror_error_set(  | 
1927  | 0  |      error,  | 
1928  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1929  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
1930  | 0  |      "%s: invalid UTF-32 index.",  | 
1931  | 0  |      function );  | 
1932  |  | 
  | 
1933  | 0  |     return( -1 );  | 
1934  | 0  |   }  | 
1935  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
1936  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
1937  |  | 
  | 
1938  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
1939  | 0  |   { | 
1940  | 0  |     libcerror_error_set(  | 
1941  | 0  |      error,  | 
1942  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
1943  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
1944  | 0  |      "%s: missing string format flags.",  | 
1945  | 0  |      function );  | 
1946  |  | 
  | 
1947  | 0  |     return( -1 );  | 
1948  | 0  |   }  | 
1949  | 0  |   supported_flags = required_flags  | 
1950  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
1951  |  | 
  | 
1952  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
1953  | 0  |   { | 
1954  | 0  |     libcerror_error_set(  | 
1955  | 0  |      error,  | 
1956  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1957  | 0  |      LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,  | 
1958  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
1959  | 0  |      function,  | 
1960  | 0  |      string_format_flags );  | 
1961  |  | 
  | 
1962  | 0  |     return( -1 );  | 
1963  | 0  |   }  | 
1964  | 0  |   string_length = 36;  | 
1965  |  | 
  | 
1966  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1967  | 0  |   { | 
1968  | 0  |     string_length += 2;  | 
1969  | 0  |   }  | 
1970  | 0  |   string_index = *utf32_string_index;  | 
1971  |  | 
  | 
1972  | 0  |   if( ( string_index + string_length ) > utf32_string_length )  | 
1973  | 0  |   { | 
1974  | 0  |     libcerror_error_set(  | 
1975  | 0  |      error,  | 
1976  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
1977  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
1978  | 0  |      "%s: UTF-32 string is too small.",  | 
1979  | 0  |      function );  | 
1980  |  | 
  | 
1981  | 0  |     return( -1 );  | 
1982  | 0  |   }  | 
1983  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
1984  | 0  |   { | 
1985  | 0  |     if( utf32_string[ string_index ] != (uint32_t) '{' ) | 
1986  | 0  |     { | 
1987  | 0  |       goto on_error;  | 
1988  | 0  |     }  | 
1989  | 0  |     string_index++;  | 
1990  | 0  |   }  | 
1991  | 0  |   for( byte_index = 0;  | 
1992  | 0  |        byte_index < 8;  | 
1993  | 0  |        byte_index++ )  | 
1994  | 0  |   { | 
1995  | 0  |     internal_identifier->time.lower <<= 4;  | 
1996  |  | 
  | 
1997  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
1998  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
1999  | 0  |     { | 
2000  | 0  |       internal_identifier->time.lower |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2001  | 0  |     }  | 
2002  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2003  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2004  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2005  | 0  |     { | 
2006  | 0  |       internal_identifier->time.lower |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2007  | 0  |     }  | 
2008  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2009  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2010  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2011  | 0  |     { | 
2012  | 0  |       internal_identifier->time.lower |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2013  | 0  |     }  | 
2014  | 0  |     else  | 
2015  | 0  |     { | 
2016  | 0  |       goto on_error;  | 
2017  | 0  |     }  | 
2018  | 0  |     string_index++;  | 
2019  | 0  |   }  | 
2020  | 0  |   if( utf32_string[ string_index ] != (uint32_t) '-' )  | 
2021  | 0  |   { | 
2022  | 0  |     goto on_error;  | 
2023  | 0  |   }  | 
2024  | 0  |   string_index++;  | 
2025  |  | 
  | 
2026  | 0  |   for( byte_index = 0;  | 
2027  | 0  |        byte_index < 4;  | 
2028  | 0  |        byte_index++ )  | 
2029  | 0  |   { | 
2030  | 0  |     internal_identifier->time.middle <<= 4;  | 
2031  |  | 
  | 
2032  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
2033  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
2034  | 0  |     { | 
2035  | 0  |       internal_identifier->time.middle |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2036  | 0  |     }  | 
2037  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2038  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2039  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2040  | 0  |     { | 
2041  | 0  |       internal_identifier->time.middle |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2042  | 0  |     }  | 
2043  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2044  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2045  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2046  | 0  |     { | 
2047  | 0  |       internal_identifier->time.middle |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2048  | 0  |     }  | 
2049  | 0  |     else  | 
2050  | 0  |     { | 
2051  | 0  |       goto on_error;  | 
2052  | 0  |     }  | 
2053  | 0  |     string_index++;  | 
2054  | 0  |   }  | 
2055  | 0  |   if( utf32_string[ string_index ] != (uint32_t) '-' )  | 
2056  | 0  |   { | 
2057  | 0  |     goto on_error;  | 
2058  | 0  |   }  | 
2059  | 0  |   string_index++;  | 
2060  |  | 
  | 
2061  | 0  |   for( byte_index = 0;  | 
2062  | 0  |        byte_index < 4;  | 
2063  | 0  |        byte_index++ )  | 
2064  | 0  |   { | 
2065  | 0  |     internal_identifier->time.upper <<= 4;  | 
2066  |  | 
  | 
2067  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
2068  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
2069  | 0  |     { | 
2070  | 0  |       internal_identifier->time.upper |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2071  | 0  |     }  | 
2072  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2073  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2074  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2075  | 0  |     { | 
2076  | 0  |       internal_identifier->time.upper |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2077  | 0  |     }  | 
2078  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2079  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2080  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2081  | 0  |     { | 
2082  | 0  |       internal_identifier->time.upper |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2083  | 0  |     }  | 
2084  | 0  |     else  | 
2085  | 0  |     { | 
2086  | 0  |       goto on_error;  | 
2087  | 0  |     }  | 
2088  | 0  |     string_index++;  | 
2089  | 0  |   }  | 
2090  | 0  |   if( utf32_string[ string_index ] != (uint32_t) '-' )  | 
2091  | 0  |   { | 
2092  | 0  |     goto on_error;  | 
2093  | 0  |   }  | 
2094  | 0  |   string_index++;  | 
2095  |  | 
  | 
2096  | 0  |   for( byte_index = 0;  | 
2097  | 0  |        byte_index < 2;  | 
2098  | 0  |        byte_index++ )  | 
2099  | 0  |   { | 
2100  | 0  |     internal_identifier->clock_sequence.upper <<= 4;  | 
2101  |  | 
  | 
2102  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
2103  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
2104  | 0  |     { | 
2105  | 0  |       internal_identifier->clock_sequence.upper |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2106  | 0  |     }  | 
2107  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2108  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2109  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2110  | 0  |     { | 
2111  | 0  |       internal_identifier->clock_sequence.upper |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2112  | 0  |     }  | 
2113  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2114  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2115  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2116  | 0  |     { | 
2117  | 0  |       internal_identifier->clock_sequence.upper |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2118  | 0  |     }  | 
2119  | 0  |     else  | 
2120  | 0  |     { | 
2121  | 0  |       goto on_error;  | 
2122  | 0  |     }  | 
2123  | 0  |     string_index++;  | 
2124  | 0  |   }  | 
2125  | 0  |   for( byte_index = 0;  | 
2126  | 0  |        byte_index < 2;  | 
2127  | 0  |        byte_index++ )  | 
2128  | 0  |   { | 
2129  | 0  |     internal_identifier->clock_sequence.lower <<= 4;  | 
2130  |  | 
  | 
2131  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
2132  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
2133  | 0  |     { | 
2134  | 0  |       internal_identifier->clock_sequence.lower |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2135  | 0  |     }  | 
2136  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2137  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2138  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2139  | 0  |     { | 
2140  | 0  |       internal_identifier->clock_sequence.lower |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2141  | 0  |     }  | 
2142  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2143  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2144  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2145  | 0  |     { | 
2146  | 0  |       internal_identifier->clock_sequence.lower |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2147  | 0  |     }  | 
2148  | 0  |     else  | 
2149  | 0  |     { | 
2150  | 0  |       goto on_error;  | 
2151  | 0  |     }  | 
2152  | 0  |     string_index++;  | 
2153  | 0  |   }  | 
2154  | 0  |   if( utf32_string[ string_index ] != (uint32_t) '-' )  | 
2155  | 0  |   { | 
2156  | 0  |     goto on_error;  | 
2157  | 0  |   }  | 
2158  | 0  |   string_index++;  | 
2159  |  | 
  | 
2160  | 0  |   for( byte_index = 0;  | 
2161  | 0  |        byte_index < 12;  | 
2162  | 0  |        byte_index++ )  | 
2163  | 0  |   { | 
2164  | 0  |     node_index = byte_index / 2;  | 
2165  |  | 
  | 
2166  | 0  |     internal_identifier->node[ node_index ] <<= 4;  | 
2167  |  | 
  | 
2168  | 0  |     if( ( utf32_string[ string_index ] >= (uint32_t) '0' )  | 
2169  | 0  |      && ( utf32_string[ string_index ] <= (uint32_t) '9' ) )  | 
2170  | 0  |     { | 
2171  | 0  |       internal_identifier->node[ node_index ] |= utf32_string[ string_index ] - (uint32_t) '0';  | 
2172  | 0  |     }  | 
2173  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE ) != 0 )  | 
2174  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'a' )  | 
2175  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'f' ) )  | 
2176  | 0  |     { | 
2177  | 0  |       internal_identifier->node[ node_index ] |= utf32_string[ string_index ] - (uint32_t) 'a' + 10;  | 
2178  | 0  |     }  | 
2179  | 0  |     else if( ( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2180  | 0  |           && ( utf32_string[ string_index ] >= (uint32_t) 'A' )  | 
2181  | 0  |           && ( utf32_string[ string_index ] <= (uint32_t) 'F' ) )  | 
2182  | 0  |     { | 
2183  | 0  |       internal_identifier->node[ node_index ] |= utf32_string[ string_index ] - (uint32_t) 'A' + 10;  | 
2184  | 0  |     }  | 
2185  | 0  |     else  | 
2186  | 0  |     { | 
2187  | 0  |       goto on_error;  | 
2188  | 0  |     }  | 
2189  | 0  |     string_index++;  | 
2190  | 0  |   }  | 
2191  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
2192  | 0  |   { | 
2193  | 0  |     if( utf32_string[ string_index ] != (uint32_t) '}' )  | 
2194  | 0  |     { | 
2195  | 0  |       goto on_error;  | 
2196  | 0  |     }  | 
2197  | 0  |     string_index++;  | 
2198  | 0  |   }  | 
2199  | 0  |   *utf32_string_index = string_index;  | 
2200  |  | 
  | 
2201  | 0  |   return( 1 );  | 
2202  |  |  | 
2203  | 0  | on_error:  | 
2204  | 0  |   libcerror_error_set(  | 
2205  | 0  |    error,  | 
2206  | 0  |    LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
2207  | 0  |    LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
2208  | 0  |    "%s: unsupported character value: 0x%08" PRIx32 " at index: %d.",  | 
2209  | 0  |    function,  | 
2210  | 0  |    utf32_string[ string_index ],  | 
2211  | 0  |    string_index );  | 
2212  |  | 
  | 
2213  | 0  |   return( -1 );  | 
2214  | 0  | }  | 
2215  |  |  | 
2216  |  | /* Copies the identifier to an UTF-32 encoded string  | 
2217  |  |  * The string size should include the end of string character  | 
2218  |  |  * Returns 1 if successful or -1 on error  | 
2219  |  |  */  | 
2220  |  | int libfguid_identifier_copy_to_utf32_string(  | 
2221  |  |      libfguid_identifier_t *identifier,  | 
2222  |  |      uint32_t *utf32_string,  | 
2223  |  |      size_t utf32_string_size,  | 
2224  |  |      uint32_t string_format_flags,  | 
2225  |  |      libcerror_error_t **error )  | 
2226  | 0  | { | 
2227  | 0  |   static char *function     = "libfguid_identifier_copy_to_utf32_string";  | 
2228  | 0  |   size_t utf32_string_index = 0;  | 
2229  |  | 
  | 
2230  | 0  |   if( libfguid_identifier_copy_to_utf32_string_with_index(  | 
2231  | 0  |        identifier,  | 
2232  | 0  |        utf32_string,  | 
2233  | 0  |        utf32_string_size,  | 
2234  | 0  |        &utf32_string_index,  | 
2235  | 0  |        string_format_flags,  | 
2236  | 0  |        error ) != 1 )  | 
2237  | 0  |   { | 
2238  | 0  |     libcerror_error_set(  | 
2239  | 0  |      error,  | 
2240  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
2241  | 0  |      LIBCERROR_RUNTIME_ERROR_COPY_FAILED,  | 
2242  | 0  |      "%s: unable to copy identifier to UTF-32 string.",  | 
2243  | 0  |      function );  | 
2244  |  | 
  | 
2245  | 0  |     return( -1 );  | 
2246  | 0  |   }  | 
2247  | 0  |   return( 1 );  | 
2248  | 0  | }  | 
2249  |  |  | 
2250  |  | /* Copies the identifier to an UTF-32 encoded string  | 
2251  |  |  * The string size should include the end of string character  | 
2252  |  |  * Returns 1 if successful or -1 on error  | 
2253  |  |  */  | 
2254  |  | int libfguid_identifier_copy_to_utf32_string_with_index(  | 
2255  |  |      libfguid_identifier_t *identifier,  | 
2256  |  |      uint32_t *utf32_string,  | 
2257  |  |      size_t utf32_string_size,  | 
2258  |  |      size_t *utf32_string_index,  | 
2259  |  |      uint32_t string_format_flags,  | 
2260  |  |      libcerror_error_t **error )  | 
2261  | 0  | { | 
2262  | 0  |   libfguid_internal_identifier_t *internal_identifier = NULL;  | 
2263  | 0  |   static char *function                               = "libfguid_identifier_copy_to_utf32_string_with_index";  | 
2264  | 0  |   size_t string_index                                 = 0;  | 
2265  | 0  |   size_t string_size                                  = 0;  | 
2266  | 0  |   uint32_t required_flags                             = 0;  | 
2267  | 0  |   uint32_t supported_flags                            = 0;  | 
2268  | 0  |   uint8_t byte_value                                  = 0;  | 
2269  | 0  |   uint8_t node_index                                  = 0;  | 
2270  | 0  |   int8_t byte_shift                                   = 0;  | 
2271  |  | 
  | 
2272  | 0  |   if( identifier == NULL )  | 
2273  | 0  |   { | 
2274  | 0  |     libcerror_error_set(  | 
2275  | 0  |      error,  | 
2276  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
2277  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
2278  | 0  |      "%s: invalid identifier.",  | 
2279  | 0  |      function );  | 
2280  |  | 
  | 
2281  | 0  |     return( -1 );  | 
2282  | 0  |   }  | 
2283  | 0  |   internal_identifier = (libfguid_internal_identifier_t *) identifier;  | 
2284  |  | 
  | 
2285  | 0  |   if( utf32_string == NULL )  | 
2286  | 0  |   { | 
2287  | 0  |     libcerror_error_set(  | 
2288  | 0  |      error,  | 
2289  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
2290  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
2291  | 0  |      "%s: invalid UTF-32.",  | 
2292  | 0  |      function );  | 
2293  |  | 
  | 
2294  | 0  |     return( -1 );  | 
2295  | 0  |   }  | 
2296  | 0  |   if( utf32_string_size > (size_t) SSIZE_MAX )  | 
2297  | 0  |   { | 
2298  | 0  |     libcerror_error_set(  | 
2299  | 0  |      error,  | 
2300  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
2301  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,  | 
2302  | 0  |      "%s: UTF-32 string size exceeds maximum.",  | 
2303  | 0  |      function );  | 
2304  |  | 
  | 
2305  | 0  |     return( -1 );  | 
2306  | 0  |   }  | 
2307  | 0  |   if( utf32_string_index == NULL )  | 
2308  | 0  |   { | 
2309  | 0  |     libcerror_error_set(  | 
2310  | 0  |      error,  | 
2311  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
2312  | 0  |      LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,  | 
2313  | 0  |      "%s: invalid UTF-32 index.",  | 
2314  | 0  |      function );  | 
2315  |  | 
  | 
2316  | 0  |     return( -1 );  | 
2317  | 0  |   }  | 
2318  | 0  |   required_flags = LIBFGUID_STRING_FORMAT_FLAG_USE_LOWER_CASE  | 
2319  | 0  |                  | LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE;  | 
2320  |  | 
  | 
2321  | 0  |   if( ( string_format_flags & required_flags ) == 0 )  | 
2322  | 0  |   { | 
2323  | 0  |     libcerror_error_set(  | 
2324  | 0  |      error,  | 
2325  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
2326  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
2327  | 0  |      "%s: missing string format flags.",  | 
2328  | 0  |      function );  | 
2329  |  | 
  | 
2330  | 0  |     return( -1 );  | 
2331  | 0  |   }  | 
2332  | 0  |   supported_flags = required_flags  | 
2333  | 0  |                   | LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES;  | 
2334  |  | 
  | 
2335  | 0  |   if( ( string_format_flags & ~( supported_flags ) ) != 0 )  | 
2336  | 0  |   { | 
2337  | 0  |     libcerror_error_set(  | 
2338  | 0  |      error,  | 
2339  | 0  |      LIBCERROR_ERROR_DOMAIN_RUNTIME,  | 
2340  | 0  |      LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,  | 
2341  | 0  |      "%s: unsupported string format flags: 0x%08" PRIx32 ".",  | 
2342  | 0  |      function,  | 
2343  | 0  |      string_format_flags );  | 
2344  |  | 
  | 
2345  | 0  |     return( -1 );  | 
2346  | 0  |   }  | 
2347  | 0  |   string_size = 37;  | 
2348  |  | 
  | 
2349  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
2350  | 0  |   { | 
2351  | 0  |     string_size += 2;  | 
2352  | 0  |   }  | 
2353  | 0  |   string_index = *utf32_string_index;  | 
2354  |  | 
  | 
2355  | 0  |   if( ( string_index + string_size ) > utf32_string_size )  | 
2356  | 0  |   { | 
2357  | 0  |     libcerror_error_set(  | 
2358  | 0  |      error,  | 
2359  | 0  |      LIBCERROR_ERROR_DOMAIN_ARGUMENTS,  | 
2360  | 0  |      LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,  | 
2361  | 0  |      "%s: UTF-32 string is too small.",  | 
2362  | 0  |      function );  | 
2363  |  | 
  | 
2364  | 0  |     return( -1 );  | 
2365  | 0  |   }  | 
2366  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
2367  | 0  |   { | 
2368  | 0  |     utf32_string[ string_index++ ] = (uint32_t) '{'; | 
2369  | 0  |   }  | 
2370  | 0  |   byte_shift = 28;  | 
2371  |  | 
  | 
2372  | 0  |   do  | 
2373  | 0  |   { | 
2374  | 0  |     byte_value = ( internal_identifier->time.lower >> byte_shift ) & 0x0f;  | 
2375  |  | 
  | 
2376  | 0  |     if( byte_value <= 9 )  | 
2377  | 0  |     { | 
2378  | 0  |       utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2379  | 0  |     }  | 
2380  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2381  | 0  |     { | 
2382  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2383  | 0  |     }  | 
2384  | 0  |     else  | 
2385  | 0  |     { | 
2386  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2387  | 0  |     }  | 
2388  | 0  |     byte_shift -= 4;  | 
2389  | 0  |   }  | 
2390  | 0  |   while( byte_shift >= 0 );  | 
2391  |  | 
  | 
2392  | 0  |   utf32_string[ string_index++ ] = (uint32_t) '-';  | 
2393  |  | 
  | 
2394  | 0  |   byte_shift = 12;  | 
2395  |  | 
  | 
2396  | 0  |   do  | 
2397  | 0  |   { | 
2398  | 0  |     byte_value = ( internal_identifier->time.middle >> byte_shift ) & 0x0f;  | 
2399  |  | 
  | 
2400  | 0  |     if( byte_value <= 9 )  | 
2401  | 0  |     { | 
2402  | 0  |       utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2403  | 0  |     }  | 
2404  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2405  | 0  |     { | 
2406  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2407  | 0  |     }  | 
2408  | 0  |     else  | 
2409  | 0  |     { | 
2410  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2411  | 0  |     }  | 
2412  | 0  |     byte_shift -= 4;  | 
2413  | 0  |   }  | 
2414  | 0  |   while( byte_shift >= 0 );  | 
2415  |  | 
  | 
2416  | 0  |   utf32_string[ string_index++ ] = (uint32_t) '-';  | 
2417  |  | 
  | 
2418  | 0  |   byte_shift = 12;  | 
2419  |  | 
  | 
2420  | 0  |   do  | 
2421  | 0  |   { | 
2422  | 0  |     byte_value = ( internal_identifier->time.upper >> byte_shift ) & 0x0f;  | 
2423  |  | 
  | 
2424  | 0  |     if( byte_value <= 9 )  | 
2425  | 0  |     { | 
2426  | 0  |       utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2427  | 0  |     }  | 
2428  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2429  | 0  |     { | 
2430  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2431  | 0  |     }  | 
2432  | 0  |     else  | 
2433  | 0  |     { | 
2434  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2435  | 0  |     }  | 
2436  | 0  |     byte_shift -= 4;  | 
2437  | 0  |   }  | 
2438  | 0  |   while( byte_shift >= 0 );  | 
2439  |  | 
  | 
2440  | 0  |   utf32_string[ string_index++ ] = (uint32_t) '-';  | 
2441  |  | 
  | 
2442  | 0  |   byte_shift = 4;  | 
2443  |  | 
  | 
2444  | 0  |   do  | 
2445  | 0  |   { | 
2446  | 0  |     byte_value = ( internal_identifier->clock_sequence.upper >> byte_shift ) & 0x0f;  | 
2447  |  | 
  | 
2448  | 0  |     if( byte_value <= 9 )  | 
2449  | 0  |     { | 
2450  | 0  |       utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2451  | 0  |     }  | 
2452  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2453  | 0  |     { | 
2454  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2455  | 0  |     }  | 
2456  | 0  |     else  | 
2457  | 0  |     { | 
2458  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2459  | 0  |     }  | 
2460  | 0  |     byte_shift -= 4;  | 
2461  | 0  |   }  | 
2462  | 0  |   while( byte_shift >= 0 );  | 
2463  |  | 
  | 
2464  | 0  |   byte_shift = 4;  | 
2465  |  | 
  | 
2466  | 0  |   do  | 
2467  | 0  |   { | 
2468  | 0  |     byte_value = ( internal_identifier->clock_sequence.lower >> byte_shift ) & 0x0f;  | 
2469  |  | 
  | 
2470  | 0  |     if( byte_value <= 9 )  | 
2471  | 0  |     { | 
2472  | 0  |       utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2473  | 0  |     }  | 
2474  | 0  |     else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2475  | 0  |     { | 
2476  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2477  | 0  |     }  | 
2478  | 0  |     else  | 
2479  | 0  |     { | 
2480  | 0  |       utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2481  | 0  |     }  | 
2482  | 0  |     byte_shift -= 4;  | 
2483  | 0  |   }  | 
2484  | 0  |   while( byte_shift >= 0 );  | 
2485  |  | 
  | 
2486  | 0  |   utf32_string[ string_index++ ] = (uint32_t) '-';  | 
2487  |  | 
  | 
2488  | 0  |   for( node_index = 0;  | 
2489  | 0  |        node_index < 6;  | 
2490  | 0  |        node_index++ )  | 
2491  | 0  |   { | 
2492  | 0  |     byte_shift = 4;  | 
2493  |  | 
  | 
2494  | 0  |     do  | 
2495  | 0  |     { | 
2496  | 0  |       byte_value = ( internal_identifier->node[ node_index ] >> byte_shift ) & 0x0f;  | 
2497  |  | 
  | 
2498  | 0  |       if( byte_value <= 9 )  | 
2499  | 0  |       { | 
2500  | 0  |         utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;  | 
2501  | 0  |       }  | 
2502  | 0  |       else if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_UPPER_CASE ) != 0 )  | 
2503  | 0  |       { | 
2504  | 0  |         utf32_string[ string_index++ ] = (uint32_t) 'A' + byte_value - 10;  | 
2505  | 0  |       }  | 
2506  | 0  |       else  | 
2507  | 0  |       { | 
2508  | 0  |         utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;  | 
2509  | 0  |       }  | 
2510  | 0  |       byte_shift -= 4;  | 
2511  | 0  |     }  | 
2512  | 0  |     while( byte_shift >= 0 );  | 
2513  | 0  |   }  | 
2514  | 0  |   if( ( string_format_flags & LIBFGUID_STRING_FORMAT_FLAG_USE_SURROUNDING_BRACES ) != 0 )  | 
2515  | 0  |   { | 
2516  | 0  |     utf32_string[ string_index++ ] = (uint32_t) '}';  | 
2517  | 0  |   }  | 
2518  | 0  |   utf32_string[ string_index++ ] = 0;  | 
2519  |  | 
  | 
2520  | 0  |   *utf32_string_index = string_index;  | 
2521  |  | 
  | 
2522  | 0  |   return( 1 );  | 
2523  | 0  | }  | 
2524  |  |  |