MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cif_root

Function cif_root

src/discover/inventory_metadata.c:38–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36#endif
37
38static bool cif_root(cif_context *c, size_t *length) {
39 const unsigned char *root = (const unsigned char *)c->source->native_root;
40 size_t n = 0;
41 for (; n <= CIF_PATH_MAX; n++) {
42 if (!cif_bytes(c, 1)) {
43 return false;
44 }
45 if (!root[n]) {
46 break;
47 }
48 }
49 if (!n) {
50 return cif_fail(c, CBM_INVENTORY_INVALID);
51 }
52 if (n > CIF_PATH_MAX) {
53 return cif_fail(c, CBM_INVENTORY_LIMIT);
54 }
55#ifdef _WIN32
56 if (cif_device_root(root, n)) {
57 return cif_fail(c, CBM_INVENTORY_UNSUPPORTED);
58 }
59 if (!cif_poll(c)) {
60 return false;
61 }
62 if (cbm_path_windows_absolute((const char *)root, n) != CBM_PATH_SYNTAX_OK) {
63 return cif_fail(c, CBM_INVENTORY_INVALID);
64 }
65 if (!cif_poll(c) || !cif_windows_encoding(c, (const char *)root, n)) {
66 return false;
67 }
68#else
69 if (root[0] != '/') {
70 return cif_fail(c, CBM_INVENTORY_INVALID);
71 }
72#endif
73 *length = n;
74 c->owner->view.native_root = (const char *)cif_string(c, root, n);
75 return c->owner->view.native_root != NULL;
76}
77
78static bool cif_component(cif_context *c, const unsigned char *p, size_t n) {
79 if (!n || (n == 1 && p[0] == '.') || (n == 2 && p[0] == '.' && p[1] == '.')) {

Callers 1

cif_metadataFunction · 0.85

Calls 7

cif_bytesFunction · 0.85
cif_failFunction · 0.85
cif_device_rootFunction · 0.85
cif_pollFunction · 0.85
cif_windows_encodingFunction · 0.85
cif_stringFunction · 0.85

Tested by

no test coverage detected