Esempio n. 1
0
MHD_Response *execute(struct MHD_Connection *connection, const char *bas) {
  const char *width =
    MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "width");
  const char *height =
    MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "height");
  const char *command =
    MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "command");
  const char *graphicText =
    MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "graphic-text");
  const char *accept =
    MHD_lookup_connection_value(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT);

  if (width != NULL) {
    os_graf_mx = atoi(width);
  }
  if (height != NULL) {
    os_graf_my = atoi(height);
  }
  if (graphicText != NULL) {
    g_graphicText = atoi(graphicText) > 0;
  }
  if (command != NULL) {
    strcpy(opt_command, command);
  }

  log("%s dim:%dX%d", bas, os_graf_mx, os_graf_my);
  g_connection = connection;
  g_canvas.reset();
  g_start = dev_get_millisecond_count();
  g_canvas.setGraphicText(g_graphicText);
  g_canvas.setJSON((strncmp(accept, "application/json", 16) == 0));
  g_cookies.removeAll();
  sbasic_main(bas);
  g_connection = NULL;
  String page = g_canvas.getPage();
  MHD_Response *response =
    MHD_create_response_from_buffer(page.length(), (void *)page.c_str(),
                                    MHD_RESPMEM_MUST_COPY);
  List_each(String *, it, g_cookies) {
    String *next = (*it);
    MHD_add_response_header(response,
                            MHD_HTTP_HEADER_SET_COOKIE,
                            next->c_str());
  }
Esempio n. 2
0
int maGetMilliSecondCount(void) {
  return dev_get_millisecond_count();
}