1 /***************************************
2 $Header: /home/amb/routino/src/RCS/logging.c,v 1.1 2010/11/13 14:22:40 amb Exp $
4 Functions to handle logging functions.
6 Part of the Routino routing software.
7 ******************/ /******************
8 This file Copyright 2008-2010 Andrew M. Bishop
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU Affero General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Affero General Public License for more details.
20 You should have received a copy of the GNU Affero General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ***************************************/
31 /*+ The option to print the output in a way that allows logging to a file. +*/
32 int option_loggable=0;
37 static void vfprintf_first(FILE *file,const char *format,va_list ap);
38 static void vfprintf_middle(FILE *file,const char *format,va_list ap);
39 static void vfprintf_last(FILE *file,const char *format,va_list ap);
43 static int printed_length=0;
46 /*++++++++++++++++++++++++++++++++++++++
47 Print the first message in an overwriting sequence.
49 const char *format The format string.
51 ... The other arguments.
52 ++++++++++++++++++++++++++++++++++++++*/
54 void printf_first(const char *format, ...)
63 vfprintf_first(stdout,format,ap);
69 /*++++++++++++++++++++++++++++++++++++++
70 Print the middle message in an overwriting sequence.
72 const char *format The format string.
74 ... The other arguments.
75 ++++++++++++++++++++++++++++++++++++++*/
77 void printf_middle(const char *format, ...)
86 vfprintf_middle(stdout,format,ap);
92 /*++++++++++++++++++++++++++++++++++++++
93 Print the last message in an overwriting sequence.
95 const char *format The format string.
97 ... The other arguments.
98 ++++++++++++++++++++++++++++++++++++++*/
100 void printf_last(const char *format, ...)
106 vfprintf_last(stdout,format,ap);
112 /*++++++++++++++++++++++++++++++++++++++
113 Print the first message in an overwriting sequence.
115 FILE *file The file to write to.
117 const char *format The format string.
119 ... The other arguments.
120 ++++++++++++++++++++++++++++++++++++++*/
122 void fprintf_first(FILE *file,const char *format, ...)
131 vfprintf_first(file,format,ap);
137 /*++++++++++++++++++++++++++++++++++++++
138 Print the middle message in an overwriting sequence.
140 FILE *file The file to write to.
142 const char *format The format string.
144 ... The other arguments.
145 ++++++++++++++++++++++++++++++++++++++*/
147 void fprintf_middle(FILE *file,const char *format, ...)
156 vfprintf_middle(file,format,ap);
162 /*++++++++++++++++++++++++++++++++++++++
163 Print the last message in an overwriting sequence.
165 FILE *file The file to write to.
167 const char *format The format string.
169 ... The other arguments.
170 ++++++++++++++++++++++++++++++++++++++*/
172 void fprintf_last(FILE *file,const char *format, ...)
178 vfprintf_last(file,format,ap);
184 /*++++++++++++++++++++++++++++++++++++++
185 Print the first message in an overwriting sequence.
187 FILE *file The file to write to.
189 const char *format The format string.
191 va_list ap The other arguments.
192 ++++++++++++++++++++++++++++++++++++++*/
194 static void vfprintf_first(FILE *file,const char *format,va_list ap)
198 retval=vfprintf(file,format,ap);
202 printed_length=retval;
206 /*++++++++++++++++++++++++++++++++++++++
207 Print the middle message in an overwriting sequence.
209 FILE *file The file to write to.
211 const char *format The format string.
213 va_list ap The other arguments.
214 ++++++++++++++++++++++++++++++++++++++*/
216 static void vfprintf_middle(FILE *file,const char *format,va_list ap)
221 retval=vfprintf(file,format,ap);
225 printed_length=retval;
229 /*++++++++++++++++++++++++++++++++++++++
230 Print the last message in an overwriting sequence.
232 FILE *file The file to write to.
234 const char *format The format string.
236 va_list ap The other arguments.
237 ++++++++++++++++++++++++++++++++++++++*/
239 static void vfprintf_last(FILE *file,const char *format,va_list ap)
245 retval=vfprintf(file,format,ap);
248 while(retval++<printed_length)