#!/bin/sh
# This is a template file for transferring a print job
#
#  Modified by Patrick Powell <papowell@astart.com> for the LPRngTool
#   Note 1: the .config file is assumed to be in the current directory
#   Note 2: entries can be in any order in the file
#
# 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
#
# atalk:lp=/dev/null:sd=/usr/spool/lpd/atalk:if=/usr/local/filters/atalkprint
#
# which would create a unix printer called "atalk" that will print via this 
# script.
#
# The script gets its information from the .config file in the
# printer spool directory


# Should read the following variables set in the config file:
#   host=host           host for printing
#   printer=printer     printer
#   share=//host/share  for SMB printing
#   hostip=whatever     for SMB printing
#   authfile=auth       for authentication
#
#  The following are set in the authfile:
#   username=username   for authentication
#   password=password   for authentication


options=`echo "${PRINTCAP_ENTRY}" | sed -n 's/:xfer_options=//p' `
if [ -n "$options" ] ; then
	eval export $options
elif [ -f ./general.cfg ] ; then
	. ./general.cfg
fi

# do this if you need to set the value in shell variables
#if [ -n "$authfile" -a -f "$authfile" ] ; then
#	. ${authfile}
#fi

# now you simply use the paramters you have to extract the options and
# put them on the command line.
#
# here is an example for SMB printing using smbprint
# smbclient "$share" -E ${hostip:+-I} $hostip -N ${workgroup:+-W} "$workgroup" \
#     ${auth:+-A} "$auth" -c "$command" 2>&1
