Esempio n. 1
0
void
ply_progress_status_update (ply_progress_t* progress,
                             const char  *status)
{
  ply_progress_message_t *message, *message_next;
  message = ply_progress_message_search(progress->current_message_list, status);
  if (message)
    {
      message->disabled = true;
    }                                                   /* Remove duplicates as they confuse things*/
  else
    {
      message = ply_progress_message_search(progress->previous_message_list, status);
      if (message)
        {
          message_next = ply_progress_message_search_next(progress->previous_message_list, message->time);
          if (message_next)
              progress->next_message_percentage = message_next->time;
          else
              progress->next_message_percentage = 1;
              
          progress->scalar += message->time / (ply_progress_get_time(progress)-progress->dead_time);
          progress->scalar /= 2;
        }
      message = malloc(sizeof(ply_progress_message_t));
      message->time = ply_progress_get_time (progress);
      message->string = strdup(status);
      message->disabled = false;
      ply_list_append_data(progress->current_message_list, message);
    }
}
Esempio n. 2
0
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;
        }
    }
}
Esempio n. 3
0
static void
add_pixel_displays (ply_seat_t *seat)
{
        ply_list_t *heads;
        ply_list_node_t *node;

        heads = ply_renderer_get_heads (seat->renderer);

        ply_trace ("Adding displays for %d heads",
                   ply_list_get_length (heads));

        node = ply_list_get_first_node (heads);
        while (node != NULL) {
                ply_list_node_t *next_node;
                ply_renderer_head_t *head;
                ply_pixel_display_t *display;

                head = ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (heads, node);

                display = ply_pixel_display_new (seat->renderer, head);

                ply_list_append_data (seat->pixel_displays, display);

                node = next_node;
        }
}
Esempio n. 4
0
static void
ply_boot_server_on_new_connection (ply_boot_server_t *server)
{
  ply_boot_connection_t *connection;
  int fd;

  assert (server != NULL);

  fd = accept (server->socket_fd, NULL, NULL);

  if (fd < 0)
    return;

  connection = ply_boot_connection_new (server, fd);

  connection->watch = 
      ply_event_loop_watch_fd (server->loop, fd,
                               PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
                               (ply_event_handler_t)
                               ply_boot_connection_on_request,
                               (ply_event_handler_t)
                               ply_boot_connection_on_hangup,
                               connection);

  ply_list_append_data (server->connections, connection);
}
Esempio n. 5
0
static void
ply_boot_connection_on_password_answer (ply_boot_connection_t *connection,
                                        const char            *password)
{
  ply_trace ("got password answer");

  ply_boot_connection_send_answer (connection, password);
  if (password != NULL)
    ply_list_append_data (connection->server->cached_passwords,
                          strdup (password));

}
Esempio n. 6
0
void
ply_terminal_watch_for_input (ply_terminal_t              *terminal,
                              ply_terminal_input_handler_t input_handler,
                              void                        *user_data)
{
    ply_terminal_input_closure_t *closure;

    closure = calloc (1, sizeof(*closure));
    closure->handler = input_handler;
    closure->user_data = user_data;

    ply_list_append_data (terminal->input_closures, closure);
}
Esempio n. 7
0
static void
add_pixel_display (ply_boot_splash_plugin_t *plugin,
                   ply_pixel_display_t      *display)
{
        view_t *view;

        ply_trace ("adding pixel display to plugin");
        view = view_new (plugin, display);

        ply_pixel_display_set_draw_handler (view->display,
                                            (ply_pixel_display_draw_handler_t)
                                            on_draw, view);

        if (plugin->is_visible) {
                if (view_load (view))
                        ply_list_append_data (plugin->views, view);
                else
                        view_free (view);
        } else {
                ply_list_append_data (plugin->views, view);
        }
}
Esempio n. 8
0
static void
add_pixel_display (ply_boot_splash_plugin_t *plugin,
                   ply_pixel_display_t      *display)
{
  view_t *view;

  view = view_new (plugin, display);

  ply_pixel_display_set_draw_handler (view->display,
                                      (ply_pixel_display_draw_handler_t)
                                      on_draw, view);
  ply_list_append_data (plugin->views, view);
}
Esempio n. 9
0
void
ply_trigger_add_handler (ply_trigger_t         *trigger,
                         ply_trigger_handler_t  handler,
                         void                  *user_data)
{
  ply_trigger_closure_t *closure;

  closure = calloc (1, sizeof (ply_trigger_closure_t));
  closure->handler = handler;
  closure->user_data = user_data;

  ply_list_append_data (trigger->closures, closure);
}
Esempio n. 10
0
static ply_list_t *script_parse_op_list (script_scan_t *scan)
{
  ply_list_t *op_list = ply_list_new ();

  while (true)
    {
      script_op_t *op = script_parse_op (scan);
      if (!op) break;
      ply_list_append_data (op_list, op);
    }

  return op_list;
}
Esempio n. 11
0
void
ply_terminal_watch_for_active_vt_change (ply_terminal_t                          *terminal,
        ply_terminal_active_vt_changed_handler_t active_vt_changed_handler,
        void                                    *user_data)
{
    ply_terminal_active_vt_changed_closure_t *closure;

    if (!ply_terminal_is_vt (terminal))
        return;

    closure = calloc (1, sizeof(*closure));
    closure->handler = active_vt_changed_handler;
    closure->user_data = user_data;

    ply_list_append_data (terminal->vt_change_closures, closure);
}
Esempio n. 12
0
void
ply_progress_load_cache (ply_progress_t* progress,
                         const char *filename)
{
  FILE *fp;

  fp = fopen (filename,"r");
  if (fp == NULL)
    return;

  while (1)
    {
      int items_matched;
      double time;
      int string_size=81;
      char *string;
      char colon;
      int i=0;

      items_matched = fscanf (fp, "%lf", &time);
      if (items_matched<1) break;
      items_matched = fscanf (fp, "%c", &colon);
      if (items_matched<1 || colon != ':') break;

      string = malloc(sizeof(char)*string_size);
      while (1)
        {
          if (i>=string_size)
            {
              string_size*=2;
              string = realloc(string, sizeof(char)*string_size);
            }
          items_matched = fscanf (fp, "%c", &string[i]);
          if (items_matched<1 || string[i] == '\n')
            {
              string[i] = '\0';
              break;
            }
          i++;
        }
      ply_progress_message_t* message = malloc(sizeof(ply_progress_message_t));
      message->time = time;
      message->string = string;
      ply_list_append_data(progress->previous_message_list, message);
    }
  fclose (fp);
}
Esempio n. 13
0
static script_function_t *script_parse_function_def (script_scan_t *scan)
{
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);
  ply_list_t *parameter_list;

  if (!script_scan_token_is_symbol_of_value (curtoken, '('))
    {
      script_parse_error (&curtoken->location,
        "Function declaration requires parameters to be declared within '(' brackets");
      return NULL;
    }
  curtoken = script_scan_get_next_token (scan);
  parameter_list = ply_list_new ();

  while (true)
    {
      if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
      if (!script_scan_token_is_identifier (curtoken))
        {
          script_parse_error (&curtoken->location,
            "Function declaration parameters must be valid identifiers");
          return NULL;
        }
      char *parameter = strdup (curtoken->data.string);
      ply_list_append_data (parameter_list, parameter);

      curtoken = script_scan_get_next_token (scan);

      if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
      if (!script_scan_token_is_symbol_of_value (curtoken, ','))
        {
          script_parse_error (&curtoken->location,
            "Function declaration parameters must separated with ',' and terminated with a ')'");
          return NULL;
        }
      curtoken = script_scan_get_next_token (scan);
    }

  curtoken = script_scan_get_next_token (scan);

  script_op_t *func_op = script_parse_op (scan);
  
  script_function_t *function = script_function_script_new (func_op,
                                                            NULL,
                                                            parameter_list);
  return function;
}
Esempio n. 14
0
static void 
add_script_env_var (const char *group_name,
                    const char *key,
                    const char *value,
                    void       *user_data)
{
  ply_list_t *script_env_vars;
  script_env_var_t *new_env_var;

  if (strcmp (group_name, "script-env-vars") != 0)
    return;

  script_env_vars = user_data;
  new_env_var = malloc (sizeof (script_env_var_t));
  new_env_var->key = strdup (key);
  new_env_var->value = strdup (value);

  ply_list_append_data (script_env_vars, new_env_var);
}
Esempio n. 15
0
static void
add_text_displays (ply_seat_t *seat)
{
        ply_text_display_t *display;

        if (!ply_terminal_is_open (seat->terminal)) {
                if (!ply_terminal_open (seat->terminal)) {
                        ply_trace ("could not add terminal %s: %m",
                                   ply_terminal_get_name (seat->terminal));
                        return;
                }
        }

        ply_trace ("adding text display for terminal %s",
                   ply_terminal_get_name (seat->terminal));

        display = ply_text_display_new (seat->terminal);
        ply_list_append_data (seat->text_displays, display);
}
Esempio n. 16
0
static void
add_text_display (ply_boot_splash_plugin_t *plugin,
                  ply_text_display_t       *display)
{
        view_t *view;
        ply_terminal_t *terminal;

        view = view_new (plugin, display);

        terminal = ply_text_display_get_terminal (view->display);
        if (ply_terminal_open (terminal))
                ply_terminal_activate_vt (terminal);

        ply_text_display_set_draw_handler (view->display,
                                           (ply_text_display_draw_handler_t)
                                           on_draw, view);

        ply_list_append_data (plugin->views, view);
}
Esempio n. 17
0
static void
ply_boot_client_queue_request (ply_boot_client_t                  *client,
                               const char                         *request_command,
                               const char                         *request_argument,
                               ply_boot_client_response_handler_t  handler,
                               ply_boot_client_response_handler_t  failed_handler,
                               void                               *user_data)
{
  assert (client != NULL);
  assert (client->loop != NULL);
  assert (request_command != NULL);
  assert (request_argument == NULL || strlen (request_argument) <= UCHAR_MAX);
  assert (handler != NULL);

  if (client->daemon_can_take_request_watch == NULL &&
      client->socket_fd >= 0)
    {
      assert (ply_list_get_length (client->requests_to_send) == 0);
      client->daemon_can_take_request_watch = 
          ply_event_loop_watch_fd (client->loop, client->socket_fd,
                                   PLY_EVENT_LOOP_FD_STATUS_CAN_TAKE_DATA,
                                   (ply_event_handler_t)
                                   ply_boot_client_process_pending_requests,
                                   NULL, client);
    }

  if (!client->is_connected)
    {
      if (failed_handler != NULL)
        {
          failed_handler (user_data, client);
        }
    }
  else
    {
      ply_boot_client_request_t *request;

      request = ply_boot_client_request_new (client, request_command,
                                             request_argument,
                                             handler, failed_handler, user_data);
      ply_list_append_data (client->requests_to_send, request);
    }
}
Esempio n. 18
0
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);
}
Esempio n. 19
0
static script_op_t *script_parse_for (script_scan_t *scan)
{
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);

  if (!script_scan_token_is_identifier_of_value (curtoken, "for")) return NULL;
  script_debug_location_t location_for = curtoken->location;
  curtoken = script_scan_get_next_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, '('))
    {
      script_parse_error (&curtoken->location,
                          "Expected a '(' at the start of a condition block");
      return NULL;
    }
  curtoken = script_scan_get_next_token (scan);
  script_debug_location_t location_first = curtoken->location;

  script_exp_t *first = script_parse_exp (scan);
  if (!first)
    {
      script_parse_error (&curtoken->location, "Expected a valid first expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ';'))
    {
      script_parse_error (&curtoken->location,
                          "Expected a ';' after the first 'for' expression");
      return NULL;
    }
  script_scan_get_next_token (scan);

  script_exp_t *cond = script_parse_exp (scan);
  if (!cond)
    {
      script_parse_error (&curtoken->location, "Expected a valid condition expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ';'))
    {
      script_parse_error (&curtoken->location, "Expected a ';' after the 'for' condition");
      return NULL;
    }
  script_scan_get_next_token (scan);
  script_debug_location_t location_last = curtoken->location;

  script_exp_t *last = script_parse_exp (scan);
  if (!last)
    {
      script_parse_error (&curtoken->location, "Expected a valid last expression");
      return NULL;
    }
  curtoken = script_scan_get_current_token (scan);
  if (!script_scan_token_is_symbol_of_value (curtoken, ')'))
    {
      script_parse_error (&curtoken->location, "Expected a ')' at the end of a for block");
      return NULL;
    }
  script_scan_get_next_token (scan);
  script_op_t *op_body = script_parse_op (scan);

  script_op_t *op_first = script_parse_new_op_exp (first, &location_first);
  script_op_t *op_last = script_parse_new_op_exp (last, &location_last);
  script_op_t *op_for = script_parse_new_op_cond (SCRIPT_OP_TYPE_FOR, cond, op_body, op_last, &location_for);

  ply_list_t *op_list = ply_list_new ();
  ply_list_append_data (op_list, op_first);
  ply_list_append_data (op_list, op_for);

  script_op_t *op_block = script_parse_new_op_block (op_list, &location_for);

  return op_block;
}
Esempio n. 20
0
static script_exp_t *script_parse_exp_pi (script_scan_t *scan)
{
  script_exp_t *exp = script_parse_exp_tm (scan);
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);

  while (true)
    {
      script_debug_location_t location = curtoken->location;
      if (!script_scan_token_is_symbol (curtoken)) break;
      if (script_scan_token_is_symbol_of_value (curtoken, '('))
        {
          ply_list_t *parameters = ply_list_new ();
          script_scan_get_next_token (scan);
          while (true)
            {
              if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
              script_exp_t *parameter = script_parse_exp (scan);

              ply_list_append_data (parameters, parameter);

              curtoken = script_scan_get_current_token (scan);
              if (script_scan_token_is_symbol_of_value (curtoken, ')')) break;
              if (!script_scan_token_is_symbol_of_value (curtoken, ','))
                {
                  script_parse_error (&curtoken->location,
                    "Function parameters should be separated with a ',' and terminated with a ')'");
                  return NULL;
                }
              curtoken = script_scan_get_next_token (scan);
            }
          script_scan_get_next_token (scan);
          exp = script_parse_new_exp_function_exe (exp, parameters, &location);
          continue;
        }
      script_exp_t *key;

      if (script_scan_token_is_symbol_of_value (curtoken, '.'))
        {
          script_scan_get_next_token (scan);
          if (script_scan_token_is_identifier (curtoken))
            {
              key = script_parse_new_exp_string (curtoken->data.string, &curtoken->location);
            }
          else
            {
              script_parse_error (&curtoken->location,
                "A dot based hash index must be an identifier");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      else if (script_scan_token_is_symbol_of_value (curtoken, '['))
        {
          script_scan_get_next_token (scan);
          key = script_parse_exp (scan);
          if (!key)
            {
              script_parse_error (&curtoken->location,
                "Expected a valid index expression");
              return NULL;
            }
          curtoken = script_scan_get_current_token (scan);
          if (!script_scan_token_is_symbol_of_value (curtoken, ']'))
            {
              script_parse_error (&curtoken->location,
                "Expected a ']' to terminate the index expression");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      else break;
      exp = script_parse_new_exp_dual (SCRIPT_EXP_TYPE_HASH, exp, key, &location);
    }
  return exp;
}
Esempio n. 21
0
static script_exp_t *script_parse_exp_tm (script_scan_t *scan)
{
  script_scan_token_t *curtoken = script_scan_get_current_token (scan);
  script_exp_t *exp = NULL;

  if (script_scan_token_is_integer (curtoken))
    {
      exp = script_parse_new_exp_number (curtoken->data.integer, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_float (curtoken))
    {
      exp = script_parse_new_exp_number (curtoken->data.floatpoint, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_identifier (curtoken))
    {
      if (script_scan_token_is_identifier_of_value (curtoken, "NULL"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_NULL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "INFINITY"))
        exp = script_parse_new_exp_number (INFINITY, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "NAN"))
        exp = script_parse_new_exp_number (NAN, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "global"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_GLOBAL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "local"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_LOCAL, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "this"))
        exp = script_parse_new_exp(SCRIPT_EXP_TYPE_TERM_THIS, &curtoken->location);
      else if (script_scan_token_is_identifier_of_value (curtoken, "fun"))
        {
          script_debug_location_t location = curtoken->location;
          script_scan_get_next_token (scan);
          exp = script_parse_new_exp_function_def (script_parse_function_def (scan), &location);
          return exp;
        }
      else
        {
          exp = script_parse_new_exp_var (curtoken->data.string, &curtoken->location);
        }
      curtoken = script_scan_get_next_token (scan);
      return exp;
    }
  if (script_scan_token_is_string (curtoken))
    {
      exp = script_parse_new_exp_string (curtoken->data.string, &curtoken->location);
      script_scan_get_next_token (scan);
      return exp;
    }
  
  if (script_scan_token_is_symbol_of_value (curtoken, '['))
    {
      ply_list_t *parameters = ply_list_new ();
      script_debug_location_t location = curtoken->location;
      script_scan_get_next_token (scan);
      while (true)
        {
          if (script_scan_token_is_symbol_of_value (curtoken, ']')) break;
          script_exp_t *parameter = script_parse_exp (scan);

          ply_list_append_data (parameters, parameter);

          curtoken = script_scan_get_current_token (scan);
          if (script_scan_token_is_symbol_of_value (curtoken, ']')) break;
          if (!script_scan_token_is_symbol_of_value (curtoken, ','))
            {
              script_parse_error (&curtoken->location,
                "Set parameters should be separated with a ',' and terminated with a ']'");
              return NULL;
            }
          curtoken = script_scan_get_next_token (scan);
        }
      script_scan_get_next_token (scan);
      exp = script_parse_new_exp_set (parameters, &location);
      return exp;
    }
  if (script_scan_token_is_symbol_of_value (curtoken, '('))
    {
      script_scan_get_next_token (scan);
      exp = script_parse_exp (scan);
      curtoken = script_scan_get_current_token (scan);
      if (!exp)
        {
          script_parse_error (&curtoken->location,
            "Expected valid contents of bracketed expression");
          return NULL;
        }
      if (!script_scan_token_is_symbol_of_value (curtoken, ')'))
        {
          script_parse_error (&curtoken->location,
            "Expected bracketed block to be terminated with a ')'");
          return NULL;
        }
      script_scan_get_next_token (scan);
      return exp;
    }
  return NULL;
}
Esempio n. 22
0
static void
add_pixel_display (ply_boot_splash_plugin_t *plugin,
                   ply_pixel_display_t      *display)
{
  ply_list_append_data (plugin->displays, display);
}
Esempio n. 23
0
static void
view_add_star (view_t *view)
{
        ply_boot_splash_plugin_t *plugin;
        ply_rectangle_t logo_area;
        star_t *star;
        unsigned int x, y;
        unsigned int width, height;
        unsigned long screen_width, screen_height;
        ply_list_node_t *node;

        assert (view != NULL);

        plugin = view->plugin;

        screen_width = ply_pixel_display_get_width (view->display);
        screen_height = ply_pixel_display_get_height (view->display);
        width = ply_image_get_width (plugin->logo_image);
        height = ply_image_get_height (plugin->logo_image);
        logo_area.x = (screen_width / 2) - (width / 2);
        logo_area.y = (screen_height / 2) - (height / 2);
        logo_area.width = width;
        logo_area.height = height;

        width = ply_image_get_width (plugin->star_image);
        height = ply_image_get_height (plugin->star_image);

        node = NULL;
        do {
                x = rand () % screen_width;
                y = rand () % screen_height;

                if ((x <= logo_area.x + logo_area.width)
                    && (x >= logo_area.x)
                    && (y >= logo_area.y)
                    && (y <= logo_area.y + logo_area.height))
                        continue;

                if ((x + width >= logo_area.x)
                    && (x + width <= logo_area.x + logo_area.width)
                    && (y + height >= logo_area.y)
                    && (y + height <= logo_area.y + logo_area.height))
                        continue;

                node = ply_list_get_first_node (view->stars);
                while (node != NULL) {
                        ply_list_node_t *next_node;

                        star = (star_t *) ply_list_node_get_data (node);
                        next_node = ply_list_get_next_node (view->stars, node);

                        if ((x <= star->x + width)
                            && (x >= star->x)
                            && (y >= star->y)
                            && (y <= star->y + height))
                                break;

                        if ((x + width >= star->x)
                            && (x + width <= star->x + width)
                            && (y + height >= star->y)
                            && (y + height <= star->y + height))
                                break;

                        node = next_node;
                }
        } while (node != NULL);

        star = star_new (x, y, (double) ((rand () % 50) + 1));
        ply_list_append_data (view->stars, star);
}
Esempio n. 24
0
static bool
create_heads_for_active_connectors (ply_renderer_backend_t *backend)
{
  int i;
  drmModeConnector *connector;

  for (i = 0; i < backend->resources->count_connectors; i++)
    {
      ply_renderer_head_t *head;
      drmModeEncoder *encoder;
      uint32_t controller_id;
      uint32_t encoder_id;
      uint32_t console_buffer_id;
      drmModeModeInfo *mode;

      connector = drmModeGetConnector (backend->device_fd,
                                       backend->resources->connectors[i]);

      if (connector == NULL)
        continue;

      if (connector->connection != DRM_MODE_CONNECTED)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      if (connector->count_modes <= 0)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      encoder = find_encoder_for_connector (backend, connector);

      if (encoder == NULL)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      encoder_id = encoder->encoder_id;
      controller_id = find_controller_for_encoder (backend, encoder);
      drmModeFreeEncoder (encoder);

      if (controller_id == 0)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      mode = get_active_mode_for_connector (backend, connector);

      console_buffer_id = get_console_buffer_id (backend, controller_id);

      head = ply_renderer_head_new (backend, connector, encoder_id,
                                    controller_id, console_buffer_id,
                                    mode);

      ply_list_append_data (backend->heads, head);
    }

#ifdef PLY_ENABLE_GDM_TRANSITION
  /* If the driver doesn't support mapping the fb console
   * then we can't get a smooth crossfade transition to
   * the display manager unless we use the /dev/fb interface
   * or the plymouth deactivate interface.
   *
   * In multihead configurations, we'd rather have working
   * multihead, but otherwise bail now.
   */
  if (!backend->driver_supports_mapping_console &&
      ply_list_get_length (backend->heads) == 1)
    {
      ply_trace ("Only one monitor configured, and driver doesn't "
                 "support mapping console, so letting frame-buffer "
                 "take over");

      free_heads (backend);
      return false;
    }
#endif

  return ply_list_get_length (backend->heads) > 0;
}
Esempio n. 25
0
static bool
create_heads_for_active_connectors (ply_renderer_backend_t *backend)
{
  int i;
  drmModeConnector *connector;
  ply_hashtable_t *heads_by_controller_id;

  heads_by_controller_id = ply_hashtable_new (NULL, NULL);

  for (i = 0; i < backend->resources->count_connectors; i++)
    {
      ply_renderer_head_t *head;
      drmModeEncoder *encoder;
      uint32_t encoder_id;
      drmModeCrtc *controller;
      uint32_t controller_id;
      uint32_t console_buffer_id;
      int connector_mode_index;

      connector = drmModeGetConnector (backend->device_fd,
                                       backend->resources->connectors[i]);

      if (connector == NULL)
        continue;

      if (connector->connection != DRM_MODE_CONNECTED)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      if (connector->count_modes <= 0)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      encoder = find_encoder_for_connector (backend, connector);

      if (encoder == NULL)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      encoder_id = encoder->encoder_id;
      controller = find_controller_for_encoder (backend, encoder);
      drmModeFreeEncoder (encoder);

      if (controller == NULL)
        {
          drmModeFreeConnector (connector);
          continue;
        }

      controller_id = controller->crtc_id;

      connector_mode_index = get_index_of_active_mode (backend, controller, connector);

      /* If we couldn't find the current active mode, fall back to the first available.
       */
      if (connector_mode_index < 0)
        {
          ply_trace ("falling back to first available mode");
          connector_mode_index = 0;
        }

      console_buffer_id = controller->buffer_id;
      drmModeFreeCrtc (controller);

      head = ply_hashtable_lookup (heads_by_controller_id,
                                   (void *) (intptr_t) controller_id);

      if (head == NULL)
        {
          head = ply_renderer_head_new (backend, connector, connector_mode_index,
                                        encoder_id, controller_id,
                                        console_buffer_id);

          ply_list_append_data (backend->heads, head);

          ply_hashtable_insert (heads_by_controller_id,
                                (void *) (intptr_t) controller_id,
                                head);
        }
      else
        {
          if (!ply_renderer_head_add_connector (head, connector, connector_mode_index))
            {
              ply_trace ("couldn't connect monitor to existing head");
            }

          drmModeFreeConnector (connector);
        }
    }

  ply_hashtable_free (heads_by_controller_id);

#ifdef PLY_ENABLE_DEPRECATED_GDM_TRANSITION
  /* If the driver doesn't support mapping the fb console
   * then we can't get a smooth crossfade transition to
   * the display manager unless we use the /dev/fb interface
   * or the plymouth deactivate interface.
   *
   * In multihead configurations, we'd rather have working
   * multihead, but otherwise bail now.
   */
  if (!backend->driver_supports_mapping_console &&
      ply_list_get_length (backend->heads) == 1)
    {
      ply_list_node_t *node;
      ply_renderer_head_t *head;

      node = ply_list_get_first_node (backend->heads);
      head = (ply_renderer_head_t *) ply_list_node_get_data (node);

      if (ply_array_get_size (head->connector_ids) == 1)
        {
          ply_trace ("Only one monitor configured, and driver doesn't "
                     "support mapping console, so letting frame-buffer "
                     "take over");

          free_heads (backend);
          return false;
        }
    }
#endif

  return ply_list_get_length (backend->heads) > 0;
}