]> granicus.if.org Git - p11-kit/commitdiff
Separate library init from message code
authorStef Walter <stefw@gnome.org>
Tue, 2 Apr 2013 18:40:53 +0000 (20:40 +0200)
committerStef Walter <stefw@gnome.org>
Wed, 3 Apr 2013 08:39:09 +0000 (10:39 +0200)
Put library init/uninit code its into their own statically
linked library so that they don't get linked into the p11-kit
executable.

Refactor the message code so that the library initialization can
plug in its per thread message buffer.

https://bugs.freedesktop.org/show_bug.cgi?id=63046

52 files changed:
common/Makefile.am
common/lexer.c
common/library.c
common/library.h
common/message.c [new file with mode: 0644]
common/message.h [new file with mode: 0644]
common/mock.c
common/tests/Makefile.am
common/tests/test-base64.c
common/tests/test-lexer.c
common/tests/test-url.c
p11-kit/Makefile.am
p11-kit/conf.c
p11-kit/modules.c
p11-kit/pin.c
p11-kit/proxy.c
p11-kit/tests/Makefile.am
p11-kit/tests/conf-test.c
p11-kit/tests/test-iter.c
p11-kit/tests/test-modules.c
p11-kit/tests/uri-test.c
p11-kit/uri.c
p11-kit/util.c
tools/Makefile.am
tools/extract-info.c
tools/extract-jks.c
tools/extract-openssl.c
tools/extract-pem.c
tools/extract-x509.c
tools/extract.c
tools/list.c
tools/save.c
tools/tests/Makefile.am
tools/tests/test-extract.c
tools/tests/test-openssl.c
tools/tests/test-pem.c
tools/tests/test-save.c
tools/tests/test-x509.c
tools/tool.c
trust/Makefile.am
trust/builder.c
trust/module.c
trust/parser.c
trust/session.c
trust/tests/Makefile.am
trust/tests/test-builder.c
trust/tests/test-index.c
trust/tests/test-module.c
trust/tests/test-parser.c
trust/tests/test-persist.c
trust/tests/test-token.c
trust/token.c

index bfed1d79e274281cba045c09003ba5dd79b10965..cb6e95e47376bbe1cce4f00182a7bf5d62a7e4af 100644 (file)
@@ -10,29 +10,30 @@ inc_HEADERS = \
        $(NULL)
 
 noinst_LTLIBRARIES = \
-       libp11-compat.la \
+       libp11-common.la \
        libp11-library.la \
        libp11-mock.la \
        $(NULL)
 
-libp11_compat_la_SOURCES = \
-       compat.c compat.h \
-       $(NULL)
-
-libp11_library_la_SOURCES = \
+libp11_common_la_SOURCES = \
        attrs.c attrs.h \
        array.c array.h \
        buffer.c buffer.h \
+       compat.c compat.h \
        constants.c constants.h \
        debug.c debug.h \
        dict.c dict.h \
        hash.c hash.h \
        lexer.c lexer.h \
-       library.c library.h \
+       message.c message.h \
        pkcs11.h pkcs11x.h \
        url.c url.h \
        $(NULL)
 
+libp11_library_la_SOURCES = \
+       library.c library.h \
+       $(NULL)
+
 libp11_mock_la_SOURCES = \
        mock.c mock.h \
        $(NULL)
index 9898e2c8beef5e6a4298f40ab4992a51a9b7a1d7..329881f045178563ee11a672385ddce09aeebbae 100644 (file)
@@ -41,7 +41,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_CONF
 #include "debug.h"
 #include "lexer.h"
-#include "library.h"
+#include "message.h"
 
 #include <assert.h>
 #include <ctype.h>
index 71dd3b9af9ce39b41d6c9c150332b14a31a89874..1f9dc7ab2ed604ad1475f1f8b38c4126329d7d5e 100644 (file)
@@ -41,6 +41,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_LIB
 #include "debug.h"
 #include "library.h"
+#include "message.h"
 
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 
-#define P11_MAX_MESSAGE 512
+#define P11_MESSAGE_MAX 512
 
 typedef struct {
-       char message[P11_MAX_MESSAGE];
-#ifdef OS_WIN32
-       void *last_error;
-#endif
+       char message[P11_MESSAGE_MAX];
 } p11_local;
 
 static p11_local * _p11_library_get_thread_local (void);
@@ -65,76 +63,18 @@ p11_mutex_t p11_library_mutex;
 pthread_once_t p11_library_once;
 #endif
 
-static bool print_messages = true;
-
-void
-p11_message_store (const char* msg,
-                   size_t length)
+static char *
+thread_local_message (void)
 {
        p11_local *local;
-
-       if (length > P11_MAX_MESSAGE - 1)
-               length = P11_MAX_MESSAGE - 1;
-
        local = _p11_library_get_thread_local ();
-       if (local != NULL) {
-               memcpy (local->message, msg, length);
-               local->message[length] = 0;
-       }
+       return local ? local->message : NULL;
 }
 
