summaryrefslogtreecommitdiffstats
path: root/examples/printing
diff options
context:
space:
mode:
authorCVS Import User <samba-bugs@samba.org>2004-04-04 09:21:52 +0000
committerCVS Import User <samba-bugs@samba.org>2004-04-04 09:21:52 +0000
commit9f765b7406282904ce56f2535dcd929a9aefc5ca (patch)
treedbdff78b624ac7c1afcb8851f395df3d99eb1f84 /examples/printing
parent111b4e05ab96eafc4212f38dc5977538907187c7 (diff)
downloadsamba-9f765b7406282904ce56f2535dcd929a9aefc5ca.tar.gz
samba-9f765b7406282904ce56f2535dcd929a9aefc5ca.tar.xz
samba-9f765b7406282904ce56f2535dcd929a9aefc5ca.zip
r2: import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
metze
Diffstat (limited to 'examples/printing')
-rw-r--r--examples/printing/prtpub.c238
-rw-r--r--examples/printing/readme.prtpub12
-rwxr-xr-xexamples/printing/smbprint144
-rw-r--r--examples/printing/smbprint-new.sh144
-rwxr-xr-xexamples/printing/smbprint.old95
-rw-r--r--examples/printing/smbprint.sysv52
6 files changed, 685 insertions, 0 deletions
diff --git a/examples/printing/prtpub.c b/examples/printing/prtpub.c
new file mode 100644
index 00000000000..ea71e03d073
--- /dev/null
+++ b/examples/printing/prtpub.c
@@ -0,0 +1,238 @@
+/*
+ * Set printer capabilities in DsDriver Keys on remote printer
+ * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* This needs to be defined for certain compilers */
+#define WINVER 0x0500
+
+#include <tchar.h>
+#include <windows.h>
+#include <stdio.h>
+
+#define SAMBA_PORT _T("Samba")
+
+TCHAR *PrintLastError(void)
+{
+ static TCHAR msgtxt[1024*sizeof(TCHAR)];
+
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, GetLastError(),
+ 0, msgtxt, 0, NULL);
+
+ return msgtxt;
+}
+
+void map_orientation(HANDLE ph, TCHAR *printer, TCHAR *port)
+{
+ DWORD rot;
+ TCHAR portrait_only[] = _T("PORTRAIT\0");
+ TCHAR both[] = _T("LANDSCAPE\0PORTRAIT\0");
+
+ /* orentation of 90 or 270 indicates landscape supported, 0 means it isn't */
+ rot = DeviceCapabilities(printer, port, DC_BINNAMES, NULL, NULL);
+
+ printf("printOrientationsSupported:\n");
+
+ if (rot) {
+ printf("\tPORTRAIT\n\tLANDSCAPE\n");
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printOrientationsSupported"), REG_MULTI_SZ,
+ both, sizeof(both));
+ } else {
+ printf("\tPORTRAIT\n");
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printOrientationsSupported"), REG_MULTI_SZ,
+ portrait_only, sizeof(portrait_only));
+ }
+}
+
+void map_resolution(HANDLE ph, TCHAR *printer, TCHAR *port)
+{
+ DWORD num, *res, maxres = 0, i;
+
+ num = DeviceCapabilities(printer, port, DC_ENUMRESOLUTIONS, NULL, NULL);
+ if ((DWORD) -1 == num)
+ return;
+ res = malloc(num*2*sizeof(DWORD));
+ num = DeviceCapabilities(printer, port, DC_ENUMRESOLUTIONS, (BYTE *) res, NULL);
+ for (i=0; i < num*2; i++) {
+ maxres = (res[i] > maxres) ? res[i] : maxres;
+ }
+ printf("printMaxResolutionSupported: %d\n", maxres);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printMaxResolutionSupported"), REG_DWORD,
+ (BYTE *) &maxres, sizeof(maxres));
+}
+
+void map_extents(HANDLE ph, TCHAR *printer, TCHAR *port)
+{
+ DWORD extentval, xval, yval;
+
+ extentval = DeviceCapabilities(printer, port, DC_MINEXTENT, NULL, NULL);
+ xval = (DWORD) (LOWORD(extentval));
+ yval = (DWORD) (HIWORD(extentval));
+ printf("printMinXExtent: %d\n", xval);
+ printf("printMinYExtent: %d\n", yval);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printMinXExtent"), REG_DWORD, (BYTE *) &xval, sizeof(xval));
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printMinYExtent"), REG_DWORD, (BYTE *) &yval, sizeof(yval));
+ extentval = DeviceCapabilities(printer, port, DC_MAXEXTENT, NULL, NULL);
+ xval = (DWORD) (LOWORD(extentval));
+ yval = (DWORD) (HIWORD(extentval));
+ printf("printMaxXExtent: %d\n", xval);
+ printf("printMaxYExtent: %d\n", yval);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printMaxXExtent"), REG_DWORD, (BYTE *) &xval, sizeof(xval));
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printMaxYExtent"), REG_DWORD, (BYTE *) &yval, sizeof(yval));
+}
+
+void map_printrateunit(HANDLE ph, TCHAR *printer, TCHAR *port)
+{
+ DWORD unit;
+ TCHAR ppm[] = _T("PagesPerMinute");
+ TCHAR ipm[] = _T("InchesPerMinute");
+ TCHAR lpm[] = _T("LinesPerMinute");
+ TCHAR cps[] = _T("CharactersPerSecond");
+
+ unit = DeviceCapabilities(printer, port, DC_PRINTRATEUNIT, NULL, NULL);
+ switch(unit) {
+ case PRINTRATEUNIT_PPM:
+ printf("printRateUnit: %s\n", ppm);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printRateUnit"), REG_SZ, ppm, sizeof(ppm));
+ break;
+ case PRINTRATEUNIT_IPM:
+ printf("printRateUnit: %s\n", ipm);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printRateUnit"), REG_SZ, ipm, sizeof(ipm));
+ break;
+ case PRINTRATEUNIT_LPM:
+ printf("printRateUnit: %s\n", lpm);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printRateUnit"), REG_SZ, lpm, sizeof(lpm));
+ break;
+ case PRINTRATEUNIT_CPS:
+ printf("printRateUnit: %s\n", cps);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, _T("printRateUnit"), REG_SZ, cps, sizeof(cps));
+ break;
+ default:
+ printf("printRateUnit: unknown value %d\n", unit);
+ }
+}
+
+void map_generic_boolean(HANDLE ph, TCHAR *printer, TCHAR *port, WORD cap, TCHAR *key)
+{
+ BYTE boolval;
+ /* DeviceCapabilities doesn't always return 1 for true...just nonzero */
+ boolval = (BYTE) (DeviceCapabilities(printer, port, cap, NULL, NULL) ? 1 : 0);
+ printf("%s: %s\n", key, boolval ? "TRUE" : "FALSE");
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, key, REG_BINARY, &boolval, sizeof(boolval));
+}
+
+void map_generic_dword(HANDLE ph, TCHAR *printer, TCHAR *port, WORD cap, TCHAR *key)
+{
+ DWORD dword;
+
+ dword = DeviceCapabilities(printer, port, cap, NULL, NULL);
+ if ((DWORD) -1 == dword)
+ return;
+
+ printf("%s: %d\n", key, dword);
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, key, REG_DWORD, (BYTE *) &dword, sizeof(dword));
+}
+
+void map_generic_multi_sz(HANDLE ph, TCHAR *printer, TCHAR *port, WORD cap, TCHAR *key, int size)
+{
+ TCHAR *strings_in;
+ TCHAR *strings_out, *strings_cur;
+ DWORD num_items, i;
+
+ num_items = DeviceCapabilities(printer, port, cap, NULL, NULL);
+ if ((DWORD) -1 == num_items)
+ return;
+ strings_in = malloc(num_items * size);
+ strings_out = calloc(num_items, size);
+ num_items = DeviceCapabilities(printer, port, cap, strings_in, NULL);
+ printf("%s:\n", key);
+ for (i=0, strings_cur = strings_out; i < num_items; i++) {
+ _tcsncpy(strings_cur, &strings_in[i*size], size);
+ printf("\t%s\n", strings_cur);
+ strings_cur += _tcslen(strings_cur) + 1;
+ }
+
+ SetPrinterDataEx(ph, SPLDS_DRIVER_KEY, key, REG_MULTI_SZ, strings_out,
+ (strings_cur - strings_out + 1) * sizeof(TCHAR));
+
+ free(strings_in);
+ free(strings_out);
+}
+
+int main(int argc, char *argv[])
+{
+ HANDLE ph;
+ BYTE *driver_info;
+ DWORD needed;
+ TCHAR *printer;
+ TCHAR *port = SAMBA_PORT;
+ PRINTER_DEFAULTS admin_access = {NULL, NULL, PRINTER_ACCESS_ADMINISTER};
+ PRINTER_INFO_7 publish = {NULL, DSPRINT_PUBLISH};
+
+ if (argc < 2) {
+ printf("Usage: %s <printername>\n", argv[0]);
+ return -1;
+ }
+
+ printer = argv[1];
+
+ if (!(OpenPrinter(printer, &ph, &admin_access))) {
+ printf("OpenPrinter failed, error = %s\n", PrintLastError());
+ return -1;
+ }
+
+ GetPrinterDriver(ph, NULL, 1, NULL, 0, &needed);
+ if (!needed) {
+ printf("GetPrinterDriver failed, error = %s\n", PrintLastError());
+ ClosePrinter(ph);
+ return -1;
+ }
+ driver_info = malloc(needed);
+ if (!(GetPrinterDriver(ph, NULL, 1, driver_info, needed, &needed))) {
+ printf("GetPrinterDriver failed, error = %s\n", PrintLastError());
+ ClosePrinter(ph);
+ return -1;
+ }
+
+ map_generic_multi_sz(ph, printer, port, DC_BINNAMES, _T("printBinNames"), 24);
+ map_generic_boolean(ph, printer, port, DC_COLLATE, _T("printCollate"));
+ map_generic_dword(ph, printer, port, DC_COPIES, _T("printMaxCopies"));
+ map_generic_dword(ph, printer, port, DC_DRIVER, _T("driverVersion"));
+ map_generic_boolean(ph, printer, port, DC_DUPLEX, _T("printDuplexSupported"));
+ map_extents(ph, printer, port);
+ map_resolution(ph, printer, port);
+ map_orientation(ph, printer, port);
+ map_generic_multi_sz(ph, printer, port, DC_PAPERNAMES, _T("printMediaSupported"), 64);
+#if (WINVER >= 0x0500)
+ map_generic_boolean(ph, printer, port, DC_COLORDEVICE, _T("printColor"));
+ map_generic_multi_sz(ph, printer, port, DC_PERSONALITY, _T("printLanguage"), 64);
+ map_generic_multi_sz(ph, printer, port, DC_MEDIAREADY, _T("printMediaReady"),64);
+ map_generic_dword(ph, printer, port, DC_PRINTERMEM, _T("printMemory"));
+ map_generic_dword(ph, printer, port, DC_PRINTRATE, _T("printRate"));
+ map_printrateunit(ph, printer, port);
+#ifdef DC_STAPLE
+ map_generic_boolean(ph, printer, port, DC_STAPLE, _T("printStaplingSupported"));
+#endif
+#ifdef DC_PRINTRATEPPM
+ map_generic_dword(ph, printer, port, DC_PRINTRATEPPM, _T("printPagesPerMinute"));
+#endif
+#endif
+ SetPrinter(ph, 7, (BYTE *) &publish, 0);
+ ClosePrinter(ph);
+ return 0;
+}
diff --git a/examples/printing/readme.prtpub b/examples/printing/readme.prtpub
new file mode 100644
index 00000000000..319ce605c3b
--- /dev/null
+++ b/examples/printing/readme.prtpub
@@ -0,0 +1,12 @@
+prtpub.c contains a program which, when compiled with Visual C, can
+download a driver for a printer, query the capabilities of the driver,
+then write back the DsDriver keys necessary to publish all the fields
+of a printer in the directory. After writing back the fields, it issues
+a SetPrinter with info level 7, telling the server to publish the
+printer.
+
+It also writes the fields to stdout.
+
+In order to be distributed, it should be compiled using DLLs for C runtime.
+
+The program takes the UNC name of a printer as the only argument.
diff --git a/examples/printing/smbprint b/examples/printing/smbprint
new file mode 100755
index 00000000000..61ee41f4440
--- /dev/null
+++ b/examples/printing/smbprint
@@ -0,0 +1,144 @@
+#!/bin/sh
+
+# This script is an input filter for printcap printing on a unix machine. It
+# uses the smbclient program to print the file to the specified smb-based
+# server and service.
+# For example you could have a printcap entry like this
+#
+# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
+#
+# which would create a unix printer called "smb" that will print via this
+# script. You will need to create the spool directory /usr/spool/smb with
+# appropriate permissions and ownerships for your system.
+
+# Set these to the server and service you wish to print to
+# In this example I have a WfWg PC called "lapland" that has a printer
+# exported called "printer" with no password.
+
+#
+# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
+# so that the server, service, and password can be read from
+# a /usr/var/spool/lpd/PRINTNAME/.config file.
+#
+# Script further modified by Richard Sharpe to fix some things.
+# Get rid of the -x on the first line, and add parameters
+#
+# -t now causes translate to be used when sending files
+#
+# Further modifications by Alfred Perlstein to fix some problems and
+# improve the quality of the code (3-Dec-2001).
+#
+# More hacking by Richard Sharpe to improve portability. 9-Dec-2001.
+#
+# In order for this to work the /etc/printcap entry must include an
+# accounting file (af=...):
+#
+# cdcolour:\
+# :cm=CD IBM Colorjet on 6th:\
+# :sd=/var/spool/lpd/cdcolour:\
+# :af=/var/spool/lpd/cdcolour/acct:\
+# :if=/usr/local/etc/smbprint:\
+# :mx=0:\
+# :lp=/dev/null:
+#
+# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
+# server=PC_SERVER
+# service=PR_SHARENAME
+# password="password"
+#
+# E.g.
+# server=PAULS_PC
+# service=CJET_371
+# password=""
+
+#smbclient=/usr/pkg/bin/smbclient
+# Assume that smbclient will be in the same place as smbprint
+
+smbclient="`dirname $0`/smbclient"
+
+#
+# The last parameter to the filter is the accounting file name.
+# Extract the directory name from the file name.
+# Concat this with /.config to get the config file.
+#
+TRANS=0
+eval acct_file=\${$#}
+spool_dir=`dirname $acct_file`
+config_file=$spool_dir/.config
+
+# Should read the following variables set in the config file:
+# server
+# service
+# password
+# username (optional)
+# IP (optional)
+# debug (optional)
+# debugsmb (optional)
+# debugfile (optional)
+. $config_file
+
+if [ "x$password" = "x" ] ; then
+ password="-N"
+fi
+
+if [ "x$username" == "x" ] ; then
+ username="$server";
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ -t)
+ TRANS=1
+ ;;
+
+ *) # Bad Parameters, ignore them ...
+ ;;
+ esac
+ shift
+done
+
+command="print - ;"
+if [ $TRANS -eq 1 ]; then
+ command="translate;$command";
+fi
+
+debugfile="/tmp/smb-print.log"
+if [ "x$debug" = "x" ] ; then
+ debugfile=/dev/null debugargs=
+else
+ if [ $debug -eq 0 ] ; then
+ debugfile=/dev/null debugargs=
+ else
+ set -x; exec >>$debugfile 2>&1
+ debugargs="$debugfile."
+ #[ "x$debugsmb" == "x" ] || debugargs="$debugargs -d $debugsmb"
+ fi
+fi
+
+if [ "x$smbconf" != "x" ]; then
+
+ smbconf="-s $smbconf"
+
+fi
+
+if [ "x$IP" != "x" ]; then
+
+ IP="-I $IP"
+
+fi
+
+if [ "x$debugargs" != "x" ]; then
+
+ debugargs="-l $debugargs"
+
+fi
+
+$smbclient \
+ "\\\\$server\\$service" \
+ $password \
+ $smbconf \
+ $IP \
+ $debugargs \
+ -U $username \
+ -c "$command"
+#
diff --git a/examples/printing/smbprint-new.sh b/examples/printing/smbprint-new.sh
new file mode 100644
index 00000000000..61ee41f4440
--- /dev/null
+++ b/examples/printing/smbprint-new.sh
@@ -0,0 +1,144 @@
+#!/bin/sh
+
+# This script is an input filter for printcap printing on a unix machine. It
+# uses the smbclient program to print the file to the specified smb-based
+# server and service.
+# For example you could have a printcap entry like this
+#
+# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
+#
+# which would create a unix printer called "smb" that will print via this
+# script. You will need to create the spool directory /usr/spool/smb with
+# appropriate permissions and ownerships for your system.
+
+# Set these to the server and service you wish to print to
+# In this example I have a WfWg PC called "lapland" that has a printer
+# exported called "printer" with no password.
+
+#
+# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
+# so that the server, service, and password can be read from
+# a /usr/var/spool/lpd/PRINTNAME/.config file.
+#
+# Script further modified by Richard Sharpe to fix some things.
+# Get rid of the -x on the first line, and add parameters
+#
+# -t now causes translate to be used when sending files
+#
+# Further modifications by Alfred Perlstein to fix some problems and
+# improve the quality of the code (3-Dec-2001).
+#
+# More hacking by Richard Sharpe to improve portability. 9-Dec-2001.
+#
+# In order for this to work the /etc/printcap entry must include an
+# accounting file (af=...):
+#
+# cdcolour:\
+# :cm=CD IBM Colorjet on 6th:\
+# :sd=/var/spool/lpd/cdcolour:\
+# :af=/var/spool/lpd/cdcolour/acct:\
+# :if=/usr/local/etc/smbprint:\
+# :mx=0:\
+# :lp=/dev/null:
+#
+# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
+# server=PC_SERVER
+# service=PR_SHARENAME
+# password="password"
+#
+# E.g.
+# server=PAULS_PC
+# service=CJET_371
+# password=""
+
+#smbclient=/usr/pkg/bin/smbclient
+# Assume that smbclient will be in the same place as smbprint
+
+smbclient="`dirname $0`/smbclient"
+
+#
+# The last parameter to the filter is the accounting file name.
+# Extract the directory name from the file name.
+# Concat this with /.config to get the config file.
+#
+TRANS=0
+eval acct_file=\${$#}
+spool_dir=`dirname $acct_file`
+config_file=$spool_dir/.config
+
+# Should read the following variables set in the config file:
+# server
+# service
+# password
+# username (optional)
+# IP (optional)
+# debug (optional)
+# debugsmb (optional)
+# debugfile (optional)
+. $config_file
+
+if [ "x$password" = "x" ] ; then
+ password="-N"
+fi
+
+if [ "x$username" == "x" ] ; then
+ username="$server";
+fi
+
+while test $# -gt 0; do
+ case "$1" in
+ -t)
+ TRANS=1
+ ;;
+
+ *) # Bad Parameters, ignore them ...
+ ;;
+ esac
+ shift
+done
+
+command="print - ;"
+if [ $TRANS -eq 1 ]; then
+ command="translate;$command";
+fi
+
+debugfile="/tmp/smb-print.log"
+if [ "x$debug" = "x" ] ; then
+ debugfile=/dev/null debugargs=
+else
+ if [ $debug -eq 0 ] ; then
+ debugfile=/dev/null debugargs=
+ else
+ set -x; exec >>$debugfile 2>&1
+ debugargs="$debugfile."
+ #[ "x$debugsmb" == "x" ] || debugargs="$debugargs -d $debugsmb"
+ fi
+fi
+
+if [ "x$smbconf" != "x" ]; then
+
+ smbconf="-s $smbconf"
+
+fi
+
+if [ "x$IP" != "x" ]; then
+
+ IP="-I $IP"
+
+fi
+
+if [ "x$debugargs" != "x" ]; then
+
+ debugargs="-l $debugargs"
+
+fi
+
+$smbclient \
+ "\\\\$server\\$service" \
+ $password \
+ $smbconf \
+ $IP \
+ $debugargs \
+ -U $username \
+ -c "$command"
+#
diff --git a/examples/printing/smbprint.old b/examples/printing/smbprint.old
new file mode 100755
index 00000000000..5a00a2a8aa8
--- /dev/null
+++ b/examples/printing/smbprint.old
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+# This script is an input filter for printcap printing on a unix machine. It
+# uses the smbclient program to print the file to the specified smb-based
+# server and service.
+# For example you could have a printcap entry like this
+#
+# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
+#
+# which would create a unix printer called "smb" that will print via this
+# script. You will need to create the spool directory /usr/spool/smb with
+# appropriate permissions and ownerships for your system.
+
+# Set these to the server and service you wish to print to
+# In this example I have a WfWg PC called "lapland" that has a printer
+# exported called "printer" with no password.
+
+#
+# Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
+# so that the server, service, and password can be read from
+# a /usr/var/spool/lpd/PRINTNAME/.config file.
+#
+# Script further modified by Richard Sharpe to fix some things.
+# Get rid of the -x on the first line, and add parameters
+#
+# -t now causes translate to be used when sending files
+#
+# In order for this to work the /etc/printcap entry must include an
+# accounting file (af=...):
+#
+# cdcolour:\
+# :cm=CD IBM Colorjet on 6th:\
+# :sd=/var/spool/lpd/cdcolour:\
+# :af=/var/spool/lpd/cdcolour/acct:\
+# :if=/usr/local/etc/smbprint:\
+# :mx=0:\
+# :lp=/dev/null:
+#
+# The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
+# server=PC_SERVER
+# service=PR_SHARENAME
+# password="password"
+#
+# E.g.
+# server=PAULS_PC
+# service=CJET_371
+# password=""
+
+#
+# Debugging log file, change to /dev/null if you like.
+#
+logfile=/tmp/smb-print.log
+# logfile=/dev/null
+
+
+#
+# The last parameter to the filter is the accounting file name.
+# Extract the directory name from the file name.
+# Concat this with /.config to get the config file.
+#
+TRANS=0
+eval acct_file=\${$#}
+spool_dir=`dirname $acct_file`
+config_file=$spool_dir/.config
+
+# Should read the following variables set in the config file:
+# server
+# service
+# password
+eval `cat $config_file`
+
+while getopts t c; do
+ case $c in
+ t)
+ TRANS=1
+ ;;
+
+ '?') # Bad parameters, ignore it ...
+ ;;
+ esac
+done
+#
+# Some debugging help, change the >> to > if you want to same space.
+#
+echo "server $server, service $service" >> $logfile
+
+(
+# NOTE You may wish to add the line `echo translate' if you want automatic
+# CR/LF translation when printing.
+ if [ $TRANS -eq 1 ]; then
+ echo translate
+ fi
+ echo "print -"
+ cat
+) | /usr/local/samba/bin/smbclient "\\\\$server\\$service" $password -U $server -N -P >> $logfile
diff --git a/examples/printing/smbprint.sysv b/examples/printing/smbprint.sysv
new file mode 100644
index 00000000000..11fea21441b
--- /dev/null
+++ b/examples/printing/smbprint.sysv
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# @(#) smbprint.sysv version 1.0 Ross Wakelin <r.wakelin@march.co.uk>
+#
+# Version 1.0 13 January 1995
+# modified from the original smbprint (bsd) script
+#
+# this script is a System 5 printer interface script. It
+# uses the smbclient program to print the file to the specified smb-based
+# server and service.
+#
+# To add this to your lp system, copy this file into your samba directory
+# (the example here is /opt/samba), modify the server and service variables
+# and then execute the following command (as root)
+#
+# lpadmin -punixprintername -v/dev/null -i/opt/samba/smbprint
+#
+# where unixprintername is the name that the printer will be known as
+# on your unix box.
+#
+# the script smbprint will be copied into your printer administration
+# directory (/usr/lib/lp or /etc/lp) as a new interface
+# (interface/unixprintername)
+# Then you have to enable unixprintername and accept unixprintername
+#
+# This script will then be called by the lp service to print the files
+# This script will have 6 or more parameters passed to it by the lp service.
+# The first five will contain details of the print job, who queued it etc,
+# while parameters 6 onwards are a list of files to print. We just
+# cat these at the samba client.
+#
+# Set these to the server and service you wish to print to
+# In this example I have a WfWg PC called "lapland" that has a printer
+# exported called "printer" with no password.
+#
+# clear out the unwanted parameters
+shift;shift;shift;shift;shift
+# now the argument list is just the files to print
+
+server=admin
+service=hplj2
+password=""
+
+(
+# NOTE You may wish to add the line `echo translate' if you want automatic
+# CR/LF translation when printing.
+ echo translate
+ echo "print -"
+ cat $*
+) | /opt/samba/smbclient "\\\\$server\\$service" $password -N > /dev/null
+exit $?
+