00001 /* L I N E B U F . C 00002 * BRL-CAD 00003 * 00004 * Copyright (c) 2004-2006 United States Government as represented by 00005 * the U.S. Army Research Laboratory. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either version 2 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this file; see the file named COPYING for more 00019 * information. 00020 */ 00021 00022 /** \addtogroup bu_log */ 00023 /*@{*/ 00024 00025 /** @file linebuf.c 00026 * 00027 * @brief A portable way of doing setlinebuf(). 00028 * 00029 * A portable way of doing setlinebuf(). 00030 * 00031 * @author Doug A. Gwyn 00032 * @author Michael John Muuss 00033 * @author Christopher Sean Morrison 00034 * 00035 * @par Source - 00036 * @n The U. S. Army Research Laboratory 00037 * @n Aberdeen Proving Ground, Maryland 21005-5068 USA 00038 * 00039 */ 00040 00041 00042 #ifndef lint 00043 static const char libbu_linebuf_RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbu/linebuf.c,v 14.16 2006/09/03 15:14:07 lbutler Exp $ (ARL)"; 00044 #endif 00045 00046 #include "common.h" 00047 00048 #include <stdio.h> 00049 00050 #include "machine.h" 00051 #include "bu.h" 00052 00053 00054 /** deprecated call for compatibility 00055 */ 00056 void 00057 port_setlinebuf(FILE *fp) 00058 { 00059 bu_log("\ 00060 WARNING: port_setlinebuf is deprecated and will be removed in a\n\ 00061 future release of BRL-CAD. Use bu_setlinebuf instead.\n"); 00062 bu_setlinebuf(fp); 00063 return ; 00064 } 00065 00066 void 00067 bu_setlinebuf(FILE *fp) 00068 { 00069 #if defined(HAVE_SETVBUF) 00070 /* prefer this one */ 00071 if (setvbuf( fp, (char *) NULL, _IOLBF, 0) != 0) { 00072 perror("bu_setlinebuf"); 00073 } 00074 #elif defined(HAVE_SETLINEBUF) 00075 /* setlinebuf() returns int on bsd, void on linux */ 00076 (void)setlinebuf( fp ); 00077 #else 00078 # error "Do not know how to set line buffered mode for this platform" 00079 #endif 00080 } 00081 /*@}*/ 00082 /* 00083 * Local Variables: 00084 * mode: C 00085 * tab-width: 8 00086 * c-basic-offset: 4 00087 * indent-tabs-mode: t 00088 * End: 00089 * ex: shiftwidth=4 tabstop=8 00090 */