dbid.h

00001 #ifndef __DBID_H
00002 #define __DBID_H
00003 
00004 /* functions and structures for generating unique database IDs */
00005 
00006 #include <string.h>
00007 
00008 #define MAX_DBID_LEN    48
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 typedef char dbid_t[MAX_DBID_LEN];
00015 
00017 void generate_dbid_ptr(dbid_t dst, void *data_ptr);
00018 
00019 #ifdef SER
00020 void generate_dbid(dbid_t dst);
00021 #endif
00022 
00023 /* macros for conversion to string representation of DBID
00024  * (if dbid becomes structure with binary information 
00025  * these should be removed and replaced by functions) */
00026 #define dbid_strlen(id) strlen(id)
00027 #define dbid_strptr(id) ((char*)(id))
00028 
00029 #define dbid_clear(id)  do { (id)[0] = 0; } while (0)
00030 
00031 #define is_dbid_empty(id) (!(id)[0])
00032 
00035 #define dbid_strcpy(dst,id,l) do { memcpy((dst)->s,id,l); (dst)->len = l; } while (0)
00036 
00037 #ifdef __cplusplus
00038 }
00039 #endif
00040 
00041 #endif