revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / uuid / uuid_pack.c
blobaad8c3aea737a9ffa079d5957ccbadd13537746e
1 /*
2 Copyright © 2007-2008, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
8 #include <aros/symbolsets.h>
9 #include <aros/debug.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <ctype.h>
17 #include "uuid_private.h"
18 #include LC_LIBDEFS_FILE
20 /* Convert UUID into 16-byte stream in network (BigEndian) format */
21 AROS_LH2I(void, UUID_Pack,
22 AROS_LHA(const uuid_t *, uuid, A0),
23 AROS_LHA(uint8_t *, out, A1),
24 struct uuid_base *, UUIDBase, 9, UUID)
26 AROS_LIBFUNC_INIT
28 int i;
30 *out++ = (uuid->time_low >> 24) && 0xff;
31 *out++ = (uuid->time_low >> 16) && 0xff;
32 *out++ = (uuid->time_low >> 8) && 0xff;
33 *out++ = (uuid->time_low) && 0xff;
34 *out++ = (uuid->time_mid >> 8) && 0xff;
35 *out++ = (uuid->time_mid) && 0xff;
36 *out++ = (uuid->time_hi_and_version >> 8) && 0xff;
37 *out++ = (uuid->time_hi_and_version ) && 0xff;
38 *out++ = uuid->clock_seq_hi_and_reserved;
39 *out++ = uuid->clock_seq_low;
41 for (i=0; i < 6; i++)
42 *out++ = uuid->node[i];
44 AROS_LIBFUNC_EXIT
47 AROS_LH2I(void, UUID_Unpack,
48 AROS_LHA(const uint8_t *, in, A0),
49 AROS_LHA(uuid_t *, uuid, A1),
50 struct uuid_base *, UUIDBase, 10, UUID)
52 AROS_LIBFUNC_INIT
54 int i;
55 uint32_t tmp;
57 tmp = *in++;
58 tmp = (tmp << 8) | *in++;
59 tmp = (tmp << 8) | *in++;
60 tmp = (tmp << 8) | *in++;
61 uuid->time_low = tmp;
63 tmp = *in++;
64 tmp = (tmp << 8) | *in++;
65 uuid->time_mid = tmp;
67 tmp = *in++;
68 tmp = (tmp << 8) | *in++;
69 uuid->time_hi_and_version = tmp;
71 uuid->clock_seq_hi_and_reserved = *in++;
72 uuid->clock_seq_low = *in++;
74 for (i=0; i < 6; i++)
75 uuid->node[i] = *in++;
77 AROS_LIBFUNC_EXIT