qt: add device preferences for mmdevice
[vlc.git] / contrib / src / gnutls / winrt-topendir.patch
blob6051cd0f01fc8949d35c1b1d8aebb1559db92992
1 --- gnutls-3.5.16/lib/x509/verify-high2.c.orig 2016-12-19 15:10:59.000000000 +0100
2 +++ gnutls-3.5.16/lib/x509/verify-high2.c 2017-12-26 16:39:02.565137168 +0100
3 @@ -43,6 +43,9 @@
4 # endif
5 #endif
7 +#include <windows.h>
8 +#include <tchar.h>
10 /* Convenience functions for verify-high functionality
13 @@ -368,29 +371,59 @@
14 return ret;
17 +static inline char *FromWide (const wchar_t *wide)
19 + size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
20 + if (len == 0)
21 + return NULL;
23 + char *out = (char *)malloc (len);
25 + if (out)
26 + WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
27 + return out;
30 +static inline wchar_t *ToWide (const char *utf8)
32 + int len = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0);
33 + if (len == 0)
34 + return NULL;
36 + wchar_t *out = (wchar_t *)malloc (len * sizeof (wchar_t));
38 + if (out)
39 + MultiByteToWideChar (CP_UTF8, 0, utf8, -1, out, len);
40 + return out;
43 static
44 int load_dir_certs(const char *dirname,
45 gnutls_x509_trust_list_t list,
46 unsigned int tl_flags, unsigned int tl_vflags,
47 unsigned type, unsigned crl)
49 - DIR *dirp;
50 - struct dirent *d;
51 + _TDIR *dirp;
52 + struct _tdirent *d;
53 int ret;
54 int r = 0;
55 char path[GNUTLS_PATH_MAX];
57 - dirp = opendir(dirname);
58 + TCHAR* dirnameW = ToWide(dirname);
59 + dirp = _topendir(dirnameW);
60 + free(dirnameW);
61 if (dirp != NULL) {
62 do {
63 - d = readdir(dirp);
64 + d = _treaddir(dirp);
65 if (d != NULL
66 #ifdef _DIRENT_HAVE_D_TYPE
67 && (d->d_type == DT_REG || d->d_type == DT_LNK || d->d_type == DT_UNKNOWN)
68 #endif
69 ) {
70 + char* d_name = FromWide(d->d_name);
71 snprintf(path, sizeof(path), "%s/%s",
72 - dirname, d->d_name);
73 + dirname, d_name);
74 + free(d_name);
76 if (crl != 0) {
77 ret =
78 @@ -408,7 +441,7 @@
81 while (d != NULL);
82 - closedir(dirp);
83 + _tclosedir(dirp);
86 return r;