BRL-CAD
linebuf.c
Go to the documentation of this file.
1 /* L I N E B U F . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "common.h"
22 
23 #include <stdio.h>
24 
25 #include "bu/log.h"
26 
27 #ifndef BUFSIZE
28 # define BUFSIZE 2048
29 #endif
30 
31 
32 void
33 port_setlinebuf(FILE *fp)
34 {
35  bu_log("\
36 WARNING: port_setlinebuf is deprecated and will be removed in a\n\
37 future release of BRL-CAD. Use bu_setlinebuf instead.\n");
38  bu_setlinebuf(fp);
39  return;
40 }
41 
42 
43 void
44 bu_setlinebuf(FILE *fp)
45 {
46  if (UNLIKELY(!fp)) {
47  return;
48  }
49 
50  /* prefer this one */
51  if (UNLIKELY(setvbuf(fp, (char *)NULL, _IOLBF, BUFSIZE) != 0)) {
52  perror("bu_setlinebuf");
53  }
54 }
55 
56 
57 /*
58  * Local Variables:
59  * mode: C
60  * tab-width: 8
61  * indent-tabs-mode: t
62  * c-file-style: "stroustrup"
63  * End:
64  * ex: shiftwidth=4 tabstop=8
65  */
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
Header file for the BRL-CAD common definitions.
void port_setlinebuf(FILE *fp)
Definition: linebuf.c:33
#define BUFSIZE
Definition: linebuf.c:28
void bu_setlinebuf(FILE *fp)
Definition: linebuf.c:44
#define UNLIKELY(expression)
Definition: common.h:282