@based/db 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
  2. package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
  3. package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
  4. package/dist/lib/darwin_aarch64/libnode-v25.node +0 -0
  5. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  6. package/dist/lib/linux_aarch64/include/cdefs.h +324 -0
  7. package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
  8. package/dist/lib/linux_aarch64/include/libdeflate.h +345 -0
  9. package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
  10. package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
  11. package/dist/lib/linux_aarch64/include/queue.h +627 -0
  12. package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
  13. package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
  14. package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
  15. package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
  16. package/dist/lib/linux_aarch64/include/selva/colvec.h +71 -0
  17. package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
  18. package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
  19. package/dist/lib/linux_aarch64/include/selva/db.h +450 -0
  20. package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
  21. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +27 -0
  22. package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
  23. package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
  24. package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
  25. package/dist/lib/linux_aarch64/include/selva/fields.h +341 -0
  26. package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
  27. package/dist/lib/linux_aarch64/include/selva/hll.h +85 -0
  28. package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
  29. package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
  30. package/dist/lib/linux_aarch64/include/selva/membar.h +32 -0
  31. package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
  32. package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
  33. package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
  34. package/dist/lib/linux_aarch64/include/selva/selva_lang.h +112 -0
  35. package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
  36. package/dist/lib/linux_aarch64/include/selva/selva_string.h +683 -0
  37. package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
  38. package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
  39. package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
  40. package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
  41. package/dist/lib/linux_aarch64/include/selva/types.h +115 -0
  42. package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
  43. package/dist/lib/linux_aarch64/include/selva_error.h +140 -0
  44. package/dist/lib/linux_aarch64/include/selva_lang_code.h +160 -0
  45. package/dist/lib/linux_aarch64/include/tree.h +852 -0
  46. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  47. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  48. package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
  49. package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
  50. package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
  51. package/dist/lib/linux_aarch64/libnode-v25.node +0 -0
  52. package/dist/lib/linux_aarch64/libselva.so +0 -0
  53. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  54. package/dist/lib/linux_x86_64/include/cdefs.h +324 -0
  55. package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
  56. package/dist/lib/linux_x86_64/include/libdeflate.h +345 -0
  57. package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
  58. package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
  59. package/dist/lib/linux_x86_64/include/queue.h +627 -0
  60. package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
  61. package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
  62. package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
  63. package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
  64. package/dist/lib/linux_x86_64/include/selva/colvec.h +71 -0
  65. package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
  66. package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
  67. package/dist/lib/linux_x86_64/include/selva/db.h +450 -0
  68. package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
  69. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +27 -0
  70. package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
  71. package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
  72. package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
  73. package/dist/lib/linux_x86_64/include/selva/fields.h +341 -0
  74. package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
  75. package/dist/lib/linux_x86_64/include/selva/hll.h +85 -0
  76. package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
  77. package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
  78. package/dist/lib/linux_x86_64/include/selva/membar.h +32 -0
  79. package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
  80. package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
  81. package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
  82. package/dist/lib/linux_x86_64/include/selva/selva_lang.h +112 -0
  83. package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
  84. package/dist/lib/linux_x86_64/include/selva/selva_string.h +683 -0
  85. package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
  86. package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
  87. package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
  88. package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
  89. package/dist/lib/linux_x86_64/include/selva/types.h +115 -0
  90. package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
  91. package/dist/lib/linux_x86_64/include/selva_error.h +140 -0
  92. package/dist/lib/linux_x86_64/include/selva_lang_code.h +160 -0
  93. package/dist/lib/linux_x86_64/include/tree.h +852 -0
  94. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  95. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  96. package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
  97. package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
  98. package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
  99. package/dist/lib/linux_x86_64/libnode-v25.node +0 -0
  100. package/dist/lib/linux_x86_64/libselva.so +0 -0
  101. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  102. package/package.json +1 -1
