r25446: Merge some changes I made on the way home from SFO:
[jelmer/samba4-debian.git] / source / libcli / smb2 / connect.c
index b185ff7a883c870f479ce9d2138a856f06880d4d..bb70311c56a9c8af852215e4b0fcfa7971037dc1 100644 (file)
@@ -7,7 +7,7 @@
    
    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 2 of the License, or
+   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,
@@ -16,8 +16,7 @@
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -26,6 +25,7 @@
 #include "libcli/smb2/smb2_calls.h"
 #include "libcli/composite/composite.h"
 #include "libcli/resolve/resolve.h"
+#include "param/param.h"
 
 struct smb2_connect_state {
        struct cli_credentials *credentials;
@@ -171,38 +171,25 @@ struct composite_context *smb2_connect_send(TALLOC_CTX *mem_ctx,
        struct nbt_name name;
        struct composite_context *creq;
 
-       c = talloc_zero(mem_ctx, struct composite_context);
+       c = composite_create(mem_ctx, ev);
        if (c == NULL) return NULL;
 
        state = talloc(c, struct smb2_connect_state);
-       if (state == NULL) {
-               c->status = NT_STATUS_NO_MEMORY;
-               goto failed;
-       }
-
-       c->state = COMPOSITE_STATE_IN_PROGRESS;
+       if (composite_nomem(state, c)) return c;
        c->private_data = state;
-       c->event_ctx = ev;
 
        state->credentials = credentials;
        state->host = talloc_strdup(c, host);
+       if (composite_nomem(state->host, c)) return c;
        state->share = talloc_strdup(c, share);
-       if (state->host == NULL || state->share == NULL) {
-               c->status = NT_STATUS_NO_MEMORY;
-               goto failed;
-       }
+       if (composite_nomem(state->share, c)) return c;
 
        ZERO_STRUCT(name);
        name.name = host;
 
-       creq = resolve_name_send(&name, c->event_ctx, lp_name_resolve_order());
-
+       creq = resolve_name_send(&name, c->event_ctx, 
+                                lp_name_resolve_order(global_loadparm));
        composite_continue(c, creq, continue_resolve, c);
-
-       return c;
-
-failed:
-       composite_error(c, c->status);
        return c;
 }