GET /api/why?project=X&id=N|qn=Q&dir=up|down — the trigger tree. */
| 2841 | |
| 2842 | /* GET /api/why?project=X&id=N|qn=Q&dir=up|down — the trigger tree. */ |
| 2843 | static void handle_atlas_why(cbm_http_conn_t *c, const cbm_http_req_t *req) { |
| 2844 | char project[256] = {0}; |
| 2845 | cbm_store_t *store = atlas_open_project(c, req, project, sizeof(project)); |
| 2846 | if (!store) |
| 2847 | return; |
| 2848 | char idbuf[32] = {0}; |
| 2849 | char qn[1024] = {0}; |
| 2850 | char dir[8] = {0}; |
| 2851 | cbm_http_query_param(req->query, "id", idbuf, (int)sizeof(idbuf)); |
| 2852 | cbm_http_query_param(req->query, "qn", qn, (int)sizeof(qn)); |
| 2853 | cbm_http_query_param(req->query, "dir", dir, (int)sizeof(dir)); |
| 2854 | if (!idbuf[0] && !qn[0]) { |
| 2855 | cbm_store_close(store); |
| 2856 | cbm_http_replyf(c, 400, g_cors_json, "{\"error\":\"missing id or qn parameter\"}"); |
| 2857 | return; |
| 2858 | } |
| 2859 | int64_t id = idbuf[0] ? strtoll(idbuf, NULL, 10) : -1; |
| 2860 | bool upward = strcmp(dir, "down") != 0; |
| 2861 | char *json = cbm_atlas_why_json(store, project, id, qn[0] ? qn : NULL, upward); |
| 2862 | cbm_store_close(store); |
| 2863 | atlas_reply_json(c, json, 404, "{\"error\":\"symbol not found\"}"); |
| 2864 | } |
| 2865 | |
| 2866 | /* GET /api/handout?project=X — the self-contained newcomer document. */ |
| 2867 | static void handle_atlas_handout(cbm_http_conn_t *c, const cbm_http_req_t *req) { |
no test coverage detected