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]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
31 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
36 #include "sys/types.h"
37 #include "sys/utsname.h"
49 ** putrequest() - WRITE REQUEST STRUCTURE TO DISK FILE
59 putrequest (file
, reqbufp
)
72 * First go through the structure and see if we have
77 || !(reqbufp
->destination
)
78 || !reqbufp
->file_list
|| !*(reqbufp
->file_list
)
79 || (reqbufp
->actions
& (ACT_MAIL
|ACT_WRITE
))
80 && (reqbufp
->alert
&& *(reqbufp
->alert
))
81 || reqbufp
->priority
< -1 || 39 < reqbufp
->priority
88 * Now open the file and write out the request.
92 * Full pathname? If so the file must lie in LP's
93 * regular temporary directory.
96 if (!STRNEQU(file
, Lp_Tmp
, strlen(Lp_Tmp
))) {
103 * A relative pathname (such as system/name)?
104 * If so we'll locate it under LP's regular temporary
107 } else if (strchr(file
, '/')) {
108 if (!(path
= makepath(Lp_Tmp
, file
, (char *)0)))
112 * If must be a simple name. Locate this under the
113 * special temporary directory that is linked to the
114 * regular place for the local system.
116 } else if (!(path
= makepath(Lp_Temp
, file
, (char *)0)))
119 if ((fd
= open_locked(path
, "w", MODE_NOREAD
)) < 0) {
125 for (fld
= 0; fld
< RQ_MAX
; fld
++) switch (fld
) {
127 #define HEAD reqheadings[fld].v
130 (void)fdprintf(fd
, "%s%d\n", HEAD
, reqbufp
->copies
);
134 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->destination
);
138 for (pp
= reqbufp
->file_list
; *pp
; pp
++)
139 (void)fdprintf(fd
, "%s%s\n", HEAD
, *pp
);
144 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->form
);
148 if ((reqbufp
->actions
& ACT_SPECIAL
) == ACT_IMMEDIATE
)
149 (void)fdprintf(fd
, "%s%s\n", HEAD
, NAME_IMMEDIATE
);
150 else if ((reqbufp
->actions
& ACT_SPECIAL
) == ACT_RESUME
)
151 (void)fdprintf(fd
, "%s%s\n", HEAD
, NAME_RESUME
);
152 else if ((reqbufp
->actions
& ACT_SPECIAL
) == ACT_HOLD
)
153 (void)fdprintf(fd
, "%s%s\n", HEAD
, NAME_HOLD
);
157 if (reqbufp
->actions
& ACT_MAIL
)
158 (void)fdprintf(fd
, "%sM\n", HEAD
);
159 else if (reqbufp
->actions
& ACT_WRITE
)
160 (void)fdprintf(fd
, "%sW\n", HEAD
);
161 else if (reqbufp
->actions
& ACT_NOTIFY
)
162 (void)fdprintf(fd
, "%sN\n", HEAD
);
163 else if (reqbufp
->alert
&& *(reqbufp
->alert
))
164 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->alert
);
168 if (reqbufp
->options
)
169 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->options
);
173 if (reqbufp
->priority
!= -1)
174 (void)fdprintf(fd
, "%s%d\n", HEAD
, reqbufp
->priority
);
179 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->pages
);
183 if (reqbufp
->charset
)
184 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->charset
);
189 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->title
);
194 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->modes
);
198 if (reqbufp
->input_type
)
199 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->input_type
);
204 (void)fdprintf(fd
, "%s%s\n", HEAD
, reqbufp
->user
);
208 if (reqbufp
->actions
& ACT_RAW
)
209 (void)fdprintf(fd
, "%s\n", HEAD
);
213 if (reqbufp
->actions
& ACT_FAST
)
214 (void)fdprintf(fd
, "%s\n", HEAD
);
218 (void)fdprintf(fd
, "%s%#6.4x\n", HEAD
, reqbufp
->outcome
);