1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_RTL_UUID_H
20 #define INCLUDED_RTL_UUID_H
22 #include "sal/config.h"
24 #include "rtl/string.h"
25 #include "sal/saldllapi.h"
26 #include "sal/types.h"
30 Specification (from draft-leach-uuids-guids-01.txt )
33 A UUID is an identifier that is unique across both space and time,
34 with respect to the space of all UUIDs. To be precise, the UUID
35 consists of a finite bit space. Thus, collision cannot be avoided in
36 principle. A UUID can be used for multiple purposes, from tagging objects
37 with an extremely short lifetime, to reliably identifying very persistent
38 objects across a network.
41 The generation of UUIDs does not require that a registration
42 authority be contacted for each identifier. Instead, Version 4 UUIDs are
43 generated from (pseudo unique) sequences of (pseudo) random bits.
50 /** Generates a new Version 4 (random number based) UUID (Universally Unique
53 @param pTargetUUID pointer to at least 16 bytes of memory. After the call it contains
54 the newly generated uuid in network byte order.
55 @param pPredecessorUUID ignored (was used when this function returned
56 Version 1 instead of Version 4 UUIDs).
57 @param bUseEthernetAddress ignored (was used when this function returned
58 Version 1 instead of Version 4 UUIDs).
60 SAL_DLLPUBLIC
void SAL_CALL
rtl_createUuid(
61 sal_uInt8
*pTargetUUID
,
62 const sal_uInt8
*pPredecessorUUID
,
63 sal_Bool bUseEthernetAddress
);
65 /** Compare two UUID's lexically
68 Note: lexical ordering is not temporal ordering!
70 Note: For equalnesschecking, a memcmp(pUUID1,pUUID2,16) is more efficient
74 <li>-1 u1 is lexically before u2
75 <li>0 u1 is equal to u2
76 <li>1 u1 is lexically after u2
80 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_compareUuid(
81 const sal_uInt8
*pUUID1
, const sal_uInt8
*pUUID2
);
83 /** Creates named UUIDs.
86 The version 3 UUID is meant for generating UUIDs from <em>names</em> that
87 are drawn from, and unique within, some <em>name space</em>. Some examples
88 of names (and, implicitly, name spaces) might be DNS names, URLs, ISO
89 Object IDs (OIDs), reserved words in a programming language, or X.500
90 Distinguished Names (DNs); thus, the concept of name and name space
91 should be broadly construed, and not limited to textual names.
94 The requirements for such UUIDs are as follows:
97 <li> The UUIDs generated at different times from the same name in the
98 same namespace MUST be equal
100 <li> The UUIDs generated from two different names in the same namespace
101 should be different (with very high probability)
103 <li> The UUIDs generated from the same name in two different namespaces
104 should be different with (very high probability)
106 <li> If two UUIDs that were generated from names are equal, then they
107 were generated from the same name in the same namespace (with very
111 @param pTargetUUID pointer to at least 16 bytes of memory. After the call
112 it contains the newly generated uuid in network byte order.
113 @param pNameSpaceUUID The namespace uuid. Below are some predefined ones,
114 but any arbitrary uuid can be used as namespace.
116 @param pName the name
118 SAL_DLLPUBLIC
void SAL_CALL
rtl_createNamedUuid(
119 sal_uInt8
*pTargetUUID
,
120 const sal_uInt8
*pNameSpaceUUID
,
121 const rtl_String
*pName
127 Predefined Namespaces
128 (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
133 (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
135 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
136 #define RTL_UUID_NAMESPACE_DNS {\
137 0x6b,0xa7,0xb8,0x10,\
140 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
146 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */
147 #define RTL_UUID_NAMESPACE_URL { \
148 0x6b, 0xa7, 0xb8, 0x11,\
151 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
157 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */
158 #define RTL_UUID_NAMESPACE_OID {\
159 0x6b, 0xa7, 0xb8, 0x12,\
162 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
168 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */
169 #define RTL_UUID_NAMESPACE_X500 {\
170 0x6b, 0xa7, 0xb8, 0x14,\
173 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */