File: xdgmime.win32.diff

package info (click to toggle)
gnome-vfs 1:2.24.4-6.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 17,144 kB
  • ctags: 10,422
  • sloc: ansic: 78,500; sh: 10,341; makefile: 902; perl: 99
file content (400 lines) | stat: -rw-r--r-- 10,429 bytes parent folder | download | duplicates (4)
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
Index: libgnomevfs/xdgmime.c
===================================================================
--- libgnomevfs/xdgmime.c	(revision 5502)
+++ libgnomevfs/xdgmime.c	(working copy)
@@ -63,7 +63,7 @@
 XdgMimeCache **_caches = NULL;
 static int n_caches = 0;
 
-const char xdg_mime_type_unknown[] = "application/octet-stream";
+const char *xdg_mime_type_unknown = "application/octet-stream";
 
 
 enum
@@ -140,7 +140,7 @@
 
   file_name = malloc (strlen (directory) + strlen ("/mime/mime.cache") + 1);
   strcpy (file_name, directory); strcat (file_name, "/mime/mime.cache");
-  if (stat (file_name, &st) == 0)
+  if (XDG_STAT (file_name, &st) == 0)
     {
       XdgMimeCache *cache = _xdg_mime_cache_new_from_file (file_name);
 
@@ -160,7 +160,7 @@
 
   file_name = malloc (strlen (directory) + strlen ("/mime/globs2") + 1);
   strcpy (file_name, directory); strcat (file_name, "/mime/globs2");
-  if (stat (file_name, &st) == 0)
+  if (XDG_STAT (file_name, &st) == 0)
     {
       _xdg_mime_glob_read_from_file (global_hash, file_name);
       xdg_dir_time_list_add (file_name, st.st_mtime);
@@ -170,7 +170,7 @@
       free (file_name);
       file_name = malloc (strlen (directory) + strlen ("/mime/globs") + 1);
       strcpy (file_name, directory); strcat (file_name, "/mime/globs");
-      if (stat (file_name, &st) == 0)
+      if (XDG_STAT (file_name, &st) == 0)
         {
           _xdg_mime_glob_read_from_file (global_hash, file_name);
           xdg_dir_time_list_add (file_name, st.st_mtime);
@@ -183,7 +183,7 @@
 
   file_name = malloc (strlen (directory) + strlen ("/mime/magic") + 1);
   strcpy (file_name, directory); strcat (file_name, "/mime/magic");
-  if (stat (file_name, &st) == 0)
+  if (XDG_STAT (file_name, &st) == 0)
     {
       _xdg_mime_magic_read_from_file (global_magic, file_name);
       xdg_dir_time_list_add (file_name, st.st_mtime);
@@ -225,7 +225,7 @@
   const char *xdg_data_dirs;
   const char *ptr;
 
-  xdg_data_home = getenv ("XDG_DATA_HOME");
+  xdg_data_home = XDG_GETENV ("XDG_DATA_HOME");
   if (xdg_data_home)
     {
       if ((func) (xdg_data_home, user_data))
@@ -235,7 +235,7 @@
     {
       const char *home;
 
-      home = getenv ("HOME");
+      home = XDG_GET_HOME ();
       if (home != NULL)
 	{
 	  char *guessed_xdg_home;
@@ -252,9 +252,9 @@
 	}
     }
 
-  xdg_data_dirs = getenv ("XDG_DATA_DIRS");
+  xdg_data_dirs = XDG_GETENV ("XDG_DATA_DIRS");
   if (xdg_data_dirs == NULL)
-    xdg_data_dirs = "/usr/local/share/:/usr/share/";
+    xdg_data_dirs = XDG_DEFAULT_DATA_DIRS;
 
   ptr = xdg_data_dirs;
 
@@ -266,7 +266,7 @@
       int stop_processing;
 
       end_ptr = ptr;
-      while (*end_ptr != ':' && *end_ptr != '\000')
+      while (*end_ptr != XDG_SEARCHPATH_SEPARATOR && *end_ptr != '\000')
 	end_ptr ++;
 
       if (end_ptr == ptr)
@@ -275,7 +275,7 @@
 	  continue;
 	}
 
-      if (*end_ptr == ':')
+      if (*end_ptr == XDG_SEARCHPATH_SEPARATOR)
 	len = end_ptr - ptr;
       else
 	len = end_ptr - ptr + 1;
@@ -305,7 +305,7 @@
   struct stat st;
 
   /* If the file exists */
-  if (stat (file_path, &st) == 0)
+  if (XDG_STAT (file_path, &st) == 0)
     {
       XdgDirTimeList *list;
 
@@ -415,12 +415,10 @@
 static int
 xdg_check_time_and_dirs (void)
 {
-  struct timeval tv;
   time_t current_time;
   int retval = FALSE;
 
-  gettimeofday (&tv, NULL);
-  current_time = tv.tv_sec;
+  time (&current_time);
 
   if (current_time >= last_stat_time + 5)
     {
@@ -512,7 +510,7 @@
 
   if (!statbuf)
     {
-      if (stat (file_name, &buf) != 0)
+      if (XDG_STAT (file_name, &buf) != 0)
 	return XDG_MIME_TYPE_UNKNOWN;
 
       statbuf = &buf;
@@ -529,7 +527,7 @@
   if (data == NULL)
     return XDG_MIME_TYPE_UNKNOWN;
         
-  file = fopen (file_name, "r");
+  file = XDG_FOPEN (file_name, "r");
   if (file == NULL)
     {
       free (data);
Index: libgnomevfs/xdgmime.h
===================================================================
--- libgnomevfs/xdgmime.h	(revision 5502)
+++ libgnomevfs/xdgmime.h	(working copy)
@@ -76,7 +76,7 @@
 #define _xdg_mime_unalias_mime_type           XDG_RESERVED_ENTRY(unalias_mime_type)  
 #endif
 
-extern const char xdg_mime_type_unknown[];
+extern const char *xdg_mime_type_unknown;
 #define XDG_MIME_TYPE_UNKNOWN xdg_mime_type_unknown
 
 const char  *xdg_mime_get_mime_type_for_data       (const void *data,
Index: libgnomevfs/xdgmimealias.c
===================================================================
--- libgnomevfs/xdgmimealias.c	(revision 5502)
+++ libgnomevfs/xdgmimealias.c	(working copy)
@@ -35,16 +35,7 @@
 #include <stdio.h>
 #include <assert.h>
 #include <string.h>
-#include <fnmatch.h>
 
-#ifndef	FALSE
-#define	FALSE	(0)
-#endif
-
-#ifndef	TRUE
-#define	TRUE	(!FALSE)
-#endif
-
 typedef struct XdgAlias XdgAlias;
 
 struct XdgAlias 
@@ -124,7 +115,7 @@
   char line[255];
   int alloc;
 
-  file = fopen (file_name, "r");
+  file = XDG_FOPEN (file_name, "r");
 
   if (file == NULL)
     return;
Index: libgnomevfs/xdgmimecache.c
===================================================================
--- libgnomevfs/xdgmimecache.c	(revision 5502)
+++ libgnomevfs/xdgmimecache.c	(working copy)
@@ -37,12 +37,15 @@
 #include <fnmatch.h>
 #include <assert.h>
 
+#ifdef _WIN32
+#include <winsock2.h> /* for ntohl/ntohs */
+#else
 #include <netinet/in.h> /* for ntohl/ntohs */
+#endif
 
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #else
-#warning Building xdgmime without MMAP support. Binary "mime.info" cache files will not be used.
 #endif
 
 #include <sys/stat.h>
@@ -688,7 +692,7 @@
 
   if (!statbuf)
     {
-      if (stat (file_name, &buf) != 0)
+      if (XDG_STAT (file_name, &buf) != 0)
 	return XDG_MIME_TYPE_UNKNOWN;
 
       statbuf = &buf;
@@ -705,7 +709,7 @@
   if (data == NULL)
     return XDG_MIME_TYPE_UNKNOWN;
         
-  file = fopen (file_name, "r");
+  file = XDG_FOPEN (file_name, "r");
   if (file == NULL)
     {
       free (data);
Index: libgnomevfs/xdgmimeglob.c
===================================================================
--- libgnomevfs/xdgmimeglob.c	(revision 5502)
+++ libgnomevfs/xdgmimeglob.c	(working copy)
@@ -37,14 +37,6 @@
 #include <string.h>
 #include <fnmatch.h>
 
-#ifndef	FALSE
-#define	FALSE	(0)
-#endif
-
-#ifndef	TRUE
-#define	TRUE	(!FALSE)
-#endif
-
 typedef struct XdgGlobHashNode XdgGlobHashNode;
 typedef struct XdgGlobList XdgGlobList;
 
@@ -562,7 +554,7 @@
   FILE *glob_file;
   char line[255];
 
-  glob_file = fopen (file_name, "r");
+  glob_file = XDG_FOPEN (file_name, "r");
 
   if (glob_file == NULL)
     return;
Index: libgnomevfs/xdgmimeint.c
===================================================================
--- libgnomevfs/xdgmimeint.c	(revision 5502)
+++ libgnomevfs/xdgmimeint.c	(working copy)
@@ -33,14 +33,6 @@
 #include <ctype.h>
 #include <string.h>
 
-#ifndef	FALSE
-#define	FALSE	(0)
-#endif
-
-#ifndef	TRUE
-#define	TRUE	(!FALSE)
-#endif
-
 static const char _xdg_utf8_skip_data[256] = {
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@@ -52,7 +44,7 @@
   3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
 };
 
-const char * const _xdg_utf8_skip = _xdg_utf8_skip_data;
+const char *_xdg_utf8_skip = _xdg_utf8_skip_data;
 
 
 
@@ -153,6 +145,23 @@
     return base_name + 1;
 }
 
+#ifdef USE_GLIB
+
+const char *
+_xdg_get_default_data_dirs (void)
+{
+  GQuark quark;
+  const char * const *dirs = g_get_system_data_dirs ();
+  char *string = g_strjoinv (G_SEARCHPATH_SEPARATOR_S, (char **) dirs);
+
+  quark = g_quark_from_string (string);
+  g_free (string);
+
+  return g_quark_to_string (quark);
+}
+
+#endif
+
 xdg_unichar_t *
 _xdg_convert_to_ucs4 (const char *source, int *len)
 {
Index: libgnomevfs/xdgmimeint.h
===================================================================
--- libgnomevfs/xdgmimeint.h	(revision 5502)
+++ libgnomevfs/xdgmimeint.h	(working copy)
@@ -63,7 +63,7 @@
 					      (((xdg_uint32_t)(val) & 0x000000FFU) << 24))
 /* UTF-8 utils
  */
-extern const char *const _xdg_utf8_skip;
+extern const char *_xdg_utf8_skip;
 #define _xdg_utf8_next_char(p) (char *)((p) + _xdg_utf8_skip[*(unsigned char *)(p)])
 #define _xdg_utf8_char_size(p) (int) (_xdg_utf8_skip[*(unsigned char *)(p)])
 
@@ -74,4 +74,28 @@
 void           _xdg_reverse_ucs4 (xdg_unichar_t *source, int len);
 const char    *_xdg_get_base_name (const char    *file_name);
 
+#if defined (G_OS_WIN32) && defined (GNOME_VFS_PREFIX)
+/* If building as part of gnome-vfs on Win32 */
+#define USE_GLIB
+#endif
+
+#ifdef USE_GLIB
+#include <glib.h>
+#include <glib/gstdio.h>
+#define XDG_GETENV g_getenv
+#define XDG_STAT g_stat
+#define XDG_FOPEN g_fopen
+#define XDG_GET_HOME() g_get_home_dir ()
+const char *_xdg_get_default_data_dirs (void);
+#define XDG_DEFAULT_DATA_DIRS _xdg_get_default_data_dirs ()
+#define XDG_SEARCHPATH_SEPARATOR G_SEARCHPATH_SEPARATOR
+#else
+#define XDG_GETENV getenv
+#define XDG_STAT stat
+#define XDG_FOPEN fopen
+#define XDG_GET_HOME() getenv ("HOME")
+#define XDG_DEFAULT_DATA_DIRS "/usr/local/share/:/usr/share/"
+#define XDG_SEARCHPATH_SEPARATOR ':'
+#endif
+
 #endif /* __XDG_MIME_INT_H__ */
Index: libgnomevfs/xdgmimemagic.c
===================================================================
--- libgnomevfs/xdgmimemagic.c	(revision 5502)
+++ libgnomevfs/xdgmimemagic.c	(working copy)
@@ -39,12 +39,12 @@
 #include <errno.h>
 #include <limits.h>
 
-#ifndef	FALSE
-#define	FALSE	(0)
+#ifdef _WIN32
+#define LITTLE_ENDIAN 1
 #endif
 
-#ifndef	TRUE
-#define	TRUE	(!FALSE)
+#ifndef _WIN32
+extern int errno;
 #endif
 
 #if !defined getc_unlocked && !defined HAVE_GETC_UNLOCKED
@@ -798,7 +798,7 @@
   FILE *magic_file;
   char header[12];
 
-  magic_file = fopen (file_name, "r");
+  magic_file = XDG_FOPEN (file_name, "r");
 
   if (magic_file == NULL)
     return;
Index: libgnomevfs/xdgmimeparent.c
===================================================================
--- libgnomevfs/xdgmimeparent.c	(revision 5502)
+++ libgnomevfs/xdgmimeparent.c	(working copy)
@@ -37,14 +37,6 @@
 #include <string.h>
 #include <fnmatch.h>
 
-#ifndef	FALSE
-#define	FALSE	(0)
-#endif
-
-#ifndef	TRUE
-#define	TRUE	(!FALSE)
-#endif
-
 typedef struct XdgMimeParents XdgMimeParents;
 
 struct XdgMimeParents
@@ -130,7 +122,7 @@
   int i, alloc;
   XdgMimeParents *entry;
 
-  file = fopen (file_name, "r");
+  file = XDG_FOPEN (file_name, "r");
 
   if (file == NULL)
     return;