-void
-p11_message (const char* msg,
-             ...)
+static char *
+dont_store_message (void)
 {
-       char buffer[P11_MAX_MESSAGE];
-       va_list va;
-       size_t length;
-
-       va_start (va, msg);
-       length = vsnprintf (buffer, P11_MAX_MESSAGE - 1, msg, va);
-       va_end (va);
-
-       /* Was it truncated? */
-       if (length > P11_MAX_MESSAGE - 1)
-               length = P11_MAX_MESSAGE - 1;
-       buffer[length] = 0;
-
-       /* If printing is not disabled, just print out */
-       if (print_messages)
-               fprintf (stderr, "p11-kit: %s\n", buffer);
-       else
-               p11_debug_message (P11_DEBUG_LIB, "message: %s", buffer);
-       p11_message_store (buffer, length);
-}
-
-void
-p11_message_quiet (void)
-{
-       print_messages = false;
-}
-
-void
-p11_message_loud (void)
-{
-       print_messages = true;
-}
-
-const char*
-p11_message_last (void)
-{
-       p11_local *local;
-       local = _p11_library_get_thread_local ();
-       return local && local->message[0] ? local->message : NULL;
-}
-
-void
-p11_message_clear (void)
-{
-       p11_local *local;
-       local = _p11_library_get_thread_local ();
-       if (local != NULL)
-               local->message[0] = 0;
+       return NULL;
 }
 
 static void
@@ -170,6 +110,7 @@ p11_library_init_impl (void)
        p11_debug ("initializing library");
        p11_mutex_init (&p11_library_mutex);
        pthread_key_create (&thread_local, free);
+       p11_message_storage = thread_local_message;
 }
 
 void
@@ -187,6 +128,7 @@ p11_library_uninit (void)
        free (pthread_getspecific (thread_local));
        pthread_setspecific (thread_local, NULL);
 
+       p11_message_storage = dont_store_message;
        pthread_key_delete (thread_local);
        p11_mutex_uninit (&p11_library_mutex);
 }
@@ -225,6 +167,8 @@ p11_library_init (void)
        thread_local = TlsAlloc ();
        if (thread_local == TLS_OUT_OF_INDEXES)
                p11_debug ("couldn't setup tls");
+       else
+               p11_message_storage = thread_local_message;
 }
 
 void
@@ -234,8 +178,6 @@ p11_library_thread_cleanup (void)
        if (thread_local != TLS_OUT_OF_INDEXES) {
                p11_debug ("thread stopped, freeing tls");
                local = TlsGetValue (thread_local);
-               if (local->last_error)
-                       LocalFree (local->last_error);
                LocalFree (local);
        }
 }
