MCPcopy Create free account
hub / github.com/HelenOS/helenos / struct_node_get

Function struct_node_get

uspace/lib/bithenge/src/sequence.c:372–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372static errno_t struct_node_get(bithenge_node_t *base, bithenge_node_t *key,
373 bithenge_node_t **out)
374{
375 struct_node_t *self = node_as_struct(base);
376
377 errno_t rc = ENOENT;
378 if (bithenge_node_type(key) != BITHENGE_NODE_STRING)
379 goto end;
380 const char *name = bithenge_string_node_value(key);
381
382 const bithenge_named_transform_t *subxforms =
383 self->transform->subtransforms;
384 for (bithenge_int_t i = 0; subxforms[i].transform; i++) {
385 if (subxforms[i].name && !str_cmp(name, subxforms[i].name)) {
386 rc = seq_node_subtransform(struct_as_seq(self), out, i);
387 goto end;
388 }
389 }
390
391 for (bithenge_int_t i = 0; subxforms[i].transform; i++) {
392 if (subxforms[i].name)
393 continue;
394 bithenge_node_t *subxform_result;
395 rc = seq_node_subtransform(struct_as_seq(self),
396 &subxform_result, i);
397 if (rc != EOK)
398 goto end;
399 if (bithenge_node_type(subxform_result) !=
400 BITHENGE_NODE_INTERNAL) {
401 bithenge_node_dec_ref(subxform_result);
402 rc = EINVAL;
403 goto end;
404 }
405 bithenge_node_inc_ref(key);
406 rc = bithenge_node_get(subxform_result, key, out);
407 bithenge_node_dec_ref(subxform_result);
408 if (rc != ENOENT)
409 goto end;
410 }
411
412 rc = ENOENT;
413end:
414 bithenge_node_dec_ref(key);
415 return rc;
416}
417
418static void struct_node_destroy(bithenge_node_t *base)
419{

Callers

nothing calls this directly

Calls 9

node_as_structFunction · 0.85
bithenge_node_typeFunction · 0.85
seq_node_subtransformFunction · 0.85
struct_as_seqFunction · 0.85
bithenge_node_dec_refFunction · 0.85
bithenge_node_inc_refFunction · 0.85
bithenge_node_getFunction · 0.85
str_cmpFunction · 0.50

Tested by

no test coverage detected