summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_spoolss_nt.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-03-12 00:16:03 +0000
committerTim Potter <tpot@samba.org>2002-03-12 00:16:03 +0000
commit92e59edc410a1de09a3d1eaba09cd46f4db1367f (patch)
tree3f449a8525fc167602abd8bc484f513c02d1f99d /source3/rpc_server/srv_spoolss_nt.c
parent3bb219161a270f12c27c3bc7e1220829c6e9f284 (diff)
downloadsamba-92e59edc410a1de09a3d1eaba09cd46f4db1367f.tar.gz
samba-92e59edc410a1de09a3d1eaba09cd46f4db1367f.tar.bz2
samba-92e59edc410a1de09a3d1eaba09cd46f4db1367f.zip
Merge of enumprinters vs getprinter naming patch from 2.2
(This used to be commit dfd51bc8d0714473880bf50369f7994304c1d83f)
Diffstat (limited to 'source3/rpc_server/srv_spoolss_nt.c')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index f489802f77..f0ea088dc3 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -4,9 +4,10 @@
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-2000,
* Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
- * Copyright (C) Jean François Micouleau 1998-2000.
- * Copyright (C) Jeremy Allison 2001.
- * Copyright (C) Gerald Carter 2000-2001.
+ * Copyright (C) Jean François Micouleau 1998-2000,
+ * Copyright (C) Jeremy Allison 2001,
+ * Copyright (C) Gerald Carter 2000-2001,
+ * Copyright (C) Tim Potter 2001-2002.
*
* 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
@@ -2617,9 +2618,13 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
/********************************************************************
* construct_printer_info_1
* fill a printer_info_1 struct
+ *
+ * The is_enum parameter says whether the PRINTER_INFO_1 returned is
+ * to be used in an enumprinters call. This affects whether the netbios
+ * name of the server is prefixed to the printer and server names.
********************************************************************/
-
-static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum)
+static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer,
+ int snum, BOOL is_enum)
{
pstring chaine;
pstring chaine2;
@@ -2632,13 +2637,23 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int
if (*ntprinter->info_2->comment == '\0') {
init_unistr(&printer->comment, lp_comment(snum));
- slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername,
- ntprinter->info_2->drivername, lp_comment(snum));
- }
- else {
+ if (is_enum) {
+ char *p;
+
+ p = strchr(ntprinter->info_2->printername + 2, '\\');
+
+ if (p)
+ fstrcpy(ntprinter->info_2->printername, p + 1);
+ }
+ slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s",
+ ntprinter->info_2->printername,
+ ntprinter->info_2->drivername, lp_comment(snum));
+ } else {
init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
- slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername,
- ntprinter->info_2->drivername, ntprinter->info_2->comment);
+ slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s",
+ ntprinter->info_2->printername,
+ ntprinter->info_2->drivername,
+ ntprinter->info_2->comment);
}
slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername);
@@ -2926,8 +2941,8 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32
for (snum=0; snum<n_services; snum++) {
if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
-
- if (construct_printer_info_1(flags, &current_prt, snum)) {
+
+ if (construct_printer_info_1(flags, &current_prt, snum, True)) {
if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
SAFE_FREE(printers);
@@ -2936,6 +2951,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32
}
else printers = tp;
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));
+
memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_1));
(*returned)++;
}
@@ -3290,7 +3306,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u
if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL)
return WERR_NOMEM;
- construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum);
+ construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum, False);
/* check the required size. */
*needed += spoolss_size_printer_info_1(printer);