// Обрабатываем новое сообщение int handleEvent(int fd) { struct Connection *connection = getConnection(fd); if (connection == NULL) { fprintf(stderr, "Error: connection from epoll wasn't found in list\n"); return -1; } if (checkConnectionTimeout(connection) == 1) { return 0; } if (checkAuthentication(connection) > 0) { passAuthentication(connection); } else { if (connection->ptm == -1) { if (createPty(connection) == -1) { fprintf(stderr, "Error: creating new pty\n"); return -1; } } if (fd == connection->connectionfd) { sendMessage(connection->ptm, connection->connectionfd); } else { sendMessage(connection->connectionfd, connection->ptm); } } return 0; }
int main(int argc, char *argv[]) { createPty(); return 0; }