4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 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" /* SVr4.0 1.8 */
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
34 #include "sys/types.h"
50 int _search_fheading ( char * );
52 static void print_sdn(int, char *, SCALED
);
53 static void print_str(int, char *, char *);
60 wrform(char *name
, FORM
*formp
, int fd
, int (*error_handler
)( int , int , int ),
69 for (fld
= 0; fld
< FO_MAX
; fld
++)
70 if ((!which_set
|| which_set
[fld
]) &&
71 (formheadings
[fld
].infile
|| error_handler
))
74 #define HEAD formheadings[fld].v
77 print_sdn(fd
, HEAD
, formp
->plen
);
81 print_sdn(fd
, HEAD
, formp
->pwid
);
85 print_sdn(fd
, HEAD
, formp
->lpi
);
89 if (formp
->cpi
.val
== N_COMPRESSED
)
90 print_str(fd
, HEAD
, NAME_COMPRESSED
);
92 print_sdn(fd
, HEAD
, formp
->cpi
);
96 fdprintf(fd
, "%s %d\n", HEAD
, formp
->np
);
100 fdprintf(fd
, "%s %s", HEAD
, formp
->chset
);
101 if (formp
->mandatory
== 1)
102 fdprintf(fd
, ",%s", MANSTR
);
107 print_str(fd
, HEAD
, formp
->rcolor
);
111 if ((cp
= formp
->comment
) && *cp
) {
112 fdprintf(fd
, "%s\n", HEAD
);
114 char * nl
= strchr(cp
, '\n');
118 if (_search_fheading(cp
) < FO_MAX
)
120 fdprintf(fd
, "%s\n", cp
);
124 } while (cp
++); /* NOT *cp++ */
129 /* this must always be the last field in the file
130 it is done outside of this loop */
135 fdprintf(fd
, "%s %s", HEAD
, formp
->paper
);
136 if (formp
->isDefault
== 1)
137 fdprintf(fd
, ",%s", DFTSTR
);
144 if ((!which_set
|| which_set
[FO_ALIGN
]) &&
145 (formheadings
[FO_ALIGN
].infile
|| error_handler
)) {
146 print_str(fd
, formheadings
[FO_ALIGN
].v
, formp
->conttype
);
148 * Actual alignment pattern has to be written
149 * out by caller; we leave the file pointer ready.
157 * Write out comment to a separate file (?)
159 if (!error_handler
) {
164 if (!(path
= getformfile(name
, COMMENT
)))
167 if (formp
->comment
) {
168 if (dumpstring(path
, formp
->comment
) == -1) {
184 ** print_sdn() - PRINT SCALED DECIMAL NUMBER WITH HEADER
185 ** print_str() - PRINT STRING WITH HEADER
189 print_sdn(int fd
, char *head
, SCALED sdn
)
194 (void)fdprintf(fd
, "%s ", head
);
201 print_str(int fd
, char *head
, char *str
)
206 (void)fdprintf(fd
, "%s %s\n", head
, str
);