Exemple #1
0
static int
_assign_partial_auth_data (struct mu_auth_data *d, const char *key,
			   const char *val)
{
  int rc = 0;
  
  if (strcmp (key, MU_AUTH_NAME) == 0)
    rc = (d->name = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_PASSWD) == 0)
    rc = (d->passwd = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_UID) == 0)
    d->uid = atoi (val);
  else if (strcmp (key, MU_AUTH_GID) == 0)
    d->gid = atoi (val);
  else if (strcmp (key, MU_AUTH_GECOS) == 0)
    rc = (d->gecos = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_DIR) == 0)
    rc = (d->dir = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_SHELL) == 0)   
    rc = (d->shell = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_MAILBOX) == 0)
    rc = (d->mailbox = strdup (val)) ? 0 : errno;
  else if (strcmp (key, MU_AUTH_QUOTA) == 0)   
    get_quota (&d->quota, val);
  return rc;
}
Exemple #2
0
/*
** Un quota de ressources doit etre trouver en fonction
** du nombre de joueurs ainsi que la taille de la map.
** On remplit la map aleatoirement selon ce quota
** (x, y en rand).
*/
void	init_map(t_desc *serv)
{
  int	quota[7];
  int	i;
  int	x;
  int	y;

  i = 0;
  serv->map = 0;
  srand(time(0));
  get_quota(serv, quota);
  while (i < 7)
    {
      if (quota[i] > 0)
	{
	  x = rand() % serv->x;
	  y = rand() % serv->y;
	  if (update_exist_case(serv->map, x, y, i) < 0)
	    fill_map(&serv->map, x, y, i);
	}
      if (quota[i]-- <= 0)
	i++;
    }
}