1 /* assuan-logging.c - Default logging function.
2 * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 * This file is part of Assuan.
6 * Assuan is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * Assuan 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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 /* Please note that this is a stripped down and modified version of
23 the orginal Assuan code from libassuan. */
31 #ifdef HAVE_W32_SYSTEM
33 #endif /*HAVE_W32_SYSTEM*/
35 #include "assuan-defs.h"
37 static char prefix_buffer
[80];
38 static FILE *_assuan_log
;
41 _assuan_set_default_log_stream (FILE *fp
)
48 assuan_set_assuan_log_stream (FILE *fp
)
54 assuan_get_assuan_log_stream (void)
56 return _assuan_log
? _assuan_log
: stderr
;
60 /* Set the prefix to be used for logging to TEXT or
61 resets it to the default if TEXT is NULL. */
63 assuan_set_assuan_log_prefix (const char *text
)
67 strncpy (prefix_buffer
, text
, sizeof (prefix_buffer
)-1);
68 prefix_buffer
[sizeof (prefix_buffer
)-1] = 0;
75 assuan_get_assuan_log_prefix (void)
82 _assuan_log_printf (const char *format
, ...)
88 fp
= assuan_get_assuan_log_stream ();
89 prf
= assuan_get_assuan_log_prefix ();
96 va_start (arg_ptr
, format
);
97 vfprintf (fp
, format
, arg_ptr
);
103 #ifdef HAVE_W32_SYSTEM
105 _assuan_w32_strerror (int ec
)
107 static char strerr
[256];
110 ec
= (int)GetLastError ();
111 FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, ec
,
112 MAKELANGID (LANG_NEUTRAL
, SUBLANG_DEFAULT
),
113 strerr
, sizeof (strerr
)-1, NULL
);
116 #endif /*HAVE_W32_SYSTEM*/