1#!/bin/bash 2 3# 4# Copyright (c) 2015, 2017-2018 Samuel Thibault <samuel.thibault@ens-lyon.org> 5# 6# Permission is hereby granted, free of charge, to any person obtaining a copy 7# of this software and associated documentation files (the "Software"), to deal 8# in the Software without restriction, including without limitation the rights 9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10# copies of the Software, and to permit persons to whom the Software is 11# furnished to do so, subject to the following conditions: 12# 13# 14# The above copyright notice and this permission notice shall be included in 15# all copies or substantial portions of the Software. 16# 17# 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24# THE SOFTWARE. 25# 26 27# Make sure we have enough options 28if [ $# != 5 -a $# != 6 ]; then 29 echo "ERROR: $0 jobid user name nb options [filename]" >&2 30 exit 1 31fi 32 33NB=$4 34OPTIONS=$5 35FILE=$6 36if [ -z "$FILE" ] 37then 38 # Get input from stdin 39 unset FILE 40 trap -- 'rm -f "$FILE"' EXIT 41 FILE=$(mktemp "${TMPDIR:-/tmp}/brftoembosser.XXXXXX") 42 cat > "$FILE" 43fi 44 45. @CUPS_DATADIR@/braille/cups-braille.sh 46 47SENDFF=$(getOption SendFF) 48SENDSUB=$(getOption SendSUB) 49 50echo "INFO: Writing text to generic embosser" >&2 51 52while [ $NB -gt 0 ] 53do 54 < "$FILE" \ 55 sed -e 's/^$/'$'\015''/' \ 56 -e 's/'$'\302'$'\240''/ /g' \ 57 -e 's/'$'\240''/ /g' \ 58 -e 's/\([^'$'\015'']\)$/\1'$'\015''/' 59 60 if [ "$SENDFF" = True ] 61 then 62 printf '\014' 63 fi 64 if [ "$SENDSUB" = True ] 65 then 66 printf '\032' 67 fi 68 NB=$(($NB - 1)) 69done 70 71echo "INFO: Ready" >&2 72exit 0 73