unsigned int time_out,
size_t *size_ret);
NTSTATUS read_data_ntstatus(int fd, char *buffer, size_t N);
+
ssize_t write_data(int fd, const char *buffer, size_t N);
-ssize_t iov_buflen(const struct iovec *iov, int iovlen);
-uint8_t *iov_buf(TALLOC_CTX *mem_ctx, const struct iovec *iov, int iovcnt);
ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt);
bool send_keepalive(int client);
NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
--- /dev/null
+/*
+ * Unix SMB/CIFS implementation.
+ * Samba system utilities
+ * Copyright (C) Volker Lendecke 2014
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "iov_buf.h"
+
+ssize_t iov_buflen(const struct iovec *iov, int iovcnt)
+{
+ size_t buflen = 0;
+ int i;
+
+ for (i=0; i<iovcnt; i++) {
+ size_t thislen = iov[i].iov_len;
+ size_t tmp = buflen + thislen;
+
+ if ((tmp < buflen) || (tmp < thislen)) {
+ /* overflow */
+ return -1;
+ }
+ buflen = tmp;
+ }
+ return buflen;
+}
+
+uint8_t *iov_buf(TALLOC_CTX *mem_ctx, const struct iovec *iov, int iovcnt)
+{
+ int i;
+ ssize_t buflen;
+ uint8_t *buf, *p;
+
+ buflen = iov_buflen(iov, iovcnt);
+ if (buflen == -1) {
+ return NULL;
+ }
+ buf = talloc_array(mem_ctx, uint8_t, buflen);
+ if (buf == NULL) {
+ return NULL;
+ }
+
+ p = buf;
+ for (i=0; i<iovcnt; i++) {
+ size_t len = iov[i].iov_len;
+
+ memcpy(p, iov[i].iov_base, len);
+ p += len;
+ }
+ return buf;
+}
--- /dev/null
+/*
+ * Unix SMB/CIFS implementation.
+ * Samba system utilities
+ * Copyright (C) Volker Lendecke 2014
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LIB_IOV_BUF_H__
+#define __LIB_IOV_BUF_H__
+
+#include <unistd.h>
+#include <talloc.h>
+
+ssize_t iov_buflen(const struct iovec *iov, int iovlen);
+uint8_t *iov_buf(TALLOC_CTX *mem_ctx, const struct iovec *iov, int iovcnt);
+
+#endif
#include "lib/util/tevent_unix.h"
#include "lib/background.h"
#include "lib/messages_dgm.h"
+#include "lib/iov_buf.h"
struct messaging_callback {
struct messaging_callback *prev, *next;
#include "includes.h"
#include "messages.h"
#include "util_tdb.h"
+#include "lib/iov_buf.h"
/*
* It is not possible to include ctdb.h and tdb_compat.h (included via
#include "../lib/util/tevent_ntstatus.h"
#include "../lib/tsocket/tsocket.h"
#include "lib/sys_rw.h"
+#include "lib/iov_buf.h"
const char *client_addr(int fd, char *addr, size_t addrlen)
{
return read_fd_with_timeout(fd, buffer, N, N, 0, NULL);
}
-ssize_t iov_buflen(const struct iovec *iov, int iovcnt)
-{
- size_t buflen = 0;
- int i;
-
- for (i=0; i<iovcnt; i++) {
- size_t thislen = iov[i].iov_len;
- size_t tmp = buflen + thislen;
-
- if ((tmp < buflen) || (tmp < thislen)) {
- /* overflow */
- return -1;
- }
- buflen = tmp;
- }
- return buflen;
-}
-
-uint8_t *iov_buf(TALLOC_CTX *mem_ctx, const struct iovec *iov, int iovcnt)
-{
- int i;
- ssize_t buflen;
- uint8_t *buf, *p;
-
- buflen = iov_buflen(iov, iovcnt);
- if (buflen == -1) {
- return NULL;
- }
- buf = talloc_array(mem_ctx, uint8_t, buflen);
- if (buf == NULL) {
- return NULL;
- }
-
- p = buf;
- for (i=0; i<iovcnt; i++) {
- size_t len = iov[i].iov_len;
-
- memcpy(p, iov[i].iov_base, len);
- p += len;
- }
- return buf;
-}
-
/****************************************************************************
Write all data from an iov array
NB. This can be called with a non-socket fd, don't add dependencies
deps='replace',
private_library=True)
+bld.SAMBA3_LIBRARY('iov_buf',
+ source='lib/iov_buf.c',
+ deps='replace talloc',
+ private_library=True)
+
bld.SAMBA3_SUBSYSTEM('samba3util',
source='''lib/system.c
lib/sendfile.c
lib/util_sock.c
lib/util_transfer_file.c
lib/sock_exec.c''',
- deps='ndr samba-security NDR_SECURITY samba-util util_tdb ccan-hash sys_rw')
+ deps='ndr samba-security NDR_SECURITY samba-util util_tdb ccan-hash sys_rw iov_buf')
if bld.CONFIG_GET("CTDB_CFLAGS") and bld.CONFIG_GET("CTDB_INCLUDE"):
SAMBA_CLUSTER_SUPPORT_SOURCES='''