summaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-12-13 16:49:56 +0100
committerWerner Koch <wk@gnupg.org>2004-12-13 16:49:56 +0100
commit801ab885224b7d85aa11cb9f239f33cb420d3159 (patch)
tree692dfc401226c89d17e8dd3a84fb778fedb97207 /jnlib
parentAdded real code written by Timo Schulz. (diff)
downloadgnupg2-801ab885224b7d85aa11cb9f239f33cb420d3159.tar.xz
gnupg2-801ab885224b7d85aa11cb9f239f33cb420d3159.zip
VArious hacks to make it at least build under W32.
* stringhelp.c (w32_strerror) [W32]: New. * w32-pth.c, w32-pth.h: Added real code written by Timo Schulz. Not finished, though. * gpgconf-comp.c <ignore-ocsp-service-url>: Fixed typo.
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog2
-rw-r--r--jnlib/stringhelp.c46
-rw-r--r--jnlib/stringhelp.h5
-rw-r--r--jnlib/w32-afunix.h1
-rw-r--r--jnlib/w32-pth.h8
5 files changed, 52 insertions, 10 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index b33b7842f..f27ef87b6 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,5 +1,7 @@
2004-12-13 Werner Koch <wk@g10code.com>
+ * stringhelp.c (w32_strerror) [W32]: New.
+
* w32-pth.c, w32-pth.h: Added real code written by Timo Schulz.
Not finished, though.
diff --git a/jnlib/stringhelp.c b/jnlib/stringhelp.c
index 568152fdd..5a3b41528 100644
--- a/jnlib/stringhelp.c
+++ b/jnlib/stringhelp.c
@@ -1,5 +1,6 @@
/* stringhelp.c - standard string helper functions
- * Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2003,
+ * 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -23,14 +24,17 @@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
+#ifdef HAVE_W32_SYSTEM
+#include <windows.h>
+#endif
#include "libjnlib-config.h"
#include "utf8conv.h"
#include "stringhelp.h"
-/****************
- * look for the substring SUB in buffer and return a pointer to that
+/*
+ * Look for the substring SUB in buffer and return a pointer to that
* substring in BUF or NULL if not found.
* Comparison is case-insensitive.
*/
@@ -72,11 +76,12 @@ ascii_memistr( const char *buf, size_t buflen, const char *sub )
return NULL ;
}
-/****************
- * Wie strncpy(), aber es werden maximal n-1 zeichen kopiert und ein
- * '\0' angehängt. Ist n = 0, so geschieht nichts, ist Destination
- * gleich NULL, so wird via jnlib_xmalloc Speicher besorgt, ist dann nicht
- * genügend Speicher vorhanden, so bricht die funktion ab.
+/* This function is similar to strncpy(). However it won't copy more
+ than N - 1 characters and makes sure that a '\0' is appended. With
+ N given as 0, nothing will happen. With DEST given as NULL, memory
+ will be allocated using jnlib_xmalloc (i.e. if it runs out of core
+ the function terminates). Returns DES or a pointer to the
+ allocated memory.
*/
char *
mem2str( char *dest , const void *src , size_t n )
@@ -452,8 +457,29 @@ sanitize_buffer (const unsigned char *p, size_t n, int delim)
return buffer;
}
+
/****************************************************
- ******** locale insensitive ctype functions ********
+ ********** W32 specific functions ****************
+ ****************************************************/
+
+#ifdef HAVE_W32_SYSTEM
+const char *
+w32_strerror (int ec)
+{
+ static char strerr[256];
+
+ if (ec == -1)
+ ec = (int)GetLastError ();
+ FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec,
+ MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+ strerr, DIM (strerr)-1, NULL);
+ return strerr;
+}
+#endif /*HAVE_W32_SYSTEM*/
+
+
+/****************************************************
+ ******** Locale insensitive ctype functions ********
****************************************************/
/* FIXME: replace them by a table lookup and macros */
int
@@ -626,3 +652,5 @@ memicmp( const char *a, const char *b, size_t n )
return 0;
}
#endif
+
+
diff --git a/jnlib/stringhelp.h b/jnlib/stringhelp.h
index fe5786e59..412da3a0e 100644
--- a/jnlib/stringhelp.h
+++ b/jnlib/stringhelp.h
@@ -49,6 +49,11 @@ size_t print_sanitized_utf8_string (FILE *fp, const char *string, int delim);
char *sanitize_buffer (const unsigned char *p, size_t n, int delim);
+#ifdef HAVE_W32_SYSTEM
+const char *w32_strerror (int ec);
+#endif
+
+
const char *ascii_memistr( const char *buf, size_t buflen, const char *sub );
int ascii_isupper (int c);
int ascii_islower (int c);
diff --git a/jnlib/w32-afunix.h b/jnlib/w32-afunix.h
index 1319de5e6..367832299 100644
--- a/jnlib/w32-afunix.h
+++ b/jnlib/w32-afunix.h
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <windows.h>
+#include <ws2tcpip.h>
#include <unistd.h>
#define DIRSEP_C '\\'
diff --git a/jnlib/w32-pth.h b/jnlib/w32-pth.h
index efb17d255..bb010ae99 100644
--- a/jnlib/w32-pth.h
+++ b/jnlib/w32-pth.h
@@ -53,7 +53,7 @@ enum
/* Mutex values. */
#define PTH_MUTEX_INITIALIZED (1<<0)
#define PTH_MUTEX_LOCKED (1<<1)
-#define PTH_MUTEX_INIT {{NULL, NULL}, PTH_MUTEX_INITIALIZED, NULL, 0}
+#define PTH_MUTEX_INIT {PTH_MUTEX_INITIALIZED}
#define PTH_KEY_INIT (1<<0)
@@ -235,6 +235,12 @@ pth_event_t pth_event (unsigned long spec, ...);
+/* Backward compatibility (Pth < 1.5.0). */
+#define pth_event_occurred(ev) \
+ ( pth_event_status(ev) == PTH_STATUS_OCCURRED \
+ || pth_event_status(ev) == PTH_STATUS_FAILED )
+
+
/*-- pth_util.c --*/
/* void sigemptyset (struct sigset_s * ss); */