dtinfo: Fix coverity warning related to using delete not delete []
[oweals/cde.git] / cde / programs / dtprintegrate / dtlpsetup.src
1 XCOMM!/bin/sh
2 XCOMM
3 XCOMM $XConsortium: dtlpsetup.src /main/3 1996/04/23 12:01:59 drk $
4 XCOMM
5 XCOMM COMPONENT_NAME: desktop
6 XCOMM
7 XCOMM FUNCTIONS: dtlpsetup
8 XCOMM
9 XCOMM ORIGINS: 27 
10 XCOMM
11 XCOMM  (C) COPYRIGHT International Business Machines Corp. 1995
12 XCOMM  All Rights Reserved
13 XCOMM  US Government Users Restricted Rights - Use, duplication or
14 XCOMM  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
15 XCOMM
16 XCOMM
17 XCOMM Add /usr/dt/lib/nls/msg/%L/%N.cat to NLSPATH
18 XCOMM
19
20 NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat:$NLSPATH
21 export NLSPATH
22
23 XCOMM Return Codes
24 NO_VALID_FILE_ERR=7
25 NO_READ_FILE_ERR=8
26
27 usage="$0 [-b banner_title] [-d lpdest] [-f print_file] 
28          [-m print_command] [-n copy_count] [-o other_options] 
29          [-u user_filename] [-a] [-e] [-h] [-r] [-s] [-v] [-w]"
30
31 while [ $# -gt 0 ]; do
32         case "$1" in
33         -b)
34                 if [ $2 ]; then
35                   banner_title="$1 $2"
36                   shift; shift;
37                 else
38                   echo "$usage" 1>&2
39                   exit 2
40                 fi
41                 ;;
42         -b*)
43                 banner_title="-b `expr "$1" : '-b\(.*\)'`"
44                 shift
45                 ;;
46         -d)
47                 if [ $2 ]; then
48                   lpdest="$1 $2"
49                   shift; shift;
50                 else
51                   echo "$usage" 1>&2
52                   exit 2
53                 fi
54                 ;;
55         -d*)
56                 lpdest="-d `expr "$1" : '-d\(.*\)'`"
57                 shift
58                 ;;
59         -c)
60                 NOT_SUPPORTED=true
61                 ARGS="$ARGS $1"
62                 if [ $2 ]; then
63                   shift; shift;
64                 else
65                   shift
66                 fi
67                 ;;
68         -c*)
69                 NOT_SUPPORTED=true
70                 ARGS="$ARGS -c"
71                 shift
72                 ;;
73         -t)
74                 NOT_SUPPORTED=true
75                 ARGS="$ARGS $1"
76                 if [ $2 ]; then
77                   shift; shift;
78                 else
79                   shift
80                 fi
81                 ;;
82         -t*)
83                 NOT_SUPPORTED=true
84                 ARGS="$ARGS -t"
85                 shift
86                 ;;
87         -i)
88                 NOT_SUPPORTED=true
89                 ARGS="$ARGS $1"
90                 if [ $2 ]; then
91                   shift; shift;
92                 else
93                   shift
94                 fi
95                 ;;
96         -i*)
97                 NOT_SUPPORTED=true
98                 ARGS="$ARGS -i"
99                 shift
100                 ;;
101         -l)
102                 NOT_SUPPORTED=true
103                 ARGS="$ARGS $1"                
104                 if [ $2 ]; then
105                   shift; shift;
106                 else
107                   shift
108                 fi
109                 ;;
110         -l*)
111                 NOT_SUPPORTED=true
112                 ARGS="$ARGS -l"
113                 shift
114                 ;;
115         -f)
116                 if [ $2 ]; then
117                   print_file=$2
118                   shift; shift;
119                 else
120                   echo "$usage" 1>&2
121                   exit 2
122                 fi
123                 ;;
124         -f*)
125                 print_file=`expr "$1" : '-f\(.*\)'`
126                 shift
127                 ;;
128         -m)
129                 if [ $2 ]; then
130                   print_command="$1 $2"
131                   shift; shift;
132                 else
133                   echo "$usage" 1>&2
134                   exit 2
135                 fi
136                 ;;
137         -m*)
138                 print_command="-m `expr "$1" : '-m\(.*\)'`"
139                 shift
140                 ;;
141         -n)
142                 if [ $2 ]; then
143                   copy_count="$1 $2"
144                   shift; shift;
145                 else
146                   echo "$usage" 1>&2
147                   exit 2
148                 fi
149                 ;;
150         -n*)
151                 copy_count="-n `expr "$1" : '-n\(.*\)'`"
152                 shift
153                 ;;
154         -o)
155                 if [ $2 ]; then
156                   other_options="$1 $2"
157                   shift; shift;
158                 else
159                   echo "$usage" 1>&2
160                   exit 2
161                 fi
162                 ;;
163         -o*)
164                 other_options="-o `expr "$1" : '-o\(.*\)'`"
165                 shift
166                 ;;
167         -u)
168                 if [ $2 ]; then
169                   user_filename="$1 $2"
170                   shift; shift;
171                 else
172                   echo "$usage" 1>&2
173                   exit 2
174                 fi
175                 ;;
176         -u*)
177                 user_filename="-u `expr "$1" : '-u\(.*\)'`"
178                 shift
179                 ;;
180         -a)
181                 a=$1
182                 shift
183                 ;;
184         -e)
185                 e=$1
186                 shift
187                 ;;
188         -r)
189                 r=$1
190                 shift
191                 ;;
192         -s)
193                 s=$1
194                 shift
195                 ;;
196         -v)
197                 v=$1
198                 shift
199                 ;;
200         -w)
201                 w=$1
202                 shift
203                 ;;
204         -*)
205                 echo "$usage" 1>&2 
206                 exit 2
207                 ;;
208         *)
209                 break
210                 ;;
211         esac
212 done
213
214 if [ $# -gt 0 ]; then
215         echo "$usage" 1>&2 
216         exit 2
217 fi
218
219 if  [ $NOT_SUPPORTED ]; then
220   dspmsg -s 1 dtmigrate 2 'dtlpsetup: dtlpsetup has been replaced with dtlp.\
221 \tdtlp will be automatically called in its place. \
222 \tThe following flags and parameters on the dtlpsetup call \
223 \thave been ignored because dtlp does not support these flags: \
224 \t%1$s \n' "$ARGS"
225 fi
226
227 /usr/dt/bin/dtlp $banner_title $lpdest $print_command $copy_count $other_options $user_filename $a $e $h $r $s $v $w $print_file
228  
229 status=$?
230
231 XCOMM dtlp return code of 5 maps to return code 7 of dtlpsetup
232 if  [[ $status -eq 5 ]]
233   then exit NO_VALID_FILE_ERR
234 XCOMM dtlp return code of 6 maps to return code 8 of dtlpsetup
235 elif [[ $status -eq 6 ]] 
236   then exit NO_READ_FILE_ERR
237 else
238 XCOMM all others are synonomous
239   exit $status
240 fi
241