~ubuntu-branches/ubuntu/dapper/gnupg2/dapper

« back to all changes in this revision

Viewing changes to keyserver/ksutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ksutil.c - general keyserver utility functions
 
2
 * Copyright (C) 2004 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
6
 * GnuPG is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * GnuPG is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
19
 */
 
20
 
 
21
#include <config.h>
 
22
#include <signal.h>
 
23
#include <unistd.h>
 
24
#include "keyserver.h"
 
25
#include "ksutil.h"
 
26
 
 
27
static void
 
28
catch_alarm(int foo)
 
29
{
 
30
  _exit(KEYSERVER_TIMEOUT);
 
31
}
 
32
 
 
33
unsigned int
 
34
set_timeout(unsigned int seconds)
 
35
{
 
36
#ifdef HAVE_DOSISH_SYSTEM
 
37
  return 0;
 
38
#else
 
39
  return alarm(seconds);
 
40
#endif
 
41
}
 
42
 
 
43
int
 
44
register_timeout(void)
 
45
{
 
46
#ifdef HAVE_DOSISH_SYSTEM
 
47
  return 0;
 
48
#else
 
49
#if defined(HAVE_SIGACTION) && defined(HAVE_STRUCT_SIGACTION)
 
50
  struct sigaction act;
 
51
 
 
52
  act.sa_handler=catch_alarm;
 
53
  sigemptyset(&act.sa_mask);
 
54
  act.sa_flags=0;
 
55
  return sigaction(SIGALRM,&act,NULL);
 
56
#else 
 
57
  if(signal(SIGALRM,catch_alarm)==SIG_ERR)
 
58
    return -1;
 
59
  else
 
60
    return 0;
 
61
#endif
 
62
#endif
 
63
}