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

Function arch_entry_points

src/store/store.c:3725–3768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3723}
3724
3725static int arch_entry_points(cbm_store_t *s, const char *project, const char *path,
3726 cbm_architecture_info_t *out) {
3727 char norm[CBM_SZ_512];
3728 char like[CBM_SZ_512];
3729 bool scoped = arch_path_prepare(path, norm, sizeof(norm), like, sizeof(like));
3730 char sqlbuf[ST_SQL_BUF];
3731 const char *base = "SELECT name, qualified_name, file_path FROM nodes "
3732 "WHERE project=?1 AND json_extract(properties, '$.is_entry_point') = 1 "
3733 "AND (json_extract(properties, '$.is_test') IS NULL OR "
3734 "json_extract(properties, '$.is_test') != 1) "
3735 "AND file_path NOT LIKE '%test%'";
3736 if (scoped) {
3737 snprintf(sqlbuf, sizeof(sqlbuf), "%s%s LIMIT 20", base, arch_path_scope_sql());
3738 } else {
3739 snprintf(sqlbuf, sizeof(sqlbuf), "%s LIMIT 20", base);
3740 }
3741 sqlite3_stmt *stmt = NULL;
3742 if (sqlite3_prepare_v2(s->db, sqlbuf, CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) {
3743 store_set_error_sqlite(s, "arch_entry_points");
3744 return CBM_STORE_ERR;
3745 }
3746 bind_text(stmt, SKIP_ONE, project);
3747 if (scoped) {
3748 arch_bind_path_scope(stmt, ST_COL_2, ST_COL_3, norm, like);
3749 }
3750
3751 int cap = ST_INIT_CAP_8;
3752 int n = 0;
3753 cbm_entry_point_t *arr = calloc(cap, sizeof(cbm_entry_point_t));
3754 while (sqlite3_step(stmt) == SQLITE_ROW) {
3755 if (n >= cap) {
3756 cap *= ST_GROWTH;
3757 arr = safe_realloc(arr, cap * sizeof(cbm_entry_point_t));
3758 }
3759 arr[n].name = heap_strdup((const char *)sqlite3_column_text(stmt, 0));
3760 arr[n].qualified_name = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE));
3761 arr[n].file = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_2));
3762 n++;
3763 }
3764 sqlite3_finalize(stmt);
3765 out->entry_points = arr;
3766 out->entry_point_count = n;
3767 return CBM_STORE_OK;
3768}
3769
3770/* Extract a JSON string value from a simple JSON object by key name. */
3771static 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