1
/* logging.c - useful logging functions
1
/* logging.c - Useful logging functions
2
2
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
3
* 2004, 2005 Free Software Foundation, Inc.
5
* This file is part of GnuPG.
7
* GnuPG is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* GnuPG 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
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3
* 2004, 2005, 2006 Free Software Foundation, Inc.
5
* This file is part of JNLIB.
7
* JNLIB is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 3 of
10
* the License, or (at your option) any later version.
12
* JNLIB is distributed in the hope that it will be useful, but
13
* 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 program; if not, see <http://www.gnu.org/licenses/>.
47
46
#define USE_FUNWRITER 1
49
#ifdef HAVE_FOPENCOOKIE
50
typedef ssize_t my_funopen_hook_ret_t;
51
typedef size_t my_funopen_hook_size_t;
53
typedef int my_funopen_hook_ret_t;
54
typedef int my_funopen_hook_size_t;
50
58
static FILE *logstream;
51
59
static int log_socket = -1;
52
60
static char prefix_buffer[80];
114
fun_writer (void *cookie_arg, const char *buffer, size_t size)
121
static my_funopen_hook_ret_t
122
fun_writer (void *cookie_arg, const char *buffer, my_funopen_hook_size_t size)
116
124
struct fun_cookie_s *cookie = cookie_arg;
183
191
log_socket = cookie->fd;
184
192
if (cookie->fd != -1 && !writen (cookie->fd, buffer, size))
185
return size; /* Okay. */
193
return (my_funopen_hook_ret_t)size; /* Okay. */
187
195
if (!running_detached && cookie->fd != -1
188
196
&& isatty (fileno (stderr)))