@@ -248,6 +190,7 @@ p11_library_uninit (void)
        uninit_common ();
 
        if (thread_local != TLS_OUT_OF_INDEXES) {
+               p11_message_storage = dont_store_message;
                data = TlsGetValue (thread_local);
                free (data);
                TlsFree (thread_local);
index b310cb9acc1c398e4c45185e959ed00de337c9a7..33a33fb787b427cbfa66307eea9da41b8ac3f896 100644 (file)
@@ -48,20 +48,6 @@ extern p11_mutex_t p11_library_mutex;
 
 #define       p11_unlock()                 p11_mutex_unlock (&p11_library_mutex);
 
-void          p11_message                  (const char* msg,
-                                            ...) GNUC_PRINTF (1, 2);
-
-void          p11_message_store            (const char* msg,
-                                            size_t length);
-
-const char *  p11_message_last             (void);
-
-void          p11_message_clear            (void);
-
-void          p11_message_quiet            (void);
-
-void          p11_message_loud             (void);
-
 #ifdef OS_WIN32
 
 /* No implementation, because done by DllMain */
diff --git a/common/message.c b/common/message.c
new file mode 100644 (file)
index 0000000..8b54ad1
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2011 Collabora Ltd
+ * Copyright (c) 2012 Stef Walter
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *     * Redistributions of source code must retain the above
+ *       copyright notice, this list of conditions and the
+ *       following disclaimer.
+ *     * Redistributions in binary form must reproduce the
+ *       above copyright notice, this list of conditions and
+ *       the following disclaimer in the documentation and/or
+ *       other materials provided with the distribution.
+ *     * The names of contributors to this software may not be
+ *       used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ *
+ * CONTRIBUTORS
+ *  Stef Walter <stef@thewalter.net>
+ */
+
+#include "config.h"
+
+#include "compat.h"
+#define P11_DEBUG_FLAG P11_DEBUG_LIB
+#include "debug.h"
+#include "message.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+static bool print_messages = true;
+
+static char *
+default_message_storage (void)
+{
+       static char message[P11_MESSAGE_MAX] = { 0, };
+       return message;
+}
+
+/* Function pointer declared in message.h as extern */
+char * (* p11_message_storage) (void) = default_message_storage;
+
+void
+p11_message_store (const char* msg,
+                   size_t length)
+{
+       char *buffer;
+
+       /*
+        * p11_message_storage() is called to get a storage location for
+        * the last message. It defaults to a globally allocated buffer
+        * but is overridden in library.c with a function that returns
+        * per thread buffers.
+        *
+        * The returned value is P11_MESSAGE_MAX bytes long
+        */
+       buffer = p11_message_storage ();
+
+       if (length > P11_MESSAGE_MAX - 1)
+               length = P11_MESSAGE_MAX - 1;
+
+       if (buffer != NULL) {
+               memcpy (buffer, msg, length);
+               buffer[length] = 0;
+       }
+}
+
+void
+p11_message (const char* msg,
+             ...)
+{
+       char buffer[P11_MESSAGE_MAX];
+       va_list va;
+       size_t length;
+
+       va_start (va, msg);
+       length = vsnprintf (buffer, P11_MESSAGE_MAX - 1, msg, va);
+       va_end (va);
+
+       /* Was it truncated? */
+       if (length > P11_MESSAGE_MAX - 1)
+               length = P11_MESSAGE_MAX - 1;
+       buffer[length] = 0;
+
+       /* If printing is not disabled, just print out */
+       if (print_messages)
+               fprintf (stderr, "p11-kit: %s\n", buffer);
+       else
+               p11_debug_message (P11_DEBUG_LIB, "message: %s", buffer);
+       p11_message_store (buffer, length);
+}
+
+void
+p11_message_quiet (void)
+{
+       print_messages = false;
+}
+
+void
+p11_message_loud (void)
+{
+       print_messages = true;
+}
+
+const char *
+p11_message_last (void)
+{
+       char *buffer;
+       buffer = p11_message_storage ();
+       return buffer && buffer[0] ? buffer : NULL;
+}
+
+void
+p11_message_clear (void)
+{
+       char *buffer;
+       buffer = p11_message_storage ();
+       if (buffer != NULL)
+               buffer[0] = 0;
+}
diff --git a/common/message.h b/common/message.h
new file mode 100644 (file)
index 0000000..60a7f81
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011 Collabora Ltd
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *     * Redistributions of source code must retain the above
+ *       copyright notice, this list of conditions and the
+ *       following disclaimer.
+ *     * Redistributions in binary form must reproduce the
+ *       above copyright notice, this list of conditions and
+ *       the following disclaimer in the documentation and/or
+ *       other materials provided with the distribution.
+ *     * The names of contributors to this software may not be
+ *       used to endorse or promote products derived from this
+ *       software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ *
+ * CONTRIBUTORS
+ *  Stef Walter <stef@memberwebs.com>
+ */
+
+#ifndef P11_MESSAGE_H_
+#define P11_MESSAGE_H_
+
+#include "compat.h"
+
+#include <sys/types.h>
+
+#define P11_MESSAGE_MAX 512
+
+extern char * (* p11_message_storage)      (void);
+
+void          p11_message                  (const char* msg,
+                                            ...) GNUC_PRINTF (1, 2);
+
+void          p11_message_store            (const char* msg,
+                                            size_t length);
+
+const char *  p11_message_last             (void);
+
+void          p11_message_clear            (void);
+
+void          p11_message_quiet            (void);
+
+void          p11_message_loud             (void);
+
+#endif /* P11_MESSAGE_H_ */
index 9d6c96017b834ac8edef59725d4462e361726da6..1a283b92edae9c43c1ef0b7be9a64b794604d542 100644 (file)
@@ -35,9 +35,9 @@
 #include "config.h"
 
 #include "debug.h"
-#include "library.h"
 #define CRYPTOKI_EXPORTS
 #include "pkcs11.h"
+#include "message.h"
 
 #include "mock.h"
 
index d024b80c3a53fc5dcba9ac243cdd33d30dbf9383..ba9a72ff71d91e6ebc64de2da4cf20cfc043f3ea 100644 (file)
@@ -60,6 +60,5 @@ endif # WITH_ASN1
 TESTS = $(CHECK_PROGS)
 
 LDADD += \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(CUTEST_LIBS)
index c053305863c827fba7cea7b3753304e92def4bf3..90c1f49c27ba234e2590af76be04826248a21576 100644 (file)
@@ -36,7 +36,8 @@
 #include "CuTest.h"
 
 #include "base64.h"
-#include "library.h"
+#include "debug.h"
+#include "message.h"
 
 #include <assert.h>
 #include <string.h>
@@ -196,7 +197,7 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
+       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_decode_simple);
        SUITE_ADD_TEST (suite, test_decode_thawte);
