static void remove_pixel_display (ply_boot_splash_plugin_t *plugin, ply_pixel_display_t *display) { ply_list_node_t *node; node = ply_list_get_first_node (plugin->views); while (node != NULL) { view_t *view; ply_list_node_t *next_node; view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); if (view->display == display) { ply_pixel_display_set_draw_handler (view->display, NULL, NULL); view_free (view); ply_list_remove_node (plugin->views, node); return; } node = next_node; } }
static void ply_boot_client_process_pending_requests (ply_boot_client_t *client) { ply_list_node_t *request_node; ply_boot_client_request_t *request; assert (ply_list_get_length (client->requests_to_send) != 0); assert (client->daemon_can_take_request_watch != NULL); request_node = ply_list_get_first_node (client->requests_to_send); assert (request_node != NULL); request = (ply_boot_client_request_t *) ply_list_node_get_data (request_node); assert (request != NULL); ply_list_remove_node (client->requests_to_send, request_node); if (ply_boot_client_send_request (client, request)) ply_list_append_data (client->requests_waiting_for_replies, request); if (ply_list_get_length (client->requests_to_send) == 0) { if (client->daemon_has_reply_watch != NULL) { assert (client->loop != NULL); ply_event_loop_stop_watching_fd (client->loop, client->daemon_can_take_request_watch); client->daemon_can_take_request_watch = NULL; } } }
void ply_terminal_stop_watching_for_active_vt_change (ply_terminal_t *terminal, ply_terminal_active_vt_changed_handler_t active_vt_changed_handler, void *user_data) { ply_list_node_t *node; if (!ply_terminal_is_vt (terminal)) return; node = ply_list_get_first_node (terminal->vt_change_closures); while (node != NULL) { ply_terminal_active_vt_changed_closure_t *closure; ply_list_node_t *next_node; closure = ply_list_node_get_data (node); next_node = ply_list_get_next_node (terminal->vt_change_closures, node); if (closure->handler == active_vt_changed_handler && closure->user_data == user_data) { free (closure); ply_list_remove_node (terminal->vt_change_closures, node); } node = next_node; } }
static void ply_boot_client_cancel_unsent_requests (ply_boot_client_t *client) { ply_list_node_t *node; if (ply_list_get_length (client->requests_to_send) == 0) return; node = ply_list_get_first_node (client->requests_to_send); while (node != NULL) { ply_list_node_t *next_node; ply_boot_client_request_t *request; request = (ply_boot_client_request_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (client->requests_to_send, node); ply_boot_client_cancel_request (client, request); ply_list_remove_node (client->requests_to_send, node); node = next_node; } if (client->daemon_can_take_request_watch != NULL) { assert (client->loop != NULL); ply_event_loop_stop_watching_fd (client->loop, client->daemon_can_take_request_watch); client->daemon_can_take_request_watch = NULL; } }
void ply_trigger_free (ply_trigger_t *trigger) { ply_list_node_t *node; if (trigger == NULL) return; node = ply_list_get_first_node (trigger->closures); while (node != NULL) { ply_list_node_t *next_node; ply_trigger_closure_t *closure; closure = (ply_trigger_closure_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (trigger->closures, node); free (closure); ply_list_remove_node (trigger->closures, node); node = next_node; } ply_list_free (trigger->closures); if (trigger->free_address != NULL) *trigger->free_address = NULL; if (trigger->free_address != NULL) *trigger->free_address = NULL; free (trigger); }
void ply_trigger_remove_handler (ply_trigger_t *trigger, ply_trigger_handler_t handler, void *user_data) { ply_list_node_t *node; node = ply_list_get_first_node (trigger->closures); while (node != NULL) { ply_list_node_t *next_node; ply_trigger_closure_t *closure; closure = (ply_trigger_closure_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (trigger->closures, node); if (closure->handler == handler && closure->user_data == user_data) { free (closure); ply_list_remove_node (trigger->closures, node); break; } node = next_node; } }
static void ply_boot_connection_on_hangup (ply_boot_connection_t *connection) { ply_list_node_t *node; ply_boot_server_t *server; assert (connection != NULL); assert (connection->server != NULL); server = connection->server; node = ply_list_find_node (server->connections, connection); assert (node != NULL); ply_boot_connection_free (connection); ply_list_remove_node (server->connections, node); }
static void free_heads (ply_renderer_backend_t *backend) { ply_list_node_t *node; node = ply_list_get_first_node (backend->heads); while (node != NULL) { ply_list_node_t *next_node; ply_renderer_head_t *head; head = (ply_renderer_head_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (backend->heads, node); ply_renderer_head_free (head); ply_list_remove_node (backend->heads, node); node = next_node; } }
static void free_text_displays (ply_seat_t *seat) { ply_list_node_t *node; ply_trace ("freeing %d text displays", ply_list_get_length (seat->text_displays)); node = ply_list_get_first_node (seat->text_displays); while (node != NULL) { ply_list_node_t *next_node; ply_text_display_t *display; next_node = ply_list_get_next_node (seat->text_displays, node); display = ply_list_node_get_data (node); ply_text_display_free (display); ply_list_remove_node (seat->text_displays, node); node = next_node; } }
void ply_region_clear (ply_region_t *region) { ply_list_node_t *node; node = ply_list_get_first_node (region->rectangle_list); while (node != NULL) { ply_list_node_t *next_node; ply_rectangle_t *rectangle; rectangle = (ply_rectangle_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (region->rectangle_list, node); free (rectangle); ply_list_remove_node (region->rectangle_list, node); node = next_node; } }
static void free_views (ply_boot_splash_plugin_t *plugin) { ply_list_node_t *node; node = ply_list_get_first_node (plugin->views); while (node != NULL) { ply_list_node_t *next_node; view_t *view; view = ply_list_node_get_data (node); next_node = ply_list_get_next_node (plugin->views, node); view_free (view); ply_list_remove_node (plugin->views, node); node = next_node; } ply_list_free (plugin->views); plugin->views = NULL; }
void ply_terminal_stop_watching_for_input (ply_terminal_t *terminal, ply_terminal_input_handler_t input_handler, void *user_data) { ply_list_node_t *node; node = ply_list_get_first_node (terminal->input_closures); while (node != NULL) { ply_terminal_input_closure_t *closure; ply_list_node_t *next_node; closure = ply_list_node_get_data (node); next_node = ply_list_get_next_node (terminal->input_closures, node); if (closure->handler == input_handler && closure->user_data == user_data) { free (closure); ply_list_remove_node (terminal->input_closures, node); } node = next_node; } }
static void ply_boot_client_process_incoming_replies (ply_boot_client_t *client) { ply_list_node_t *request_node; ply_boot_client_request_t *request; bool processed_reply; uint8_t byte[2] = ""; uint32_t size; assert (client != NULL); processed_reply = false; if (ply_list_get_length (client->requests_waiting_for_replies) == 0) { ply_error ("received unexpected response from boot status daemon"); return; } if (!ply_read (client->socket_fd, byte, sizeof (uint8_t))) goto out; for (request_node = ply_list_get_first_node (client->requests_waiting_for_replies); request_node; request_node = ply_list_get_next_node (client->requests_waiting_for_replies, request_node)) { assert (request_node != NULL); request = (ply_boot_client_request_t *) ply_list_node_get_data (request_node); assert (request != NULL); if (! strcmp (request->command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD) || ! strcmp (request->command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUESTION) || ! strcmp (request->command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE)) { if (! memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER, sizeof (uint8_t)) || ! memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER, sizeof (uint8_t))) break; } else { if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER, sizeof (uint8_t)) && memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER, sizeof (uint8_t))) break; } } if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, sizeof (uint8_t)) == 0) request->handler (request->user_data, client); else if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER, sizeof (uint8_t)) == 0) { char *answer; if (!ply_read_uint32 (client->socket_fd, &size)) goto out; answer = malloc ((size+1) * sizeof(char)); if (size > 0) { if (!ply_read (client->socket_fd, answer, size)) goto out; } answer[size] = '\0'; ((ply_boot_client_answer_handler_t) request->handler) (request->user_data, answer, client); free(answer); } else if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_MULTIPLE_ANSWERS, sizeof (uint8_t)) == 0) { ply_array_t *array; char **answers; char *answer; char *p; char *q; uint8_t i; array = NULL; answers = NULL; if (!ply_read_uint32 (client->socket_fd, &size)) goto out; assert (size > 0); answer = malloc (size); if (!ply_read (client->socket_fd, answer, size)) { free (answer); goto out; } array = ply_array_new (); p = answer; q = p; for (i = 0; i < size; i++, q++) { if (*q == '\0') { ply_array_add_element (array, strdup (p)); p = q + 1; } } free (answer); answers = (char **) ply_array_steal_elements (array); ply_array_free (array); ((ply_boot_client_multiple_answers_handler_t) request->handler) (request->user_data, (const char * const *) answers, client); ply_free_string_array (answers); } else if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER, sizeof (uint8_t)) == 0) { ((ply_boot_client_answer_handler_t) request->handler) (request->user_data, NULL, client); } else goto out; processed_reply = true; out: if (!processed_reply) { if (request->failed_handler != NULL) request->failed_handler (request->user_data, client); } ply_list_remove_node (client->requests_waiting_for_replies, request_node); if (ply_list_get_length (client->requests_waiting_for_replies) == 0) { if (client->daemon_has_reply_watch != NULL) { assert (client->loop != NULL); ply_event_loop_stop_watching_fd (client->loop, client->daemon_has_reply_watch); client->daemon_has_reply_watch = NULL; } } }
static void merge_rectangle_with_sub_list (ply_region_t *region, ply_rectangle_t *new_area, ply_list_node_t *node) { if (ply_rectangle_is_empty (new_area)) { free (new_area); return; } while (node != NULL) { ply_list_node_t *next_node; ply_rectangle_t *old_area; ply_rectangle_overlap_t overlap; old_area = (ply_rectangle_t *) ply_list_node_get_data (node); next_node = ply_list_get_next_node (region->rectangle_list, node); if (ply_rectangle_is_empty (new_area)) overlap = PLY_RECTANGLE_OVERLAP_NO_EDGES; else if (ply_rectangle_is_empty (old_area)) overlap = PLY_RECTANGLE_OVERLAP_ALL_EDGES; else overlap = ply_rectangle_find_overlap (old_area, new_area); switch (overlap) { /* NNNN The new rectangle and node rectangle don't touch, * NNNN OOOO so let's move on to the next one. * OOOO */ case PLY_RECTANGLE_OVERLAP_NONE: break; /* NNNNN We need to split the new rectangle into * NNOOOOO two rectangles: The top row of Ns and * NNOOOOO the left side of Ns. * OOOOO */ case PLY_RECTANGLE_OVERLAP_TOP_AND_LEFT_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->y = old_area->y; rectangle->width = old_area->x - new_area->x; rectangle->height = (new_area->y + new_area->height) - old_area->y; merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->height = old_area->y - new_area->y; } break; /* NNNNN We need to split the new rectangle into * OOOOONN two rectangles: The top row of Ns and * OOOOONN the right side of Ns. * OOOOO */ case PLY_RECTANGLE_OVERLAP_TOP_AND_RIGHT_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->x = old_area->x + old_area->width; rectangle->y = old_area->y; rectangle->width = (new_area->x + new_area->width) - (old_area->x + old_area->width); rectangle->height = (new_area->y + new_area->height) - old_area->y; merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->height = old_area->y - new_area->y; } break; /* NNNNNNN We need to trim out the part of * NOOOOON old rectangle that overlaps the new * NOOOOON rectangle by shrinking and moving it * OOOOO and then we need to add the new rectangle. */ case PLY_RECTANGLE_OVERLAP_TOP_AND_SIDE_EDGES: { old_area->height = (old_area->y + old_area->height) - (new_area->y + new_area->height); old_area->y = new_area->y + new_area->height; } break; /* NNN We only care about the top row of Ns, * ONNNO everything below that is already handled by * ONNNO the old rectangle. * OOOOO */ case PLY_RECTANGLE_OVERLAP_TOP_EDGE: new_area->height = old_area->y - new_area->y; break; /* OOOOO We need to split the new rectangle into * NNOOOOO two rectangles: The left side of Ns and * NNOOOOO the bottom row of Ns. * NNOOOOO * NNNNN */ case PLY_RECTANGLE_OVERLAP_BOTTOM_AND_LEFT_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->width = old_area->x - new_area->x; rectangle->height = (old_area->y + old_area->height) - new_area->y; merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->height = (new_area->y + new_area->height) - (old_area->y + old_area->height); new_area->y = old_area->y + old_area->height; } break; /* OOOOO We need to split the new rectangle into * OOOOONN two rectangles: The right side of Ns and * OOOOONN the bottom row of Ns. * OOOOONN * NNNNN */ case PLY_RECTANGLE_OVERLAP_BOTTOM_AND_RIGHT_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->x = old_area->x + old_area->width; rectangle->width = (new_area->x + new_area->width) - (old_area->x + old_area->width); rectangle->height = (old_area->y + old_area->height) - new_area->y; merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->height = (new_area->y + new_area->height) - (old_area->y + old_area->height); new_area->y = old_area->y + old_area->height; } break; /* OOOOO We need to trim out the part of * NOOOOON old rectangle that overlaps the new * NOOOOON rectangle by shrinking it * NNNNNNN and then we need to add the new rectangle. */ case PLY_RECTANGLE_OVERLAP_BOTTOM_AND_SIDE_EDGES: { old_area->height = new_area->y - old_area->y; } break; /* OOOOO We only care about the bottom row of Ns, * ONNNO everything above that is already handled by * ONNNO the old rectangle. * NNN */ case PLY_RECTANGLE_OVERLAP_BOTTOM_EDGE: { new_area->height = (new_area->y + new_area->height) - (old_area->y + old_area->height); new_area->y = old_area->y + old_area->height; } break; /* NNNN We need to trim out the part of * NNNNO old rectangle that overlaps the new * NNNNO rectangle by shrinking it and moving it * NNNN and then we need to add the new rectangle. */ case PLY_RECTANGLE_OVERLAP_TOP_LEFT_AND_BOTTOM_EDGES: { old_area->width = (old_area->x + old_area->width) - (new_area->x + new_area->width); old_area->x = new_area->x + new_area->width; } break; /* NNNN We need to trim out the part of * ONNNN old rectangle that overlaps the new * ONNNN rectangle by shrinking it and then we * NNNN need to add the new rectangle. */ case PLY_RECTANGLE_OVERLAP_TOP_RIGHT_AND_BOTTOM_EDGES: old_area->width = new_area->x - old_area->x; break; /* NNNNNNN The old rectangle is completely inside the new rectangle * NOOOOON so replace the old rectangle with the new rectangle. * NOOOOON * NNNNNNN */ case PLY_RECTANGLE_OVERLAP_ALL_EDGES: merge_rectangle_with_sub_list (region, new_area, next_node); free (old_area); ply_list_remove_node (region->rectangle_list, node); return; /* NNN We need to split the new rectangle into * ONNNO two rectangles: the top and bottom row of Ns * ONNNO * NNN */ case PLY_RECTANGLE_OVERLAP_TOP_AND_BOTTOM_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->y = old_area->y + old_area->height; rectangle->width = new_area->width; rectangle->height = (new_area->y + new_area->height) - (old_area->y + old_area->height); merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->height = old_area->y - new_area->y; } break; /* OOOOO We only care about the side row of Ns, * NNNNOO everything rigth of that is already handled by * NNNNOO the old rectangle. * OOOOO */ case PLY_RECTANGLE_OVERLAP_LEFT_EDGE: new_area->width = old_area->x - new_area->x; break; /* OOOOO We only care about the side row of Ns, * NNNNNN everything left of that is already handled by * NNNNNN the old rectangle. * OOOOO */ case PLY_RECTANGLE_OVERLAP_RIGHT_EDGE: { long temp = new_area->x; new_area->x = old_area->x + old_area->width; new_area->width = (temp + new_area->width) - (old_area->x + old_area->width); } break; /* OOOOO We need to split the new rectangle into * NNNNNNN two rectangles: the side columns of Ns * NNNNNNN * OOOOO */ case PLY_RECTANGLE_OVERLAP_SIDE_EDGES: { ply_rectangle_t *rectangle; rectangle = copy_rectangle (new_area); rectangle->x = old_area->x + old_area->width; rectangle->width = (new_area->x + new_area->width) - (old_area->x + old_area->width); merge_rectangle_with_sub_list (region, rectangle, next_node); new_area->width = old_area->x - new_area->x; } break; /* OOOOOOO The new rectangle is completely inside an old rectangle * ONNNNNO so return early without adding the new rectangle. * ONNNNNO * OOOOOOO */ case PLY_RECTANGLE_OVERLAP_NO_EDGES: free (new_area); return; /* NNNNN We expand the old rectangle up and throw away the new. * NNNNN We must merge it because the new region may have overlapped * NNNNN something further down the list. * OOOOO */ case PLY_RECTANGLE_OVERLAP_EXACT_TOP_EDGE: { old_area->height = (old_area->y + old_area->height) - new_area->y; old_area->y = new_area->y; free (new_area); merge_rectangle_with_sub_list (region, old_area, next_node); ply_list_remove_node (region->rectangle_list, node); } return; /* OOOOO We expand the old rectangle down and throw away the new. * NNNNN We must merge it because the new region may have overlapped * NNNNN something further down the list. * NNNNN */ case PLY_RECTANGLE_OVERLAP_EXACT_BOTTOM_EDGE: { old_area->height = (new_area->y + new_area->height) - old_area->y; free (new_area); merge_rectangle_with_sub_list (region, old_area, next_node); ply_list_remove_node (region->rectangle_list, node); } return; /* NNNNNO We expand the old rectangle left and throw away the new. * NNNNNO We must merge it because the new region may have overlapped * NNNNNO something further down the list. */ case PLY_RECTANGLE_OVERLAP_EXACT_LEFT_EDGE: { old_area->width = (old_area->x + old_area->width) - new_area->x; old_area->x = new_area->x; free (new_area); merge_rectangle_with_sub_list (region, old_area, next_node); ply_list_remove_node (region->rectangle_list, node); } return; /* ONNNNN We expand the old rectangle right and throw away the new. * ONNNNN We must merge it because the new region may have overlapped * ONNNNN something further down the list. */ case PLY_RECTANGLE_OVERLAP_EXACT_RIGHT_EDGE: { old_area->width = (new_area->x + new_area->width) - old_area->x; free (new_area); merge_rectangle_with_sub_list (region, old_area, next_node); ply_list_remove_node (region->rectangle_list, node); } return; } node = ply_list_get_next_node (region->rectangle_list, node); } ply_list_append_data (region->rectangle_list, new_area); }