|
28 | 28 | BSON_BEGIN_DECLS
|
29 | 29 |
|
30 | 30 |
|
| 31 | +enum { |
| 32 | + BSON_OID_RANDOMESS_OFFSET = 4, |
| 33 | + BSON_OID_RANDOMNESS_SIZE = 5, |
| 34 | + BSON_OID_SEQ32_OFFSET = 9, |
| 35 | + BSON_OID_SEQ32_SIZE = 3, |
| 36 | + BSON_OID_SEQ64_OFFSET = 4, |
| 37 | + BSON_OID_SEQ64_SIZE = 8 |
| 38 | +}; |
| 39 | + |
31 | 40 | struct _bson_context_t {
|
32 | 41 | /* flags are defined in bson_context_flags_t */
|
33 | 42 | int flags;
|
34 |
| - int32_t seq32; |
35 |
| - int64_t seq64; |
36 |
| - uint8_t rand[5]; |
37 |
| - uint16_t pid; |
38 |
| - |
39 |
| - void (*oid_set_seq32) (bson_context_t *context, bson_oid_t *oid); |
40 |
| - void (*oid_set_seq64) (bson_context_t *context, bson_oid_t *oid); |
41 |
| - |
42 |
| - /* this function pointer allows us to mock gethostname for testing. */ |
43 |
| - void (*gethostname) (char *out); |
| 43 | + uint32_t seq32; |
| 44 | + uint64_t seq64; |
| 45 | + uint8_t randomness[BSON_OID_RANDOMNESS_SIZE]; |
| 46 | + uint64_t pid; |
44 | 47 | };
|
45 | 48 |
|
| 49 | +/** |
| 50 | + * @brief Insert the context's randomness data into the given OID |
| 51 | + * |
| 52 | + * @param context A context for some random data |
| 53 | + * @param oid The OID to update. |
| 54 | + */ |
46 | 55 | void
|
47 | 56 | _bson_context_set_oid_rand (bson_context_t *context, bson_oid_t *oid);
|
48 | 57 |
|
| 58 | +/** |
| 59 | + * @brief Insert the context's sequence counter into the given OID. Increments |
| 60 | + * the context's sequence counter. |
| 61 | + * |
| 62 | + * @param context The context with the counter to get+update |
| 63 | + * @param oid The OID to modify |
| 64 | + */ |
| 65 | +void |
| 66 | +_bson_context_set_oid_seq32 (bson_context_t *context, bson_oid_t *oid); |
| 67 | + |
| 68 | +/** |
| 69 | + * @brief Write a 64-bit counter from the given context into the OID. Increments |
| 70 | + * the context's sequence counter. |
| 71 | + * |
| 72 | + * @param context The context with the counter to get+update |
| 73 | + * @param oid The OID to modify |
| 74 | + * |
| 75 | + * @note Only used by the deprecated @ref bson_oid_init_sequence |
| 76 | + */ |
| 77 | +void |
| 78 | +_bson_context_set_oid_seq64 (bson_context_t *context, bson_oid_t *oid); |
| 79 | + |
49 | 80 |
|
50 | 81 | BSON_END_DECLS
|
51 | 82 |
|
|
0 commit comments