index 02ea5c51e06300ed9a56020de7090c8d8b34e155..58d5d65ab28efd5870ceddbc7753d2e7de7ca007 100644 (file)
@@ -42,7 +42,7 @@
 #include "compat.h"
 #include "debug.h"
 #include "lexer.h"
-#include "library.h"
+#include "message.h"
 #include "pem.h"
 
 typedef struct {
@@ -260,7 +260,6 @@ main (void)
 
        putenv ("P11_KIT_STRICT=1");
        p11_debug_init ();
-       p11_library_init ();
 
        SUITE_ADD_TEST (suite, test_basic);
        SUITE_ADD_TEST (suite, test_corners);
index 096563b26f8bab540d3f0effe481f30765e027a8..ed84f0c8edb0ebf1c46682d7a00e1c4349e78579 100644 (file)
@@ -35,7 +35,8 @@
 #include "config.h"
 #include "CuTest.h"
 
-#include "library.h"
+#include "debug.h"
+#include "message.h"
 
 #include <assert.h>
 #include <string.h>
@@ -146,7 +147,7 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
+       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_decode_success);
        SUITE_ADD_TEST (suite, test_decode_skip);
index 1967403175a738a3189c9612ff94fa37019de68c..1ab3b3d65158d3b08dde70367b5dde71e0520b6f 100644 (file)
@@ -55,7 +55,7 @@ libp11_kit_la_SOURCES = $(MODULE_SRCS)
 
 libp11_kit_la_LIBADD = \
        $(LTLIBINTL) \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(top_builddir)/common/libp11-library.la \
        $(NULL)
 
index 2cd548196a4c7cd82e6ce4ab38b010e7bca634e4..c3eb05efc86970a4beaaf20f7f20411444dbb219 100644 (file)
@@ -41,7 +41,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_CONF
 #include "debug.h"
 #include "lexer.h"
-#include "library.h"
+#include "message.h"
 #include "private.h"
 
 #include <sys/param.h>
index 7648167f8735822122e29819a13d1775cae0f193..18400bbab6a3a11559e312128982a7bb49ba95ac 100644 (file)
@@ -40,6 +40,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "library.h"
+#include "message.h"
 #include "pkcs11.h"
 #include "p11-kit.h"
 #include "private.h"
index dac635c7c7509892eeb21248094e31f131f24a1f..b64b737fd72ffd4f212944ba6bf06ac7e4693d51 100644 (file)
@@ -38,6 +38,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "library.h"
+#include "message.h"
 #include "pkcs11.h"
 #include "p11-kit.h"
 #include "pin.h"
index 35f0c822eadcda148c302a1d45074f343a6bef57..1908d34f360331866a4776fce72a472f3255932a 100644 (file)
@@ -39,6 +39,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "library.h"
+#include "message.h"
 #define CRYPTOKI_EXPORTS
 #include "pkcs11.h"
 #include "p11-kit.h"
index bc96bf42ef7af76e150618e70fc2bae5718a1ce6..c7b87ae7c067bf25109972b8deb8240e7b40f072 100644 (file)
@@ -12,8 +12,7 @@ INCLUDES = \
 LDADD = \
        $(top_builddir)/p11-kit/libp11-kit-testable.la \
        $(top_builddir)/common/libp11-mock.la \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(CUTEST_LIBS) \
        $(LTLIBINTL)
 
@@ -47,8 +46,7 @@ mock_one_la_CFLAGS = \
 
 mock_one_la_LIBADD = \
        $(top_builddir)/common/libp11-mock.la \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(NULL)
 
 mock_one_la_LDFLAGS = \
index e74da1bd7d1dee93d161143f3e070af564ee3137..d259cf80f480b83fa834f7332492be2ae8b61bba 100644 (file)
@@ -41,7 +41,8 @@
 #include <string.h>
 
 #include "conf.h"
-#include "library.h"
+#include "debug.h"
+#include "message.h"
 #include "p11-kit.h"
 #include "private.h"
 
@@ -78,7 +79,7 @@ test_parse_ignore_missing (CuTest *tc)
        CuAssertPtrNotNull (tc, map);
 
        CuAssertIntEquals (tc, 0, p11_dict_size (map));
-       CuAssertPtrEquals (tc, NULL, (void*)p11_kit_message ());
+       CuAssertPtrEquals (tc, NULL, (void*)p11_message_last ());
        p11_dict_free (map);
 }
 
@@ -89,7 +90,7 @@ test_parse_fail_missing (CuTest *tc)
 
        map = _p11_conf_parse_file (SRCDIR "/files/non-existant.conf", 0);
        CuAssertPtrEquals (tc, map, NULL);
-       CuAssertPtrNotNull (tc, p11_kit_message ());
+       CuAssertPtrNotNull (tc, p11_message_last ());
 }
 
 static void
@@ -131,7 +132,7 @@ test_load_globals_merge (CuTest *tc)
                                         SRCDIR "/files/test-user.conf",
                                         &user_mode);
        CuAssertPtrNotNull (tc, config);
