mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Whole lot of changes to support CE.
This commit is contained in:
parent
aed838b750
commit
31d7bdfe77
28 changed files with 413 additions and 151 deletions
|
@ -1,3 +1,26 @@
|
|||
2010-04-14 Werner Koch <wk@g10code.com>
|
||||
|
||||
* asshelp.c (setup_libassuan_logging): Read ASSUAN_DEBUG envvar.
|
||||
(my_libassuan_log_handler): Use it.
|
||||
* sysutils.c (_gnupg_getenv): Implement ASSUAN_DEBUG.
|
||||
|
||||
2010-04-08 Werner Koch <wk@g10code.com>
|
||||
|
||||
* w32help.h (_setmode, setmode) [W32CE]: Provide prototype and
|
||||
macro.
|
||||
|
||||
2010-04-07 Werner Koch <wk@g10code.com>
|
||||
|
||||
* mischelp.c (timegm): Replace unsetenv/putenv by gnupg_unsetenv.
|
||||
|
||||
* sysutils.c: Include setenv.h.
|
||||
(gnupg_setenv, gnupg_unsetenv): New.
|
||||
|
||||
|
||||
2010-04-06 Werner Koch <wk@g10code.com>
|
||||
|
||||
* sysutils.c (gnupg_mkdir): New.
|
||||
|
||||
2010-03-29 Werner Koch <wk@g10code.com>
|
||||
|
||||
* init.c (sleep_on_exit): Change to 400ms.
|
||||
|
|
|
@ -36,6 +36,14 @@
|
|||
#include "asshelp.h"
|
||||
|
||||
|
||||
/* A bitfield that specifies the assuan categories to log. This is
|
||||
identical to the default log handler of libassuan. We need to do
|
||||
it ourselves because we use a custom log handler and want to use
|
||||
the same assuan variables to select the categories to log. */
|
||||
static int log_cats;
|
||||
#define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
|
||||
|
||||
|
||||
static int
|
||||
my_libassuan_log_handler (assuan_context_t ctx, void *hook,
|
||||
unsigned int cat, const char *msg)
|
||||
|
@ -44,8 +52,9 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
|
|||
|
||||
(void)ctx;
|
||||
|
||||
if (cat != ASSUAN_LOG_CONTROL)
|
||||
return 0; /* We only want the control channel messages. */
|
||||
if (! TEST_LOG_CAT (cat))
|
||||
return 0;
|
||||
|
||||
dbgval = hook? *(unsigned int*)hook : 0;
|
||||
if (!(dbgval & 1024))
|
||||
return 0; /* Assuan debugging is not enabled. */
|
||||
|
@ -62,6 +71,13 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
|
|||
void
|
||||
setup_libassuan_logging (unsigned int *debug_var_address)
|
||||
{
|
||||
char *flagstr;
|
||||
|
||||
flagstr = getenv ("ASSUAN_DEBUG");
|
||||
if (flagstr)
|
||||
log_cats = atoi (flagstr);
|
||||
else /* Default to log the control channel. */
|
||||
log_cats = (1 << (ASSUAN_LOG_CONTROL - 1));
|
||||
assuan_set_log_cb (my_libassuan_log_handler, debug_var_address);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,9 @@ void *memrchr (const void *block, int c, size_t size);
|
|||
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
# define _set_errno(a) gpg_err_set_errno ((a))
|
||||
/* Setmode is missing in cegcc but available since CE 5.0. */
|
||||
int _setmode (int handle, int mode);
|
||||
# define setmode(a,b) _setmode ((a),(b))
|
||||
#else
|
||||
# define _set_errno(a) do { errno = (a); } while (0)
|
||||
#endif
|
||||
|
|
|
@ -183,11 +183,7 @@ timegm (struct tm *tm)
|
|||
putenv (old_zone);
|
||||
}
|
||||
else
|
||||
#ifdef HAVE_UNSETENV
|
||||
unsetenv("TZ");
|
||||
#else
|
||||
putenv("TZ");
|
||||
#endif
|
||||
gnupg_unsetenv("TZ");
|
||||
|
||||
tzset();
|
||||
return answer;
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "setenv.h" /* Gnulib replacement. */
|
||||
|
||||
#include "util.h"
|
||||
#include "i18n.h"
|
||||
|
||||
|
@ -529,6 +531,97 @@ gnupg_remove (const char *fname)
|
|||
}
|
||||
|
||||
|
||||
/* A wrapper around mkdir which takes a string for the mode argument.
|
||||
This makes it easier to handle the mode argument which is not
|
||||
defined on all systems. The format of the modestring is
|
||||
|
||||
"-rwxrwxrwx"
|
||||
|
||||
'-' is a don't care or not set. 'r', 'w', 'x' are read allowed,
|
||||
write allowed, execution allowed with the first group for the user,
|
||||
the second for the group and the third for all others. If the
|
||||
string is shorter than above the missing mode characters are meant
|
||||
to be not set. */
|
||||
int
|
||||
gnupg_mkdir (const char *name, const char *modestr)
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
wchar_t *wname;
|
||||
(void)modestr;
|
||||
|
||||
wname = utf8_to_wchar (name);
|
||||
if (!wname)
|
||||
return -1;
|
||||
if (!CreateDirectoryW (wname, NULL))
|
||||
{
|
||||
xfree (wname);
|
||||
return -1; /* ERRNO is automagically provided by gpg-error.h. */
|
||||
}
|
||||
xfree (wname);
|
||||
return 0;
|
||||
#elif MKDIR_TAKES_ONE_ARG
|
||||
(void)modestr;
|
||||
/* Note: In the case of W32 we better use CreateDirectory and try to
|
||||
set appropriate permissions. However using mkdir is easier
|
||||
because this sets ERRNO. */
|
||||
return mkdir (name);
|
||||
#else
|
||||
mode_t mode = 0;
|
||||
|
||||
if (modestr && *modestr)
|
||||
{
|
||||
modestr++;
|
||||
if (*modestr && *modestr++ == 'r')
|
||||
mode |= S_IRUSR;
|
||||
if (*modestr && *modestr++ == 'w')
|
||||
mode |= S_IWUSR;
|
||||
if (*modestr && *modestr++ == 'x')
|
||||
mode |= S_IXUSR;
|
||||
if (*modestr && *modestr++ == 'r')
|
||||
mode |= S_IRGRP;
|
||||
if (*modestr && *modestr++ == 'w')
|
||||
mode |= S_IWGRP;
|
||||
if (*modestr && *modestr++ == 'x')
|
||||
mode |= S_IXGRP;
|
||||
if (*modestr && *modestr++ == 'r')
|
||||
mode |= S_IROTH;
|
||||
if (*modestr && *modestr++ == 'w')
|
||||
mode |= S_IWOTH;
|
||||
if (*modestr && *modestr++ == 'x')
|
||||
mode |= S_IXOTH;
|
||||
}
|
||||
return mkdir (home, mode)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
gnupg_setenv (const char *name, const char *value, int overwrite)
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
(void)name;
|
||||
(void)value;
|
||||
(void)overwrite;
|
||||
return 0;
|
||||
#else
|
||||
setenv (name, value, overwrite);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
gnupg_unsetenv (const char *name)
|
||||
{
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
(void)name;
|
||||
return 0;
|
||||
#else
|
||||
# ifdef HAVE_UNSETENV
|
||||
unsetenv (name);
|
||||
# else
|
||||
putenv (name);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
|
@ -538,8 +631,22 @@ gnupg_remove (const char *fname)
|
|||
char *
|
||||
_gnupg_getenv (const char *name)
|
||||
{
|
||||
(void)name;
|
||||
return NULL;
|
||||
static int initialized;
|
||||
static char *assuan_debug;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
assuan_debug = read_w32_registry_string (NULL,
|
||||
"\\Software\\GNU\\libassuan",
|
||||
"debug");
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
if (!strcmp (name, "ASSUAN_DEBUG"))
|
||||
return assuan_debug;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /*HAVE_W32CE_SYSTEM*/
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ FILE *gnupg_tmpfile (void);
|
|||
void gnupg_reopen_std (const char *pgmname);
|
||||
void gnupg_allow_set_foregound_window (pid_t pid);
|
||||
int gnupg_remove (const char *fname);
|
||||
int gnupg_mkdir (const char *name, const char *modestr);
|
||||
int gnupg_setenv (const char *name, const char *value, int overwrite);
|
||||
int gnupg_unsetenv (const char *name);
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
|
||||
|
|
|
@ -298,6 +298,8 @@ ttyname (int fd)
|
|||
#define getpid() GetCurrentProcessId ()
|
||||
char *_gnupg_getenv (const char *name); /* See sysutils.c */
|
||||
#define getenv(a) _gnupg_getenv ((a))
|
||||
char *_gnupg_setenv (const char *name); /* See sysutils.c */
|
||||
#define setenv(a,b,c) _gnupg_setenv ((a),(b),(c))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -28,5 +28,12 @@ int write_w32_registry_string (const char *root, const char *dir,
|
|||
const char *name, const char *value);
|
||||
|
||||
|
||||
/* Other stuff. */
|
||||
#ifdef HAVE_W32CE_SYSTEM
|
||||
/* Setmode is missing in cegcc but available since CE 5.0. */
|
||||
int _setmode (int handle, int mode);
|
||||
# define setmode(a,b) _setmode ((a),(b))
|
||||
#endif /*HAVE_W32CE_SYSTEM*/
|
||||
|
||||
#endif /*HAVE_W32_SYSTEM*/
|
||||
#endif /*LIBJNLIB_MISCHELP_H*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue