Commit | Line | Data |
---|---|---|
586c39b1 DF |
1 | /* |
2 | * Copyright (c) 1980 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | */ | |
6 | ||
7 | #ifndef lint | |
8 | static char sccsid[] = "@(#)setbuf.c 5.1 (Berkeley) %G%"; | |
9 | #endif not lint | |
10 | ||
59641075 BJ |
11 | #include <stdio.h> |
12 | ||
13 | setbuf(iop, buf) | |
41e01b3e | 14 | register FILE *iop; |
59641075 BJ |
15 | char *buf; |
16 | { | |
17 | if (iop->_base != NULL && iop->_flag&_IOMYBUF) | |
18 | free(iop->_base); | |
19 | iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); | |
f4c06a32 | 20 | if ((iop->_base = buf) == NULL) { |
59641075 | 21 | iop->_flag |= _IONBF; |
f4c06a32 KM |
22 | iop->_bufsiz = NULL; |
23 | } else { | |
59641075 | 24 | iop->_ptr = iop->_base; |
f4c06a32 KM |
25 | iop->_bufsiz = BUFSIZ; |
26 | } | |
59641075 BJ |
27 | iop->_cnt = 0; |
28 | } |