-       CuAssertStrEquals (tc, NULL, p11_kit_message ());
+       CuAssertStrEquals (tc, NULL, p11_message_last ());
        CuAssertIntEquals (tc, CONF_USER_MERGE, user_mode);
 
        CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1");
@@ -153,7 +154,7 @@ test_load_globals_no_user (CuTest *tc)
                                         SRCDIR "/files/test-user.conf",
                                         &user_mode);
        CuAssertPtrNotNull (tc, config);
-       CuAssertStrEquals (tc, NULL, p11_kit_message ());
+       CuAssertStrEquals (tc, NULL, p11_message_last ());
        CuAssertIntEquals (tc, CONF_USER_NONE, user_mode);
 
        CuAssertStrEquals (tc, p11_dict_get (config, "key1"), "system1");
@@ -175,7 +176,7 @@ test_load_globals_user_sets_only (CuTest *tc)
                                         SRCDIR "/files/test-user-only.conf",
                                         &user_mode);
        CuAssertPtrNotNull (tc, config);
-       CuAssertStrEquals (tc, NULL, p11_kit_message ());
+       CuAssertStrEquals (tc, NULL, p11_message_last ());
        CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
 
        CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL);
@@ -197,7 +198,7 @@ test_load_globals_system_sets_only (CuTest *tc)
                                         SRCDIR "/files/test-user.conf",
                                         &user_mode);
        CuAssertPtrNotNull (tc, config);
-       CuAssertStrEquals (tc, NULL, p11_kit_message ());
+       CuAssertStrEquals (tc, NULL, p11_message_last ());
        CuAssertIntEquals (tc, CONF_USER_ONLY, user_mode);
 
        CuAssertStrEquals (tc, p11_dict_get (config, "key1"), NULL);
@@ -222,7 +223,7 @@ test_load_globals_system_sets_invalid (CuTest *tc)
        error = errno;
        CuAssertPtrEquals (tc, NULL, config);
        CuAssertIntEquals (tc, EINVAL, error);
-       CuAssertPtrNotNull (tc, p11_kit_message ());
+       CuAssertPtrNotNull (tc, p11_message_last ());
 
        p11_dict_free (config);
 }
@@ -242,7 +243,7 @@ test_load_globals_user_sets_invalid (CuTest *tc)
        error = errno;
        CuAssertPtrEquals (tc, NULL, config);
        CuAssertIntEquals (tc, EINVAL, error);
-       CuAssertPtrNotNull (tc, p11_kit_message ());
+       CuAssertPtrNotNull (tc, p11_message_last ());
 
        p11_dict_free (config);
 }
@@ -267,7 +268,7 @@ test_load_modules_merge (CuTest *tc)
                                          SRCDIR "/files/system-modules",
                                          SRCDIR "/files/user-modules");
        CuAssertPtrNotNull (tc, configs);
-       CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
+       CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
 
        config = p11_dict_get (configs, "one");
        CuAssertPtrNotNull (tc, config);
@@ -300,7 +301,7 @@ test_load_modules_user_none (CuTest *tc)
                                          SRCDIR "/files/system-modules",
                                          SRCDIR "/files/user-modules");
        CuAssertPtrNotNull (tc, configs);
-       CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
+       CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
 
        config = p11_dict_get (configs, "one");
        CuAssertPtrNotNull (tc, config);
@@ -331,7 +332,7 @@ test_load_modules_user_only (CuTest *tc)
                                          SRCDIR "/files/system-modules",
                                          SRCDIR "/files/user-modules");
        CuAssertPtrNotNull (tc, configs);
-       CuAssertPtrEquals (tc, NULL, (void *)p11_kit_message ());
+       CuAssertPtrEquals (tc, NULL, (void *)p11_message_last ());
 
        config = p11_dict_get (configs, "one");
        CuAssertPtrNotNull (tc, config);
@@ -362,7 +363,7 @@ test_load_modules_no_user (CuTest *tc)
                                          SRCDIR "/files/system-modules",
                                          SRCDIR "/files/non-existant");
        CuAssertPtrNotNull (tc, configs);
-       CuAssertTrue (tc, assert_msg_contains (p11_kit_message (), "invalid config filename"));
+       CuAssertTrue (tc, assert_msg_contains (p11_message_last (), "invalid config filename"));
 
        config = p11_dict_get (configs, "one");
        CuAssertPtrNotNull (tc, config);
@@ -398,7 +399,7 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
+       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_parse_conf_1);
        SUITE_ADD_TEST (suite, test_parse_ignore_missing);
@@ -416,8 +417,6 @@ main (void)
        SUITE_ADD_TEST (suite, test_load_modules_user_none);
        SUITE_ADD_TEST (suite, test_parse_boolean);
 
