summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-12-21 11:03:00 +0100
committerWerner Koch <wk@gnupg.org>2004-12-21 11:03:00 +0100
commit878cf2076633742ad5f4e4008059b0fc8d776d37 (patch)
tree07e7c9d7bab4f56a69d5496cede7ab6a3f36397a /common
parent* configure.ac: Add PATHSEP_C and PATHSEP_S. For W32 let all (diff)
downloadgnupg2-878cf2076633742ad5f4e4008059b0fc8d776d37.tar.xz
gnupg2-878cf2076633742ad5f4e4008059b0fc8d776d37.zip
* gpg-agent.c (main): Use default_homedir().
* protect-tool.c (main): Ditto. * signal.c (got_fatal_signal, got_usr_signal) (got_fatal_signal) [DOSISH]: Don't build. * simple-gettext.c: Include sysutils.h * homedir.c: New. * Makefile.am (libcommon_a_SOURCES): Add it. (EXTRA_DIST): Removed mkerror and mkerrtok. * gpgv.c, g10.c (main): Use default_hoemdir (). * scdaemon.c (main): Use default_homedir(). * gpgsm.c (main): Use default_homedir().
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog10
-rw-r--r--common/Makefile.am3
-rw-r--r--common/homedir.c44
-rw-r--r--common/signal.c14
-rw-r--r--common/simple-gettext.c2
-rw-r--r--common/util.h4
6 files changed, 70 insertions, 7 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 11bf8029a..667deb51a 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,13 @@
+2004-12-21 Werner Koch <wk@g10code.com>
+
+ * signal.c (got_fatal_signal, got_usr_signal)
+ (got_fatal_signal) [DOSISH]: Don't build.
+ * simple-gettext.c: Include sysutils.h
+
+ * homedir.c: New.
+ * Makefile.am (libcommon_a_SOURCES): Add it.
+ (EXTRA_DIST): Removed mkerror and mkerrtok.
+
2004-12-20 Werner Koch <wk@g10code.com>
* sysutils.h [W32]: Define sleep.
diff --git a/common/Makefile.am b/common/Makefile.am
index 795d66a1a..ccbaaad75 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -19,8 +19,6 @@
## Process this file with automake to produce Makefile.in
-EXTRA_DIST = mkerrors mkerrtok
-
noinst_LIBRARIES = libcommon.a libsimple-pwquery.a
AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(KSBA_CFLAGS)
@@ -31,6 +29,7 @@ libcommon_a_SOURCES = \
sexp-parse.h \
maperror.c \
sysutils.c sysutils.h \
+ homedir.c \
gettime.c \
yesno.c \
b64enc.c \
diff --git a/common/homedir.c b/common/homedir.c
new file mode 100644
index 000000000..8b5bc9f05
--- /dev/null
+++ b/common/homedir.c
@@ -0,0 +1,44 @@
+/* homedir.c - Setup the home directory.
+ * Copyright (C) 2004 Free Software Foundation, Inc.
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "util.h"
+#include "sysutils.h"
+
+/* Set up the default home directory. The usual --homedir option
+ should be parsed later. */
+const char *
+default_homedir (void)
+{
+ const char *dir;
+
+ dir = getenv("GNUPGHOME");
+#ifdef HAVE_W32_SYSTEM
+ if (!dir || !*dir)
+ dir = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir");
+#endif /*HAVE_W32_SYSTEM*/
+ if (!dir || !*dir)
+ dir = GNUPG_DEFAULT_HOMEDIR;
+
+ return dir;
+}
diff --git a/common/signal.c b/common/signal.c
index dc026c10f..4e773c4c0 100644
--- a/common/signal.c
+++ b/common/signal.c
@@ -30,15 +30,17 @@
#include "util.h"
+#ifndef HAVE_DOSISH_SYSTEM
static volatile int caught_fatal_sig;
static volatile int caught_sigusr1;
+#endif
static void (*cleanup_fnc)(void);
+#ifndef HAVE_DOSISH_SYSTEM
static void
init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
{
-#ifndef HAVE_DOSISH_SYSTEM
# ifdef HAVE_SIGACTION
struct sigaction oact, nact;
@@ -64,9 +66,10 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
signal (sig, SIG_IGN);
}
# endif
-#endif /*!HAVE_DOSISH_SYSTEM*/
}
+#endif /*!HAVE_DOSISH_SYSTEM*/
+#ifndef HAVE_DOSISH_SYSTEM
static const char *
get_signal_name( int signum )
{
@@ -76,7 +79,9 @@ get_signal_name( int signum )
return "some signal";
#endif
}
+#endif /*!HAVE_DOSISH_SYSTEM*/
+#ifndef HAVE_DOSISH_SYSTEM
static RETSIGTYPE
got_fatal_signal (int sig)
{
@@ -106,14 +111,15 @@ got_fatal_signal (int sig)
#endif /* __riscos__ */
raise( sig );
}
+#endif /*!HAVE_DOSISH_SYSTEM*/
-
+#ifndef HAVE_DOSISH_SYSTEM
static RETSIGTYPE
got_usr_signal (int sig)
{
caught_sigusr1 = 1;
}
-
+#endif /*!HAVE_DOSISH_SYSTEM*/
void
gnupg_init_signals (int mode, void (*fast_cleanup)(void))
diff --git a/common/simple-gettext.c b/common/simple-gettext.c
index 4287606e3..b6b851c77 100644
--- a/common/simple-gettext.c
+++ b/common/simple-gettext.c
@@ -40,7 +40,7 @@
#include <sys/stat.h>
#include "util.h"
-
+#include "sysutils.h"
/* The magic number of the GNU message catalog format. */
#define MAGIC 0x950412de
diff --git a/common/util.h b/common/util.h
index 1159da925..4ab55acb4 100644
--- a/common/util.h
+++ b/common/util.h
@@ -121,6 +121,10 @@ gpg_error_t b64enc_write (struct b64state *state,
gpg_error_t b64enc_finish (struct b64state *state);
+/*-- homedir. c --*/
+const char *default_homedir (void);
+
+
/*-- miscellaneous.c --*/
/* Same as asprintf but return an allocated buffer suitable to be