Lumiera  0.pre.03
»edit your freedom«
luid.h
Go to the documentation of this file.
1 /*
2  LUID.h - Lumiera unique identifiers
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (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, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21 
22 
52 #ifndef LIB_LUID_H
53 #define LIB_LUID_H
54 
55 
56 #include "lib/hash-value.h" /* Types lumiera_uid and LumieraUid */
57 
58 #include <stdlib.h>
59 
60 
61 
62 /*
63  C++ can't initialise arrays from string literals with the trailing \0 cropped
64  C can't initialise non constant members,
65  there we go
67 */
68 #ifdef __cplusplus
69 #define LUMIERA_UID_INITIALIZER(l) \
70  { \
71  l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], \
72  l[8], l[9], l[10], l[11], l[12], l[13], l[14], l[15] \
73  }
74 #else
75 #define LUMIERA_UID_INITIALIZER(l) l
76 #endif
77 
78 #define LUMIERA_UID_FMT \
79  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
80  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
81  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
82  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho"
83 
84 #define LUMIERA_UID_CHAR(l,n) ((unsigned char*)l)[n]
85 
86 
87 #define LUMIERA_UID_ELEMENTS(l) \
88  LUMIERA_UID_CHAR(l,0), LUMIERA_UID_CHAR(l,1), LUMIERA_UID_CHAR(l,2), LUMIERA_UID_CHAR(l,3), \
89  LUMIERA_UID_CHAR(l,4), LUMIERA_UID_CHAR(l,5), LUMIERA_UID_CHAR(l,6), LUMIERA_UID_CHAR(l,7), \
90  LUMIERA_UID_CHAR(l,8), LUMIERA_UID_CHAR(l,9), LUMIERA_UID_CHAR(l,10), LUMIERA_UID_CHAR(l,11), \
91  LUMIERA_UID_CHAR(l,12), LUMIERA_UID_CHAR(l,13), LUMIERA_UID_CHAR(l,14), LUMIERA_UID_CHAR(l,15)
92 
96 #define LUIDGEN PLEASE_RUN_THE_LUIDGEN_TOOL_ON_THIS_FILE
97 
98 
102 void*
103 lumiera_uid_ptr_get (const lumiera_uid* luid);
104 
108 void
110 
114 void
115 lumiera_uid_set_ptr (lumiera_uid* luid, void* ptr);
116 
117 
121 void
123 
124 
128 int
129 lumiera_uid_eq (const lumiera_uid* luida, const lumiera_uid* luidb);
130 
131 
135 size_t
136 lumiera_uid_hash (const lumiera_uid* luid);
137 
138 #endif /*LIB_LUID_H*/
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.
Definition: luid.c:42
void lumiera_uid_copy(lumiera_uid *dest, lumiera_uid *src)
Copy an luid.
Definition: luid.c:99
size_t lumiera_uid_hash(const lumiera_uid *luid)
Generate a hash sum over an luid.
Definition: luid.c:112
void * lumiera_uid_ptr_get(const lumiera_uid *luid)
Retrieve a generic pointer stored in a luid.
Definition: luid.c:50
Hash value types and utilities.
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
Definition: hash-value.h:45
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid&#39;s for equality.
Definition: luid.c:106
void lumiera_uid_gen(lumiera_uid *luid)
Generate a new luid.
Definition: luid.c:57