Exemple #1
0
int		print_loadbar(t_all *all, t_image *together,
			      double minmax, time_t start)
{
  static int	last_pc = -1;
  static int	last_time = -1;
  time_t	elapsed;
  int		pos;

  pos = (WIN_X / 2) - (630 / 2);
  elapsed = time(NULL) - start;
  if (last_time == elapsed && ABS(last_pc - minmax) < 5 && minmax != 100)
    return (0);
  mlx_clear_window(all->mlx_ptr, all->win_ptr);
  get_motd(all, elapsed);
  mlx_put_image_to_window(all->mlx_ptr, all->win_ptr,
			  together[0].img_ptr, pos, 2 * WIN_Y / 3);
  mlx_put_image_to_window(all->mlx_ptr, all->win_ptr,
			  together[1].img_ptr, pos + 30, 2 * WIN_Y / 3);
  mlx_put_image_to_window(all->mlx_ptr, all->win_ptr,
			  together[2].img_ptr,
			  pos + (minmax * 6) + 30, 2 * WIN_Y / 3);
  put_info(all, elapsed, minmax);
  last_time = elapsed;
  last_pc = minmax;
  return (0);
}
Exemple #2
0
void client_read(client *cl)
{
  int status, pn;

  status = mr_cont_receive(cl->con, &cl->req);
  if (status == -1)
    return;
  else if (status != MR_SUCCESS)
    {
      cl->state = CL_CLOSING;
      if (status != MR_NOT_CONNECTED)
	com_err(whoami, status, "while reading from socket");
      return;
    }

  pn = cl->req.u.mr_procno;
  if (pn < 0 || pn > MR_MAX_PROC)
    {
      com_err(whoami, 0, "procno out of range");
      client_reply(cl, MR_UNKNOWN_PROC);
      goto out;
    }
  log_args(procnames[pn], 2, cl->req.mr_argc, cl->req.mr_argv);

  if (dormant == ASLEEP && pn != MR_NOOP && pn != MR_MOTD)
    {
      client_reply(cl, MR_DOWN);
      com_err(whoami, MR_DOWN, "(query refused)");
      goto out;
    }

  /* make sure this gets cleared before every operation */
  dbms_errno = 0;

  switch (pn)
    {
    case MR_NOOP:
      client_reply(cl, MR_SUCCESS);
      break;

    case MR_AUTH:
      do_auth(cl);
      break;

    case MR_QUERY:
      do_retr(cl);
      break;

    case MR_ACCESS:
      do_access(cl);
      break;

    case MR_SHUTDOWN:
      do_shutdown(cl);
      break;

    case MR_DO_UPDATE:
      client_reply(cl, MR_PERM);
      break;

    case MR_MOTD:
      get_motd(cl);
      break;

    case MR_PROXY:
      do_proxy(cl);
      break;

    case MR_SETVERSION:
      do_version(cl);
      break;

    case MR_KRB5_AUTH:
      do_krb5_auth(cl);
      break;

    }

out:
  mr_destroy_reply(cl->req);
  memset(&cl->req, 0, sizeof(mr_params));
}