summaryrefslogtreecommitdiff
path: root/source/printing/pcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/printing/pcap.c')
-rw-r--r--source/printing/pcap.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/source/printing/pcap.c b/source/printing/pcap.c
index 8973b1627fb..d51e69ad743 100644
--- a/source/printing/pcap.c
+++ b/source/printing/pcap.c
@@ -2,11 +2,13 @@
Unix SMB/Netbios implementation.
Version 1.9.
printcap parsing
- Copyright (C) Karl Auer 1993,1994
+ Copyright (C) Karl Auer 1993-1998
Re-working by Martin Kiff, 1994
Re-written again by Andrew Tridgell
+
+ Modified for SVID support by Norm Jacobs, 1997
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
@@ -49,13 +51,14 @@
* Opening a pipe for "lpc status" and reading that would probably
* be pretty effective. Code to do this already exists in the freely
* distributable PCNFS server code.
+ *
+ * Modified to call SVID/XPG4 support if printcap name is set to "lpstat"
+ * in smb.conf under Solaris.
*/
#include "includes.h"
#include "smb.h"
-#include "loadparm.h"
-#include "pcap.h"
extern int DEBUGLEVEL;
@@ -120,7 +123,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)())
p = strtok(line,":");
if (strcmp(p,"bsh")!=0)
{
- strcpy(name,p);
+ pstrcpy(name,p);
iEtat = 1;
continue;
}
@@ -179,7 +182,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
free(pName);
return(False);
}
- sprintf(pName,"%s:",pszPrintername);
+ slprintf(pName, iLg + 9, "%s:",pszPrintername);
iLg = strlen(pName);
/*DEBUG(3,( " Looking for entry %s\n",pName));*/
iEtat = 0;
@@ -229,8 +232,9 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
fclose(pfile);
return(False);
}
+#endif /* AIX */
+
-#endif
/***************************************************************************
Scan printcap file pszPrintcapname for a printer called pszPrintername.
Return True if found, else False. Returns False on error, too, after logging
@@ -257,10 +261,17 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
DEBUG(0,( "No printcap file name configured!\n"));
return(False);
}
+
+#ifdef SYSV
+ if (strequal(psz, "lpstat"))
+ return (sysv_printername_ok(pszPrintername));
+#endif
+
#ifdef AIX
- if (strlocate(psz,"/qconfig") != NULL)
+ if (strlocate(psz,"/qconfig"))
return(ScanQconfig(psz,pszPrintername));
#endif
+
if ((pfile = fopen(psz, "r")) == NULL)
{
DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
@@ -285,7 +296,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
if (strequal(p,pszPrintername))
{
/* normalise the case */
- strcpy(pszPrintername,p);
+ pstrcpy(pszPrintername,p);
free(line);
fclose(pfile);
return(True);
@@ -294,7 +305,6 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
}
}
-
fclose(pfile);
return(False);
}
@@ -304,7 +314,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
run a function on each printer name in the printcap file. The function is
passed the primary name and the comment (if possible)
***************************************************************************/
-void pcap_printer_fn(void (*fn)())
+void pcap_printer_fn(void (*fn)(char *, char *))
{
pstring name,comment;
char *line;
@@ -319,13 +329,21 @@ void pcap_printer_fn(void (*fn)())
return;
}
+#ifdef SYSV
+ if (strequal(psz, "lpstat")) {
+ sysv_printer_fn(fn);
+ return;
+ }
+#endif
+
#ifdef AIX
- if (strlocate(psz,"/qconfig") != NULL)
+ if (strlocate(psz,"/qconfig"))
{
ScanQconfig_fn(psz,fn);
return;
}
#endif
+
if ((pfile = fopen(psz, "r")) == NULL)
{
DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
@@ -358,10 +376,10 @@ void pcap_printer_fn(void (*fn)())
continue;
}
- if (strlen(p) <= 8 && strlen(p)>strlen(name) && !has_punctuation)
+ if (strlen(p) <= MAXPRINTERLEN && strlen(p)>strlen(name) && !has_punctuation)
{
- if (!*comment) strcpy(comment,name);
- strcpy(name,p);
+ if (!*comment) pstrcpy(comment,name);
+ pstrcpy(name,p);
continue;
}
@@ -374,7 +392,7 @@ void pcap_printer_fn(void (*fn)())
}
comment[60] = 0;
- name[8] = 0;
+ name[MAXPRINTERLEN] = 0;
if (*name)
fn(name,comment);