dbid.h 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef __DBID_H
  2. #define __DBID_H
  3. /* functions and structures for generating unique database IDs */
  4. #include <string.h>
  5. #define MAX_DBID_LEN 48
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef char dbid_t[MAX_DBID_LEN];
  10. /** generates ID for data in shared memory at address given by data_ptr */
  11. void generate_dbid_ptr(dbid_t dst, void *data_ptr);
  12. #ifdef SER
  13. void generate_dbid(dbid_t dst);
  14. #endif
  15. /* macros for conversion to string representation of DBID
  16. * (if dbid becomes structure with binary information
  17. * these should be removed and replaced by functions) */
  18. #define dbid_strlen(id) strlen(id)
  19. #define dbid_strptr(id) ((char*)(id))
  20. #define dbid_clear(id) do { (id)[0] = 0; } while (0)
  21. #define is_dbid_empty(id) (!(id)[0])
  22. /** Copies dbid as string into destination. The destination string
  23. * data buffer MUST be allocated in needed size! */
  24. #define dbid_strcpy(dst,id,l) do { memcpy((dst)->s,id,l); (dst)->len = l; } while (0)
  25. #ifdef __cplusplus
  26. }
  27. #endif
  28. #endif