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)
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 */
12 
13 
43 #ifndef LIB_LUID_H
44 #define LIB_LUID_H
45 
46 
47 #include "lib/hash-value.h" /* Types lumiera_uid and LumieraUid */
48 
49 #include <stdlib.h>
50 
51 
52 
53 /*
54  C++ can't initialise arrays from string literals with the trailing \0 cropped
55  C can't initialise non constant members,
56  there we go
58 */
59 #ifdef __cplusplus
60 #define LUMIERA_UID_INITIALIZER(l) \
61  { \
62  l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], \
63  l[8], l[9], l[10], l[11], l[12], l[13], l[14], l[15] \
64  }
65 #else
66 #define LUMIERA_UID_INITIALIZER(l) l
67 #endif
68 
69 #define LUMIERA_UID_FMT \
70  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
71  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
72  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho" \
73  "\\%.3hho\\%.3hho\\%.3hho\\%.3hho"
74 
75 #define LUMIERA_UID_CHAR(l,n) ((unsigned char*)l)[n]
76 
77 
78 #define LUMIERA_UID_ELEMENTS(l) \
79  LUMIERA_UID_CHAR(l,0), LUMIERA_UID_CHAR(l,1), LUMIERA_UID_CHAR(l,2), LUMIERA_UID_CHAR(l,3), \
80  LUMIERA_UID_CHAR(l,4), LUMIERA_UID_CHAR(l,5), LUMIERA_UID_CHAR(l,6), LUMIERA_UID_CHAR(l,7), \
81  LUMIERA_UID_CHAR(l,8), LUMIERA_UID_CHAR(l,9), LUMIERA_UID_CHAR(l,10), LUMIERA_UID_CHAR(l,11), \
82  LUMIERA_UID_CHAR(l,12), LUMIERA_UID_CHAR(l,13), LUMIERA_UID_CHAR(l,14), LUMIERA_UID_CHAR(l,15)
83 
87 #define LUIDGEN PLEASE_RUN_THE_LUIDGEN_TOOL_ON_THIS_FILE
88 
89 
93 void*
94 lumiera_uid_ptr_get (const lumiera_uid* luid);
95 
99 void
101 
105 void
106 lumiera_uid_set_ptr (lumiera_uid* luid, void* ptr);
107 
108 
112 void
114 
115 
119 int
120 lumiera_uid_eq (const lumiera_uid* luida, const lumiera_uid* luidb);
121 
122 
126 size_t
127 lumiera_uid_hash (const lumiera_uid* luid);
128 
129 #endif /*LIB_LUID_H*/
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.
Definition: luid.c:33
void lumiera_uid_copy(lumiera_uid *dest, lumiera_uid *src)
Copy an luid.
Definition: luid.c:90
size_t lumiera_uid_hash(const lumiera_uid *luid)
Generate a hash sum over an luid.
Definition: luid.c:103
void * lumiera_uid_ptr_get(const lumiera_uid *luid)
Retrieve a generic pointer stored in a luid.
Definition: luid.c:41
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:40
int lumiera_uid_eq(const lumiera_uid *luida, const lumiera_uid *luidb)
Test 2 luid&#39;s for equality.
Definition: luid.c:97
void lumiera_uid_gen(lumiera_uid *luid)
Generate a new luid.
Definition: luid.c:48