Revert "s3:libsmb: add an option to cli_push to let the caller provide the buffers"
authorStefan Metzmacher <metze@samba.org>
Thu, 12 Mar 2009 08:02:02 +0000 (09:02 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 12 Mar 2009 10:03:50 +0000 (11:03 +0100)
This reverts commit 9579a6f193f570e4ce2af80f4aac7c2f25ae5b22.

It's confusing to have a boolean to alter the behavior of cli_push
and as the new feature isn't used yet I revert it.

We can readd a extra function later.

metze

source3/client/client.c
source3/include/proto.h
source3/libsmb/clireadwrite.c
source3/torture/torture.c

index 67a2458a94c860a9f146541e0ea55b756bbf52d3..aaa9e35d9689bdc8768db5b99f81aa90cb4cce78 100644 (file)
@@ -220,9 +220,7 @@ struct push_state {
        SMB_OFF_T nread;
 };
 
-static size_t push_source(uint8_t *inbuf, size_t n,
-                         const uint8_t **outbuf,
-                         void *priv)
+static size_t push_source(uint8_t *buf, size_t n, void *priv)
 {
        struct push_state *state = (struct push_state *)priv;
        int result;
@@ -231,7 +229,7 @@ static size_t push_source(uint8_t *inbuf, size_t n,
                return 0;
        }
 
-       result = readfile(inbuf, n, state->f);
+       result = readfile(buf, n, state->f);
        state->nread += result;
        return result;
 }
@@ -1683,8 +1681,8 @@ static int do_put(const char *rname, const char *lname, bool reput)
        state.f = f;
        state.nread = 0;
 
-       status = cli_push(targetcli, fnum, 0, 0, io_bufsize,
-                         false, push_source, &state);
+       status = cli_push(targetcli, fnum, 0, 0, io_bufsize, push_source,
+                         &state);
        if (!NT_STATUS_IS_OK(status)) {
                d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
        }
index 794a006a687a6d839c0cde79d1d01ffe44c6b245..a1cafb6837f63da6298818e0f6ca3130156eadf5 100644 (file)
@@ -2790,18 +2790,13 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                struct cli_state *cli,
                                uint16_t fnum, uint16_t mode,
                                off_t start_offset, size_t window_size,
-                               bool caller_buffers,
-                               size_t (*source)(uint8_t *inbuf, size_t n,
-                                                const uint8_t **outbuf,
+                               size_t (*source)(uint8_t *buf, size_t n,
                                                 void *priv),
                                void *priv);
 NTSTATUS cli_push_recv(struct async_req *req);
 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
                  off_t start_offset, size_t window_size,
-                 bool caller_buffers,
-                 size_t (*source)(uint8_t *inbuf, size_t n,
-                                  const uint8_t **outbuf,
-                                  void *priv),
+                 size_t (*source)(uint8_t *buf, size_t n, void *priv),
                  void *priv);
 
 /* The following definitions come from libsmb/clisecdesc.c  */
index 7e7cf0d682129a26c173f99061a9cb671ff72704..f2f447b4c95661f7d87190473afd6f4b200cc073 100644 (file)
@@ -930,11 +930,8 @@ struct cli_push_state {
        uint16_t mode;
        off_t start_offset;
        size_t window_size;
-       bool caller_buffers;
 
-       size_t (*source)(uint8_t *inbuf, size_t n,
-                        const uint8_t **outbuf,
-                        void *priv);
+       size_t (*source)(uint8_t *buf, size_t n, void *priv);
        void *priv;
 
        bool eof;
@@ -966,21 +963,13 @@ static bool cli_push_write_setup(struct async_req *req,
        substate->req = req;
        substate->idx = idx;
        substate->ofs = state->next_offset;
-       if (state->caller_buffers) {
-               substate->buf = NULL;
-       } else {
-               substate->buf = talloc_array(substate, uint8_t,
-                                            state->chunk_size);
-               if (!substate->buf) {
-                       talloc_free(substate);
-                       return false;
-               }
+       substate->buf = talloc_array(substate, uint8_t, state->chunk_size);
+       if (!substate->buf) {
+               talloc_free(substate);
+               return false;
        }
-
-       /* source function can overwrite substate->buf... */
        substate->size = state->source(substate->buf,
                                       state->chunk_size,
-                                      (const uint8_t **)&substate->buf,
                                       state->priv);
        if (substate->size == 0) {
                state->eof = true;
@@ -1013,9 +1002,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                struct cli_state *cli,
                                uint16_t fnum, uint16_t mode,
                                off_t start_offset, size_t window_size,
-                               bool caller_buffers,
-                               size_t (*source)(uint8_t *inbuf, size_t n,
-                                                const uint8_t **outbuf,
+                               size_t (*source)(uint8_t *buf, size_t n,
                                                 void *priv),
                                void *priv)
 {
@@ -1032,7 +1019,6 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
        state->fnum = fnum;
        state->start_offset = start_offset;
        state->mode = mode;
-       state->caller_buffers = caller_buffers;
        state->source = source;
        state->priv = priv;
        state->eof = false;
@@ -1122,10 +1108,7 @@ NTSTATUS cli_push_recv(struct async_req *req)
 
 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
                  off_t start_offset, size_t window_size,
-                 bool caller_buffers,
-                 size_t (*source)(uint8_t *inbuf, size_t n,
-                                  const uint8_t **outbuf,
-                                  void *priv),
+                 size_t (*source)(uint8_t *buf, size_t n, void *priv),
                  void *priv)
 {
        TALLOC_CTX *frame = talloc_stackframe();
@@ -1146,7 +1129,7 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
        }
 
        req = cli_push_send(frame, ev, cli, fnum, mode, start_offset,
-                           window_size, caller_buffers, source, priv);
+                           window_size, source, priv);
        if (req == NULL) {
                goto nomem;
        }
index 12a4aec9a0b98939d0bbbfe8e535bd72c3abb2c5..10e541f3845c13e2e141f05dd083dbba6f0b108f 100644 (file)
@@ -5117,9 +5117,7 @@ static bool run_chain1(int dummy)
        return True;
 }
 
-static size_t null_source(uint8_t *inbuf, size_t n,
-                         const uint8_t **outbuf,
-                         void *priv)
+static size_t null_source(uint8_t *buf, size_t n, void *priv)
 {
        size_t *to_pull = (size_t *)priv;
        size_t thistime = *to_pull;
@@ -5129,7 +5127,7 @@ static size_t null_source(uint8_t *inbuf, size_t n,
                return 0;
        }
 
-       memset(inbuf, 0, thistime);
+       memset(buf, 0, thistime);
        *to_pull -= thistime;
        return thistime;
 }
@@ -5172,7 +5170,7 @@ static bool run_windows_write(int dummy)
                }
 
                status = cli_push(cli1, fnum, 0, i * torture_blocksize, torture_blocksize,
-                                 false, null_source, &to_pull);
+                                 null_source, &to_pull);
                if (!NT_STATUS_IS_OK(status)) {
                        printf("cli_push returned: %s\n", nt_errstr(status));
                        goto fail;