Ejemplo n.º 1
0
void	close_connection(int cs, struct sockaddr_in *client_sin)
{
  char	*name;
  char	*ntoa;
  char	*port;
  int	i = 17;
  int	j = 0;

  xclose(cs);
  port = my_getstr(ntohs(client_sin->sin_port), "0123456789");
  ntoa = inet_ntoa(client_sin->sin_addr);
  name = xmalloc(sizeof(*name) * (my_strlen(port)
				  + my_strlen(ntoa) + 20));
  name = my_strcpy(name, "Disconnection of ");
  while (ntoa[j] != '\0')
    name[i++] = ntoa[j++];
  j = 0;
  name[i++] = ':';
  while (port[j] != '\0')
    name[i++] = port[j++];
  name[i++] = '\n';
  name[i++] = '\0';
  my_putstr(name);
  xfree(name);
  xfree(port);
}
Ejemplo n.º 2
0
t_sound		*init_sound_amb(char *path)
{
  int		i;
  char		*path_sound;
  char		*tmp;
  t_sound	*sound_tab;
  FMOD_RESULT	c;

  i = -1;
  if ((sound_tab = malloc(sizeof(t_sound) * NB_SOUND_AMB_MAX)) == NULL)
    return (NULL);
  while (++i < NB_SOUND_AMB_MAX)
    {
      FMOD_System_Create(&sound_tab[i].sys);
      FMOD_System_Init(sound_tab[i].sys, 1, FMOD_INIT_NORMAL, NULL);
      tmp = my_getstr(i, "0123456789");
      path_sound = my_str_concat(tmp, FORMAT_SOUND);
      if ((c = FMOD_System_CreateSound
	   (sound_tab[i].sys, my_str_concat(path, path_sound),
	    FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0,
	    &sound_tab[i].sound)) != FMOD_OK)
	return (NULL);
      printf("[*] Sound ambiance %s load\n", path_sound);
      free(tmp);
      free(path_sound);
    }
  return (sound_tab);
}