@@ -0,0 +1,450 @@
1
+ /*
2
+ * Copyright (c) 2024-2025 SAULX
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ #pragma once
6
+
7
+ #include <assert.h>
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+ #include <sys/types.h>
11
+ #include "selva/_export.h"
12
+ #include "selva/types.h"
13
+
14
+ /*
15
+ * TODO Don't like this one but it compiles.
16
+ * We should have something with selva_hash_state;
17
+ */
18
+ struct XXH3_state_s;
19
+
20
+ struct selva_dump_common_data {
21
+ /**
22
+ * Pointer to data returned here when loading; Data read from here when saving.
23
+ */
24
+ const void *meta_data __pcounted_by(meta_len);
25
+ size_t meta_len;
26
+
27
+ /**
28
+ * Can be nullptr. Also set errlog_size to 0.
29
+ */
30
+ char *errlog_buf __pcounted_by(errlog_size);
31
+ size_t errlog_size;
32
+ };
33
+
34
+ /**
35
+ * Create a new DB instance.
36
+ */
37
+ SELVA_EXPORT
38
+ struct SelvaDb *selva_db_create(void);
39
+
40
+ /**
41
+ * Destroy a DB instance.
42
+ */
43
+ SELVA_EXPORT
44
+ void selva_db_destroy(struct SelvaDb *db) __attribute__((nonnull));
45
+
46
+ /**
47
+ * Create a new node type with a schema.
48
+ * @param type must not exist before.
49
+ */
50
+ SELVA_EXPORT
51
+ int selva_db_create_type(struct SelvaDb *db, node_type_t type, const uint8_t *schema_buf, size_t schema_len) __attribute__((nonnull));
52
+
53
+ /**
54
+ * Save the common/shared data of the database.
55
+ */
56
+ SELVA_EXPORT
57
+ int selva_dump_save_common(struct SelvaDb *db, struct selva_dump_common_data *com, const char *filename) __attribute__((nonnull));
58
+
59
+ /**
60
+ * Save a nodes block starting from start.
61
+ */
62
+ SELVA_EXPORT
63
+ int selva_dump_save_block(struct SelvaDb *db, struct SelvaTypeEntry *te, const char *filename, node_id_t start, selva_hash128_t *range_hash_out) __attribute__((nonnull));
64
+
65
+ /**
66
+ * **Usage:**
67
+ * ```c
68
+ * struct SelvaDb *db = selva_db_create();
69
+ * selva_dump_load_common(db, filename_common);
70
+ * selva_dump_load_block(db, filename_range_n);
71
+ * ```
72
+ */
73
+ SELVA_EXPORT
74
+ int selva_dump_load_common(struct SelvaDb *db, struct selva_dump_common_data *com, const char *filename) __attribute__((nonnull));
75
+
76
+ SELVA_EXPORT
77
+ int selva_dump_load_block(struct SelvaDb *db, const char *filename, char *errlog_buf, size_t errlog_size) __attribute__((nonnull));
78
+
79
+ /**
80
+ * Find a type by type id.
81
+ */
82
+ SELVA_EXPORT
83
+ struct SelvaTypeEntry *selva_get_type_by_index(const struct SelvaDb *db, node_type_t type) __attribute__((nonnull));
84
+
85
+ /**
86
+ * Get the type for node.
87
+ */
88
+ SELVA_EXPORT
89
+ struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct SelvaNode *node) __attribute__((nonnull, pure));
90
+
91
+ SELVA_EXPORT
92
+ inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
93
+ #ifndef __zig
94
+ {
95
+ return te->blocks->block_capacity;
96
+ }
97
+ #else
98
+ ;
99
+ #endif
100
+
101
+ inline block_id_t selva_node_id2block_i3(block_id_t block_capacity, node_id_t node_id)
102
+ {
103
+ assert(node_id > 0);
104
+ return ((node_id - 1) - ((node_id - 1) % block_capacity)) / block_capacity;
105
+ }
106
+
107
+ SELVA_EXPORT
108
+ inline block_id_t selva_node_id2block_i(const struct SelvaTypeBlocks *blocks, node_id_t node_id)
109
+ #ifndef __zig
110
+ {
111
+ return selva_node_id2block_i3(blocks->block_capacity, node_id);
112
+ }
113
+ #else
114
+ ;
115
+ #endif
116
+
117
+ SELVA_EXPORT
118
+ inline block_id_t selva_node_id2block_i2(const struct SelvaTypeEntry *te, node_id_t node_id)
119
+ #ifndef __zig
120
+ {
121
+ return selva_node_id2block_i(te->blocks, node_id);
122
+ }
123
+ #else
124
+ ;
125
+ #endif
126
+
127
+ /**
128
+ * Get the node schema for type.
129
+ */
130
+ SELVA_EXPORT
131
+ __attribute__((nonnull, pure))
132
+ inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
133
+ #ifndef __zig
134
+ {
135
+ return &te->ns;
136
+ }
137
+ #else
138
+ ;
139
+ #endif
140
+
141
+ SELVA_EXPORT
142
+ inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
143
+ #ifndef __zig
144
+ {
145
+ if (!fields_schema || field >= fields_schema->nr_fields) {
146
+ return nullptr;
147
+ }
148
+
149
+ return &fields_schema->field_schemas[field];
150
+ }
151
+ #else
152
+ ;
153
+ #endif
154
+
155
+ /**
156
+ * Get the field schema for field.
157
+ */
158
+ SELVA_EXPORT
159
+ __attribute__((nonnull, pure))
160
+ inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
161
+ #ifndef __zig
162
+ {
163
+ return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
164
+ }
165
+ #else
166
+ ;
167
+ #endif
168
+
169
+ /**
170
+ * Get the field schema for field.
171
+ */
172
+ SELVA_EXPORT
173
+ __attribute__((nonnull, pure))
174
+ inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
175
+ #ifndef __zig
176
+ {
177
+ return get_fs_by_fields_schema_field(&ns->fields_schema, field);
178
+ }
179
+ #else
180
+ ;
181
+ #endif
182
+
183
+ /**
184
+ * Get the field schema for field.
185
+ */
186
+ SELVA_EXPORT
187
+ __attribute__((nonnull, pure))
188
+ inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
189
+ #ifndef __zig
190
+ {
191
+ struct SelvaTypeEntry *type;
192
+
193
+ type = selva_get_type_by_node(db, node);
194
+ if (!type) {
195
+ return nullptr;
196
+ }
197
+
198
+ return selva_get_fs_by_ns_field(&type->ns, field);
199
+ }
200
+ #else
201
+ ;
202
+ #endif
203
+
204
+ SELVA_EXPORT
205
+ #if __has_c_attribute(reproducible)
206
+ [[reproducible]]
207
+ #endif
208
+ inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
209
+ #ifndef __zig
210
+ {
211
+ return fs->type;
212
+ }
213
+ #else
214
+ ;
215
+ #endif
216
+
217
+ /**
218
+ * Get the EdgeFieldConstraint from a ref field schema.
219
+ * struct EdgeFieldConstraint *efc = selva_get_edge_field_constraint(src_fs);
220
+ * struct SelvaTypeEntry *dst_type = selva_get_type_by_index(db, efc->dst_node_type);
221
+ * struct SelvaFieldSchema *dst_fs = selva_get_fs_by_node(db, dst, efc->inverse_field);
222
+ */
223
+ SELVA_EXPORT
224
+ __attribute__((returns_nonnull))
225
+ __attribute__((nonnull))
226
+ inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
227
+ #ifndef __zig
228
+ {
229
+ assert(fs->type == SELVA_FIELD_TYPE_REFERENCE ||
230
+ fs->type == SELVA_FIELD_TYPE_REFERENCES);
231
+ return &fs->edge_constraint;
232
+ }
233
+ #else
234
+ ;
235
+ #endif
236
+
237
+ SELVA_EXPORT
238
+ inline const struct SelvaFieldsSchema *selva_get_edge_field_fields_schema(struct SelvaDb *db, const struct EdgeFieldConstraint *efc)
239
+ #ifndef __zig
240
+ {
241
+ struct SelvaTypeEntry *te = selva_get_type_by_index(db, efc->meta_node_type);
242
+
243
+ return (te) ? &selva_get_ns_by_te(te)->fields_schema : nullptr;
244
+ }
245
+ #else
246
+ ;
247
+ #endif
248
+
249
+ /**
250
+ * Strategy for adding new node expires.
251
+ */
252
+ enum selva_expire_node_strategy {
253
+ /**
254
+ * Ignore any existing expire and just add a new one.
255
+ */
256
+ SELVA_EXPIRE_NODE_STRATEGY_IGNORE = 0,
257
+ /**
258
+ * Cancel adding an expire if one already exists.
259
+ */
260
+ SELVA_EXPIRE_NODE_STRATEGY_CANCEL = 1,
261
+ /**
262
+ * Cancel the previous expire before adding a new one.
263
+ * TODO This will currently only cancel one previous hit.
264
+ */
265
+ SELVA_EXPIRE_NODE_STRATEGY_CANCEL_OLD = 2,
266
+ };
267
+
268
+ SELVA_EXPORT
269
+ void selva_expire_node(struct SelvaDb *db, node_type_t type, node_id_t node_id, int64_t ts, enum selva_expire_node_strategy stg);
270
+
271
+ SELVA_EXPORT
272
+ void selva_expire_node_cancel(struct SelvaDb *db, node_type_t type, node_id_t node_id);
273
+
274
+ SELVA_EXPORT
275
+ void selva_db_expire_tick(struct SelvaDb *db, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx, int64_t now);
276
+
277
+ /**
278
+ * Delete a node.
279
+ * @param dirty_cb is called for any newly dirty nodes in addition to the node being deleted.
280
+ */
281
+ SELVA_EXPORT
282
+ void selva_del_node(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx) __attribute__((nonnull(1, 2, 3)));
283
+
284
+ SELVA_EXPORT
285
+ void selva_flush_node(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx);
286
+
287
+ SELVA_EXPORT
288
+ void selva_del_block(struct SelvaDb *db, struct SelvaTypeEntry *te, node_id_t start);
289
+
290
+ /**
291
+ * Get a node by id.
292
+ */
293
+ SELVA_EXPORT
294
+ struct SelvaNode *selva_find_node(struct SelvaTypeEntry *type, node_id_t node_id) __attribute__((nonnull));
295
+
296
+ /**
297
+ * Find the first node greater than or equal to the provided id, or NULL.
298
+ */
299
+ SELVA_EXPORT
300
+ struct SelvaNode *selva_nfind_node(struct SelvaTypeEntry *type, node_id_t node_id) __attribute__((nonnull));
301
+
302
+ /**
303
+ * Get or create a node by id.
304
+ */
305
+ SELVA_EXPORT
306
+ struct SelvaNode *selva_upsert_node(struct SelvaDb *db, struct SelvaTypeEntry *type, node_id_t node_id) __attribute__((nonnull));
307
+
308
+ /**
309
+ * **Example**
310
+ * ```c
311
+ * for (struct SelvaNode *np = selva_min_node(type); np; np = selva_next_node(type, np))
312
+ * ```
313
+ */
314
+ SELVA_EXPORT
315
+ struct SelvaNode *selva_min_node(struct SelvaTypeEntry *type) __attribute__((nonnull));
316
+
317
+ /**
318
+ * **Example**
319
+ * ```c
320
+ * for (struct SelvaNode *np = selva_max_node(type); np; np = selva_prev_node(type, np))
321
+ * ```
322
+ */
323
+ SELVA_EXPORT
324
+ struct SelvaNode *selva_max_node(struct SelvaTypeEntry *type) __attribute__((nonnull));
325
+
326
+ /**
327
+ * Get previous node with a lower node id.
328
+ */
329
+ SELVA_EXPORT
330
+ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
331
+
332
+ /**
333
+ * Get next node with higher node id.
334
+ */
335
+ SELVA_EXPORT
336
+ struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
337
+
338
+ /**
339
+ * Total count of nodes of type.
340
+ */
341
+ SELVA_EXPORT
342
+ size_t selva_node_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
343
+
344
+ /**
345
+ * Get the node id of of node.
346
+ */
347
+ SELVA_EXPORT
348
+ __attribute__((nonnull, pure))
349
+ inline node_id_t selva_get_node_id(const struct SelvaNode *node)
350
+ #ifndef __zig
351
+ {
352
+ return node->node_id;
353
+ }
354
+ #else
355
+ ;
356
+ #endif
357
+
358
+ /**
359
+ * Get the type of of node.
360
+ */
361
+ SELVA_EXPORT
362
+ __attribute__((nonnull, pure))
363
+ inline node_type_t selva_get_node_type(const struct SelvaNode *node)
364
+ #ifndef __zig
365
+ {
366
+ return node->type;
367
+ }
368
+ #else
369
+ ;
370
+ #endif
371
+
372
+ /**
373
+ * \addtogroup node_hash
374
+ * @{
375
+ */
376
+
377
+ /**
378
+ * Calculate the node hash.
379
+ * Update node hash by using a temp hash state allocated earlier.
380
+ * @param tmp_hash_state is only used for computation and it's reset before use.
381
+ */
382
+ SELVA_EXPORT
383
+ selva_hash128_t selva_node_hash_update(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node, struct XXH3_state_s *tmp_hash_state);
384
+
385
+ SELVA_EXPORT
386
+ selva_hash128_t selva_node_hash(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node);
387
+
388
+ SELVA_EXPORT
389
+ int selva_node_hash_range(struct SelvaDb *db, struct SelvaTypeEntry *type, node_id_t start, node_id_t end, selva_hash128_t *hash_out) __attribute__((nonnull, warn_unused_result));
390
+
391
+ /**
392
+ * @}
393
+ */
394
+
395
+ /**
396
+ * Get the number of aliases under given type.
397
+ */
398
+ SELVA_EXPORT
399
+ size_t selva_alias_count(const struct SelvaAliases *aliases);
400
+
401
+ /**
402
+ * Set new alias.
403
+ * @param name is copied.
404
+ * @returns the previous node_id the alias was pointing to; Otherwise 0.
405
+ */
406
+ SELVA_EXPORT
407
+ node_id_t selva_set_alias(struct SelvaAliases *aliases, node_id_t dest, const char *name_str, size_t name_len);
408
+
409
+ /**
410
+ * Delete alias by name.
411
+ * @return the destination node_id the alias was pointing to; 0 if SELVA_ENOENT.
412
+ */
413
+ SELVA_EXPORT
414
+ node_id_t selva_del_alias_by_name(struct SelvaAliases *aliases, const char *name_str, size_t name_len);
415
+
416
+ /**
417
+ * Delete all aliases pointing to dest.
418
+ */
419
+ SELVA_EXPORT
420
+ void selva_del_alias_by_dest(struct SelvaAliases *aliases, node_id_t dest);
421
+
422
+ /**
423
+ * Get alias by name.
424
+ */
425
+ SELVA_EXPORT
426
+ struct SelvaNode *selva_get_alias(struct SelvaTypeEntry *type, struct SelvaAliases *aliases, const char *name_str, size_t name_len);
427
+
428
+ /**
429
+ * Get alias by destination id.
430
+ * This may not seem very useful but this is actually the way that allows you to
431
+ * traverse all aliases to the given node_id by following the `next` pointer or
432
+ * by calling selva_get_next_alias().
433
+ */
434
+ SELVA_EXPORT
435
+ const struct SelvaAlias *selva_get_alias_by_dest(struct SelvaAliases *aliases, node_id_t dest);
436
+
437
+ SELVA_EXPORT
438
+ const struct SelvaAlias *selva_get_next_alias(const struct SelvaAlias *alias);
439
+
440
+ SELVA_EXPORT
441
+ const char *selva_get_alias_name(const struct SelvaAlias *alias, size_t *len) __attribute__((nonnull, pure));
442
+
443
+ SELVA_EXPORT
444
+ struct SelvaAliases *selva_get_aliases(struct SelvaTypeEntry *type, field_t field);
445
+
446
+ /***
447
+ * Remove all aliases to the given node_id.
448
+ */
449
+ SELVA_EXPORT
450
+ void selva_remove_all_aliases(struct SelvaTypeEntry *type, node_id_t node_id);