This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / gnu / usr.bin / as / output-file.c
CommitLineData
7b374118
NW
1/* output-file.c - Deal with the output file
2 Copyright (C) 1987 Free Software Foundation, Inc.
3
4This file is part of GAS, the GNU Assembler.
5
6GAS is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GAS is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GAS; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/*
21 * Confines all details of emitting object bytes to this module.
22 * All O/S specific crocks should live here.
23 * What we lose in "efficiency" we gain in modularity.
24 * Note we don't need to #include the "as.h" file. No common coupling!
25 */
26
27/* #include "style.h" */
28#include <stdio.h>
29
30void as_perror();
31
32static FILE *
33stdoutput;
34
35void
36output_file_create (name)
37 char * name;
38{
39 if(name[0]=='-' && name[1]=='\0')
40 stdoutput=stdout;
41 else if ( ! (stdoutput = fopen( name, "w" )) )
42 {
43 as_perror ("FATAL: Can't create %s", name);
44 exit(42);
45 }
46}
47
48
49
50void
51output_file_close (filename)
52 char * filename;
53{
54 if ( EOF == fclose( stdoutput ) )
55 {
56 as_perror ("FATAL: Can't close %s", filename);
57 exit(42);
58 }
59 stdoutput = NULL; /* Trust nobody! */
60}
61
62void
63output_file_append (where, length, filename)
64 char * where;
65 long int length;
66 char * filename;
67{
68
69 for (; length; length--,where++)
70 {
71 (void)putc(*where,stdoutput);
72 if(ferror(stdoutput))
73 /* if ( EOF == (putc( *where, stdoutput )) ) */
74 {
75 as_perror("Failed to emit an object byte", filename);
76 as_fatal("Can't continue");
77 }
78 }
79}
80
81/* end: output-file.c */