diff options
author | Jim McDonough <jmcd@samba.org> | 2002-02-12 18:22:47 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-02-12 18:22:47 +0000 |
commit | d6b82723a0f626c52a3cf05d3bb4f0ff5f7e0f7a (patch) | |
tree | 687f7042c6f0b7dd522329e4a5ead8f81be4c5fe | |
parent | a346cfb4677fcfcb5900e3a299bf7bc0bc76f758 (diff) | |
download | samba-d6b82723a0f626c52a3cf05d3bb4f0ff5f7e0f7a.tar.gz samba-d6b82723a0f626c52a3cf05d3bb4f0ff5f7e0f7a.tar.bz2 samba-d6b82723a0f626c52a3cf05d3bb4f0ff5f7e0f7a.zip |
talloc'ify ads modify functions.
(This used to be commit e097666499564ffe28836876a7a191149c14f199)
-rw-r--r-- | source3/libads/ldap_printer.c | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c index 50f4302201..52771ba39a 100644 --- a/source3/libads/ldap_printer.c +++ b/source3/libads/ldap_printer.c @@ -45,7 +45,7 @@ ADS_STATUS ads_find_printer_on_server(ADS_STRUCT *ads, void **res, asprintf(&exp, "(printerName=%s)", printer); status = ads_do_search(ads, srv_dn, LDAP_SCOPE_SUBTREE, - exp, &attrs, res); + exp, attrs, res); free(exp); return status; @@ -57,46 +57,51 @@ ADS_STATUS ads_find_printer_on_server(ADS_STRUCT *ads, void **res, ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn, const ADS_PRINTER_ENTRY *prt) { - ADS_MODLIST *mods; + ADS_MODLIST mods; ADS_STATUS status; + TALLOC_CTX *ctx; + + if (!(ctx = talloc_init_named("mod_printer_entry"))) + return ADS_ERROR(LDAP_NO_MEMORY); /* allocate the list */ - *mods = ads_init_mods(); + mods = ads_init_mods(ctx); /* add the attributes to the list - required ones first */ - ads_mod_repl(mods, "printerName", prt->printerName); - ads_mod_repl(mods, "serverName", prt->serverName); - ads_mod_repl(mods, "shortServerName", prt->shortServerName); - ads_mod_repl(mods, "uNCName", prt->uNCName); - ads_mod_repl(mods, "versionNumber", prt->versionNumber); + ads_mod_repl(ctx, &mods, "printerName", prt->printerName); + ads_mod_repl(ctx, &mods, "serverName", prt->serverName); + ads_mod_repl(ctx, &mods, "shortServerName", prt->shortServerName); + ads_mod_repl(ctx, &mods, "uNCName", prt->uNCName); + ads_mod_repl(ctx, &mods, "versionNumber", prt->versionNumber); /* now the optional ones */ - ads_mod_repl_list(mods, "description", prt->description); - ads_mod_repl(mods, "assetNumber",prt->assetNumber); - ads_mod_repl(mods, "bytesPerMinute",prt->bytesPerMinute); - ads_mod_repl(mods, "defaultPriority",prt->defaultPriority); - ads_mod_repl(mods, "driverName", prt->driverName); - ads_mod_repl(mods, "driverVersion",prt->driverVersion); - ads_mod_repl(mods, "location", prt->location); - ads_mod_repl(mods, "operatingSystem",prt->operatingSystem); - ads_mod_repl(mods, "operatingSystemHotfix",prt->operatingSystemHotfix); - ads_mod_repl(mods, "operatingSystemServicePack", + ads_mod_repl_list(ctx, &mods, "description", prt->description); + ads_mod_repl(ctx, &mods, "assetNumber",prt->assetNumber); + ads_mod_repl(ctx, &mods, "bytesPerMinute",prt->bytesPerMinute); + ads_mod_repl(ctx, &mods, "defaultPriority",prt->defaultPriority); + ads_mod_repl(ctx, &mods, "driverName", prt->driverName); + ads_mod_repl(ctx, &mods, "driverVersion",prt->driverVersion); + ads_mod_repl(ctx, &mods, "location", prt->location); + ads_mod_repl(ctx, &mods, "operatingSystem",prt->operatingSystem); + ads_mod_repl(ctx, &mods, "operatingSystemHotfix", + prt->operatingSystemHotfix); + ads_mod_repl(ctx, &mods, "operatingSystemServicePack", prt->operatingSystemServicePack); - ads_mod_repl(mods, "operatingSystemVersion", + ads_mod_repl(ctx, &mods, "operatingSystemVersion", prt->operatingSystemVersion); - ads_mod_repl(mods, "physicalLocationObject", + ads_mod_repl(ctx, &mods, "physicalLocationObject", prt->physicalLocationObject); - ads_mod_repl_list(mods, "portName", prt->portName); - ads_mod_repl(mods, "printStartTime", prt->printStartTime); - ads_mod_repl(mods, "printEndTime", prt->printEndTime); - ads_mod_repl_list(mods, "printBinNames", prt->printBinNames); + ads_mod_repl_list(ctx, &mods, "portName", prt->portName); + ads_mod_repl(ctx, &mods, "printStartTime", prt->printStartTime); + ads_mod_repl(ctx, &mods, "printEndTime", prt->printEndTime); + ads_mod_repl_list(ctx, &mods, "printBinNames", prt->printBinNames); /*... and many others */ /* do the ldap modify */ - status = ads_gen_mod(ads, prt_dn, *mods); + status = ads_gen_mod(ads, prt_dn, mods); /* free mod list, mods, and values */ - ads_free_mods(*mods); + talloc_destroy(ctx); return status; } @@ -109,16 +114,27 @@ static ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char *prt_dn, const ADS_PRINTER_ENTRY *prt) { ADS_STATUS status; - + TALLOC_CTX *ctx; + ADS_MODLIST mods; + + if (!(ctx = talloc_init_named("add_printer_entry"))) + return ADS_ERROR(LDAP_NO_MEMORY); + + if (!(mods = ads_init_mods(ctx))) + return ADS_ERROR(LDAP_NO_MEMORY); + /* These are the fields a printQueue must contain */ - status = ads_gen_add(ads, prt_dn, - "uNCName", prt->uNCName, NULL, - "versionNumber", prt->versionNumber, NULL, - "serverName", prt->serverName, NULL, - "shortServerName", prt->shortServerName, NULL, - "printerName", prt->printerName, NULL, - "objectClass", "printQueue", NULL, - NULL); + ads_mod_add(ctx, &mods, "uNCName", prt->uNCName); + ads_mod_add(ctx, &mods, "versionNumber", prt->versionNumber); + ads_mod_add(ctx, &mods, "serverName", prt->serverName); + ads_mod_add(ctx, &mods, "shortServerName", prt->shortServerName); + ads_mod_add(ctx, &mods, "printerName", prt->printerName); + ads_mod_add(ctx, &mods, "objectClass", "printQueue"); + + + status = ads_gen_add(ads, prt_dn, mods); + + talloc_destroy(ctx); return status; } |