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

Function arch_entry_points

src/store/store.c:5561–5612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5559}
5560
5561static int arch_entry_points(cbm_store_t *s, const char *project, const char *path,
5562 cbm_architecture_info_t *out) {
5563 char norm[CBM_SZ_512];
5564 char like[CBM_SZ_512];
5565 bool scoped = arch_path_prepare(path, norm, sizeof(norm), like, sizeof(like));
5566 char sqlbuf[ST_SQL_BUF];
5567 const char *base = "SELECT name, qualified_name, file_path FROM nodes "
5568 "WHERE project=?1 AND json_extract(properties, '$.is_entry_point') = 1 "
5569 "AND (json_extract(properties, '$.is_test') IS NULL OR "
5570 "json_extract(properties, '$.is_test') != 1) "
5571 "AND file_path NOT LIKE '%test%'";
5572 if (scoped) {
5573 snprintf(sqlbuf, sizeof(sqlbuf), "%s%s LIMIT 20", base, arch_path_scope_sql());
5574 } else {
5575 snprintf(sqlbuf, sizeof(sqlbuf), "%s LIMIT 20", base);
5576 }
5577 sqlite3_stmt *stmt = NULL;
5578 if (sqlite3_prepare_v2(s->db, sqlbuf, CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) {
5579 store_set_error_sqlite(s, "arch_entry_points");
5580 return CBM_STORE_ERR;
5581 }
5582 bind_text(stmt, SKIP_ONE, project);
5583 if (scoped) {
5584 arch_bind_path_scope(stmt, ST_COL_2, ST_COL_3, norm, like);
5585 }
5586
5587 int cap = ST_INIT_CAP_8;
5588 int n = 0;
5589 cbm_entry_point_t *arr = calloc(cap, sizeof(cbm_entry_point_t));
5590 int scan_rc21;
5591 while ((scan_rc21 = sqlite3_step(stmt)) == SQLITE_ROW) {
5592 if (n >= cap) {
5593 cap *= ST_GROWTH;
5594 arr = safe_realloc(arr, cap * sizeof(cbm_entry_point_t));
5595 }
5596 arr[n].name = heap_strdup((const char *)sqlite3_column_text(stmt, 0));
5597 arr[n].qualified_name = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE));
5598 arr[n].file = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_2));
5599 n++;
5600 }
5601 if (scan_rc21 != SQLITE_DONE) { /* SCANCHK:21:stmt */
5602 store_set_error_sqlite(s, "row scan aborted");
5603 sqlite3_finalize(stmt);
5604 out->entry_points = arr;
5605 out->entry_point_count = n;
5606 return CBM_STORE_ERR;
5607 }
5608 sqlite3_finalize(stmt);
5609 out->entry_points = arr;
5610 out->entry_point_count = n;
5611 return CBM_STORE_OK;
5612}
5613
5614/* Extract a JSON string value from a simple JSON object by key name. */
5615static char *extract_json_string_prop(const char *json, const char *key, int key_len) {

Callers 1

Calls 7

arch_path_prepareFunction · 0.85
arch_path_scope_sqlFunction · 0.85
store_set_error_sqliteFunction · 0.85
bind_textFunction · 0.85
arch_bind_path_scopeFunction · 0.85
safe_reallocFunction · 0.85
heap_strdupFunction · 0.70

Tested by

no test coverage detected