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 .
21 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_RTL_UUID_H
24 #define INCLUDED_RTL_UUID_H
26 #include "sal/config.h"
28 #include "rtl/string.h"
29 #include "sal/saldllapi.h"
30 #include "sal/types.h"
34 Specification (from draft-leach-uuids-guids-01.txt )
37 A UUID is an identifier that is unique across both space and time,
38 with respect to the space of all UUIDs. To be precise, the UUID
39 consists of a finite bit space. Thus, collision cannot be avoided in
40 principle. A UUID can be used for multiple purposes, from tagging objects
41 with an extremely short lifetime, to reliably identifying very persistent
42 objects across a network.
45 The generation of UUIDs does not require that a registration
46 authority be contacted for each identifier. Instead, Version 4 UUIDs are
47 generated from (pseudo unique) sequences of (pseudo) random bits.
54 /** Generates a new Version 4 (random number based) UUID (Universally Unique
57 @param pTargetUUID pointer to at least 16 bytes of memory. After the call it contains
58 the newly generated uuid in network byte order.
59 @param pPredecessorUUID ignored (was used when this function returned
60 Version 1 instead of Version 4 UUIDs).
61 @param bUseEthernetAddress ignored (was used when this function returned
62 Version 1 instead of Version 4 UUIDs).
64 SAL_DLLPUBLIC
void SAL_CALL
rtl_createUuid(
65 sal_uInt8
*pTargetUUID
,
66 const sal_uInt8
*pPredecessorUUID
,
67 sal_Bool bUseEthernetAddress
);
69 /** Compare two UUID's lexically
72 Note: lexical ordering is not temporal ordering!
74 Note: For equalnesschecking, a memcmp(pUUID1,pUUID2,16) is more efficient
78 <li>-1 u1 is lexically before u2
79 <li>0 u1 is equal to u2
80 <li>1 u1 is lexically after u2
84 SAL_DLLPUBLIC sal_Int32 SAL_CALL
rtl_compareUuid(
85 const sal_uInt8
*pUUID1
, const sal_uInt8
*pUUID2
);
87 /** Creates named UUIDs.
90 The version 3 UUID is meant for generating UUIDs from <em>names</em> that
91 are drawn from, and unique within, some <em>name space</em>. Some examples
92 of names (and, implicitly, name spaces) might be DNS names, URLs, ISO
93 Object IDs (OIDs), reserved words in a programming language, or X.500
94 Distinguished Names (DNs); thus, the concept of name and name space
95 should be broadly construed, and not limited to textual names.
98 The requirements for such UUIDs are as follows:
101 <li> The UUIDs generated at different times from the same name in the
102 same namespace MUST be equal
104 <li> The UUIDs generated from two different names in the same namespace
105 should be different (with very high probability)
107 <li> The UUIDs generated from the same name in two different namespaces
108 should be different with (very high probability)
110 <li> If two UUIDs that were generated from names are equal, then they
111 were generated from the same name in the same namespace (with very
115 @param pTargetUUID pointer to at least 16 bytes of memory. After the call
116 it contains the newly generated uuid in network byte order.
117 @param pNameSpaceUUID The namespace uuid. Below are some predefined ones,
118 but any arbitrary uuid can be used as namespace.
120 @param pName the name
122 SAL_DLLPUBLIC
void SAL_CALL
rtl_createNamedUuid(
123 sal_uInt8
*pTargetUUID
,
124 const sal_uInt8
*pNameSpaceUUID
,
125 const rtl_String
*pName
131 Predefined Namespaces
132 (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
137 (Use them the following way : sal_uInt8 aNsDNS[16]) = RTL_UUID_NAMESPACE_DNS;
139 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
140 #define RTL_UUID_NAMESPACE_DNS {\
141 0x6b,0xa7,0xb8,0x10,\
144 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
150 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */
151 #define RTL_UUID_NAMESPACE_URL { \
152 0x6b, 0xa7, 0xb8, 0x11,\
155 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
161 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */
162 #define RTL_UUID_NAMESPACE_OID {\
163 0x6b, 0xa7, 0xb8, 0x12,\
166 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
172 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */
173 #define RTL_UUID_NAMESPACE_X500 {\
174 0x6b, 0xa7, 0xb8, 0x14,\
177 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8\
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */