Merge pull request #3320 from kormax/calypso-node-database

Add calypso node database json
This commit is contained in:
Iceman authored and GitHub committed 2026-05-20 18:06:45 +02:00
commit e68b721a78
2 files changed
+912 -97

No files matched your search

+810
View File
@@ -0,0 +1,810 @@
[
{
"name": "ICC",
"sfi": "02",
"path": [
"0002"
]
},
{
"name": "ID",
"sfi": "03",
"path": [
"0003"
]
},
{
"name": "EP_AID",
"sfi": null,
"path": [
"1000",
"1004"
]
},
{
"name": "EP_LOAD_LOG",
"sfi": "14",
"path": [
"1000",
"1014"
]
},
{
"name": "EP_PURCHASE_LOG",
"sfi": "15",
"path": [
"1000",
"1015"
]
},
{
"name": "TICKETING_ENVIRONMENT",
"sfi": "07",
"path": [
"2000",
"2001"
]
},
{
"name": "TICKETING_HOLDER",
"sfi": null,
"path": [
"2000",
"2002"
]
},
{
"name": "UNKNOWN_EF_2003",
"sfi": "14",
"path": [
"2000",
"2003"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_AID",
"sfi": null,
"path": [
"2000",
"2004"
]
},
{
"name": "TICKETING_LOG",
"sfi": "08",
"path": [
"2000",
"2010"
]
},
{
"name": "UNKNOWN_EF_2011",
"sfi": "13",
"path": [
"2000",
"2011"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_2012",
"sfi": "12",
"path": [
"2000",
"2012"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_2016",
"sfi": "16",
"path": [
"2000",
"2016"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_2017",
"sfi": "17",
"path": [
"2000",
"2017"
],
"description": "Found on CDMX card"
},
{
"name": "UNKNOWN_EF_2018",
"sfi": "18",
"path": [
"2000",
"2018"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_201C",
"sfi": "1C",
"path": [
"2000",
"201C"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_CONTRACTS_1",
"sfi": "09",
"path": [
"2000",
"2020"
]
},
{
"name": "UNKNOWN_EF_2023",
"sfi": "15",
"path": [
"2000",
"2023"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_COUNTERS_1",
"sfi": "0A",
"path": [
"2000",
"202A"
]
},
{
"name": "TICKETING_COUNTERS_2",
"sfi": "0B",
"path": [
"2000",
"202B"
]
},
{
"name": "TICKETING_COUNTERS_3",
"sfi": "0C",
"path": [
"2000",
"202C"
]
},
{
"name": "TICKETING_COUNTERS_4",
"sfi": "0D",
"path": [
"2000",
"202D"
]
},
{
"name": "TICKETING_COUNTERS_5",
"sfi": null,
"path": [
"2000",
"202E"
]
},
{
"name": "TICKETING_COUNTERS_6",
"sfi": null,
"path": [
"2000",
"202F"
]
},
{
"name": "TICKETING_CONTRACTS_2",
"sfi": "06",
"path": [
"2000",
"2030"
]
},
{
"name": "TICKETING_SPECIAL_EVENTS",
"sfi": "1D",
"path": [
"2000",
"2040"
]
},
{
"name": "UNKNOWN_EF_2043",
"sfi": "1A",
"path": [
"2000",
"2043"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_CONTRACT_LIST",
"sfi": "1E",
"path": [
"2000",
"2050"
]
},
{
"name": "TICKETING_COUNTERS_7",
"sfi": null,
"path": [
"2000",
"2060"
]
},
{
"name": "TICKETING_COUNTERS_8",
"sfi": null,
"path": [
"2000",
"2062"
]
},
{
"name": "UNKNOWN_EF_2063",
"sfi": "1B",
"path": [
"2000",
"2063"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_COUNTERS_9",
"sfi": "19",
"path": [
"2000",
"2069"
]
},
{
"name": "TICKETING_COUNTERS_10",
"sfi": "10",
"path": [
"2000",
"206A"
]
},
{
"name": "UNKNOWN_EF_2091",
"sfi": "11",
"path": [
"2000",
"2091"
],
"description": "Found on MOBIB card"
},
{
"name": "TICKETING_FREE",
"sfi": "01",
"path": [
"2000",
"20F0"
]
},
{
"name": "RT2_ENVIRONMENT",
"sfi": null,
"path": [
"2100",
"2101"
]
},
{
"name": "UNKNOWN_EF_2103",
"sfi": "14",
"path": [
"2100",
"2103"
],
"description": "Found on MOBIB card"
},
{
"name": "RT2_AID",
"sfi": null,
"path": [
"2100",
"2104"
]
},
{
"name": "RT2_LOG",
"sfi": null,
"path": [
"2100",
"2110"
]
},
{
"name": "UNKNOWN_EF_2118",
"sfi": "18",
"path": [
"2100",
"2118"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_211C",
"sfi": "1C",
"path": [
"2100",
"211C"
],
"description": "Found on MOBIB card"
},
{
"name": "RT2_CONTRACTS",
"sfi": null,
"path": [
"2100",
"2120"
]
},
{
"name": "UNKNOWN_EF_2123",
"sfi": "15",
"path": [
"2100",
"2123"
],
"description": "Found on MOBIB card"
},
{
"name": "RT2_SPECIAL_EVENTS",
"sfi": null,
"path": [
"2100",
"2140"
]
},
{
"name": "UNKNOWN_EF_2143",
"sfi": "1A",
"path": [
"2100",
"2143"
],
"description": "Found on MOBIB card"
},
{
"name": "RT2_CONTRACT_LIST",
"sfi": null,
"path": [
"2100",
"2150"
]
},
{
"name": "UNKNOWN_EF_2163",
"sfi": "1B",
"path": [
"2100",
"2163"
],
"description": "Found on MOBIB card"
},
{
"name": "RT2_COUNTERS",
"sfi": null,
"path": [
"2100",
"2169"
]
},
{
"name": "RT2_FREE",
"sfi": null,
"path": [
"2100",
"21F0"
]
},
{
"name": "DISPLAY",
"sfi": "05",
"path": [
"2F10"
]
},
{
"name": "UNKNOWN_EF_3101",
"sfi": "00",
"path": [
"3100",
"3101"
],
"description": "Found on Lignes D azur card"
},
{
"name": "MPP_PUBLIC_PARAMETERS",
"sfi": "17",
"path": [
"3100",
"3102"
]
},
{
"name": "MPP_AID",
"sfi": null,
"path": [
"3100",
"3104"
]
},
{
"name": "UNKNOWN_EF_3107",
"sfi": "07",
"path": [
"3100",
"3107"
],
"description": "Found on CDMX card"
},
{
"name": "UNKNOWN_EF_3112",
"sfi": "12",
"path": [
"3100",
"3112"
],
"description": "Found on MOBIB card"
},
{
"name": "MPP_COUNTERS_1",
"sfi": null,
"path": [
"3100",
"3113"
]
},
{
"name": "MPP_LOG",
"sfi": null,
"path": [
"3100",
"3115"
]
},
{
"name": "UNKNOWN_EF_3116",
"sfi": "16",
"path": [
"3100",
"3116"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_311A",
"sfi": "1A",
"path": [
"3100",
"311A"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_311C",
"sfi": "16",
"path": [
"3100",
"311C"
],
"description": "Found on CDMX card"
},
{
"name": "MPP_CONTRACTS",
"sfi": null,
"path": [
"3100",
"3120"
]
},
{
"name": "MPP_COUNTERS_2",
"sfi": null,
"path": [
"3100",
"3123"
]
},
{
"name": "MPP_COUNTERS_3",
"sfi": null,
"path": [
"3100",
"3133"
]
},
{
"name": "MPP_MISCELLANEOUS",
"sfi": null,
"path": [
"3100",
"3150"
]
},
{
"name": "MPP_COUNTERS_4",
"sfi": null,
"path": [
"3100",
"3169"
]
},
{
"name": "MPP_FREE",
"sfi": null,
"path": [
"3100",
"31F0"
]
},
{
"name": "UNKNOWN_EF_3202",
"sfi": "17",
"path": [
"3200",
"3202"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3203",
"sfi": "03",
"path": [
"3200",
"3203"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_3209",
"sfi": "09",
"path": [
"3200",
"3209"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_3214",
"sfi": "14",
"path": [
"3200",
"3214"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_3217",
"sfi": "17",
"path": [
"3200",
"3217"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_3219",
"sfi": "19",
"path": [
"3200",
"3219"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_321A",
"sfi": "1A",
"path": [
"3200",
"321A"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_321B",
"sfi": "1B",
"path": [
"3200",
"321B"
],
"description": "Found on Lignes D azur card"
},
{
"name": "UNKNOWN_EF_3220",
"sfi": "18",
"path": [
"3200",
"3220"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3250",
"sfi": "1B",
"path": [
"3200",
"3250"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3269",
"sfi": "19",
"path": [
"3200",
"3269"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3302",
"sfi": "17",
"path": [
"3300",
"3302"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3320",
"sfi": "18",
"path": [
"3300",
"3320"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3350",
"sfi": "1B",
"path": [
"3300",
"3350"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3369",
"sfi": "19",
"path": [
"3300",
"3369"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3402",
"sfi": "17",
"path": [
"3400",
"3402"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3420",
"sfi": "18",
"path": [
"3400",
"3420"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3450",
"sfi": "1B",
"path": [
"3400",
"3450"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3469",
"sfi": "19",
"path": [
"3400",
"3469"
],
"description": "Found on MOBIB card"
},
{
"name": "AID",
"sfi": "04",
"path": [
"3F04"
]
},
{
"name": "UNKNOWN_EF_3F05",
"sfi": "05",
"path": [
"3F05"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_3F06",
"sfi": "06",
"path": [
"3F06"
],
"description": "Found on MOBIB card"
},
{
"name": "HOLDER_EXTENDED",
"sfi": null,
"path": [
"3F1C"
]
},
{
"name": "UNKNOWN_EF_4101",
"sfi": "01",
"path": [
"4100",
"4101"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_4102",
"sfi": "17",
"path": [
"4100",
"4102"
],
"description": "Found on MOBIB card"
},
{
"name": "UNKNOWN_EF_4150",
"sfi": "1B",
"path": [
"4100",
"4150"
],
"description": "Found on MOBIB card"
},
{
"name": "ETICKET",
"sfi": null,
"path": [
"8000",
"8004"
]
},
{
"name": "ETICKET_EVENT_LOGS",
"sfi": null,
"path": [
"8000",
"8010"
]
},
{
"name": "ETICKET_PRESELECTION",
"sfi": null,
"path": [
"8000",
"8030"
]
},
{
"name": "UNKNOWN_EF_CAFE",
"sfi": "00",
"path": [
"CAFE"
],
"description": "Found on Navigo card"
}
]
+102 -97
View File
@@ -69,6 +69,7 @@
#define CALYPSO_MANUFACTURERS_RESOURCE "calypso/manufacturers"
#define CALYPSO_IC_FAMILIES_RESOURCE "calypso/ic_families"
#define CALYPSO_OPERATORS_RESOURCE "calypso/operators"
#define CALYPSO_NODES_RESOURCE "calypso/nodes"
#define CALYPSO_DUMP_PATH_MAX 2
// https://docs.keyple.org/keyple-card-calypso-cpp-lib/2.2.5.6/_cmd_card_select_file_8cpp_source.html
#define CALYPSO_SELECT_FIRST_EF_P1 0x02
@@ -229,6 +230,7 @@ typedef struct {
static calypso_resource_t calypso_manufacturers_resource = {CALYPSO_MANUFACTURERS_RESOURCE, NULL, false};
static calypso_resource_t calypso_ic_families_resource = {CALYPSO_IC_FAMILIES_RESOURCE, NULL, false};
static calypso_resource_t calypso_operators_resource = {CALYPSO_OPERATORS_RESOURCE, NULL, false};
static calypso_resource_t calypso_nodes_resource = {CALYPSO_NODES_RESOURCE, NULL, false};
static const char *calypso_json_lookup_name(calypso_resource_t *resource, uint32_t id);
static void calypso_set_selected_result(bool is_implicitly_selected, const uint8_t *aid, size_t aid_len, bool has_df_lid, uint16_t df_lid, const calypso_rf_info_t *rf, const uint8_t *fci_data, size_t fci_len, uint16_t sw, const calypso_fci_t *fci, calypso_select_result_t *selected);
@@ -242,81 +244,6 @@ static void calypso_print_rf_info(const calypso_rf_info_t *rf);
static int CmdHelp(const char *Cmd);
static const calypso_file_ref_t calypso_file_refs[] = {
{"TICKETING_ENVIRONMENT", 0x07, {0x2000, 0x2001}, 2},
{"AID", 0x04, {0x3F04}, 1},
{"ICC", 0x02, {0x0002}, 1},
{"ID", 0x03, {0x0003}, 1},
{"HOLDER_EXTENDED", -1, {0x3F1C}, 1},
{"DISPLAY", 0x05, {0x2F10}, 1},
// NAVIGO
{"UNKNOWN_EF_CAFE", 0x00, {0xCAFE}, 1},
{"TICKETING_HOLDER", -1, {0x2000, 0x2002}, 2},
{"TICKETING_AID", -1, {0x2000, 0x2004}, 2},
{"TICKETING_LOG", 0x08, {0x2000, 0x2010}, 2},
// CDMX
{"UNKNOWN_EF_2017", 0x17, {0x2000, 0x2017}, 2},
{"TICKETING_CONTRACTS_1", 0x09, {0x2000, 0x2020}, 2},
{"TICKETING_CONTRACTS_2", 0x06, {0x2000, 0x2030}, 2},
{"TICKETING_COUNTERS_1", 0x0A, {0x2000, 0x202A}, 2},
{"TICKETING_COUNTERS_2", 0x0B, {0x2000, 0x202B}, 2},
{"TICKETING_COUNTERS_3", 0x0C, {0x2000, 0x202C}, 2},
{"TICKETING_COUNTERS_4", 0x0D, {0x2000, 0x202D}, 2},
{"TICKETING_COUNTERS_5", -1, {0x2000, 0x202E}, 2},
{"TICKETING_COUNTERS_6", -1, {0x2000, 0x202F}, 2},
{"TICKETING_SPECIAL_EVENTS", 0x1D, {0x2000, 0x2040}, 2},
{"TICKETING_CONTRACT_LIST", 0x1E, {0x2000, 0x2050}, 2},
{"TICKETING_COUNTERS_7", -1, {0x2000, 0x2060}, 2},
{"TICKETING_COUNTERS_8", -1, {0x2000, 0x2062}, 2},
{"TICKETING_COUNTERS_9", 0x19, {0x2000, 0x2069}, 2},
{"TICKETING_COUNTERS_10", 0x10, {0x2000, 0x206A}, 2},
{"TICKETING_FREE", 0x01, {0x2000, 0x20F0}, 2},
// Lignes D azur
{"UNKNOWN_EF_3101", 0x00, {0x3100, 0x3101}, 2},
{"MPP_PUBLIC_PARAMETERS", 0x17, {0x3100, 0x3102}, 2},
{"MPP_AID", -1, {0x3100, 0x3104}, 2},
// CDMX
{"UNKNOWN_EF_3107", 0x07, {0x3100, 0x3107}, 2},
{"MPP_LOG", -1, {0x3100, 0x3115}, 2},
// CDMX
{"UNKNOWN_EF_311C", 0x16, {0x3100, 0x311C}, 2},
{"MPP_CONTRACTS", -1, {0x3100, 0x3120}, 2},
{"MPP_COUNTERS_1", -1, {0x3100, 0x3113}, 2},
{"MPP_COUNTERS_2", -1, {0x3100, 0x3123}, 2},
{"MPP_COUNTERS_3", -1, {0x3100, 0x3133}, 2},
{"MPP_MISCELLANEOUS", -1, {0x3100, 0x3150}, 2},
{"MPP_COUNTERS_4", -1, {0x3100, 0x3169}, 2},
{"MPP_FREE", -1, {0x3100, 0x31F0}, 2},
// Lignes D azur
{"UNKNOWN_EF_3203", 0x03, {0x3200, 0x3203}, 2},
// Lignes D azur
{"UNKNOWN_EF_3209", 0x09, {0x3200, 0x3209}, 2},
// Lignes D azur
{"UNKNOWN_EF_3214", 0x14, {0x3200, 0x3214}, 2},
// Lignes D azur
{"UNKNOWN_EF_3217", 0x17, {0x3200, 0x3217}, 2},
// Lignes D azur
{"UNKNOWN_EF_3219", 0x19, {0x3200, 0x3219}, 2},
// Lignes D azur
{"UNKNOWN_EF_321A", 0x1A, {0x3200, 0x321A}, 2},
// Lignes D azur
{"UNKNOWN_EF_321B", 0x1B, {0x3200, 0x321B}, 2},
{"RT2_ENVIRONMENT", -1, {0x2100, 0x2101}, 2},
{"RT2_AID", -1, {0x2100, 0x2104}, 2},
{"RT2_LOG", -1, {0x2100, 0x2110}, 2},
{"RT2_CONTRACTS", -1, {0x2100, 0x2120}, 2},
{"RT2_SPECIAL_EVENTS", -1, {0x2100, 0x2140}, 2},
{"RT2_CONTRACT_LIST", -1, {0x2100, 0x2150}, 2},
{"RT2_COUNTERS", -1, {0x2100, 0x2169}, 2},
{"RT2_FREE", -1, {0x2100, 0x21F0}, 2},
{"EP_AID", -1, {0x1000, 0x1004}, 2},
{"EP_LOAD_LOG", 0x14, {0x1000, 0x1014}, 2},
{"EP_PURCHASE_LOG", 0x15, {0x1000, 0x1015}, 2},
{"ETICKET", -1, {0x8000, 0x8004}, 2},
{"ETICKET_EVENT_LOGS", -1, {0x8000, 0x8010}, 2},
{"ETICKET_PRESELECTION", -1, {0x8000, 0x8030}, 2},
};
// https://docs.keypop.org/keypop-calypso-card-cpp-api/latest-stable/namespacekeypop_1_1calypso_1_1card.html#aa274077fbdeafe85dfe208791490462f
// https://gnupg.org/ftp/specs/OpenPGP-smart-card-application-2.0.pdf
static const calypso_get_data_probe_t calypso_get_data_probes[] = {
@@ -663,22 +590,17 @@ static json_t *calypso_json_resource_root(calypso_resource_t *resource) {
return resource->root;
}
static bool calypso_json_lookup_id(json_t *obj, uint32_t *id) {
if (obj == NULL || id == NULL) {
static bool calypso_json_parse_hex_uint(json_t *value, uint32_t max, uint32_t *out) {
if (out == NULL) {
return false;
}
json_t *value = json_object_get(obj, "id");
if (value == NULL) {
value = json_object_get(obj, "ID");
}
if (json_is_integer(value)) {
json_int_t int_id = json_integer_value(value);
if (int_id < 0 || int_id > UINT32_MAX) {
json_int_t int_value = json_integer_value(value);
if (int_value < 0 || (uint64_t)int_value > max) {
return false;
}
*id = (uint32_t)int_id;
*out = (uint32_t)int_value;
return true;
}
@@ -698,7 +620,7 @@ static bool calypso_json_lookup_id(json_t *obj, uint32_t *id) {
errno = 0;
char *end = NULL;
unsigned long parsed = strtoul(text, &end, 16);
if (errno != 0 || end == text || parsed > UINT32_MAX) {
if (errno != 0 || end == text || parsed > max) {
return false;
}
@@ -710,7 +632,24 @@ static bool calypso_json_lookup_id(json_t *obj, uint32_t *id) {
return false;
}
*id = (uint32_t)parsed;
*out = (uint32_t)parsed;
return true;
}
static bool calypso_json_lookup_id(json_t *obj, uint32_t *id) {
if (obj == NULL || id == NULL) {
return false;
}
json_t *value = json_object_get(obj, "id");
if (value == NULL) {
value = json_object_get(obj, "ID");
}
if (calypso_json_parse_hex_uint(value, UINT32_MAX, id) == false) {
return false;
}
return true;
}
@@ -741,6 +680,46 @@ static const char *calypso_json_lookup_name(calypso_resource_t *resource, uint32
return NULL;
}
static bool calypso_json_file_ref_parse(json_t *obj, calypso_file_ref_t *file) {
if (json_is_object(obj) == false || file == NULL) {
return false;
}
const char *name = calypso_json_string_get(obj, "name");
json_t *path = json_object_get(obj, "path");
if (name == NULL || json_is_array(path) == false) {
return false;
}
size_t path_len = json_array_size(path);
if (path_len == 0 || path_len > CALYPSO_DUMP_PATH_MAX) {
return false;
}
memset(file, 0, sizeof(*file));
file->name = name;
file->sfi = -1;
json_t *sfi = json_object_get(obj, "sfi");
if (sfi != NULL && json_is_null(sfi) == false) {
uint32_t parsed_sfi = 0;
if (calypso_json_parse_hex_uint(sfi, CALYPSO_MAX_ENCODED_SFI, &parsed_sfi) == false) {
return false;
}
file->sfi = (int)parsed_sfi;
}
for (size_t i = 0; i < path_len; i++) {
uint32_t parsed_lid = 0;
if (calypso_json_parse_hex_uint(json_array_get(path, i), UINT16_MAX, &parsed_lid) == false) {
return false;
}
file->path[i] = (uint16_t)parsed_lid;
}
file->path_len = path_len;
return true;
}
static bool calypso_aid_is_prefix(const uint8_t *aid, size_t aid_len) {
return aid != NULL && aid_len == CALYPSO_MIN_AID_LEN;
}
@@ -1945,9 +1924,17 @@ static size_t calypso_probe_get_data_objects(json_t *entries, bool print_results
}
static const char *calypso_file_name_for_sfi(uint8_t sfi) {
for (size_t i = 0; i < ARRAYLEN(calypso_file_refs); i++) {
if (calypso_file_refs[i].sfi == sfi) {
return calypso_file_refs[i].name;
json_t *root = calypso_json_resource_root(&calypso_nodes_resource);
if (root == NULL) {
return NULL;
}
size_t index;
json_t *entry;
json_array_foreach(root, index, entry) {
calypso_file_ref_t file = {0};
if (calypso_json_file_ref_parse(entry, &file) && file.sfi == sfi) {
return file.name;
}
}
return NULL;
@@ -1983,8 +1970,16 @@ static bool calypso_file_ref_path_equals(const calypso_file_ref_t *file, const u
}
static bool calypso_lid_is_known(uint16_t lid) {
for (size_t i = 0; i < ARRAYLEN(calypso_file_refs); i++) {
if (calypso_file_ref_leaf_lid(&calypso_file_refs[i]) == lid) {
json_t *root = calypso_json_resource_root(&calypso_nodes_resource);
if (root == NULL) {
return false;
}
size_t index;
json_t *entry;
json_array_foreach(root, index, entry) {
calypso_file_ref_t file = {0};
if (calypso_json_file_ref_parse(entry, &file) && calypso_file_ref_leaf_lid(&file) == lid) {
return true;
}
}
@@ -2060,12 +2055,22 @@ static size_t calypso_infer_lid_path(uint16_t lid, uint16_t *path) {
static size_t calypso_build_lid_file_candidates(const calypso_ef_list_t *ef_list, calypso_file_candidate_t *candidates, size_t capacity) {
size_t count = 0;
for (size_t i = 0; i < ARRAYLEN(calypso_file_refs); i++) {
uint8_t source = CALYPSO_FILE_SOURCE_KNOWN;
if (calypso_ef_list_contains_lid(ef_list, calypso_file_ref_leaf_lid(&calypso_file_refs[i]))) {
source |= CALYPSO_FILE_SOURCE_EF_LIST;
json_t *root = calypso_json_resource_root(&calypso_nodes_resource);
if (root != NULL) {
size_t index;
json_t *entry;
json_array_foreach(root, index, entry) {
calypso_file_ref_t file = {0};
if (calypso_json_file_ref_parse(entry, &file) == false) {
continue;
}
uint8_t source = CALYPSO_FILE_SOURCE_KNOWN;
if (calypso_ef_list_contains_lid(ef_list, calypso_file_ref_leaf_lid(&file))) {
source |= CALYPSO_FILE_SOURCE_EF_LIST;
}
calypso_add_file_candidate(candidates, capacity, &count, file.name, file.path, file.path_len, source);
}
calypso_add_file_candidate(candidates, capacity, &count, calypso_file_refs[i].name, calypso_file_refs[i].path, calypso_file_refs[i].path_len, source);
}
if (ef_list == NULL) {