void FileTransfertUpload::onSocketError(QAbstractSocket::SocketError) { sender()->deleteLater(); _errors++; emit clientError("Client reject file."); check_nbr(); }
int ft_printf(char *format, ...) { char *tmp; va_list arg; int i; int u; u = 0; i = -1; va_start(arg, format); while (format[++i]) { if (format[i] == '%') { tmp = ft_strsub(format, (i + 1), (ft_strlen(format) - i)); if (check_flag(format[i + 1]) != -1) u = u + (wflag(format[i + 1], arg, &i)); else if (check_space(tmp) != -1) u = u + (wspace(tmp, &i, format, arg)); else i = i + (check_nbr(tmp, &u, arg)); } else u = u + (wformat(format[i])); } va_end(arg); return (u); }
void FileTransfertUpload::onSocketWritten() { QTcpSocket *socket = dynamic_cast<QTcpSocket*>(sender()); if (socket->bytesToWrite() == 0) { socket->close(); socket->deleteLater(); _completed++; check_nbr(); } }
void FileTransfertUpload::receiveAcceptFile(NetworkClient *client, int port) { if (port == 0) { _errors++; emit clientError("Client reject file."); check_nbr(); } else { QTcpSocket *socket = new QTcpSocket(this); socket->connectToHost(client->getTcpSocket()->peerAddress(), port); connect(socket, SIGNAL(connected()), this, SLOT(onSocketConnected())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(onSocketWritten())); } }
t_data first_take(t_data the) { the.i = 0; the.j = 0; if ((the.aff = (char **)malloc(sizeof(char *) * 10000)) == NULL) error(); get_next_line(0, &the.line); the.nbr = check_nbr(the); the = take_ants(the); if ((the.tube = (char **)malloc(sizeof(char *) * (the.nbr * 1000 + 1))) ==\ NULL) error(); the.aff[0] = ft_strdup(the.line); return (the); }
int my_getnbr(char *nbr) { int n; int i; int res; n = 1; if (check_nbr(nbr) == -1) return (-1); res = 0; i = my_strlen(nbr) - 1; while (i >= 0) { res += n * (nbr[i] - 48); n = n * 10; i--; } return (res); }