* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)yymain.c 8.2 (Berkeley) 5/24/94";
#include "tree_ty.h" /* must be included for yy.h */
* Yymain initializes each of the utility
* clusters and then starts the processing
* initialize symbol table temp files
Perror(filename
, "No lines in file");
* Initialize the clusters
* save outermost block of namelist
writef(2, "File not rewritten because of errors\n");
(void) signal(SIGHUP
, SIG_IGN
);
(void) signal(SIGINT
, SIG_IGN
);
pexit(eflg
? ERRS
: AOK
);
if (creat(firstname
, 0644) != 1) {
if (lseek(fout
[0], (off_t
)0, 0) == -1)
perror("copyfile: lseek"), panic("copyfile");
while ((c
= read(fout
[0], &fout
[3], 512)) > 0) {
if (write(1, &fout
[3], c
) != c
) {
short buf
[HEADER_BYTES
/ sizeof ( short )];
unsigned *ubuf
= (unsigned *) buf
;
if (hf
>= 0 && read(hf
, (char *) buf
, HEADER_BYTES
) > sizeof(struct exec
)) {
magichdr
.a_magic
= ubuf
[0];
magichdr
.a_text
= ubuf
[1];
magichdr
.a_data
= ubuf
[2];
magichdr
.a_bss
= ubuf
[3];
magichdr
.a_syms
= ubuf
[4];
magichdr
.a_entry
= ubuf
[5];
magichdr
.a_trsize
= ubuf
[6];
magichdr
.a_drsize
= ubuf
[7];
for (i
= 0; i
< HEADER_BYTES
/ sizeof ( short ); i
++)
if (magichdr
.a_magic
!= 0407)
magichdr
.a_data
= ( unsigned ) lc
- magichdr
.a_text
;
magichdr
.a_data
-= sizeof (struct exec
);
pxhd
.objsize
= ( ( unsigned ) lc
) - HEADER_BYTES
;
pxhd
.symtabsize
= nlhdrsize();
magichdr
.a_data
+= pxhd
.symtabsize
;
(void) time((long *) (&pxhd
.maketime
));
pxhd
.magicnum
= MAGICNUM
;
if (lseek(ofil
, (off_t
)0, 0) == -1)
perror("magic2: lseek1"), panic("magic2");
write(ofil
, (char *) (&magichdr
), sizeof(struct exec
));
if (lseek(ofil
, (off_t
)(HEADER_BYTES
- sizeof(pxhd
)), 0) == -1)
perror("magic2: lseek2"), panic("magic2");
write(ofil
, (char *) (&pxhd
), sizeof (pxhd
));
write(i
, cp
, strlen(cp
));