- if(state_ptr && (strstr(text, "Connection") || strstr(text, "connection"))) {
- for(i = 0; i < state_ptr->num_nodes; i++) {
- assert(snprintf(connection_match_msg, sizeof(connection_match_msg),
- "Connection with %s", state_ptr->node_names[i]) >= 0);
-
- if(strstr(text, connection_match_msg) && strstr(text, "activated")) {
- meta_conn_status[i] = true;
- continue;
- }
-
- assert(snprintf(connection_match_msg, sizeof(connection_match_msg),
- "Already connected to %s", state_ptr->node_names[i]) >= 0);
-
- if(strstr(text, connection_match_msg)) {
- meta_conn_status[i] = true;
- continue;
- }
-
- assert(snprintf(connection_match_msg, sizeof(connection_match_msg),
- "Connection closed by %s", state_ptr->node_names[i]) >= 0);
-
- if(strstr(text, connection_match_msg)) {
- meta_conn_status[i] = false;
- continue;
- }
-
- assert(snprintf(connection_match_msg, sizeof(connection_match_msg),
- "Closing connection with %s", state_ptr->node_names[i]) >= 0);
-
- if(strstr(text, connection_match_msg)) {
- meta_conn_status[i] = false;
- continue;
- }
+ if(state_ptr) {
+ bool status;
+ char name[100];
+
+ if(sscanf(text, "Connection with %s activated", name) == 1) {
+ status = true;
+ } else if(sscanf(text, "Already connected to %s", name) == 1) {
+ status = true;
+ } else if(sscanf(text, "Connection closed by %s", name) == 1) {
+ status = false;
+ } else if(sscanf(text, "Closing connection with %s", name) == 1) {
+ status = false;
+ } else {
+ return;