#include "para.h"
#include "error.h"
+/*
+ * Write a buffer to a file descriptor, re-write on short writes.
+ *
+ * \param fd The file descriptor.
+ * \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.
+ */
+int write_all(int fd, const char *buf, size_t *len)
+{
+ size_t total = *len;
+
+ assert(total);
+ *len = 0;
+ while (*len < total) {
+ int ret = write(fd, buf + *len, total - *len);
+ if (ret == -1)
+ return -ERRNO_TO_PARA_ERROR(errno);
+ *len += ret;
+ }
+ return 1;
+}
+
/**
* Check whether a file exists.
*
/** \file fd.h exported symbols from fd.c */
+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);
#define AI_ADDRCONFIG 0
#endif
+#include <dirent.h>
#include "para.h"
#include "error.h"
#include "net.h"
#include "string.h"
+#include "fd.h"
/** Information about one encrypted connection. */
return ia;
}
-/*
- * Write a buffer to a file descriptor, re-write on short writes.
- *
- * \param fd The file descriptor.
- * \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.
- */
-static int write_all(int fd, const char *buf, size_t *len)
-{
- size_t total = *len;
-
- assert(total);
- *len = 0;
- while (*len < total) {
- int ret = write(fd, buf + *len, total - *len);
- if (ret == -1)
- return -ERRNO_TO_PARA_ERROR(errno);
- *len += ret;
- }
- return 1;
-}
-
/**
* Encrypt and send a binary buffer.
*