s3: Rename new parameter "ldap ref follow" to "ldap follow referral".
[Samba/gebeck_regimport.git] / source3 / lib / util_uuid.c
blob656ba2a57cb16bbed501ac949ddd145ea38945e9
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
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.
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.
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/>.
21 #include "includes.h"
23 void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr)
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);
32 void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu)
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);
41 /*****************************************************************
42 Return the binary string representation of a GUID.
43 Caller must free.
44 *****************************************************************/
46 char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
48 UUID_FLAT guid_flat;
50 smb_uuid_pack(*guid, &guid_flat);
52 return binary_string_rfc2254(mem_ctx, guid_flat.info, UUID_FLAT_SIZE);