3635cf
#!/bin/sh
3635cf
# This is a modified version of 'ncpprint'.  It can now be used as a CUPS
3635cf
# backend.
3635cf
# Modifications:
3635cf
# Copyright (C) 2002  Red Hat, inc
3635cf
# Copyright (C) 2002  Tim Waugh
3635cf
# Before modification: shipped as /usr/share/printconf/util/ncpprint
3635cf
3635cf
if [ -z "$*" ]
3635cf
then
3635cf
  # This is where we would enumerate all the URIs we support.
3635cf
  # Patches welcome.
3635cf
  exit 0
3635cf
fi
3635cf
3635cf
FILE=$6
3635cf
if [ -z "$FILE" ]
3635cf
then
3635cf
  FILE=-
3635cf
fi
3635cf
3635cf
# $DEVICE_URI is 'ncp://[user:password@]server/queue'
3635cf
URI=${DEVICE_URI#*://}
3635cf
queue=${URI#*/}
3635cf
URI=${URI%/$queue}
3635cf
server=${URI#*@}
3635cf
URI=${URI%$server}
3635cf
URI=${URI%@}
3635cf
if [ -n "$URI" ]
3635cf
then
3635cf
  user=${URI%:*}
3635cf
  URI=${URI#$user}
3635cf
  password=${URI#:}
3635cf
fi
3635cf
3635cf
#echo user: ${user-(none)}
3635cf
#echo password: ${password-(none)}
3635cf
#echo server: $server
3635cf
#echo queue: $queue
3635cf
3635cf
if [ -n "$user" ]
3635cf
then
3635cf
  if [ -n "$password" ]
3635cf
  then
3635cf
    /usr/bin/nprint -S "$server" -q "$queue" -U "$user" -P "$password" -N "$FILE" 2>/dev/null
3635cf
  else
3635cf
    /usr/bin/nprint -S "$server" -q "$queue" -U "$user" -n -N "$FILE" 2>/dev/null
3635cf
  fi
3635cf
else
3635cf
  /usr/bin/nprint -S "$server" -q "$queue" -N "$FILE" 2>/dev/null
3635cf
fi