~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to jnlib/logging.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
4
 
 *
5
 
 * This file is part of GnuPG.
6
 
 *
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.
11
 
 *
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.
16
 
 *
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.
 
4
 *
 
5
 * This file is part of JNLIB.
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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/>.
20
19
 */
21
20
 
22
21
 
47
46
#define USE_FUNWRITER 1
48
47
#endif
49
48
 
 
49
#ifdef HAVE_FOPENCOOKIE
 
50
typedef ssize_t my_funopen_hook_ret_t;
 
51
typedef size_t  my_funopen_hook_size_t;
 
52
#else
 
53
typedef int     my_funopen_hook_ret_t;
 
54
typedef int     my_funopen_hook_size_t;
 
55
#endif
 
56
 
 
57
 
50
58
static FILE *logstream;
51
59
static int log_socket = -1;
52
60
static char prefix_buffer[80];
110
118
}
111
119
 
112
120
 
113
 
static int 
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)
115
123
{
116
124
  struct fun_cookie_s *cookie = cookie_arg;
117
125
 
182
190
 
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. */ 
186
194
 
187
195
  if (!running_detached && cookie->fd != -1
188
196
      && isatty (fileno (stderr)))
201
209
      log_socket = -1;
202
210
    }
203
211
 
204
 
  return size;
 
212
  return (my_funopen_hook_ret_t)size;
205
213
}
206
214
 
207
215
static int
485
493
    }
486
494
 
487
495
  if (level == JNLIB_LOG_FATAL)
488
 
    exit(2);
 
496
    {
 
497
      if (missing_lf)
 
498
        putc('\n', logstream );
 
499
      exit(2);
 
500
    }
489
501
  if (level == JNLIB_LOG_BUG)
490
 
    abort();
 
502
    {
 
503
      if (missing_lf)
 
504
        putc('\n', logstream );
 
505
      abort();
 
506
    }
491
507
}
492
508
 
493
509
static void