if (!size)
continue;
PARA_INFO_LOG("writing chunk %lu\n", i);
- ret = write_all(STDOUT_FILENO, buf, &size);
+ ret = write_all(STDOUT_FILENO, buf, size);
if (ret < 0)
return ret;
}
size_t n = ret = recv_bin_buffer(fd, buf, bufsize);
if (ret <= 0)
break;
- ret = write_all(STDOUT_FILENO, buf, &n);
+ ret = write_all(STDOUT_FILENO, buf, n);
} while (ret >= 0);
out:
if (ret < 0)
memcpy(remainder, buf + l1, len - l1);
RC4(&scc->send->key, len - l1, remainder, tmp + l1);
}
- ret = write_all(scc->fd, (char *)tmp, &len);
+ ret = write_all(scc->fd, (char *)tmp, len);
free(tmp);
return ret;
}
* \param buf The buffer to be sent.
* \param len The length of \a buf.
*
- * \return Standard. In any case, the number of bytes that have been written is
- * stored in \a len.
+ * \return Standard.
*/
-int write_all(int fd, const char *buf, size_t *len)
+int write_all(int fd, const char *buf, size_t len)
{
- size_t total = *len;
+ size_t total = len;
assert(total);
- *len = 0;
- while (*len < total) {
- int ret = write(fd, buf + *len, total - *len);
+ len = 0;
+ while (len < total) {
+ int ret = write(fd, buf + len, total - len);
if (ret == -1)
return -ERRNO_TO_PARA_ERROR(errno);
- *len += ret;
+ len += ret;
}
- return 1;
+ return len;
}
/**
/** \file fd.h exported symbols from fd.c */
-int write_all(int fd, const char *buf, size_t *len);
+int write_all(int fd, const char *buf, size_t len);
int file_exists(const char *);
int para_select(int n, fd_set *readfds, fd_set *writefds,
struct timeval *timeout_tv);
gret = gcry_cipher_encrypt(scc->send->handle, tmp, size,
(unsigned char *)buf, size);
assert(gret == 0);
- ret = write_all(scc->fd, (char *)tmp, &size);
+ ret = write_all(scc->fd, (char *)tmp, size);
free(tmp);
return ret;
}
{
if (!len)
PARA_CRIT_LOG("len == 0\n");
- return write_all(fd, buf, &len);
+ return write_all(fd, buf, len);
}
/**