Fix some nonempty blank lines
[ira/wip.git] / source3 / lib / util_uuid.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  UUID server routines
4  *  Copyright (C) Theodore Ts'o               1996, 1997,
5  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002, 2003
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *  
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *  
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include "includes.h"
22
23 void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr)
24 {
25         SIVAL(ptr->info, 0, uu.time_low);
26         SSVAL(ptr->info, 4, uu.time_mid);
27         SSVAL(ptr->info, 6, uu.time_hi_and_version);
28         memcpy(ptr->info+8, uu.clock_seq, 2);
29         memcpy(ptr->info+10, uu.node, 6);
30 }
31
32 void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu)
33 {
34         uu->time_low = IVAL(in.info, 0);
35         uu->time_mid = SVAL(in.info, 4);
36         uu->time_hi_and_version = SVAL(in.info, 6);
37         memcpy(uu->clock_seq, in.info+8, 2);
38         memcpy(uu->node, in.info+10, 6);
39 }
40
41 /*****************************************************************
42  Return the binary string representation of a GUID.
43  Caller must free.
44 *****************************************************************/
45
46 char *guid_binstring(const struct GUID *guid)
47 {
48         UUID_FLAT guid_flat;
49
50         smb_uuid_pack(*guid, &guid_flat);
51
52         return binary_string_rfc2254((char *)guid_flat.info, UUID_FLAT_SIZE);
53 }