File: uuid.h

package info (click to toggle)
389-ds-base 2.3.1%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 37,536 kB
  • sloc: ansic: 306,972; python: 96,937; cpp: 10,257; perl: 2,854; makefile: 2,046; sh: 925; yacc: 806; xml: 379; lex: 366; javascript: 148; java: 50
file content (119 lines) | stat: -rw-r--r-- 4,215 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/** BEGIN COPYRIGHT BLOCK
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 *
 * License: GPL (version 3 or any later version).
 * See LICENSE for details.
 * END COPYRIGHT BLOCK **/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/* uuid.h - interface  to uuid layer. UUID is generated in accordance
            with UUIDs and GUIDs IETF draft
 */

/*
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
** Digital Equipment Corporation, Maynard, Mass.
** Copyright (c) 1998 Microsoft.
** To anyone who acknowledges that this file is provided "AS IS"
** without any express or implied warranty: permission to use, copy,
** modify, and distribute this file for any purpose is hereby
** granted without fee, provided that the above copyright notices and
** this notice appears in all source code copies, and that none of
** the names of Open Software Foundation, Inc., Hewlett-Packard
** Company, or Digital Equipment Corporation be used in advertising
** or publicity pertaining to distribution of the software without
** specific, written prior permission.  Neither Open Software
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
** Corporation makes any representations about the suitability of
** this software for any purpose.
*/


#ifndef UUID_H
#define UUID_H

/* Set this to what your compiler uses for 64 bit data type */
#define unsigned64_t unsigned long long
#define I64(C) C##LL

/***** uuid related data types *****/
/*
 * DBDB These types were broken on 64-bit architectures
 * This file has been modified to fix that problem.
 */
#if defined(__LP64__) || defined(_LP64)
typedef unsigned int unsigned32;
#else
typedef unsigned long unsigned32;
#endif
typedef unsigned short unsigned16;
typedef unsigned char unsigned8;
typedef unsigned64_t uuid_time_t;
typedef struct
{
    char nodeID[6];
} uuid_node_t;

typedef struct guid_t_
{
    unsigned32 time_low;
    unsigned16 time_mid;
    unsigned16 time_hi_and_version;
    unsigned8 clock_seq_hi_and_reserved;
    unsigned8 clock_seq_low;
    PRUint8 node[6];
} guid_t;

enum
{
    UUID_SUCCESS,      /* operation succeded */
    UUID_IO_ERROR,     /* file I/O failed */
    UUID_LOCK_ERROR,   /* lock creation failed */
    UUID_TIME_ERROR,   /* ran out of time sequence numbers, need
                           time update to generate the id          */
    UUID_BAD_FORMAT,   /* data in a string buffer is not in UUID format */
    UUID_MEMORY_ERROR, /* memory allocation failed */
    UUID_LDAP_ERROR,   /* LDAP operation failed */
    UUID_NOTFOUND,     /* generator state is missing */
    UUID_FORMAT_ERROR, /* state entry does not contain right data */
    UUID_UNKNOWN_ERROR
};

/***** uuid interface *****/

/* uuid_init -- initialize uuid layer */
int uuid_init(const char *configDir, const Slapi_DN *configDN, PRBool mtGen);

/* uuid_cleanup -- cleanup of uuid layer */
void uuid_cleanup(void);

/* uuid_create -- generate a UUID */
int uuid_create(guid_t *uuid);

/* uuid_compare --  Compare two UUID's "lexically" and return
                      -1   u1 is lexically before u2
                       0   u1 is equal to u2
                       1   u1 is lexically after u2
   Note:   lexical ordering is not temporal ordering!
*/
int uuid_compare(const guid_t *u1, const guid_t *u2);

/* uuid_format -- converts UUID to its string representation and stores it
                  in the buff. buff must be at list 40 bytes long
*/
void uuid_format(const guid_t *u, char *buff);

/* uuid_create_from_name -- create a UUID using a "name" from a "name space" */
void uuid_create_from_name(guid_t *uuid,      /* resulting UUID */
                           const guid_t nsid, /* UUID to serve as context, so identical
                                                    names from different name spaces generate
                                                    different UUIDs */
                           const void *name,  /* the name from which to generate a UUID */
                           int namelen);      /* the length of the name */
#endif