diff options
author | Jeremy Allison <jra@samba.org> | 2002-01-08 00:47:26 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-01-08 00:47:26 +0000 |
commit | 3f26d9f9fc11e556574cc433bd571bb9855271e5 (patch) | |
tree | ad1fcb8713b656cd1dc2063342b3067981534606 | |
parent | 25c0c06458af1dab6c797a0b3eb2927225b21570 (diff) | |
download | samba-3f26d9f9fc11e556574cc433bd571bb9855271e5.tar.gz samba-3f26d9f9fc11e556574cc433bd571bb9855271e5.tar.xz samba-3f26d9f9fc11e556574cc433bd571bb9855271e5.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.
-rw-r--r-- | source/include/proto.h | 1 | ||||
-rw-r--r-- | source/param/loadparm.c | 10 | ||||
-rw-r--r-- | source/printing/nt_printing.c | 14 | ||||
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 36 |
4 files changed, 32 insertions, 29 deletions
diff --git a/source/include/proto.h b/source/include/proto.h index ffa61d62be2..d996beaef87 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -2084,6 +2084,7 @@ void lp_set_name_resolve_order(char *new_order); char *lp_printername(int snum); void get_private_directory(pstring priv_dir); void lp_set_logfile(const char *name); +const char *get_called_name(void); /*The following definitions come from param/params.c */ diff --git a/source/param/loadparm.c b/source/param/loadparm.c index 41bf490acd0..7b5291b9e91 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -3760,3 +3760,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/source/printing/nt_printing.c b/source/printing/nt_printing.c index 094efa61ddf..cde59779eec 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -2422,19 +2422,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)); @@ -2509,10 +2506,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; @@ -2558,8 +2552,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/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 912aa7d1ddf..c8b3d2196a9 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -28,8 +28,6 @@ #include "includes.h" -extern pstring global_myname; - #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif @@ -1448,7 +1446,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 = (uint32)dos_PutUniCode(temp, temp_name, sizeof(temp) - 2, True); @@ -2586,7 +2584,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; @@ -2654,12 +2652,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); } @@ -2994,8 +2992,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); @@ -3884,7 +3882,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)) @@ -4213,9 +4211,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 \ @@ -4239,7 +4237,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)); @@ -4719,7 +4717,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)); @@ -4748,11 +4746,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); @@ -5266,7 +5264,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; @@ -5767,7 +5765,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) { @@ -5915,7 +5913,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)); @@ -7134,7 +7132,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)); |