コード例 #1
0
ファイル: client.c プロジェクト: noelq/EpiHistory
void		client(char *name, int port)
{
  struct sockaddr_in    sockin;
  int                   sock;
  fd_set                readfds;
  fd_set                writefds;
  char                  buf[4096];
  t_curse               curse;

  init_sockin(&sockin, &sock, name, port);
  init_interface(&curse);
  while (strcmp(buf, "/part") != 0)
    {
      if (strncmp(buf, "/server", 7) == 0)
        cmd(buf, sock);
      reset_loop(sock, &readfds);
      memset(buf, 0, 4096);
      if (select(sock + 1, &readfds, &writefds, NULL, NULL) != -1)
	{
	  if (FD_ISSET(sock, &readfds))
	    send_msg(sock, curse, buf);
	  if (FD_ISSET(0, &readfds))
	    recup_msg(sock, curse, buf);
	}
    }
  endwin();
  close(sock);
}
コード例 #2
0
int	send_private(t_client *client)
{
  int	pos;

  if (count_tab(client->tab) < 3)
    return (derrorn("/msg usage: /msg _nickname_ _message_"));
  pos = recup_msg(client->buffer_in);
  snprintf(client->buffer_out, 512, "PRIVMSG %s :%s",
	   client->tab[1], client->buffer_in + pos);
  client->action = WRITE;
  return (0);
}