blob: 3c59f8cd63b63264c96f5746036758dc0f5f6bef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#include <unistd.h>
#include "bootlib.h"
/* OS_WRITE -- Write to the output file. If the output file is a text file
* we must convert the binary input (text) stream to the record structured
* stream required by the host.
*/
int
os_write (
int fd, /* output file */
char *buf, /* data to be written */
int nbytes /* num bytes to be written */
)
{
register char *ip;
register XCHAR *op, *otop;
register int ch, n;
XINT nchars, status, xfd=fd;
extern int ZPUTTX();
if (osfiletype == BINARY_FILE)
return (write (fd, buf, nbytes));
n = nbytes;
ip = buf;
op = txop;
otop = &text[SZ_FBUF];
/* Accumulate an output line of text and pass it on to the system when
* newline is seen or when the output buffer fills (unlikely).
*/
while (--n >= 0) {
*op++ = ch = *ip++;
if (ch == '\n' || op >= otop) {
nchars = op - text;
ZPUTTX (&xfd, text, &nchars, &status);
op = txop = text;
if (status == XERR)
return (ERR);
}
}
txop = op;
return (nbytes);
}
|