2 * log.c Functions in the library call radlib_log() which
3 * sets a global error string "char *librad_errstr".
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * Copyright 2000,2006 The FreeRADIUS server project
24 #include <freeradius-devel/ident.h>
27 #include <freeradius-devel/autoconf.h>
33 #include <freeradius-devel/missing.h>
34 #include <freeradius-devel/libradius.h>
36 char librad_errstr[1024];
39 * Do logging to a static buffer. Note that we MIGHT be asked
40 * to write a previous log message to librad_errstr.
42 * This also isn't multithreaded-safe, so it'll have to be changed
45 void librad_log(const char *fmt, ...)
48 char my_errstr[sizeof(librad_errstr)];
51 vsnprintf(my_errstr, sizeof(my_errstr), fmt, ap);
52 strcpy(librad_errstr, my_errstr);
56 void librad_perror(const char *fmt, ...)
61 vfprintf(stderr, fmt, ap);
62 if (strchr(fmt, ':') == NULL)
63 fprintf(stderr, ": ");
64 fprintf(stderr, "%s\n", librad_errstr);