s3: Add async cli_setpathinfo
authorVolker Lendecke <vl@samba.org>
Sun, 24 Oct 2010 14:45:54 +0000 (16:45 +0200)
committerVolker Lendecke <vlendec@samba.org>
Sun, 24 Oct 2010 20:46:28 +0000 (20:46 +0000)
source3/include/proto.h
source3/libsmb/clifile.c

index 0c05e6ecc58a2ba79073968a301ec203a083dfb1..97e19236253eb9c007deacd6127ee46af7711f68 100644 (file)
@@ -1768,6 +1768,15 @@ bool cli_state_is_connected(struct cli_state *cli);
 
 /* The following definitions come from libsmb/clifile.c  */
 
+struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       struct cli_state *cli,
+                                       uint16_t level,
+                                       const char *path,
+                                       uint8_t *data,
+                                       size_t data_len);
+NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
+
 struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
                                        struct event_context *ev,
                                        struct cli_state *cli,
index 6ce884adf56755cc222d5fec65bfbdc4aae71e4a..e735a6e3db5510ef1759a4ce0c60f1c99f60e446 100644 (file)
@@ -127,6 +127,84 @@ static uint8_t *trans2_bytes_push_str(uint8_t *buf, bool ucs2,
                        false, pconverted_size);
 }
 
+struct cli_setpathinfo_state {
+       uint16_t setup;
+       uint8_t *param;
+};
+
+static void cli_setpathinfo_done(struct tevent_req *subreq);
+
+struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
+                                       struct tevent_context *ev,
+                                       struct cli_state *cli,
+                                       uint16_t level,
+                                       const char *path,
+                                       uint8_t *data,
+                                       size_t data_len)
+{
+       struct tevent_req *req, *subreq;
+       struct cli_setpathinfo_state *state;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct cli_setpathinfo_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       /* Setup setup word. */
+       SSVAL(&state->setup, 0, TRANSACT2_SETPATHINFO);
+
+       /* Setup param array. */
+       state->param = TALLOC_ZERO_ARRAY(state, uint8_t, 6);
+       if (tevent_req_nomem(state->param, req)) {
+               return tevent_req_post(req, ev);
+       }
+       SSVAL(state->param, 0, level);
+
+       state->param = trans2_bytes_push_str(
+               state->param, cli_ucs2(cli), path, strlen(path)+1, NULL);
+       if (tevent_req_nomem(state->param, req)) {
+               return tevent_req_post(req, ev);
+       }
+
+       subreq = cli_trans_send(
+               state,                  /* mem ctx. */
+               ev,                     /* event ctx. */
+               cli,                    /* cli_state. */
+               SMBtrans2,              /* cmd. */
+               NULL,                   /* pipe name. */
+               -1,                     /* fid. */
+               0,                      /* function. */
+               0,                      /* flags. */
+               &state->setup,          /* setup. */
+               1,                      /* num setup uint16_t words. */
+               0,                      /* max returned setup. */
+               state->param,           /* param. */
+               talloc_get_size(state->param),  /* num param. */
+               2,                      /* max returned param. */
+               data,                   /* data. */
+               data_len,               /* num data. */
+               0);                     /* max returned data. */
+
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, cli_setpathinfo_done, req);
+       return req;
+}
+
+static void cli_setpathinfo_done(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL,
+                                        NULL, 0, NULL, NULL, 0, NULL);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_setpathinfo_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
 /****************************************************************************
  Hard/Symlink a file (UNIX extensions).
  Creates new name (sym)linked to oldname.