Extract PSR-4 autoload entries from composer.json root. */
| 438 | |
| 439 | /* Extract PSR-4 autoload entries from composer.json root. */ |
| 440 | static void extract_psr4(yyjson_val *root, const char *dir, cbm_pkg_entries_t *entries) { |
| 441 | yyjson_val *autoload = yyjson_obj_get(root, "autoload"); |
| 442 | if (!yyjson_is_obj(autoload)) { |
| 443 | return; |
| 444 | } |
| 445 | yyjson_val *psr4 = yyjson_obj_get(autoload, "psr-4"); |
| 446 | if (!yyjson_is_obj(psr4)) { |
| 447 | return; |
| 448 | } |
| 449 | yyjson_val *key = NULL; |
| 450 | yyjson_obj_iter iter = yyjson_obj_iter_with(psr4); |
| 451 | while ((key = yyjson_obj_iter_next(&iter)) != NULL) { |
| 452 | yyjson_val *val = yyjson_obj_iter_get_val(key); |
| 453 | if (!yyjson_is_str(key) || !yyjson_is_str(val)) { |
| 454 | continue; |
| 455 | } |
| 456 | const char *ns_prefix = yyjson_get_str(key); |
| 457 | const char *ns_dir = yyjson_get_str(val); |
| 458 | char ns_entry[PKGMAP_PATH_BUF]; |
| 459 | if (dir[0]) { |
| 460 | snprintf(ns_entry, sizeof(ns_entry), "%s/%s", dir, ns_dir); |
| 461 | } else { |
| 462 | snprintf(ns_entry, sizeof(ns_entry), "%s", ns_dir); |
| 463 | } |
| 464 | size_t nelen = strlen(ns_entry); |
| 465 | if (nelen > 0 && ns_entry[nelen - SKIP_ONE] == '/') { |
| 466 | ns_entry[nelen - SKIP_ONE] = '\0'; |
| 467 | } |
| 468 | pkg_entries_push(entries, strdup(ns_prefix), strdup(ns_entry)); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | /* PHP: composer.json — name + PSR-4 autoload */ |
| 473 | static void parse_composer_json(const char *source, int source_len, const char *rel_path, |
no test coverage detected