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

Function arch_entry_points

src/store/store.c:5772–5823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5770}
5771
5772static int arch_entry_points(cbm_store_t *s, const char *project, const char *path,
5773 cbm_architecture_info_t *out) {
5774 char norm[CBM_SZ_512];
5775 char like[CBM_SZ_512];
5776 bool scoped = arch_path_prepare(path, norm, sizeof(norm), like, sizeof(like));
5777 char sqlbuf[ST_SQL_BUF];
5778 const char *base = "SELECT name, qualified_name, file_path FROM nodes "
5779 "WHERE project=?1 AND json_extract(properties, '$.is_entry_point') = 1 "
5780 "AND (json_extract(properties, '$.is_test') IS NULL OR "
5781 "json_extract(properties, '$.is_test') != 1) "
5782 "AND file_path NOT LIKE '%test%'";
5783 if (scoped) {
5784 snprintf(sqlbuf, sizeof(sqlbuf), "%s%s LIMIT 20", base, arch_path_scope_sql());
5785 } else {
5786 snprintf(sqlbuf, sizeof(sqlbuf), "%s LIMIT 20", base);
5787 }
5788 sqlite3_stmt *stmt = NULL;
5789 if (sqlite3_prepare_v2(s->db, sqlbuf, CBM_NOT_FOUND, &stmt, NULL) != SQLITE_OK) {
5790 store_set_error_sqlite(s, "arch_entry_points");
5791 return CBM_STORE_ERR;
5792 }
5793 bind_text(stmt, SKIP_ONE, project);
5794 if (scoped) {
5795 arch_bind_path_scope(stmt, ST_COL_2, ST_COL_3, norm, like);
5796 }
5797
5798 int cap = ST_INIT_CAP_8;
5799 int n = 0;
5800 cbm_entry_point_t *arr = calloc(cap, sizeof(cbm_entry_point_t));
5801 int scan_rc21;
5802 while ((scan_rc21 = sqlite3_step(stmt)) == SQLITE_ROW) {
5803 if (n >= cap) {
5804 cap *= ST_GROWTH;
5805 arr = safe_realloc(arr, cap * sizeof(cbm_entry_point_t));
5806 }
5807 arr[n].name = heap_strdup((const char *)sqlite3_column_text(stmt, 0));
5808 arr[n].qualified_name = heap_strdup((const char *)sqlite3_column_text(stmt, SKIP_ONE));
5809 arr[n].file = heap_strdup((const char *)sqlite3_column_text(stmt, CBM_SZ_2));
5810 n++;
5811 }
5812 if (scan_rc21 != SQLITE_DONE) { /* SCANCHK:21:stmt */
5813 store_set_error_sqlite(s, "row scan aborted");
5814 sqlite3_finalize(stmt);
5815 out->entry_points = arr;
5816 out->entry_point_count = n;
5817 return CBM_STORE_ERR;
5818 }
5819 sqlite3_finalize(stmt);
5820 out->entry_points = arr;
5821 out->entry_point_count = n;
5822 return CBM_STORE_OK;
5823}
5824
5825/* Extract a JSON string value from a simple JSON object by key name. */
5826static 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