-       p11_kit_be_quiet ();
-
        CuSuiteRun (suite);
        CuSuiteSummary (suite, output);
        CuSuiteDetails (suite, output);
index ccfce2c003b59ca93af2b0be4280e6a55c0c3dc3..08e43b30e8c8d6b39aaf2c0ca40455008cde49c2 100644 (file)
@@ -40,6 +40,7 @@
 #include "attrs.h"
 #include "iter.h"
 #include "library.h"
+#include "message.h"
 #include "mock.h"
 
 #include <assert.h>
index 3f0e4e0d96c831dc5aebf01cd818e09438576a30..3a6e968acfa0e21b769ea21eadb9f3636ec08684 100644 (file)
@@ -40,6 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "debug.h"
 #include "library.h"
 #include "p11-kit.h"
 #include "private.h"
index 18ee706e9cef1c3c4e713c7bc662afd6f687b88e..2bc121c7181c3ecaeb1c0065d536ebe721668e99 100644 (file)
@@ -35,7 +35,8 @@
 #include "config.h"
 #include "CuTest.h"
 
-#include "library.h"
+#include "debug.h"
+#include "message.h"
 
 #include <assert.h>
 #include <string.h>
@@ -1203,7 +1204,7 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
+       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_uri_parse);
        SUITE_ADD_TEST (suite, test_uri_parse_bad_scheme);
index 52bd61dd98c0c58d621af832e129071872ab1b70..a811b92079ca1ad178e9da09242a53ed4f2fa37e 100644 (file)
@@ -38,7 +38,7 @@
 #include "buffer.h"
 #define P11_DEBUG_FLAG P11_DEBUG_URI
 #include "debug.h"
-#include "library.h"
+#include "message.h"
 #include "pkcs11.h"
 #include "private.h"
 #include "p11-kit.h"
index bb074ac10f6dfc545a0cdb47b4347c49ab9e64f2..c4e5636001155284d0bdf87e89b66599c2d24710 100644 (file)
@@ -41,6 +41,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_LIB
 #include "debug.h"
 #include "library.h"
+#include "message.h"
 #include "p11-kit.h"
 #include "private.h"
 
index aaf7e99acb8c44bf1fe59868f57d91b35b1cd853..92c2644799cf7ca227be3b694af05078344d1dc9 100644 (file)
@@ -27,8 +27,7 @@ p11_kit_CFLAGS = \
 
 p11_kit_LDADD = \
        $(top_builddir)/p11-kit/libp11-kit.la \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(LTLIBINTL) \
        $(NULL)
 
index 1c81e0796722cc09a213f107043072f1c85eade3..133b1cd7f84be649146bad59dd1047bf9f08443c 100644 (file)
@@ -41,7 +41,7 @@
 #include "oid.h"
 #include "dict.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
 #include "x509.h"
index d72b1dc60a4e0d4cf8e561eee31b6f668f96cb35..2c78a510848b826ac26c6af3bac251b6d223b117 100644 (file)
@@ -40,7 +40,7 @@
 #include "debug.h"
 #include "extract.h"
 #include "hash.h"
-#include "library.h"
+#include "message.h"
 #include "save.h"
 
 #include <assert.h>
index cf387f72f54b47716c44acb664825f5681efa40c..2b8005a961facb6cefa74300b2b71a54401b3a5b 100644 (file)
@@ -42,7 +42,7 @@
 #include "dict.h"
 #include "extract.h"
 #include "hash.h"
-#include "library.h"
+#include "message.h"
 #include "oid.h"
 #include "pem.h"
 #include "pkcs11.h"
index 4d0320853469ffe47a55a054818ef8643ee33c07..a1a08651f472feb963f79fcbc7a35b5a81bf65d0 100644 (file)
@@ -39,7 +39,7 @@
 #include "compat.h"
 #include "debug.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "pem.h"
 #include "save.h"
 
index c6fe15fb51c403d70b58560abc8adc9eab034fe9..4a0d9c0a29dfa71de4271d4e595da5533bca375e 100644 (file)
@@ -37,7 +37,7 @@
 #include "compat.h"
 #include "debug.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "save.h"
 
 #include <stdlib.h>
index cf08ae978bb7b53b6f7f0fde87cbddba2b4a0aab..cd0f369d6bd4663341cd8b8effc1f6243724e45b 100644 (file)
@@ -39,7 +39,7 @@
 #include "debug.h"
 #include "extract.h"
 #include "iter.h"
-#include "library.h"
+#include "message.h"
 #include "oid.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
index 8430d78e7d397c1420ace9330ae8972923811e9b..da99940db5541bead4965a3edb6cd8c225242ff6 100644 (file)
@@ -44,7 +44,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#include "library.h"
+#include "message.h"
 #include "p11-kit.h"
 #include "tool.h"
 #include "uri.h"
