summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-05-07 16:24:04 +0200
committerVolker Lendecke <vl@samba.org>2009-05-07 16:37:54 +0200
commitd52b0a25ad2ce52f01015547d1c384dab6b931ac (patch)
tree2d0bcdee62658ebb39770a99d3921bdcf1f746d4 /source3/libsmb
parentb35967edba35965f4e8242759a7d9d1d9ded980f (diff)
downloadsamba-d52b0a25ad2ce52f01015547d1c384dab6b931ac.tar.gz
samba-d52b0a25ad2ce52f01015547d1c384dab6b931ac.tar.bz2
samba-d52b0a25ad2ce52f01015547d1c384dab6b931ac.zip
Make cli_tcon_andx chainable
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cliconnect.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 48a4f1f703..7a8a93078d 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1245,15 +1245,17 @@ bool cli_ulogoff(struct cli_state *cli)
struct cli_tcon_andx_state {
struct cli_state *cli;
uint16_t vwv[4];
+ struct iovec bytes;
};
static void cli_tcon_andx_done(struct tevent_req *subreq);
-struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- const char *share, const char *dev,
- const char *pass, int passlen)
+struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *share, const char *dev,
+ const char *pass, int passlen,
+ struct tevent_req **psmbreq)
{
struct tevent_req *req, *subreq;
struct cli_tcon_andx_state *state;
@@ -1341,8 +1343,9 @@ struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
*/
tmp = talloc_asprintf_strupper_m(talloc_tos(), "\\\\%s\\%s",
cli->desthost, share);
- if (tevent_req_nomem(tmp, req)) {
- return tevent_req_post(req, ev);
+ if (tmp == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), tmp, strlen(tmp)+1,
NULL);
@@ -1352,22 +1355,29 @@ struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
* Add the devicetype
*/
tmp = talloc_strdup_upper(talloc_tos(), dev);
- if (tevent_req_nomem(tmp, req)) {
- return tevent_req_post(req, ev);
+ if (tmp == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
bytes = smb_bytes_push_str(bytes, false, tmp, strlen(tmp)+1, NULL);
TALLOC_FREE(tmp);
- if (tevent_req_nomem(bytes, req)) {
- return tevent_req_post(req, ev);
+ if (bytes == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
- subreq = cli_smb_send(state, ev, cli, SMBtconX, 0, 4, vwv,
- talloc_get_size(bytes), bytes);
- if (tevent_req_nomem(subreq, req)) {
- return tevent_req_post(req, ev);
+ state->bytes.iov_base = bytes;
+ state->bytes.iov_len = talloc_get_size(bytes);
+
+ subreq = cli_smb_req_create(state, ev, cli, SMBtconX, 0, 4, vwv,
+ 1, &state->bytes);
+ if (subreq == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
}
tevent_req_set_callback(subreq, cli_tcon_andx_done, req);
+ *psmbreq = subreq;
return req;
access_denied:
@@ -1375,6 +1385,23 @@ struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
+struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ const char *share, const char *dev,
+ const char *pass, int passlen)
+{
+ struct tevent_req *req, *subreq;
+
+ req = cli_tcon_andx_create(mem_ctx, ev, cli, share, dev, pass, passlen,
+ &subreq);
+ if ((req == NULL) || !cli_smb_req_send(subreq)) {
+ TALLOC_FREE(req);
+ return NULL;
+ }
+ return req;
+}
+
static void cli_tcon_andx_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(