コード例 #1
0
ファイル: cursesui.cpp プロジェクト: evgeni/sysdig
void sinsp_cursesui::pause()
{
	m_paused = !m_paused;
	if(m_datatable != NULL)
	{
		m_datatable->set_paused(m_paused);
	}
#ifndef NOCURSESUI
	render_header();
#endif
}
コード例 #2
0
ファイル: main.cpp プロジェクト: no1msd/headerize
int main(int argc, char* argv[]) {
  po::options_description desc("Allowed options");
  desc.add_options()
      ("help,h", "show help")
      ("output,o", po::value<std::string>(),
          "Output file. Leave empty to use stdout.")
      ("namespace,n", po::value<std::string>(),
          "Namespace to put the variables in.")
      ("input,i", po::value<std::vector<std::string>>(),
          "List of files to parse.");
  po::variables_map vm;

  try {
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    if (vm.count("help") || !vm.count("input")) {
      std::cout << desc << std::endl;
      return 1;
    }

    if (vm.count("output")) {
      auto filename = vm["output"].as<std::string>();
      open_file(filename, std::ios::out, [&vm](std::fstream& file) {
        render_header(file, vm);
      });
    } else {
      render_header(std::cout, vm);
    }
  } catch(std::exception& error) {
    std::cerr << error.what() << std::endl;
    return 1;
  }

  return 0;
}
コード例 #3
0
ファイル: cursesui.cpp プロジェクト: hlieberman/sysdig
void sinsp_cursesui::render()
{
	//
	// Draw the header at the top of the page
	//
	render_header();

	//
	// Print the position in the chart
	//
	if(m_output_filtering || m_output_searching || m_search_caller_interface != NULL)
	{
		render_position_info();
	}

	//
	// Draw the menu at the bottom of the screen
	//
	render_main_menu();

	//
	// If required, draw the side menu
	//
	if(m_view_sidemenu)
	{
		m_view_sidemenu->render();
	}

	if(m_action_sidemenu)
	{
		m_action_sidemenu->render();
	}

	//
	// Print the position in the chart
	//
	if(!(m_output_filtering || m_output_searching || m_search_caller_interface != NULL))
	{
		render_position_info();
	}
}
コード例 #4
0
ファイル: gdashboard.c プロジェクト: MartinReidy/goaccess
/* render dashboard content */
static void
render_content (WINDOW * win, GDashModule * data, int *y, int *offset,
                int *total, GScroll * gscroll)
{
  GModule module = data->module;
  int i, j, size, h, w, data_pos = get_data_pos_rows ();

  getmaxyx (win, h, w);
  (void) w;

  size = data->dash_size;
  for (i = *offset, j = 0; i < size; i++) {
    /* header */
    if ((i % size) == DASH_HEAD_POS) {
      render_header (win, data, gscroll->current, y);
    } else if ((i % size) == DASH_DASHES_POS && !conf.no_column_names) {
      /* account for already printed dash lines under columns */
      (*y)++;
    } else if ((i % size) == DASH_EMPTY_POS || (i % size) == size - 1) {
      /* blank lines */
      (*y)++;
    } else if ((i % size) == DASH_COLS_POS && !conf.no_column_names) {
      /* column headers lines */
      render_cols (win, data, y);
      (*y)++;
    } else if ((i % size) >= data_pos || (i % size) <= size - 2) {
      /* account for 2 lines at the header and 2 blank lines */
      j = ((i % size) - data_pos) + gscroll->module[module].offset;
      /* actual data */
      render_data_line (win, data, y, j, gscroll);
    } else {
      /* everything else should be empty */
      (*y)++;
    }
    (*total)++;
    if (*y >= h)
      break;
  }
}
コード例 #5
0
ファイル: server.c プロジェクト: sailbrowser/http-server2
void *thread_worker(void *arg)
{
  struct thread_info *tinfo = arg;
  static char buffer[4096];
  int pipe_socket = tinfo->pipe_socket;
  // printf("thread %d pipe %d\n", tinfo->thread_num, pipe_socket);

  int epoll = epoll_create1(0);

  struct epoll_event pipe_event;
  pipe_event.data.fd = pipe_socket;
  pipe_event.events = EPOLLIN;
  if(epoll_ctl(epoll, EPOLL_CTL_ADD, pipe_socket, &pipe_event) == -1) {
    perror("Error epoll_ctl connection sock\n");
    exit(1);
  }

  while (1) {
    struct epoll_event events[MAX_EVENTS];
    int n_events = epoll_wait(epoll, events, MAX_EVENTS, -1);
    if(n_events == -1) {
      perror("Error epoll_wait\n");
      exit(1);
    }

    for (int i = 0; i < n_events; ++i)
    {
      if(events[i].data.fd == pipe_socket) {
        int accept_socket;
        recv_socket_from_pipeline(pipe_socket, &accept_socket);

        struct epoll_event new_event;
        new_event.data.fd = accept_socket;
        new_event.events = EPOLLIN | EPOLLET;
        if(epoll_ctl(epoll, EPOLL_CTL_ADD, accept_socket, &new_event) == -1) {
          perror("Error epoll_ctl connection sock\n");
          exit(1);
        }
      } else {
        int cur_socket = events[i].data.fd;
        // printf("socket = %d\n", cur_socket);
        ssize_t size = recv(cur_socket, buffer, sizeof(buffer), MSG_NOSIGNAL);
        // printf("size = %lu\n", size);
        if (size > 0) {
          buffer[size] = 0;
          // printf("%s", buffer);
          struct http_request req;
          http_request_init(&req);
          struct http_response res;
          http_response_init(&res);
          int fd;
            // struct http_io *w_read = (struct http_io *)watcher;
          if(http_request_parse(&req, buffer, size) == -1) {
            res.code = _501;
          } else if(req.method != GET) {
            res.code = _501;
          } else {
            fd = open(req.path, O_RDONLY);
            if(fd == -1) {
              res.code = _404;
            } else {
              res.code = _200;
                /* get the size of the file to be sent */
              struct stat stat_buf;
              fstat(fd, &stat_buf);
              res.content_length = stat_buf.st_size;
              res.content_type = html;
            }
            render_header(&res);
            send(cur_socket, res.header, strlen(res.header), MSG_NOSIGNAL);
            if(res.code == _200) {
              ssize_t l;
              while((l = read(fd, buffer, sizeof(buffer))) > 0) {
                send(cur_socket, buffer, l, MSG_NOSIGNAL);
              }
              close(fd);
            }
          }
        }
        shutdown(cur_socket, SHUT_RDWR);
        close(cur_socket);
      }
    }
  }

  // sem_post(&semaphore);
  return NULL;
}