aboutsummaryrefslogtreecommitdiffstats
path: root/win32/patches/gcr.patch
blob: 1ba13b8788dd8bd24a56b39fa37909b846dac647 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/configure.ac gcr-3.10.1/configure.ac
--- gcr-3.10.1.old/configure.ac 2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/configure.ac 2014-06-20 21:46:28 +0000
@@ -62,20 +62,44 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GET
 AC_SUBST(GETTEXT_PACKAGE)
 AM_GLIB_GNU_GETTEXT
 
+dnl ******************************
+dnl Check for Win32
+dnl ******************************
+AC_MSG_CHECKING([for Win32])
+case "$host" in
+*-mingw*)
+   os_win32='yes'
+   AC_CACHE_VAL(ac_cv_have_addrinfo, [ac_cv_have_addrinfo=yes])
+   AC_DEFINE(_WIN32_WINNT, 0x501, [To get getaddrinfo etc declarations])
+   ;;
+*)
+   os_win32='no'
+   ;;
+esac
+AC_MSG_RESULT([$os_win32])
+AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
+
 # -----------------------------------------------------------------------------
 # GLib and GTK+ stuff
 
+GIO_PLAT=
+if test "$os_win32" = "yes" ; then
+   GIO_PLAT=gio-windows-2.0
+else
+   GIO_PLAT=gio-unix-2.0
+fi
+
 PKG_CHECK_MODULES(GLIB,
    glib-2.0 >= 2.32.0
    gmodule-no-export-2.0
    gthread-2.0
    gobject-2.0
-   gio-2.0 gio-unix-2.0)
+   gio-2.0 $GIO_PLAT)
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
 GLIB_GSETTINGS
-GOBJECT_INTROSPECTION_CHECK([1.34])
+dnl GOBJECT_INTROSPECTION_CHECK([1.34])
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
 
@@ -107,7 +131,7 @@ fi
 
 VALA_REQUIRED=0.18.0.22
 
-VAPIGEN_CHECK($VALA_REQUIRED)
+dnl VAPIGEN_CHECK($VALA_REQUIRED)
 
 if test "$enable_vala" != "no"; then
    AC_PATH_PROG([VALAC], [valac], [])
