示例#1
0
void		send_client(t_fds *fds, t_server *srv, int tim)
{
	int			n;
	char		*cmd;
	t_gfx		*gfx;
	t_client	*clt;

	cmd = time_lapse(fds, srv, tim);
	while (tim >= 0 && --fds->max > 0 && !(n = 0))
	{
		if (!(clt = srv->clt) && !FD_ISSET(fds->max, &fds->wr))
			continue ;
		while (clt != NULL && clt->socket != fds->max)
			clt = clt->next;
		gfx = srv->gfx;
		while (gfx != NULL && gfx->socket != fds->max)
			gfx = gfx->next;
		if (!incant_process(clt, srv) || (!clt && gfx))
			cmd = !clt ? ring_send(srv, gfx->ring) : ring_send(srv, clt->ring);
		while (cmd && n < (clt ? 13 : 10) && strncmp(cmd, (!clt ? g_gfx_cmd[n] :
				g_clt_cmd[n]), strlen(!clt ? g_gfx_cmd[n] : g_clt_cmd[n])) != 0)
			n++;
		(!clt && cmd && 0 <= n && n < 11) ? g_tfg[n](fds, srv, gfx, cmd) : NULL;
		if ((n = time_action((save_cur_cmd(clt, cmd, n) ? n : 13), clt, srv)))
			g_tfc[n - 1](fds, srv, clt, cmd);
		ft_memdel((void **)&cmd);
	}
}
示例#2
0
static bool postconfig_run(void)
{
  struct account account = {0};
  char *zone = 0;
  bool utc = true;
  
  if(chdir(INSTALL_ROOT) == -1)
  {
    error(strerror(errno));
    return false;
  }

  if(mount("none",INSTALL_ROOT "/dev","devtmpfs",0,0) == -1)
  {
    error(strerror(errno));
    return false;
  }
  
  if(mount("none",INSTALL_ROOT "/proc","proc",0,0) == -1)
  {
    error(strerror(errno));
    return false;
  }
  
  if(mount("none",INSTALL_ROOT "/sys","sysfs",0,0) == -1)
  {
    error(strerror(errno));
    return false;
  }
  
  if(!is_root_setup() && (!ui_window_root(&account) || !root_action(&account)))
  {
    account_free(&account);
    return false;
  }
  
  account_free(&account);
  
  if(!is_user_setup() && (!ui_window_user(&account) || !user_action(&account)))
  {
    account_free(&account);
    return false;
  }
  
  account_free(&account);

  if(!get_timezone_data() || !ui_window_time(tz_data,&zone,&utc) || !time_action(zone,utc))
    return false;

  if(umount2(INSTALL_ROOT "/dev",MNT_DETACH) == -1)
  {
    error(strerror(errno));
    return false;    
  }
  
  if(umount2(INSTALL_ROOT "/proc",MNT_DETACH) == -1)
  {
    error(strerror(errno));
    return false;
  }
  
  if(umount2(INSTALL_ROOT "/sys",MNT_DETACH) == -1)
  {
    error(strerror(errno));
    return false;
  }
  
  return true;
}