4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
37 #include "sys/types.h"
49 ** getrequest() - EXTRACT REQUEST STRUCTURE FROM DISK FILE
74 * Full pathname? If so the file must lie in LP's
75 * regular temporary directory.
78 if (!STRNEQU(file
, Lp_Tmp
, strlen(Lp_Tmp
))) {
85 * A relative pathname (such as system/name)?
86 * If so we'll locate it under LP's regular temporary
89 } else if (strchr(file
, '/')) {
90 if (!(path
= makepath(Lp_Tmp
, file
, (char *)0)))
94 * It must be a simple name. Locate this under the
95 * special temporary directory that is linked to the
96 * regular place for the local system.
98 } else if (!(path
= makepath(Lp_Temp
, file
, (char *)0)))
102 if ((fd
= open_locked(path
, "r", 0)) < 0) {
108 reqp
= calloc(sizeof (*reqp
), 1);
113 while (fdgets(buf
, BUFSIZ
, fd
)) {
115 buf
[strlen(buf
) - 1] = 0;
117 for (fld
= 0; fld
< RQ_MAX
; fld
++)
120 && reqheadings
[fld
].len
127 p
= buf
+ reqheadings
[fld
].len
;
132 * To allow future extensions to not impact applications
133 * using old versions of this routine, ignore strange
142 reqp
->copies
= atoi(p
);
146 reqp
->destination
= Strdup(p
);
150 appendlist (&reqp
->file_list
, p
);
154 if (!STREQU(p
, NAME_ANY
))
155 reqp
->form
= Strdup(p
);
159 if (STREQU(p
, NAME_RESUME
))
160 reqp
->actions
|= ACT_RESUME
;
161 else if (STREQU(p
, NAME_HOLD
))
162 reqp
->actions
|= ACT_HOLD
;
163 else if (STREQU(p
, NAME_IMMEDIATE
))
164 reqp
->actions
|= ACT_IMMEDIATE
;
169 reqp
->actions
|= ACT_MAIL
;
170 else if (STREQU(p
, "W"))
171 reqp
->actions
|= ACT_WRITE
;
172 else if (STREQU(p
, "N"))
173 reqp
->actions
|= ACT_NOTIFY
;
175 reqp
->alert
= Strdup(p
);
179 reqp
->options
= Strdup(p
);
183 reqp
->priority
= atoi(p
);
187 reqp
->pages
= Strdup(p
);
191 if (!STREQU(p
, NAME_ANY
))
192 reqp
->charset
= Strdup(p
);
196 reqp
->title
= Strdup(p
);
200 reqp
->modes
= Strdup(p
);
204 reqp
->input_type
= Strdup(p
);
208 reqp
->user
= Strdup(p
);
212 reqp
->actions
|= ACT_RAW
;
216 reqp
->actions
|= ACT_FAST
;
220 reqp
->outcome
= (ushort
)strtol(p
, (char **)0, 16);
227 int save_errno
= errno
;
236 * Now go through the structure and see if we have
241 || !reqp
->file_list
|| !*(reqp
->file_list
)
242 || reqp
->priority
< -1 || 39 < reqp
->priority
243 || STREQU(reqp
->input_type
, NAME_ANY
)
244 || STREQU(reqp
->input_type
, NAME_TERMINFO
)
252 * Guarantee some return values won't be null or empty.
254 if (!reqp
->destination
|| !*reqp
->destination
) {
255 if (reqp
->destination
)
256 Free (reqp
->destination
);
257 reqp
->destination
= Strdup(NAME_ANY
);
259 if (!reqp
->input_type
|| !*reqp
->input_type
) {
260 if (reqp
->input_type
)
261 Free (reqp
->input_type
);
262 reqp
->input_type
= Strdup(NAME_SIMPLE
);