index 856a7238f1669de125eb2f45a121306d664f5063..f1605a32a9b0ffd2a285437ef6fc63dec9280446 100644 (file)
@@ -37,7 +37,7 @@
 #include "buffer.h"
 #include "debug.h"
 #include "dict.h"
-#include "library.h"
+#include "message.h"
 #include "save.h"
 
 #include <sys/stat.h>
index 79367438af45fa76dd1d43d8ab15201dcecd9c2f..f6609ecef43f367a38ae0c06e01f1c2d80a53ae1 100644 (file)
@@ -24,8 +24,7 @@ LDADD = \
        $(top_builddir)/p11-kit/libp11-kit.la \
        $(top_builddir)/common/libp11-data.la \
        $(top_builddir)/common/libp11-mock.la \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(builddir)/libtestcommon.la \
        $(LIBTASN1_LIBS) \
        $(LTLIBINTL) \
index 29ee9869446f05a5bd4639f83ff9e7e5fb88ad80..74e3c9c730ca7f0543e890db048b7b374e5550ae 100644 (file)
@@ -40,7 +40,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "mock.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
@@ -524,7 +524,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        mock_module_init ();
        p11_debug_init ();
 
index 77df10944b0336acbd82382df00e237dc158c129..286b4e9b9f84759cdf21e192e3be6acfdb077598 100644 (file)
@@ -41,7 +41,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "mock.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
@@ -655,7 +655,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        mock_module_init ();
        p11_debug_init ();
 
index 5c19455e9ff9d65489b7e904c34daa89afb7d75c..be792791345b639755c540b5be1683a406eacaf6 100644 (file)
@@ -40,7 +40,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "mock.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
@@ -249,7 +249,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        mock_module_init ();
        p11_debug_init ();
 
index 32713ee6f94192491287cb08c01886ba1b91af48..d686bd6c064805772f16b92be00df404580d3929 100644 (file)
@@ -39,7 +39,7 @@
 #include "compat.h"
 #include "debug.h"
 #include "dict.h"
-#include "library.h"
+#include "message.h"
 #include "save.h"
 #include "test.h"
 
@@ -537,7 +537,8 @@ main (void)
        CuSuite* suite = CuSuiteNew ();
        int ret;
 
-       p11_library_init ();
+       putenv ("P11_KIT_STRICT=1");
+       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_file_write);
        SUITE_ADD_TEST (suite, test_file_exists);
index 7cf97876400219816964525f8a9d445d6b706bac..138e6b76bfa925e685dadbe4dbdb5f90251e87dd 100644 (file)
@@ -40,7 +40,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "extract.h"
-#include "library.h"
+#include "message.h"
 #include "mock.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
@@ -259,7 +259,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        mock_module_init ();
        p11_debug_init ();
 
index fa68eed9a55d87ca35baa783fc31b469ae5f451f..9ec41a49147f48439e20d910cb75ce7b73a15f3d 100644 (file)
@@ -37,7 +37,7 @@
 #include "buffer.h"
 #include "compat.h"
 #include "debug.h"
-#include "library.h"
+#include "message.h"
 #include "p11-kit.h"
 
 #include <assert.h>
index 60323a8919d2149e73203bfd56f8aa479bd4b1a7..264ea7cad734c574963e0df7c03e4681eeb9585d 100644 (file)
@@ -36,7 +36,7 @@ p11_kit_trust_la_CFLAGS = \
 p11_kit_trust_la_LIBADD = \
        $(top_builddir)/common/libp11-data.la \
        $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(LIBTASN1_LIBS) \
        $(NULL)
 
index 32f2d1b67dfe79b80b40801f6704f1f56f64e382..e41d73f8d0cba2264ee13c96deab7abfd36373af 100644 (file)
@@ -44,7 +44,7 @@
 #include "debug.h"
 #include "hash.h"
 #include "index.h"
-#include "library.h"
+#include "message.h"
 #include "oid.h"
 #include "pkcs11x.h"
 #include "x509.h"
index 51a75e02969e989fa923ead663be8779cb6d9f6d..46ebeb6ab10d0b00c55b84965a41c162bbef69df 100644 (file)
@@ -42,6 +42,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "library.h"
+#include "message.h"
 #include "module.h"
 #include "parser.h"
 #include "pkcs11.h"
index 7ea879a7f445b0e9e7a026dea6364e316126bae3..7eb18c92db42b1e2fde930bdd2c16405979772bc 100644 (file)
@@ -41,7 +41,7 @@
 #include "debug.h"
 #include "dict.h"
 #include "hash.h"
-#include "library.h"
+#include "message.h"
 #include "module.h"
 #include "oid.h"
 #include "parser.h"
index 2a8c9f9c7d0696d4d947b106495258c5ac0e45d0..b04b8bf1b9c16e6ac886afb9dc81f1c4e0c281c1 100644 (file)
@@ -38,7 +38,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_TRUST
 #include "debug.h"
 #include "dict.h"
