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