rdform.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1997 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.17 */
/* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
#include "stdio.h"
#include "string.h"
#include "errno.h"
#include "stdlib.h"
#include "lp.h"
#include "form.h"
extern struct {
char *v;
short len;
short infile;
} formheadings[];
#if defined(__STDC__)
int _search_fheading ( char * );
#else
int _search_fheading();
#endif
int
int *which_set)
{
char * rest;
char * mandp;
char * dftp;
char * here;
int fld;
int have_line_already;
int size;
int add_size;
int linenum;
int i;
register char * p;
/*
* Initialize the entire structure, to ensure no random
* values get in it. However, make sure some values won't
* be null or empty. Do the latter here as opposed to
* after reading the file, because sometimes the file
*/
/*
* Read the file.
*/
have_line_already = 0;
linenum = 0;
errno = 0;
while (!found_alignment_pattern
) {
have_line_already = 0;
if (error_handler) {
return (-1);
continue;
} else {
/*
* To allow future extensions to not
* impact applications using old versions
* of this routine, ignore strange fields.
*/
continue;
}
}
while (isspace(*p))
p++;
if (which_set)
if (
) switch (fld) {
case FO_PLEN:
goto BadFile;
}
break;
case FO_PWID:
goto BadFile;
}
break;
case FO_CPI:
goto BadFile;
}
break;
case FO_LPI:
goto BadFile;
}
break;
case FO_NP:
if (
|| *rest
) {
goto BadFile;
}
break;
case FO_CHSET:
else {
do
*mandp++ = 0;
else {
goto BadFile;
}
}
if (!syn_name(p)) {
goto BadFile;
}
break;
case FO_RCOLOR:
break;
case FO_CMT:
if (*p) {
goto BadFile;
}
size = 0;
p = buf;
/*
* A recognized header ends the comment.
*/
if (_search_fheading(p) < FO_MAX) {
have_line_already = 1;
break;
}
/*
* On the other hand, a '>' may hide what
* would otherwise look like a header.
*/
if (
p[0] == '>'
)
p++;
/*
* (Re)allocate space to hold this
* (additional) line of the comment.
*/
);
else
);
return (-1);
}
/*
* Copy this (additional) line of the
* comment to the allocated space. "here"
* points to where to copy the line.
*/
}
if (errno != 0)
goto BadFile;
/*
* The comment is held internally without a
* trailing newline.
*/
break;
case FO_ALIGN:
if (*p) {
if (!syn_type(p)) {
goto BadFile;
}
}
/*
* Actual alignment pattern has to be read in
* by caller; we leave the file pointer ready.
*/
break;
case FO_PAPER:
else {
do
*dftp++ = 0;
else {
goto BadFile;
}
}
if (!syn_name(p)) {
goto BadFile;
}
break;
}
}
if (errno != 0) {
int save_errno = errno;
errno = save_errno;
return (-1);
}
/*
* Get the form description (if it exists) (?)
*/
if (!error_handler) {
char * path;
return (-1);
}
if (
) {
return (-1);
}
}
return (0);
}