The branch, master has been updated via 84a0076c4b62d23b21153dd00ec72fe8042b39cc (commit) via 438af255c6dcbc225357ae5162853915002d0d15 (commit) from b3a2b3ade0ddd3ddd93079286d2a06547d182a99 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 84a0076c4b62d23b21153dd00ec72fe8042b39cc Author: Günther Deschner <g...@samba.org> Date: Mon Feb 9 19:02:56 2009 +0100 s3-rpcclient: remove a pointless fstring. Guenther commit 438af255c6dcbc225357ae5162853915002d0d15 Author: Günther Deschner <g...@samba.org> Date: Mon Feb 9 18:10:18 2009 +0100 s3-rpcclient: use srv_name_slash instead of formating servername again and again. Guenther ----------------------------------------------------------------------- Summary of changes: source3/libads/ldap_printer.c | 7 +- source3/rpcclient/cmd_spoolss.c | 224 +++++++++++---------------------------- source3/utils/net_rpc_printer.c | 17 ++-- 3 files changed, 74 insertions(+), 174 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/libads/ldap_printer.c b/source3/libads/ldap_printer.c index 023acaa..c9c43f0 100644 --- a/source3/libads/ldap_printer.c +++ b/source3/libads/ldap_printer.c @@ -310,20 +310,19 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli, const char *printer) { WERROR result; - char *printername, *servername; + char *printername; REGVAL_CTR *dsdriver_ctr, *dsspooler_ctr; uint32 i; POLICY_HND pol; - if ((asprintf(&servername, "\\\\%s", cli->desthost) == -1) - || (asprintf(&printername, "%s\\%s", servername, printer) == -1)) { + if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) { DEBUG(3, ("Insufficient memory\n")); return WERR_NOMEM; } result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, cli->auth->user_name, + cli->srv_name_slash, cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) { DEBUG(3, ("Unable to open printer %s, error is %s.\n", diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 4b35f57..aba961a 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -98,7 +98,6 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli, { WERROR werror; fstring printername; - fstring servername, user; POLICY_HND hnd; if (argc != 2) { @@ -109,16 +108,14 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli, if (!cli) return WERR_GENERAL_FAILURE; - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - fstrcpy(user, cli->auth->user_name); fstrcpy(printername, argv[1]); /* Open the printer handle */ werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, - servername, user, &hnd); + cli->srv_name_slash, + cli->auth->user_name, &hnd); if (W_ERROR_IS_OK(werror)) { printf("Printer %s opened successfully\n", printername); @@ -473,8 +470,6 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli, bool opened_hnd = False; PRINTER_INFO_CTR ctr; fstring printername, - servername, - user, comment; if (argc == 1 || argc > 3) { @@ -488,15 +483,12 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli, fstrcpy(comment, argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]); /* get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", - PRINTER_ALL_ACCESS, servername, - user, &pol); + PRINTER_ALL_ACCESS, cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -539,8 +531,6 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli, bool opened_hnd = False; PRINTER_INFO_CTR ctr; fstring printername, - servername, - user, new_printername; if (argc == 1 || argc > 3) { @@ -554,15 +544,12 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli, fstrcpy(new_printername, argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]); /* get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", - PRINTER_ALL_ACCESS, servername, - user, &pol); + PRINTER_ALL_ACCESS, cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -603,9 +590,7 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli, uint32 info_level = 1; bool opened_hnd = False; PRINTER_INFO_CTR ctr; - fstring printername, - servername, - user; + fstring printername; if (argc == 1 || argc > 3) { printf("Usage: %s <printername> [level]\n", argv[0]); @@ -617,16 +602,14 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli, info_level = atoi(argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]); /* get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, user, &pol); + cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -741,9 +724,7 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli, POLICY_HND pol; WERROR result; bool opened_hnd = False; - fstring printername, - servername, - user; + fstring printername; const char *valuename; REGISTRY_VALUE value; @@ -756,20 +737,18 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli, /* Open a printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); if (strncmp(argv[1], ".", sizeof(".")) == 0) - fstrcpy(printername, servername); + fstrcpy(printername, cli->srv_name_slash); else - slprintf(printername, sizeof(servername)-1, "%s\\%s", - servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + slprintf(printername, sizeof(printername)-1, "%s\\%s", + cli->srv_name_slash, argv[1]); /* get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, user, &pol); + cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -806,9 +785,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, POLICY_HND pol; WERROR result; bool opened_hnd = False; - fstring printername, - servername, - user; + fstring printername; const char *valuename, *keyname; REGISTRY_VALUE value; @@ -823,20 +800,18 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, /* Open a printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); if (strncmp(argv[1], ".", sizeof(".")) == 0) - fstrcpy(printername, servername); + fstrcpy(printername, cli->srv_name_slash); else slprintf(printername, sizeof(printername)-1, "%s\\%s", - servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + cli->srv_name_slash, argv[1]); /* get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, user, &pol); + cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -986,9 +961,7 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli, uint32 info_level = 3; bool opened_hnd = False; PRINTER_DRIVER_CTR ctr; - fstring printername, - servername, - user; + fstring printername; uint32 i; bool success = False; @@ -999,10 +972,7 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli, } /* get the arguments need to open the printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - fstrcpy(user, cli->auth->user_name); - slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]); + slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]); if (argc == 3) info_level = atoi(argv[2]); @@ -1010,7 +980,8 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli, werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ACCESS_USE, - servername, user, &pol); + cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(werror)) { printf("Error opening printer handle for %s!\n", printername); @@ -1374,7 +1345,6 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli, uint32 level = 2; PRINTER_INFO_CTR ctr; PRINTER_INFO_2 info2; - fstring servername; /* parse the command arguments */ if (argc != 5) @@ -1383,9 +1353,6 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - /* Fill in the DRIVER_INFO_2 struct */ ZERO_STRUCT(info2); @@ -1434,9 +1401,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli, bool opened_hnd = False; PRINTER_INFO_CTR ctr; PRINTER_INFO_2 info2; - fstring servername, - printername, - user; + fstring printername; /* parse the command arguments */ if (argc != 3) @@ -1445,16 +1410,14 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); - fstrcpy(user, cli->auth->user_name); + slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]); /* Get a printer handle */ result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, - servername, user, &pol); + cli->srv_name_slash, + cli->auth->user_name, &pol); if (!W_ERROR_IS_OK(result)) goto done; @@ -1573,7 +1536,6 @@ static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli, { WERROR result = WERR_OK; NTSTATUS status; - fstring servername; int i; /* parse the command arguments */ @@ -1582,14 +1544,11 @@ static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); - strupper_m(servername); - /* delete the driver for all architectures */ for (i=0; archi_table[i].long_archi; i++) { /* make the call to remove the driver */ status = rpccli_spoolss_DeletePrinterDriver(cli, mem_ctx, - servername, + cli->srv_name_slash, archi_table[i].long_archi, argv[1], &result); @@ -1619,7 +1578,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli, int argc, const char **argv) { WERROR result; - char *servername = NULL, *environment = NULL; + char *environment = NULL; fstring procdir; /* parse the command arguments */ @@ -1628,23 +1587,17 @@ static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli, return WERR_OK; } - if (asprintf(&servername, "\\\\%s", cli->desthost) < 0) - return WERR_NOMEM; - strupper_m(servername); - if (asprintf(&environment, "%s", (argc == 2) ? argv[1] : PRINTER_DRIVER_ARCHITECTURE) < 0) { - SAFE_FREE(servername); return WERR_NOMEM; } result = rpccli_spoolss_getprintprocessordirectory( - cli, mem_ctx, servername, environment, procdir); + cli, mem_ctx, cli->srv_name_slash, environment, procdir); if (W_ERROR_IS_OK(result)) printf("%s\n", procdir); - SAFE_FREE(servername); SAFE_FREE(environment); return result; @@ -1659,7 +1612,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c POLICY_HND handle; WERROR werror; NTSTATUS status; - char *servername = NULL, *printername = NULL; + char *printername = NULL; bool got_handle = False; union spoolss_AddFormInfo info; struct spoolss_AddFormInfo1 info1; @@ -1673,18 +1626,13 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /* Get a printer handle */ - if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) { - return WERR_NOMEM; - } - strupper_m(servername); - if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) { - SAFE_FREE(servername); + if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) { return WERR_NOMEM; } werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, - servername, cli->auth->user_name, + cli->srv_name_slash, cli->auth->user_name, &handle); if (!W_ERROR_IS_OK(werror)) @@ -1718,7 +1666,6 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (got_handle) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); - SAFE_FREE(servername); SAFE_FREE(printername); return werror; @@ -1733,7 +1680,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c POLICY_HND handle; WERROR werror; NTSTATUS status; - char *servername = NULL, *printername = NULL; + char *printername = NULL; bool got_handle = False; union spoolss_AddFormInfo info; struct spoolss_AddFormInfo1 info1; @@ -1747,18 +1694,13 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /* Get a printer handle */ - if (asprintf(&servername, "\\\\%s", cli->desthost)) { - return WERR_NOMEM; - } - strupper_m(servername); - if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) { - SAFE_FREE(servername); + if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) { return WERR_NOMEM; } werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, cli->auth->user_name, &handle); + cli->srv_name_slash, cli->auth->user_name, &handle); if (!W_ERROR_IS_OK(werror)) goto done; @@ -1791,7 +1733,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (got_handle) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); - SAFE_FREE(servername); SAFE_FREE(printername); return werror; @@ -1859,7 +1800,7 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c POLICY_HND handle; WERROR werror; NTSTATUS status; - char *servername = NULL, *printername = NULL; + char *printername = NULL; bool got_handle = False; DATA_BLOB buffer; uint32_t offered = 0; @@ -1875,18 +1816,13 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /* Get a printer handle */ - if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) { - return WERR_NOMEM; - } - strupper_m(servername); - if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) { - SAFE_FREE(servername); + if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) { return WERR_NOMEM; } werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, cli->auth->user_name, &handle); + cli->srv_name_slash, cli->auth->user_name, &handle); if (!W_ERROR_IS_OK(werror)) goto done; @@ -1927,7 +1863,6 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c if (got_handle) rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL); - SAFE_FREE(servername); SAFE_FREE(printername); return werror; @@ -1943,7 +1878,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, POLICY_HND handle; WERROR werror; NTSTATUS status; - char *servername = NULL, *printername = NULL; + char *printername = NULL; bool got_handle = False; /* Parse the command arguments */ @@ -1955,18 +1890,13 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, /* Get a printer handle */ - if (asprintf(&servername, "\\\\%s", cli->desthost) == -1) { - return WERR_NOMEM; - } - strupper_m(servername); - if (asprintf(&printername, "%s\\%s", servername, argv[1]) == -1) { - SAFE_FREE(servername); + if (asprintf(&printername, "%s\\%s", cli->srv_name_slash, argv[1]) == -1) { return WERR_NOMEM; } werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, - servername, cli->auth->user_name, &handle); + cli->srv_name_slash, cli->auth->user_name, &handle); -- Samba Shared Repository