uuid.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /****************************************************************************
  2. * include/uuid.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_UUID_H
  21. #define __INCLUDE_UUID_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <sys/types.h>
  26. /****************************************************************************
  27. * Pre-processor Definitions
  28. ****************************************************************************/
  29. /* Status codes returned by the functions. */
  30. #define uuid_s_ok 0
  31. #define uuid_s_bad_version 1
  32. #define uuid_s_invalid_string_uuid 2
  33. #define uuid_s_no_memory 3
  34. /* Length of a node address (an IEEE 802 address). */
  35. #define UUID_NODE_LEN 6
  36. /* Length of a UUID. */
  37. #define UUID_STR_LEN 36
  38. /****************************************************************************
  39. * Public Type Definitions
  40. ****************************************************************************/
  41. /****************************************************************************
  42. * A DCE 1.1 compatible source representation of UUIDs.
  43. * 0 1 2 3
  44. * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  45. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  46. * | time_low |
  47. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  48. * | time_mid | time_hi_and_version |
  49. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  50. * |clk_seq_hi_res | clk_seq_low | node (0-1) |
  51. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  52. * | node (2-5) |
  53. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  54. *
  55. ****************************************************************************/
  56. struct uuid
  57. {
  58. uint32_t time_low;
  59. uint16_t time_mid;
  60. uint16_t time_hi_and_version;
  61. uint8_t clock_seq_hi_and_reserved;
  62. uint8_t clock_seq_low;
  63. uint8_t node[UUID_NODE_LEN];
  64. };
  65. typedef struct uuid uuid_t;
  66. /****************************************************************************
  67. * Public Function Prototypes
  68. ****************************************************************************/
  69. #if defined(__cplusplus)
  70. extern "C"
  71. {
  72. #endif
  73. int32_t uuid_compare(const uuid_t *, const uuid_t *, uint32_t *);
  74. void uuid_create(uuid_t *, uint32_t *);
  75. void uuid_create_nil(uuid_t *, uint32_t *);
  76. int32_t uuid_equal(const uuid_t *, const uuid_t *, uint32_t *);
  77. void uuid_from_string(const char *, uuid_t *, uint32_t *);
  78. uint16_t uuid_hash(const uuid_t *, uint32_t *);
  79. int32_t uuid_is_nil(const uuid_t *, uint32_t *);
  80. void uuid_to_string(const uuid_t *, char **, uint32_t *);
  81. void uuid_enc_le(void *, const uuid_t *);
  82. void uuid_dec_le(const void *, uuid_t *);
  83. void uuid_enc_be(void *, const uuid_t *);
  84. void uuid_dec_be(const void *, uuid_t *);
  85. #if defined(__cplusplus)
  86. }
  87. #endif
  88. #endif /* __INCLUDE_UUID_H */