| 874 | } |
| 875 | |
| 876 | gboolean |
| 877 | decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, |
| 878 | int *target_rc) |
| 879 | { |
| 880 | int res = 0; |
| 881 | gboolean done = FALSE; |
| 882 | |
| 883 | CRM_CHECK(uuid != NULL, return FALSE); |
| 884 | CRM_CHECK(target_rc != NULL, return FALSE); |
| 885 | CRM_CHECK(action_id != NULL, return FALSE); |
| 886 | CRM_CHECK(transition_id != NULL, return FALSE); |
| 887 | |
| 888 | *uuid = calloc(1, strlen(key) + 1); |
| 889 | res = sscanf(key, "%d:%d:%d:%s", action_id, transition_id, target_rc, *uuid); |
| 890 | switch (res) { |
| 891 | case 4: |
| 892 | /* Post Pacemaker 0.6 */ |
| 893 | done = TRUE; |
| 894 | break; |
| 895 | case 3: |
| 896 | case 2: |
| 897 | /* this can be tricky - the UUID might start with an integer */ |
| 898 | |
| 899 | /* Until Pacemaker 0.6 */ |
| 900 | done = TRUE; |
| 901 | *target_rc = -1; |
| 902 | res = sscanf(key, "%d:%d:%s", action_id, transition_id, *uuid); |
| 903 | if (res == 2) { |
| 904 | *action_id = -1; |
| 905 | res = sscanf(key, "%d:%s", transition_id, *uuid); |
| 906 | CRM_CHECK(res == 2, done = FALSE); |
| 907 | |
| 908 | } else if (res != 3) { |
| 909 | CRM_CHECK(res == 3, done = FALSE); |
| 910 | } |
| 911 | break; |
| 912 | |
| 913 | case 1: |
| 914 | /* Prior to Heartbeat 2.0.8 */ |
| 915 | done = TRUE; |
| 916 | *action_id = -1; |
| 917 | *target_rc = -1; |
| 918 | res = sscanf(key, "%d:%s", transition_id, *uuid); |
| 919 | CRM_CHECK(res == 2, done = FALSE); |
| 920 | break; |
| 921 | default: |
| 922 | crm_crit("Unhandled sscanf result (%d) for %s", res, key); |
| 923 | |
| 924 | } |
| 925 | |
| 926 | if (strlen(*uuid) != 36) { |
| 927 | crm_warn("Bad UUID (%s) in sscanf result (%d) for %s", *uuid, res, key); |
| 928 | } |
| 929 | |
| 930 | if (done == FALSE) { |
| 931 | crm_err("Cannot decode '%s' rc=%d", key, res); |
| 932 | |
| 933 | free(*uuid); |
no outgoing calls
no test coverage detected