Compatibility with the deprecated ticket state section: * "/cib/status/tickets/instance_attributes" */
| 500 | /* Compatibility with the deprecated ticket state section: |
| 501 | * "/cib/status/tickets/instance_attributes" */ |
| 502 | static void |
| 503 | get_ticket_state_legacy(gpointer key, gpointer value, gpointer user_data) |
| 504 | { |
| 505 | const char *long_key = key; |
| 506 | char *state_key = NULL; |
| 507 | |
| 508 | const char *granted_prefix = "granted-ticket-"; |
| 509 | const char *last_granted_prefix = "last-granted-"; |
| 510 | static int granted_prefix_strlen = 0; |
| 511 | static int last_granted_prefix_strlen = 0; |
| 512 | |
| 513 | const char *ticket_id = NULL; |
| 514 | const char *is_granted = NULL; |
| 515 | const char *last_granted = NULL; |
| 516 | const char *sep = NULL; |
| 517 | |
| 518 | ticket_t *ticket = NULL; |
| 519 | pe_working_set_t *data_set = user_data; |
| 520 | |
| 521 | if (granted_prefix_strlen == 0) { |
| 522 | granted_prefix_strlen = strlen(granted_prefix); |
| 523 | } |
| 524 | |
| 525 | if (last_granted_prefix_strlen == 0) { |
| 526 | last_granted_prefix_strlen = strlen(last_granted_prefix); |
| 527 | } |
| 528 | |
| 529 | if (strstr(long_key, granted_prefix) == long_key) { |
| 530 | ticket_id = long_key + granted_prefix_strlen; |
| 531 | if (strlen(ticket_id)) { |
| 532 | state_key = strdup("granted"); |
| 533 | is_granted = value; |
| 534 | } |
| 535 | } else if (strstr(long_key, last_granted_prefix) == long_key) { |
| 536 | ticket_id = long_key + last_granted_prefix_strlen; |
| 537 | if (strlen(ticket_id)) { |
| 538 | state_key = strdup("last-granted"); |
| 539 | last_granted = value; |
| 540 | } |
| 541 | } else if ((sep = strrchr(long_key, '-'))) { |
| 542 | ticket_id = sep + 1; |
| 543 | state_key = strndup(long_key, strlen(long_key) - strlen(sep)); |
| 544 | } |
| 545 | |
| 546 | if (ticket_id == NULL || strlen(ticket_id) == 0) { |
| 547 | free(state_key); |
| 548 | return; |
| 549 | } |
| 550 | |
| 551 | if (state_key == NULL || strlen(state_key) == 0) { |
| 552 | free(state_key); |
| 553 | return; |
| 554 | } |
| 555 | |
| 556 | ticket = g_hash_table_lookup(data_set->tickets, ticket_id); |
| 557 | if (ticket == NULL) { |
| 558 | ticket = ticket_new(ticket_id, data_set); |
| 559 | if (ticket == NULL) { |
nothing calls this directly
no test coverage detected