summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-08 00:46:56 +0000
committerJeremy Allison <jra@samba.org>2002-01-08 00:46:56 +0000
commit4702494dce15d4158fd17720d843ff5211ce1715 (patch)
tree46516cb4cabadff3f3a8234a193bc94252903f6a /source3
parent43b27771f50d5feba995c6ede961fdb4e73354f9 (diff)
downloadsamba-4702494dce15d4158fd17720d843ff5211ce1715.tar.gz
samba-4702494dce15d4158fd17720d843ff5211ce1715.tar.bz2
samba-4702494dce15d4158fd17720d843ff5211ce1715.zip
Added get_called_name() function, which replaces global_myname in printing
code (one less global, hurrah !) - to allow NetBIOS aliasing to be used with point and print. Jeremy. (This used to be commit 10d72f0b01e5950c667f3f73dff1b4da5b675ea3)
Diffstat (limited to 'source3')
-rw-r--r--source3/param/loadparm.c10
-rw-r--r--source3/printing/nt_printing.c14
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c36
3 files changed, 31 insertions, 29 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 01e5fb27aa..c900e99af4 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3892,3 +3892,13 @@ void lp_set_logfile(const char *name)
pstrcpy(Globals.szLogFile, name);
pstrcpy(debugf, name);
}
+
+/*******************************************************************
+ Return the NetBIOS called name.
+********************************************************************/
+
+const char *get_called_name(void)
+{
+ extern fstring local_machine;
+ return (*local_machine) ? local_machine : global_myname;
+}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 701944824d..3436d2c1c4 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2379,19 +2379,16 @@ get a default printer info 2 struct
****************************************************************************/
static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharename)
{
- extern pstring global_myname;
- extern fstring local_machine;
int snum;
NT_PRINTER_INFO_LEVEL_2 info;
- char *sub_name = *local_machine ? local_machine : global_myname;
ZERO_STRUCT(info);
snum = lp_servicenumber(sharename);
- slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", sub_name);
+ slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name());
slprintf(info.printername, sizeof(info.printername)-1, "\\\\%s\\%s",
- sub_name, sharename);
+ get_called_name(), sharename);
fstrcpy(info.sharename, sharename);
fstrcpy(info.portname, SAMBA_PRINTER_PORT_NAME);
fstrcpy(info.drivername, lp_printerdriver(snum));
@@ -2467,10 +2464,7 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
****************************************************************************/
static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharename)
{
- extern pstring global_myname;
- extern fstring local_machine;
pstring key;
- char *sub_name = *local_machine ? local_machine : global_myname;
NT_PRINTER_INFO_LEVEL_2 info;
int len = 0;
TDB_DATA kbuf, dbuf;
@@ -2515,8 +2509,8 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstring sharen
info.attributes |= (PRINTER_ATTRIBUTE_SHARED|PRINTER_ATTRIBUTE_RAW_ONLY);
/* Restore the stripped strings. */
- slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", sub_name);
- slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", sub_name,
+ slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", get_called_name());
+ slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", get_called_name(),
info.printername);
fstrcpy(info.printername, printername);
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 3fe21eb968..96f44c4b8b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -29,8 +29,6 @@
#include "includes.h"
-extern pstring global_myname;
-
#ifndef MAX_OPEN_PRINTER_EXS
#define MAX_OPEN_PRINTER_EXS 50
#endif
@@ -1447,7 +1445,7 @@ static void spoolss_notify_server_name(int snum,
pstring temp_name, temp;
uint32 len;
- slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname);
+ slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name());
len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE);
@@ -2573,7 +2571,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
init_unistr(&printer->printername, chaine);
- slprintf(chaine,sizeof(chaine)-1,"\\\\%s", global_myname);
+ slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_called_name());
init_unistr(&printer->servername, chaine);
printer->cjobs = count;
@@ -2641,12 +2639,12 @@ 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",global_myname, ntprinter->info_2->printername,
+ slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), 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",global_myname, ntprinter->info_2->printername,
+ slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername,
ntprinter->info_2->drivername, ntprinter->info_2->comment);
}
@@ -2981,8 +2979,8 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer,
*returned=1;
- slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", global_myname);
- slprintf(desc, sizeof(desc)-1,"%s", global_myname);
+ slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", get_called_name());
+ slprintf(desc, sizeof(desc)-1,"%s", get_called_name());
slprintf(comment, sizeof(comment)-1, "Logged on Domain");
init_unistr(&printer->description, desc);
@@ -3871,7 +3869,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_
*servermajorversion=0;
*serverminorversion=0;
- pstrcpy(servername, global_myname);
+ pstrcpy(servername, get_called_name());
unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1);
if (!get_printer_snum(p, handle, &snum))
@@ -4200,9 +4198,9 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location));
/* we force some elements to "correct" values */
- slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname);
+ slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", get_called_name());
slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s",
- global_myname, lp_servicename(snum));
+ get_called_name(), lp_servicename(snum));
fstrcpy(info->sharename, lp_servicename(snum));
info->attributes = PRINTER_ATTRIBUTE_SHARED \
| PRINTER_ATTRIBUTE_LOCAL \
@@ -4226,7 +4224,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer)
/* build driver path... only 9X architecture is needed for legacy reasons */
slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0",
- global_myname);
+ get_called_name());
/* change \ to \\ for the shell */
all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring));
@@ -4704,7 +4702,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue,
struct tm *t;
t=gmtime(&queue->time);
- slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname);
+ slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name());
job_info->jobid=queue->job;
init_unistr(&job_info->printername, lp_servicename(snum));
@@ -4733,11 +4731,11 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
struct tm *t;
t=gmtime(&queue->time);
- slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname);
+ slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name());
job_info->jobid=queue->job;
- slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername);
+ slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", get_called_name(), ntprinter->info_2->printername);
init_unistr(&job_info->printername, chaine);
@@ -5251,7 +5249,7 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS
buffer = r_u->buffer;
DEBUG(4,("_spoolss_enumprinterdrivers\n"));
- fstrcpy(servername, global_myname);
+ fstrcpy(servername, get_called_name());
*needed=0;
*returned=0;
@@ -5752,7 +5750,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_
return WERR_ACCESS_DENIED;
}
- slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname,
+ slprintf(name, sizeof(name)-1, "\\\\%s\\%s", get_called_name(),
printer->info_2->sharename);
if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) {
@@ -5900,7 +5898,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL)
return WERR_NOMEM;
- slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi);
+ slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi);
DEBUG(4,("printer driver directory: [%s]\n", path));
@@ -7119,7 +7117,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name,
Windows returns the string: C:\WINNT\System32\spool\PRTPROCS\W32X86
which is pretty bogus for a RPC. */
- slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi);
+ slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi);
DEBUG(4,("print processor directory: [%s]\n", path));