-#include "library.h"
+#include "message.h"
 #include "pkcs11.h"
 #include "module.h"
 #include "session.h"
index 653bd0dd2f39fd7ac9ea384cd7371252e1edabfe..90b9fb5c87ae32c4668b16e4415870fa8cca3524 100644 (file)
@@ -19,7 +19,7 @@ LDADD = \
        $(top_builddir)/trust/libtrust-testable.la \
        $(top_builddir)/common/libp11-data.la \
        $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(builddir)/libtestdata.la \
        $(LIBTASN1_LIBS) \
        $(CUTEST_LIBS) \
@@ -41,8 +41,7 @@ noinst_PROGRAMS = \
        $(CHECK_PROGS)
 
 frob_nss_trust_LDADD = \
-       $(top_builddir)/common/libp11-library.la \
-       $(top_builddir)/common/libp11-compat.la \
+       $(top_builddir)/common/libp11-common.la \
        $(top_builddir)/p11-kit/libp11-kit.la
 
 TESTS = $(CHECK_PROGS)
index 5ce3b2283ac2449c3273b5eae84f1a01d81a23b6..7cab1f642716fd274c5a48d08f16ad4e048095ea 100644 (file)
@@ -44,7 +44,7 @@
 #include "hash.h"
 #include "debug.h"
 #include "index.h"
-#include "library.h"
+#include "message.h"
 #include "oid.h"
 #include "pkcs11x.h"
 
@@ -1722,7 +1722,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        p11_debug_init ();
        /* p11_message_quiet (); */
 
index 14f5a8a8a7ad2346d38cf862dfeec29994763857..84050617bc30e5d3b9e78cc5422484cb27a318ad 100644 (file)
@@ -41,8 +41,8 @@
 
 #include "attrs.h"
 #include "debug.h"
-#include "library.h"
 #include "index.h"
+#include "message.h"
 
 #include "test-data.h"
 
@@ -1036,7 +1036,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        p11_debug_init ();
        p11_message_quiet ();
 
index c92e1c3cea45736620e6973fa10c461e3efb265c..525a68e905a9724aca3eef08b1795530e038da61 100644 (file)
@@ -42,7 +42,6 @@
 #define CRYPTOKI_EXPORTS
 
 #include "attrs.h"
-#include "debug.h"
 #include "hash.h"
 #include "library.h"
 #include "pkcs11x.h"
@@ -898,7 +897,6 @@ main (void)
 
        putenv ("P11_KIT_STRICT=1");
        p11_library_init ();
-       p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_get_slot_list);
        SUITE_ADD_TEST (suite, test_get_slot_info);
index 94cfc49c5572aa8dd08343bb90ffb82013fa62a4..147823aeb7b5d333d9d5a5da284adc584fc9020a 100644 (file)
@@ -43,7 +43,7 @@
 #include "attrs.h"
 #include "builder.h"
 #include "debug.h"
-#include "library.h"
+#include "message.h"
 #include "oid.h"
 #include "parser.h"
 #include "pkcs11x.h"
@@ -570,7 +570,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_parse_der_certificate);
index b9a79e9fa85c87557056611b537560f4906865de..ee733314dcc5947dc684b34c4ec6f4017d8e92e7 100644 (file)
@@ -43,7 +43,7 @@
 #include "attrs.h"
 #include "compat.h"
 #include "debug.h"
-#include "library.h"
+#include "message.h"
 #include "persist.h"
 #include "pkcs11.h"
 #include "pkcs11x.h"
@@ -441,7 +441,6 @@ main (void)
 
        putenv ("P11_KIT_STRICT=1");
        p11_debug_init ();
-       p11_library_init ();
 
        SUITE_ADD_TEST (suite, test_magic);
        SUITE_ADD_TEST (suite, test_simple);
index 6cf687b33fbecac0b82464f8c2cd5a848747364b..ffd733f329bf05da4ead053721c2cc28dd75a7d1 100644 (file)
@@ -42,7 +42,7 @@
 #include "attrs.h"
 #include "debug.h"
 #include "pkcs11x.h"
-#include "library.h"
+#include "message.h"
 #include "test-data.h"
 #include "token.h"
 
@@ -235,7 +235,6 @@ main (void)
        int ret;
 
        putenv ("P11_KIT_STRICT=1");
-       p11_library_init ();
        p11_debug_init ();
 
        SUITE_ADD_TEST (suite, test_token_load);
index b562788558c4dac07f6813879e79a3aa45e2657b..e7c91cd58422c5fe88981f1f8246a7f545a35cb1 100644 (file)
@@ -41,7 +41,7 @@
 #define P11_DEBUG_FLAG P11_DEBUG_TRUST
 #include "debug.h"
 #include "errno.h"
-#include "library.h"
+#include "message.h"
 #include "module.h"
 #include "parser.h"
 #include "pkcs11.h"