s3-talloc Change TALLOC_ARRAY() to talloc_array()
[samba.git] / source3 / libads / ldap_printer.c
index e4a7d34cf186eb53bb6014e93e41d7ad58cd55e0..8ff9f9bdc9d3f84f217a55aad4f3db2733e04805 100644 (file)
 
 #include "includes.h"
 #include "ads.h"
-#include "../librpc/gen_ndr/cli_spoolss.h"
+#include "rpc_client/rpc_client.h"
+#include "../librpc/gen_ndr/ndr_spoolss_c.h"
 #include "rpc_client/cli_spoolss.h"
-#include "registry.h"
 #include "registry/reg_objects.h"
-#include "nt_printing.h"
 
 #ifdef HAVE_ADS
 
                return status;
        }
        if (ads_count_replies(ads, *res) != 1) {
-               if (res) {
-                       ads_msgfree(ads, *res);
-                       *res = NULL;
-               }
+               ads_msgfree(ads, *res);
+               *res = NULL;
                return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
        }
        srv_dn = ldap_get_dn(ads->ldap.ld, *res);
        if (srv_dn == NULL) {
-               if (res) {
-                       ads_msgfree(ads, *res);
-                       *res = NULL;
-               }
+               ads_msgfree(ads, *res);
+               *res = NULL;
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
        srv_cn = ldap_explode_dn(srv_dn, 1);
        if (srv_cn == NULL) {
                ldap_memfree(srv_dn);
-               if (res) {
-                       ads_msgfree(ads, *res);
-                       *res = NULL;
-               }
-               return ADS_ERROR(LDAP_INVALID_DN_SYNTAX);
-       }
-       if (res) {
                ads_msgfree(ads, *res);
                *res = NULL;
+               return ADS_ERROR(LDAP_INVALID_DN_SYNTAX);
        }
+       ads_msgfree(ads, *res);
+       *res = NULL;
 
        if (asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer) == -1) {
                ldap_memfree(srv_dn);
@@ -208,7 +199,7 @@ static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
        };
 
        if (num_vals) {
-               str_values = TALLOC_ARRAY(ctx, char *, num_vals + 1);
+               str_values = talloc_array(ctx, char *, num_vals + 1);
                if (!str_values) {
                        return False;
                }
@@ -298,7 +289,7 @@ static void map_regval_to_ads(TALLOC_CTX *ctx, ADS_MODLIST *mods,
        int i;
 
        for (i=0; map[i].valname; i++) {
-               if (StrCaseCmp(map[i].valname, regval_name(value)) == 0) {
+               if (strcasecmp_m(map[i].valname, regval_name(value)) == 0) {
                        if (!map[i].fn(ctx, mods, value)) {
                                DEBUG(5, ("Add of value %s to modlist failed\n", regval_name(value)));
                        } else {
@@ -315,12 +306,14 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
                                          ADS_MODLIST *mods,
                                          const char *printer)
 {
+       struct dcerpc_binding_handle *b = cli->binding_handle;
        WERROR result;
        char *printername;
        struct spoolss_PrinterEnumValues *info;
        uint32_t count;
        uint32 i;
        struct policy_handle pol;
+       WERROR werr;
 
        if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) {
                DEBUG(3, ("Insufficient memory\n"));
@@ -392,7 +385,7 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
 
        ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer);
 
-       rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
+       dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &werr);
        SAFE_FREE(printername);
 
        return result;