@@ -120,6 +144,8 @@ AM_CONDITIONAL(HAVE_VALAC, test "x$VALAC
 
 AC_CHECK_FUNCS(timegm, AC_DEFINE(HAVE_TIMEGM,1,[Have timegm]))
 AC_CHECK_FUNCS(mlock)
+AC_CHECK_FUNCS(gmtime_r strptime memrchr)
+AC_CHECK_HEADERS([err.h pwd.h syslog.h sys/mman.h sys/wait.h])
 
 # --------------------------------------------------------------------
 # p11-kit
@@ -370,6 +396,9 @@ else
    valgrind_status="no"
 fi
 
+AM_CONDITIONAL(HAVE_INTROSPECTION, test "yes" = "no")
+AM_CONDITIONAL(ENABLE_VAPIGEN, test "yes" = "no")
+
 # ----------------------------------------------------------------------
 
 GCK_LT_RELEASE=$GCK_CURRENT:$GCK_REVISION:$GCK_AGE
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/egg/egg-armor.c gcr-3.10.1/egg/egg-armor.c
--- gcr-3.10.1.old/egg/egg-armor.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/egg/egg-armor.c  2014-06-20 21:46:28 +0000
@@ -60,6 +60,29 @@ EGG_SECURE_DECLARE (armor);
 #define ARMOR_PREF_END      "-----END "
 #define ARMOR_PREF_END_L    9
 
+#ifndef HAVE_MEMRCHR
+extern void* memrchr (const void *s, int c, size_t n);
+
+void*
+memrchr (const void *s, int c, size_t n)
+{
+   if (n > 0) {
+       const char*  p = (const char*) s;
+       const char*  q = p + n;
+
+       while (1) {
+           q--; if (q < p || q[0] == (char) c) break;
+           q--; if (q < p || q[0] == (char) c) break;
+           q--; if (q < p || q[0] == (char) c) break;
+           q--; if (q < p || q[0] == (char) c) break;
+       }
+       if (q >= p)
+           return (void*)q;
+   }
+   return NULL;
+}
+#endif
+
 static void
 parse_header_lines (const gchar *hbeg,
                     const gchar *hend,
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/egg/egg-asn1x.c gcr-3.10.1/egg/egg-asn1x.c
--- gcr-3.10.1.old/egg/egg-asn1x.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/egg/egg-asn1x.c  2014-06-20 21:46:28 +0000
@@ -1929,7 +1929,7 @@ static int
 two_to_four_digit_year (int year)
 {
    time_t now;
-   struct tm tm;
+   GDate *date;
    int century, current;
 
    g_return_val_if_fail (year >= 0 && year <= 99, -1);
@@ -1937,11 +1937,15 @@ two_to_four_digit_year (int year)
    /* Get the current year */
    now = time (NULL);
    g_return_val_if_fail (now >= 0, -1);
-   if (!gmtime_r (&now, &tm))
+   date = g_date_new ();
+   g_date_set_time_t (date, now);
+   if (!g_date_valid (date))
        g_return_val_if_reached (-1);
 
-   current = (tm.tm_year % 100);
-   century = (tm.tm_year + 1900) - current;
+   century = (g_date_get_year (date) / 100) * 100;
+   current = g_date_get_year (date) - century;
+
+   g_date_free (date);
 
    /*
     * Check if it's within 40 years before the
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/egg/egg-secure-memory.c gcr-3.10.1/egg/egg-secure-memory.c
--- gcr-3.10.1.old/egg/egg-secure-memory.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/egg/egg-secure-memory.c  2014-06-20 21:46:28 +0000
@@ -32,7 +32,9 @@
 #include "egg-secure-memory.h"
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
+#endif
 #include <stddef.h>
 #include <string.h>
 #include <stdio.h>
@@ -188,9 +190,11 @@ pool_alloc (void)
 
    /* Create a new pool */
    if (pool == NULL) {
+#if !defined(_WIN32)
        len = getpagesize () * 2;
        pages = mmap (0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
        if (pages == MAP_FAILED)
+#endif
            return NULL;
 
        /* Fill in the block header, and inlude in block list */
@@ -254,7 +258,9 @@ pool_free (void* item)
        VALGRIND_DESTROY_MEMPOOL (pool);
 #endif
 
+#if !defined(_WIN32)
        munmap (pool, pool->length);
+#endif
        return;
    }
 
@@ -860,11 +866,11 @@ sec_acquire_pages (size_t *sz,
    ASSERT (*sz);
    ASSERT (during_tag);
 
+#if defined(HAVE_MLOCK)
    /* Make sure sz is a multiple of the page size */
    pgsize = getpagesize ();
    *sz = (*sz + pgsize -1) & ~(pgsize - 1);
 
-#if defined(HAVE_MLOCK)
    pages = mmap (0, *sz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
    if (pages == MAP_FAILED) {
        if (show_warning && egg_secure_warnings)
@@ -902,9 +908,9 @@ static void
 sec_release_pages (void *pages, size_t sz)
 {
    ASSERT (pages);
-   ASSERT (sz % getpagesize () == 0);
 
 #if defined(HAVE_MLOCK)
+   ASSERT (sz % getpagesize () == 0);
    if (munlock (pages, sz) < 0 && egg_secure_warnings)
        fprintf (stderr, "couldn't unlock private memory: %s\n", strerror (errno));
 
@@ -914,7 +920,7 @@ sec_release_pages (void *pages, size_t s
    DEBUG_ALLOC ("gkr-secure-memory: freed block ", sz);
 
 #else
-   ASSERT (FALSE);
+   ASSERT (0);
 #endif
 }
 
@@ -937,6 +943,11 @@ sec_block_create (size_t size,
    if (getenv ("SECMEM_FORCE_FALLBACK"))
        return NULL;
 
+#ifdef _WIN32
+   /* win32 does not have mlock(), so just fail in that case */
+   return NULL;
+#endif
+
    block = pool_alloc ();
    if (!block)
        return NULL;
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/egg/tests/test-asn1x.c gcr-3.10.1/egg/tests/test-asn1x.c
--- gcr-3.10.1.old/egg/tests/test-asn1x.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/egg/tests/test-asn1x.c   2014-06-20 21:46:28 +0000
@@ -27,7 +27,9 @@
 #include "egg/egg-asn1-defs.h"
 #include "egg/egg-testing.h"
 
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/Makefile.am gcr-3.10.1/gck/Makefile.am
--- gcr-3.10.1.old/gck/Makefile.am  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/Makefile.am  2014-06-20 21:46:28 +0000
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = . tests
+SUBDIRS = .
 
 incdir = $(includedir)/gck-@GCK_MAJOR@/gck
 
@@ -77,16 +77,6 @@ libgck_@GCK_MAJOR@_la_LIBADD = \
    $(GIO_LIBS) \
    $(GLIB_LIBS)
 
-noinst_LTLIBRARIES = libgck-testable.la
-libgck_testable_la_SOURCES = \
-   gck-mock.c \
-   gck-mock.h \
-   gck-test.c \
-   gck-test.h
-libgck_testable_la_LIBADD = $(libgck_@GCK_MAJOR@_la_OBJECTS) \
-   $(libgck_@GCK_MAJOR@_la_LIBADD)
-libgck_testable_la_DEPENDENCIES = $(libgck_@GCK_MAJOR@_la_OBJECTS)
-
 gck-marshal.h: gck-marshal.list $(GLIB_GENMARSHAL)
    $(GLIB_GENMARSHAL) $< --header --prefix=_gck_marshal > $@
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/gck-debug.c gcr-3.10.1/gck/gck-debug.c
--- gcr-3.10.1.old/gck/gck-debug.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/gck-debug.c  2014-06-20 21:46:28 +0000
@@ -33,6 +33,11 @@
 
 #include <unistd.h>
 
+#ifdef G_OS_WIN32
+
+#include <windows.h>
+#endif
+
 #ifdef WITH_DEBUG
 
 static gsize initialized_flags = 0;
@@ -69,21 +74,30 @@ on_gck_log_debug (const gchar *log_domai
 {
    GString *gstring;
    const gchar *progname;
+#ifdef G_OS_WIN32
+   DWORD pid = GetCurrentProcessId ();
+#else
+   pid_t pid = getpid ();
+#endif
 
    gstring = g_string_new (NULL);
 
    progname = g_get_prgname ();
    g_string_append_printf (gstring, "(%s:%lu): %s-DEBUG: %s\n",
                            progname ? progname : "process",
-                           (gulong)getpid (), log_domain,
+                           (gulong) pid, log_domain,
                            message ? message : "(NULL) message");
 
+
+#ifdef G_OS_WIN32
+   g_print ("%s", gstring->str);
+#else
    /*
     * Give up on debug messages if stdout got lost.
     */
    if (write (1, gstring->str, gstring->len) != gstring->len)
        current_flags = 0;
-
+#endif
    g_string_free (gstring, TRUE);
 }
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/gck-slot.c gcr-3.10.1/gck/gck-slot.c
--- gcr-3.10.1.old/gck/gck-slot.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/gck-slot.c   2014-06-20 21:46:28 +0000
@@ -606,7 +606,7 @@ _gck_token_info_from_pkcs11 (CK_TOKEN_IN
 {
    GckTokenInfo *token_info;
    gchar *string;
-   struct tm tm;
+   GTimeVal tv;
 
    token_info = g_new0 (GckTokenInfo, 1);
    token_info->label = gck_string_from_chars (info->label, sizeof (info->label));
@@ -634,10 +634,12 @@ _gck_token_info_from_pkcs11 (CK_TOKEN_IN
    /* Parse the time into seconds since epoch */
    if (info->flags & CKF_CLOCK_ON_TOKEN) {
        string = g_strndup ((gchar*)info->utcTime, MIN (14, sizeof (info->utcTime)));
-       if (!strptime (string, "%Y%m%d%H%M%S", &tm))
+                /* Transform into an ISO-8601 string */
+       string = g_strconcat (g_strndup (string,8), "T", g_strndup (string+8,6), "Z", NULL);
+       if (!g_time_val_from_iso8601 (string, &tv))
            token_info->utc_time = -1;
        else
-           token_info->utc_time = timegm (&tm);
+           token_info->utc_time = tv.tv_sec;
        g_free (string);
    } else {
        token_info->utc_time = -1;
@@ -649,8 +651,8 @@ _gck_token_info_from_pkcs11 (CK_TOKEN_IN
 void
 _gck_token_info_to_pkcs11 (GckTokenInfo *token_info, CK_TOKEN_INFO_PTR info)
 {
-   gchar buffer[64];
-   struct tm tm;
+   gchar *buffer;
+   GDateTime *datetime = NULL;
    time_t tim;
    gsize len;
 
@@ -690,9 +692,12 @@ _gck_token_info_to_pkcs11 (GckTokenInfo
    /* Parse the time into seconds since epoch */
    if (token_info->flags & CKF_CLOCK_ON_TOKEN) {
        tim = token_info->utc_time;
-       if (!gmtime_r (&tim, &tm))
+       datetime = g_date_time_new_from_unix_utc (tim);
+       if (datetime == NULL)
            g_return_if_reached ();
-       len = strftime (buffer, sizeof (buffer), "%Y%m%d%H%M%S", &tm);
+       buffer = g_date_time_format (datetime, "%Y%m%d%H%M%S");
+       len = strlen (buffer);
+       g_date_time_unref (datetime);
        g_return_if_fail (len == sizeof (info->utcTime));
        memcpy (info->utcTime, buffer, sizeof (info->utcTime));
    } else {
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-crypto.c gcr-3.10.1/gck/tests/test-gck-crypto.c
--- gcr-3.10.1.old/gck/tests/test-gck-crypto.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-crypto.c  2014-06-20 21:46:28 +0000
@@ -57,7 +57,11 @@ setup (Test *test, gconstpointer unused)
    GckSlot *slot;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (test->module));
    g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-enumerator.c gcr-3.10.1/gck/tests/test-gck-enumerator.c
--- gcr-3.10.1.old/gck/tests/test-gck-enumerator.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-enumerator.c  2014-06-20 21:46:28 +0000
@@ -50,7 +50,11 @@ setup (Test *test, gconstpointer unused)
    GError *err = NULL;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (test->module));
    g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-module.c gcr-3.10.1/gck/tests/test-gck-module.c
--- gcr-3.10.1.old/gck/tests/test-gck-module.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-module.c  2014-06-20 21:46:28 +0000
@@ -42,7 +42,11 @@ setup (Test *test, gconstpointer unused)
    GError *err = NULL;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (test->module);
    g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
@@ -71,7 +75,11 @@ test_initialize_async (void)
    GError *error = NULL;
 
    /* Shouldn't be able to load modules */
+#ifdef G_OS_WIN32
+   gck_module_initialize_async (BUILDDIR "/.libs/libmock-test-module.dll",
+#else
    gck_module_initialize_async (BUILDDIR "/.libs/libmock-test-module.so",
+#endif
                                 NULL, fetch_async_result, &result);
 
    egg_test_wait_until (500);
@@ -101,7 +109,11 @@ test_invalid_modules (Test *test, gconst
    g_clear_error (&error);
 
    /* Shouldn't be able to load any file successfully */
+#ifdef G_OS_WIN32
+   invalid = gck_module_initialize ("c:\\windows\\system32\\shell32.dll", NULL, &error);
+#else
    invalid = gck_module_initialize ("/usr/lib/libm.so", NULL, &error);
+#endif
    g_assert_error (error, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM);
    g_assert (invalid == NULL);
 
@@ -139,7 +151,11 @@ test_module_props (Test *test, gconstpoi
 
    g_object_get (test->module, "path", &path, NULL);
    g_assert (path != NULL && "no module-path");
+#ifdef G_OS_WIN32
+   g_assert (strcmp (BUILDDIR "/.libs/libmock-test-module.dll", path) == 0 && "module path wrong");
+#else
    g_assert (strcmp (BUILDDIR "/.libs/libmock-test-module.so", path) == 0 && "module path wrong");
+#endif
    g_free (path);
 }
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-modules.c gcr-3.10.1/gck/tests/test-gck-modules.c
--- gcr-3.10.1.old/gck/tests/test-gck-modules.c 2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-modules.c 2014-06-20 21:46:28 +0000
@@ -48,7 +48,11 @@ setup (Test *test, gconstpointer unused)
    GError *err = NULL;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (module));
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-object.c gcr-3.10.1/gck/tests/test-gck-object.c
--- gcr-3.10.1.old/gck/tests/test-gck-object.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-object.c  2014-06-20 21:46:28 +0000
@@ -50,7 +50,11 @@ setup (Test *test, gconstpointer unused)
    GList *slots;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (test->module));
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-session.c gcr-3.10.1/gck/tests/test-gck-session.c
--- gcr-3.10.1.old/gck/tests/test-gck-session.c 2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-session.c 2014-06-20 21:46:28 +0000
@@ -50,7 +50,11 @@ setup (Test *test, gconstpointer unused)
    GList *slots;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (test->module));
    g_object_add_weak_pointer (G_OBJECT (test->module), (gpointer *)&test->module);
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gck/tests/test-gck-slot.c gcr-3.10.1/gck/tests/test-gck-slot.c
--- gcr-3.10.1.old/gck/tests/test-gck-slot.c    2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gck/tests/test-gck-slot.c    2014-06-20 21:46:28 +0000
@@ -43,7 +43,11 @@ setup (Test *test, gconstpointer unused)
    GList *slots;
 
    /* Successful load */
+#ifdef G_OS_WIN32
+   test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.dll", NULL, &err);
+#else
    test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
+#endif
    g_assert_no_error (err);
    g_assert (GCK_IS_MODULE (test->module));
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gcr/Makefile.am gcr-3.10.1/gcr/Makefile.am
--- gcr-3.10.1.old/gcr/Makefile.am  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gcr/Makefile.am  2014-06-20 21:46:28 +0000
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = . tests
+SUBDIRS = .
 
 incdir = $(includedir)/gcr-@GCR_MAJOR@/gcr
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gcr/gcr-gnupg-collection.c gcr-3.10.1/gcr/gcr-gnupg-collection.c
--- gcr-3.10.1.old/gcr/gcr-gnupg-collection.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gcr/gcr-gnupg-collection.c   2014-06-20 21:46:28 +0000
@@ -36,7 +36,9 @@
 #include "gcr-record.h"
 #include "gcr-util.h"
 
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 #include <string.h>
 
 enum {
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gcr/gcr-gnupg-process.c gcr-3.10.1/gcr/gcr-gnupg-process.c
--- gcr-3.10.1.old/gcr/gcr-gnupg-process.c  2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gcr/gcr-gnupg-process.c  2014-06-20 21:46:28 +0000
@@ -31,7 +31,12 @@
 
 #include <glib/gi18n-lib.h>
 
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
@@ -854,12 +859,18 @@ on_gnupg_process_child_exited (GPid pid,
    gint code;
    guint i;
 
+#if defined (G_OS_UNIX)
    _gcr_debug ("process exited: %d", (int)pid);
+#elif defined (G_OS_WIN32)
+   DWORD real_pid = GetProcessId (pid);
+   _gcr_debug ("process exited: %d", (int)real_pid);
+#endif
 
    g_spawn_close_pid (gnupg_source->child_pid);
    gnupg_source->child_pid = 0;
    gnupg_source->child_sig = 0;
 
+#ifndef G_OS_WIN32
    if (WIFEXITED (status)) {
        code = WEXITSTATUS (status);
        if (code != 0) {
@@ -873,6 +884,7 @@ on_gnupg_process_child_exited (GPid pid,
            error = g_error_new (G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
                                 _("Gnupg process was terminated with signal: %d"), code);
    }
+#endif
 
    /* Take this as the async result error */
    if (error && !self->pv->error) {
@@ -891,11 +903,16 @@ on_gnupg_process_child_exited (GPid pid,
    }
 
    complete_source_is_done (gnupg_source);
+
+#ifdef G_OS_WIN32
+   g_spawn_close_pid (pid);
+#endif
 }
 
 static void
 on_gnupg_process_child_setup (gpointer user_data)
 {
+#ifdef G_OS_UNIX 
    int *child_fds = user_data;
    long val;
    guint i;
@@ -911,6 +928,7 @@ on_gnupg_process_child_setup (gpointer u
            fcntl (child_fds[i], F_SETFD, val & ~FD_CLOEXEC);
        }
    }
+#endif
 }
 
 static void
@@ -929,9 +947,16 @@ on_cancellable_cancelled (GCancellable *
 
    /* Try and kill the child process */
    if (gnupg_source->child_pid) {
+#if defined(G_OS_UNIX)
        _gcr_debug ("sending term signal to process: %d",
                    (int)gnupg_source->child_pid);
        kill (gnupg_source->child_pid, SIGTERM);
+#elif defined(G_OS_WIN32)
+       DWORD real_pid = GetProcessId (gnupg_source->child_pid);
+       _gcr_debug ("sending term signal to process: %d",
+                   (int)real_pid);
+       TerminateProcess (gnupg_source->child_pid, 0);
+#endif
    }
 }
 
@@ -1000,14 +1025,22 @@ _gcr_gnupg_process_run_async (GcrGnupgPr
    child_fds[FD_ERROR] = 2;
 
    if (flags & GCR_GNUPG_PROCESS_WITH_STATUS) {
+#if defined(G_OS_UNIX)
        if (pipe (status_fds) < 0)
+#elif defined(G_OS_WIN32)
+       if (_pipe (status_fds, 4096, _O_BINARY) < 0)
+#endif
            g_return_if_reached ();
        child_fds[FD_STATUS] = status_fds[1];
        g_ptr_array_add (args, g_strdup ("--status-fd"));
        g_ptr_array_add (args, g_strdup_printf ("%d", child_fds[FD_STATUS]));
    }
    if (flags & GCR_GNUPG_PROCESS_WITH_ATTRIBUTES) {
+#if defined(G_OS_UNIX)
        if (pipe (attribute_fds) < 0)
+#elif defined(G_OS_WIN32)
+       if (_pipe (attribute_fds, 4096, _O_BINARY) < 0)
+#endif
            g_return_if_reached ();
        child_fds[FD_ATTRIBUTE] = attribute_fds[1];
        g_ptr_array_add (args, g_strdup ("--attribute-fd"));
@@ -1036,11 +1069,11 @@ _gcr_gnupg_process_run_async (GcrGnupgPr
 
    if (_gcr_debugging) {
        gchar *command = g_strjoinv (" ", (gchar**)args->pdata);
-       gchar *environ = g_strjoinv (", ", (gchar**)envs->pdata);
+       gchar *environment = g_strjoinv (", ", (gchar**)envs->pdata);
        _gcr_debug ("running command: %s", command);
-       _gcr_debug ("process environment: %s", environ);
+       _gcr_debug ("process environment: %s", environment);
        g_free (command);
-       g_free (environ);
+       g_free (environment);
    }
 
    g_spawn_async_with_pipes (self->pv->directory, (gchar**)args->pdata,
@@ -1068,7 +1101,12 @@ _gcr_gnupg_process_run_async (GcrGnupgPr
        return;
    }
 
+#if defined (G_OS_UNIX)
    _gcr_debug ("process started: %d", (int)pid);
+#elif defined (G_OS_WIN32)
+   DWORD real_pid = GetProcessId (pid);
+   _gcr_debug ("process started: %d", (int)real_pid);
+#endif
 
    source = g_source_new (&gnupg_source_funcs, sizeof (GnupgSource));
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/gcr/gcr-record.c gcr-3.10.1/gcr/gcr-record.c
--- gcr-3.10.1.old/gcr/gcr-record.c 2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/gcr/gcr-record.c 2014-06-20 21:46:28 +0000
@@ -597,7 +597,9 @@ _gcr_record_get_date (GcrRecord *record,
    const gchar *raw;
    gulong result;
    gchar *end = NULL;
-   struct tm tm;
+   gchar **string;
+   int year, month, day;
+   GDateTime *dt = NULL;
 
    g_return_val_if_fail (record, NULL);
 
@@ -615,14 +617,20 @@ _gcr_record_get_date (GcrRecord *record,
    }
 
    /* Try to parse as a date */
-   memset (&tm, 0, sizeof (tm));
-   end = strptime (raw, "%Y-%m-%d", &tm);
-   if (!end || end[0]) {
+   string = g_strsplit (raw, "-", 3);
+   if ((string[0] != NULL) && (string[1] != NULL) && (string[2] != NULL)) {
+       year = strtol (string[0], NULL, 10);
+       month = strtol (string[1], NULL, 10);
+       day = strtol (string[2], NULL, 10);
+       dt = g_date_time_new_utc (year, month, day, 0, 0, 0);
+   }
+   g_strfreev (string);
+   if (dt == NULL) {
        _gcr_debug ("invalid date value: %s", raw);
        return NULL;
    }
 
-   return g_date_time_new_utc (tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 0, 0, 0);
+   return dt;
 }
 
 /**
@@ -860,4 +868,4 @@ _gcr_records_parse_colons (gconstpointer
    g_free (lines);
 
    return result;
-}
+}
\ No newline at end of file
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/Makefile.am gcr-3.10.1/ui/Makefile.am
--- gcr-3.10.1.old/ui/Makefile.am   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/ui/Makefile.am   2014-06-20 21:46:28 +0000
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = . icons tests
+SUBDIRS = . icons
 
 incdir = $(includedir)/gcr-@GCR_MAJOR@/ui
 
@@ -51,11 +51,13 @@ libgcr_ui_@GCR_MAJOR@_la_LIBADD = \
    $(GTK_LIBS) \
    $(NULL)
 
+if !OS_WIN32
 # libgcr-3.so (and  friends) symlink to libgcr-ui-3.so for compatibility raisons
 install-exec-hook:
    $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so
    $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so.@GCR_CURRENT@
    $(LN_S) -f `readlink $(DESTDIR)$(libdir)/libgcr-ui-@GCR_MAJOR@.so` $(DESTDIR)$(libdir)/libgcr-@GCR_MAJOR@.so.@GCR_CURRENT@.0.0
+endif
 
 uidir = $(datadir)/gcr-@GCR_MAJOR@/ui/
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/gcr-prompt-dialog.c gcr-3.10.1/ui/gcr-prompt-dialog.c
--- gcr-3.10.1.old/ui/gcr-prompt-dialog.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/ui/gcr-prompt-dialog.c   2014-06-20 21:46:28 +0000
@@ -31,7 +31,13 @@
 #include "gcr-secure-entry-buffer.h"
 
 #include <gtk/gtk.h>
+#if defined(GDK_WINDOWING_X11)
 #include <gdk/gdkx.h>
+#endif
+#if defined(GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#include <windows.h>
+#endif
 #include <glib/gi18n.h>
 
 /**
@@ -152,12 +158,21 @@ update_transient_for (GcrPromptDialog *s
    }
 
    display = gtk_widget_get_display (GTK_WIDGET (self));
+#if defined(GDK_WINDOWING_X11)
    transient_for = gdk_x11_window_foreign_new_for_display (display, (Window)handle);
+#elif defined(GDK_WINDOWING_WIN32)
+   transient_for = gdk_win32_window_foreign_new_for_display (display, (HWND)handle);
+#endif
    if (transient_for == NULL) {
        g_warning ("caller-window property doesn't represent a window on current display: %s",
                   self->pv->caller_window);
    } else {
+#if defined(GDK_WINDOWING_X11)
        gdk_window_set_transient_for (window, transient_for);
+#elif defined(GDK_WINDOWING_WIN32)
+       HWND chandle = gdk_win32_window_get_handle (window);
+       SetWindowLongPtr (chandle, GWLP_HWNDPARENT, (LONG_PTR)handle);
+#endif
        g_object_unref (transient_for);
    }
 
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/gcr-prompter-tool.c gcr-3.10.1/ui/gcr-prompter-tool.c
--- gcr-3.10.1.old/ui/gcr-prompter-tool.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/ui/gcr-prompter-tool.c   2014-06-20 21:46:28 +0000
@@ -30,13 +30,17 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 #include <pango/pango.h>
 
 #include <locale.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_SYSLOG_H
 #include <syslog.h>
+#endif
 
 #define QUIT_TIMEOUT 10
 
@@ -138,6 +142,7 @@ log_handler (const gchar *log_domain,
              const gchar *message,
              gpointer user_data)
 {
+#ifdef HAVE_SYSLOG_H
    int level;
 
    /* Note that crit and err are the other way around in syslog */
@@ -171,6 +176,7 @@ log_handler (const gchar *log_domain,
        syslog (level, "%s: %s", log_domain, message);
    else
        syslog (level, "%s", message);
+#endif
 
    /* And then to default handler for aborting and stuff like that */
    g_log_default_handler (log_domain, log_level, message, user_data);
@@ -179,9 +185,11 @@ log_handler (const gchar *log_domain,
 static void
 printerr_handler (const gchar *string)
 {
+#ifdef HAVE_SYSLOG_H
    /* Print to syslog and stderr */
    syslog (LOG_WARNING, "%s", string);
    fprintf (stderr, "%s", string);
+#endif
 }
 
 static void
@@ -191,7 +199,9 @@ prepare_logging ()
                           G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING |
                           G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO;
 
+#ifdef HAVE_SYSLOG_H
    openlog ("gcr-prompter", LOG_PID, LOG_AUTH);
+#endif
 
    g_log_set_handler (NULL, flags, log_handler, NULL);
    g_log_set_handler ("Glib", flags, log_handler, NULL);
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/gcr-ui.pc.in gcr-3.10.1/ui/gcr-ui.pc.in
--- gcr-3.10.1.old/ui/gcr-ui.pc.in  2013-04-21 12:31:47 +0000
+++ gcr-3.10.1/ui/gcr-ui.pc.in  2014-06-20 22:22:58 +0000
@@ -11,5 +11,5 @@ Description: GObject and GUI library for
 Version: @VERSION@
 Requires: glib-2.0 gobject-2.0 gio-2.0 gtk+-3.0 gcr-base-@GCR_MAJOR@ gck-@GCK_MAJOR@
 Requires.private: p11-kit-1
-Libs: -L${libdir} -lgcr-@GCR_MAJOR@
+Libs: -L${libdir} -lgcr-ui-@GCR_MAJOR@
 Cflags: -I${includedir}/gcr-@GCR_MAJOR@
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/tests/frob-prompt.c gcr-3.10.1/ui/tests/frob-prompt.c
--- gcr-3.10.1.old/ui/tests/frob-prompt.c   2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/ui/tests/frob-prompt.c   2014-06-20 21:46:28 +0000
@@ -27,15 +27,45 @@
 #include "gcr/gcr-base.h"
 
 #include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
+#ifdef GDK_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#endif
 
+#ifdef HAVE_ERR_H
 #include <err.h>
+#else
+#include <errno.h>
+#endif
+#include <stdlib.h>
 
 static const gchar *file_name = NULL;
 static gchar *prompt_type = NULL;
 static gint prompt_delay = 0;
 static gboolean prompt_window = FALSE;
 
+#ifndef HAVE_ERR_H
+extern void errx (int eval, char *format, ...);
+
+void errx (int eval, char *format, ...)
+{
+   gchar *err_s;
+
+   va_list ap;
+   va_start (ap, format);
+   vsprintf (err_s, format, ap);
+   va_end (ap);
+
+   err_s = g_strconcat (g_get_prgname (), ": ", g_strdup (err_s), "\n", NULL);
+   g_printerr (err_s);
+   g_free (err_s);
+
+   exit (eval);
+}
+#endif
+
 static gboolean
 on_delay_timeout (gpointer data)
 {
@@ -80,7 +110,11 @@ prompt_perform (GtkWidget *parent)
        errx (1, "couldn't create prompt: %s", error->message);
 
    if (parent) {
+#if defined(GDK_WINDOWING_X11)
        caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
+#elif defined(GDK_WINDOWING_WIN32)
+       caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_HWND (gtk_widget_get_window (parent)));
+#endif
        gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
        g_free (caller_id);
    }
diff -upr -x .deps -x .libs -x '*.la' gcr-3.10.1.old/ui/tests/frob-system-prompt.c gcr-3.10.1/ui/tests/frob-system-prompt.c
--- gcr-3.10.1.old/ui/tests/frob-system-prompt.c    2014-06-20 22:20:25 +0000
+++ gcr-3.10.1/ui/tests/frob-system-prompt.c    2014-06-20 21:46:28 +0000
@@ -28,7 +28,12 @@
 #include "egg/egg-testing.h"
 
 #include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
+#ifdef GDK_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#endif
 
 #include <unistd.h>
 #include <string.h>
@@ -56,7 +61,11 @@ on_prompt_clicked (GtkToolButton *button
    gcr_prompt_set_message (GCR_PROMPT (prompt), "This is the message");
    gcr_prompt_set_description (GCR_PROMPT (prompt), "This is the description");
 
+#if defined(GDK_WINDOWING_X11)
    caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_XID (gtk_widget_get_window (parent)));
+#elif defined(GDK_WINDOWING_WIN32)
+   caller_id = g_strdup_printf ("%lu", (gulong)GDK_WINDOW_HWND (gtk_widget_get_window (parent)));
+#endif
    gcr_prompt_set_caller_window (GCR_PROMPT (prompt), caller_id);
    g_free (caller_id);