void ft_waitsock(int fd) { t_pollfd event; char buf; while (fd_size(fd)) { read(fd, &buf, 1); write(1, &buf, 1); } event.fd = fd; event.events = POLLIN; if ((poll(&event, sizeof(t_pollfd), 1)) == -1) error("poll -> "); }
static void do_reopen(cdr_fd_t *fd) { int x = 0; if (fd->fd > -1) { close(fd->fd); fd->fd = -1; } for (x = 0; x < 10; x++) { if ((fd->fd = open(fd->path, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) > -1) { fd->bytes = fd_size(fd->fd); break; } switch_yield(100000); } }
void synch_data()//a appeler dans l'interface chat et dans une fonction de securiter { int *pipefd; char *login; char *buffer; int size; if (!(pipefd = recup_pipefd(NULL))) { printf("pipe not found"); exit(-1); } while ((size = fd_size(pipefd[0]))) { login = read_line(pipefd[0]); buffer = read_line(pipefd[0]); printf("bdd login == :%s:\n", login); printf("bdd buffer == :%s:\n\n", buffer); gest(login, buffer); } }