Index: configure.ac =================================================================== --- configure.ac (revision 738) +++ configure.ac (working copy) @@ -263,6 +263,27 @@ #################################################################### +# Windows check +#################################################################### + +AC_MSG_CHECKING(for WIN32) +AC_TRY_COMPILE(, + [ + #ifndef WIN32 + #error + #endif + ], + native_win32=yes; AC_MSG_RESULT(yes), + native_win32=no; AC_MSG_RESULT(no), +) + +AM_CONDITIONAL(OS_WIN32, test "$native_win32" = "yes") + +if test "$native_win32" = "yes" ; then + AC_DEFINE(OS_WIN32, 1, [Define if we are on win32]) +fi + +#################################################################### # External SQLite check #################################################################### @@ -366,7 +387,7 @@ if test "x$enable_file_monitoring" = "xauto"; then if test "$inotify_support" = "yes"; then - primary_backend=inotify + primary_backend="inotify" if test "$inotify_linux" = "yes"; then inotify_header="linux/inotify.h" else @@ -380,7 +401,11 @@ primary_backend="fam" fi else - primary_backend="polling only" + if test "$native_win32" = "yes"; then + primary_backend="win32" + else + primary_backend="polling only" + fi fi elif test "x$enable_file_monitoring" = "xinotify"; then if test "$inotify_support" = "no"; then @@ -404,7 +429,11 @@ fi fi else - primary_backend="polling only" + if test "$native_win32" = "yes"; then + primary_backend="win32" + else + primary_backend="polling only" + fi fi if test "$primary_backend" = "inotify"; then @@ -737,6 +766,7 @@ file monitor backend to be used: $primary_backend inotify header location: $inotify_header ioprio support: $ioprio_support + Win32: $native_win32 unac accent stripper support: $enable_unac deskbar-applet support: $enable_deskbar_applet build search tool (GNOME): $have_gnome Index: src/libtracker/Makefile.am =================================================================== --- src/libtracker/Makefile.am (revision 738) +++ src/libtracker/Makefile.am (working copy) @@ -1,5 +1,5 @@ INCLUDES = \ - -DDATADIR=\""$(datadir)"\" \ + -DTRACKER_DATADIR=\""$(datadir)"\" \ -DTRACKER_LOCALEDIR=\""$(localedir)"\" \ $(GLIB2_CFLAGS) \ $(DBUS_CFLAGS) Index: src/libtracker/tracker-query.c =================================================================== --- src/libtracker/tracker-query.c (revision 738) +++ src/libtracker/tracker-query.c (working copy) @@ -26,6 +26,11 @@ #include "../libtracker/tracker.h" +#include +#ifdef OS_WIN32 +#include "../trackerd/mingw-compat.h" +#endif + static gchar *search = NULL; static gchar **fields = NULL; static gchar *service = NULL; Index: src/libtracker/tracker-tag.c =================================================================== --- src/libtracker/tracker-tag.c (revision 738) +++ src/libtracker/tracker-tag.c (working copy) @@ -26,6 +26,10 @@ #include "../libtracker/tracker.h" +#ifdef OS_WIN32 +#include "../trackerd/mingw-compat.h" +#endif + static gchar **add = NULL; static gchar **delete = NULL; static gchar **search = NULL; Index: src/sqlite3/Makefile.am =================================================================== --- src/sqlite3/Makefile.am (revision 738) +++ src/sqlite3/Makefile.am (working copy) @@ -1,5 +1,13 @@ +if OS_WIN32 +SQLITE_OS = -DOS_WIN=1 +libsqlite_private_la_LIBADD = -lpthreadGC2 +else +SQLITE_OS = -DOS_UNIX=1 +libsqlite_private_la_LIBADD = -lpthread +endif + INCLUDES = \ - -DOS_UNIX=1 \ + $(SQLITE_OS) \ -DHAVE_USLEEP=1 \ -DHAVE_FDATASYNC=1 \ -DNDEBUG \ @@ -10,9 +18,7 @@ noinst_LTLIBRARIES=libsqlite-private.la -libsqlite_private_la_LIBADD = -lpthread - libsqlite_private_la_SOURCES = \ sqlite3.h \ sqlite3ext.h \ Index: src/tracker-extract/tracker-extract-mp3.c =================================================================== --- src/tracker-extract/tracker-extract-mp3.c (revision 738) +++ src/tracker-extract/tracker-extract-mp3.c (working copy) @@ -21,7 +21,9 @@ #include #include +#ifndef OS_WIN32 #include +#endif #include #include #include @@ -966,8 +968,6 @@ } - - void tracker_extract_mp3 (const char *filename, GHashTable *metadata) { @@ -1005,7 +1005,9 @@ } //g_print ("file size is %d\n", size); +#ifndef OS_WIN32 buffer = mmap (NULL, size, PROT_READ, MAP_PRIVATE, file, 0); +#endif if ((buffer == NULL) || (buffer == (void *) -1)) { //g_print ("mmap failure\n"); @@ -1060,7 +1062,9 @@ mp3_parse (buffer, size, metadata); +#ifndef OS_WIN32 munmap (buffer, size); +#endif close(file); } Index: src/tracker-extract/tracker-extract.c =================================================================== --- src/tracker-extract/tracker-extract.c (revision 738) +++ src/tracker-extract/tracker-extract.c (working copy) @@ -18,17 +18,19 @@ * Boston, MA 02110-1301, USA. */ +#include "config.h" + #include #include #include #include +#ifndef OS_WIN32 #include +#endif #include #include #include -#include "config.h" - #define MAX_MEM 128 #define MAX_MEM_AMD64 512 @@ -171,6 +173,7 @@ static gboolean set_memory_rlimits (void) { +#ifndef OS_WIN32 struct rlimit rl; gint fail = 0; @@ -197,12 +200,14 @@ } return !fail; +#endif } void tracker_child_cb (gpointer user_data) { +#ifndef OS_WIN32 struct rlimit mem_limit, cpu_limit; gint timeout = GPOINTER_TO_INT (user_data); @@ -219,6 +224,7 @@ /* Set child's niceness to 19 */ nice (19); +#endif } Index: src/tracker-search-tool/Makefile.am =================================================================== --- src/tracker-search-tool/Makefile.am (revision 738) +++ src/tracker-search-tool/Makefile.am (working copy) @@ -12,7 +12,7 @@ $(DBUS_CFLAGS) \ -DG_DISABLE_DEPRECATED \ -DTRACKER_LOCALEDIR=\""$(localedir)"\" \ - -DDATADIR=\""$(datadir)"\" \ + -DTRACKER_DATADIR=\""$(datadir)"\" \ -DGREP_COMMAND=\""$(GREP_COMMAND)"\" \ $(LIBTRACKERGTK_CFLAGS) \ -I$(top_srcdir)/src/libtracker Index: src/tracker-search-tool/tracker-search-tool.c =================================================================== --- src/tracker-search-tool/tracker-search-tool.c (revision 738) +++ src/tracker-search-tool/tracker-search-tool.c (working copy) @@ -2332,7 +2332,7 @@ { gchar * path; - path = g_build_filename (DATADIR "/pixmaps/tracker", partial_path, NULL); + path = g_build_filename (TRACKER_DATADIR "/pixmaps/tracker", partial_path, NULL); if (g_file_test (path, G_FILE_TEST_EXISTS)) { return path; } else { @@ -2371,7 +2371,7 @@ VERSION, LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_APP_DATADIR, DATADIR, + GNOME_PARAM_APP_DATADIR, TRACKER_DATADIR, GNOME_PARAM_GOPTION_CONTEXT, option_context, GNOME_PARAM_NONE); Index: src/tracker-thumbnailer/tracker-thumbnailer.c =================================================================== --- src/tracker-thumbnailer/tracker-thumbnailer.c (revision 738) +++ src/tracker-thumbnailer/tracker-thumbnailer.c (working copy) @@ -19,8 +19,8 @@ * Boston, MA 02110-1301, USA. */ +#include "config.h" - #include #include #include @@ -31,6 +31,14 @@ #include #include "md5.h" +#ifdef OS_WIN32 +#include + +#define _fullpath_internal(res,path,size) \ + (GetFullPathName ((path), (size), (res), NULL) ? (res) : NULL) +#define realpath(path,resolved_path) _fullpath_internal(resolved_path, path, MAX_PATH) +#endif + #ifndef LIBDIR #define LIBDIR "/usr/lib" #endif Index: src/trackerd/Makefile.am =================================================================== --- src/trackerd/Makefile.am (revision 738) +++ src/trackerd/Makefile.am (working copy) @@ -1,5 +1,5 @@ INCLUDES = \ - -DDATADIR=\""$(datadir)"\" \ + -DTRACKER_DATADIR=\""$(datadir)"\" \ -DLIBDIR=\""$(libdir)"\" \ -DTRACKER_LOCALEDIR=\""$(localedir)"\" \ $(GLIB2_CFLAGS) \ @@ -25,6 +25,15 @@ endif endif +if OS_WIN32 +win_sources = \ + tracker-win-fs-changes.c \ + tracker-win-fs-changes.h \ + tracker-os-dependant-win.c +else +unix_sources = \ + tracker-os-dependant-unix.c +endif db_sources = \ tracker-indexer.c \ @@ -43,6 +52,8 @@ trackerd.c \ $(inotify_sources) \ $(fam_sources) \ + $(win_sources) \ + $(unix_sources) \ $(db_sources) \ tracker-apps.c \ tracker-apps.h \ @@ -81,6 +92,9 @@ tracker-ioprio.c \ tracker-ioprio.h +if OS_WIN32 +trackerd_win_libs = -lws2_32 -lkernel32 +endif trackerd_LDADD = \ $(GLIB2_LIBS) \ @@ -95,4 +109,5 @@ -lz \ -lm \ $(top_builddir)/src/libstemmer/libstemmer-private.la \ - $(top_builddir)/src/xdgmime/libxdgmime.la + $(top_builddir)/src/xdgmime/libxdgmime.la \ + $(trackerd_win_libs) Index: src/trackerd/mingw-compat.h =================================================================== --- src/trackerd/mingw-compat.h (revision 0) +++ src/trackerd/mingw-compat.h (revision 0) @@ -0,0 +1,109 @@ +#ifndef MINGW_COMPAT_H +#define MINGW_COMPAT_H + +#include + +#define _fullpath_internal(res,path,size) \ + (GetFullPathName ((path), (size), (res), NULL) ? (res) : NULL) + +#define realpath(path,resolved_path) _fullpath_internal(resolved_path, path, MAX_PATH) + +#define getc_unlocked(s) getc(s) + +#define RLIMIT_CPU 0 /* CPU time in seconds */ +#define RLIMIT_AS 6 /* address space (virt. memory) limit */ +typedef unsigned long rlim_t; + +struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; +}; + +#define localtime_r( _clock, _result ) \ + ( *(_result) = *localtime( (_clock) ), \ + (_result) ) + +#include +#include +#include + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ + }; + +static int gettimeofday (struct timeval *tv, struct timezone *tz) +{ + struct _timeb tb; + + if (!tv) + return (-1); + + _ftime (&tb); + tv->tv_sec = tb.time; + tv->tv_usec = tb.millitm * 1000 + 500; + if (tz) + { + tz->tz_minuteswest = -60 * _timezone; + tz->tz_dsttime = _daylight; + } + return (0); +} + +// Does not exist in a windows filesystem +#define S_IFLNK 0 +#define S_IFSOCK 0 +#define S_ISVTX 0 +#define S_ISLNK(X) 0 +#define S_ISUID 0 +#define S_ISGID 0 +#define S_ISGRP 0 +#define S_IXOTH 0 +#define S_IXGRP 0 + +#define link(from, to) 0 + +#define _LK_UNLCK 0 /* Unlock */ +#define _LK_LOCK 1 /* Lock */ +#define _LK_NBLCK 2 /* Non-blocking lock */ +#define _LK_RLCK 3 /* Lock for read only */ +#define _LK_NBRLCK 4 /* Non-blocking lock for read only */ + +#define F_TLOCK _LK_NBLCK /* Test and lock a section for exclusive use */ + +#ifndef SIGHUP +#define SIGHUP 1 /* hangup */ +#endif +#ifndef SIGBUS +#define SIGBUS 7 /* bus error */ +#endif +#ifndef SIGKILL +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#endif +#ifndef SIGSEGV +#define SIGSEGV 11 /* segment violation */ +#endif +#ifndef SIGPIPE +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#endif +#ifndef SIGCHLD +#define SIGCHLD 20 /* to parent on child stop or exit */ +#endif +#ifndef SIGUSR1 +#define SIGUSR1 30 /* user defined signal 1 */ +#endif +#ifndef SIGUSR2 +#define SIGUSR2 31 /* user defined signal 2 */ +#endif + +#define sigemptyset(pset) (*(pset) = 0) +#define sigfillset(pset) (*(pset) = (unsigned int)-1) +#define sigaddset(pset, num) (*(pset) |= (1L<<(num))) +#define sigdelset(pset, num) (*(pset) &= ~(1L<<(num))) +#define sigismember(pset, num) (*(pset) & (1L<<(num))) + +#define lockf _locking + +#define nice(nice_level) 0 + +#endif Index: src/trackerd/tracker-db-mysql.c =================================================================== --- src/trackerd/tracker-db-mysql.c (revision 738) +++ src/trackerd/tracker-db-mysql.c (working copy) @@ -219,7 +219,7 @@ char *str, *str_in_uft8; - str = g_strdup (DATADIR "/tracker/english"); + str = g_strdup (TRACKER_DATADIR "/tracker/english"); str_in_uft8 = g_filename_to_utf8 (str, -1, NULL, NULL, NULL); @@ -243,7 +243,7 @@ server_options[6] = "--character-set-server=utf8"; server_options[7] = "--ft_max_word_len=45"; server_options[8] = "--ft_min_word_len=3"; - server_options[9] = "--ft_stopword_file=" DATADIR "/tracker/tracker-stop-words.txt"; + server_options[9] = "--ft_stopword_file=" TRACKER_DATADIR "/tracker/tracker-stop-words.txt"; server_options[10] = g_strconcat ("--language=", str, NULL); @@ -939,7 +939,7 @@ db_con = db_connect ("mysql"); - sql_file = g_strdup (DATADIR "/tracker/mysql-system.sql"); + sql_file = g_strdup (TRACKER_DATADIR "/tracker/mysql-system.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); @@ -973,7 +973,7 @@ tracker_log ("Creating stored procedures..."); - sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql"); + sql_file = g_strdup (TRACKER_DATADIR "/tracker/mysql-stored-procs.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); @@ -1015,7 +1015,7 @@ mysql_close (db_con->db); db_con = db_connect ("tracker"); - sql_file = g_strdup (DATADIR "/tracker/mysql-tracker.sql"); + sql_file = g_strdup (TRACKER_DATADIR "/tracker/mysql-tracker.sql"); tracker_log ("Creating tables..."); @@ -1165,7 +1165,7 @@ i++; - sql_file = g_strconcat (DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); + sql_file = g_strconcat (TRACKER_DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); tracker_log ("Please wait while database is being updated to the latest version"); @@ -1190,7 +1190,7 @@ /* regenerate SPs */ tracker_log ("Creating stored procedures..."); - sql_file = g_strdup (DATADIR "/tracker/mysql-stored-procs.sql"); + sql_file = g_strdup (TRACKER_DATADIR "/tracker/mysql-stored-procs.sql"); if (!g_file_get_contents (sql_file, &query, NULL, NULL)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); Index: src/trackerd/tracker-db-sqlite.c =================================================================== --- src/trackerd/tracker-db-sqlite.c (revision 738) +++ src/trackerd/tracker-db-sqlite.c (working copy) @@ -34,6 +34,12 @@ #include "tracker-indexer.h" #include "tracker-metadata.h" +#include "config.h" + +#ifdef OS_WIN32 +#include "mingw-compat.h" +#endif + extern Tracker *tracker; static GHashTable *prepared_queries; @@ -219,7 +225,7 @@ { char *filename, *query; - filename = g_build_filename (DATADIR, "/tracker/", sql_file, NULL); + filename = g_build_filename (TRACKER_DATADIR, "/tracker/", sql_file, NULL); if (!g_file_get_contents (filename, &query, NULL, NULL)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); @@ -246,7 +252,7 @@ { char *filename, *query; - filename = g_build_filename (DATADIR, "/tracker/", sql_file, NULL); + filename = g_build_filename (TRACKER_DATADIR, "/tracker/", sql_file, NULL); if (!g_file_get_contents (filename, &query, NULL, NULL)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); @@ -443,7 +449,7 @@ tracker_log ("Loading prepared queries..."); - sql_file = g_strdup (DATADIR "/tracker/sqlite-stored-procs.sql"); + sql_file = g_strdup (TRACKER_DATADIR "/tracker/sqlite-stored-procs.sql"); if (!g_file_test (sql_file, G_FILE_TEST_EXISTS)) { tracker_error ("ERROR: Tracker cannot read required file %s - Please reinstall tracker or check read permissions on the file if it exists", sql_file); @@ -1952,7 +1958,7 @@ i++; - sql_file = g_strconcat (DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); + sql_file = g_strconcat (TRACKER_DATADIR, "/tracker/tracker-db-table-update", version, ".sql", NULL); tracker_log ("Please wait while database is being updated to the latest version"); Index: src/trackerd/tracker-db.c =================================================================== --- src/trackerd/tracker-db.c (revision 738) +++ src/trackerd/tracker-db.c (working copy) @@ -27,6 +27,7 @@ #include "tracker-db.h" #include "tracker-email.h" #include "tracker-metadata.h" +#include "tracker-os-dependant.h" extern Tracker *tracker; @@ -50,8 +51,7 @@ gint32 index_time; g_return_val_if_fail (db_con, FALSE); - g_return_val_if_fail (uri, FALSE); - g_return_val_if_fail (uri[0] != '/', FALSE); + g_return_val_if_fail (check_uri(uri), FALSE); if (uri[0] == G_DIR_SEPARATOR) { name = g_path_get_basename (uri); @@ -431,8 +431,7 @@ { char *str_file_id, *str_action, *str_counter; - g_return_if_fail (uri); - g_return_if_fail (uri[0] == '/'); + g_return_if_fail (check_uri(uri)); str_file_id = tracker_uint_to_str ( file_id); str_action = tracker_int_to_str (action); @@ -498,8 +497,7 @@ { char *str_counter, *str_action; - g_return_if_fail (uri); - g_return_if_fail (uri[0] == '/'); + g_return_if_fail (check_uri(uri)); str_counter = tracker_int_to_str (counter); str_action = tracker_int_to_str (action); @@ -519,8 +517,7 @@ int i; g_return_if_fail (info); - g_return_if_fail (info->uri); - g_return_if_fail (info->uri[0] == '/'); + g_return_if_fail (check_uri(info->uri)); i = g_async_queue_length (tracker->file_metadata_queue); @@ -544,8 +541,7 @@ { FileInfo *info; - g_return_if_fail (uri); - g_return_if_fail (uri[0] == '/'); + g_return_if_fail (check_uri(uri)); /* if a check action then then discard if up to date if (action == TRACKER_ACTION_CHECK || action == TRACKER_ACTION_FILE_CHECK || action == TRACKER_ACTION_DIRECTORY_CHECK) { Index: src/trackerd/tracker-dbus-methods.c =================================================================== --- src/trackerd/tracker-dbus-methods.c (revision 738) +++ src/trackerd/tracker-dbus-methods.c (working copy) @@ -24,7 +24,12 @@ #include "tracker-metadata.h" #include "tracker-rdf-query.h" +#include "config.h" +#ifdef OS_WIN32 +#include "mingw-compat.h" +#endif + void tracker_set_error (DBusRec *rec, const char *fmt, Index: src/trackerd/tracker-dbus-search.c =================================================================== --- src/trackerd/tracker-dbus-search.c (revision 738) +++ src/trackerd/tracker-dbus-search.c (working copy) @@ -809,7 +809,7 @@ { char n, m; - uint l; + int l; l = strlen (source); if (l > 50) return -1; Index: src/trackerd/tracker-indexer.c =================================================================== --- src/trackerd/tracker-indexer.c (revision 738) +++ src/trackerd/tracker-indexer.c (working copy) @@ -26,7 +26,7 @@ #define INDEXFBP 32 /* size of free block pool of inverted index */ -static gboolean shutdown; +static gboolean tracker_shutdown; static inline guint16 @@ -188,7 +188,7 @@ CURIA *word_index; Indexer *result; - shutdown = FALSE; + tracker_shutdown = FALSE; word_dir = g_build_filename (tracker->data_dir, name, NULL); @@ -241,7 +241,7 @@ { g_return_if_fail (indexer); - shutdown = TRUE; + tracker_shutdown = TRUE; g_mutex_lock (indexer->word_mutex); @@ -259,7 +259,7 @@ void tracker_indexer_sync (Indexer *indexer) { - if (shutdown) { + if (tracker_shutdown) { return; } @@ -274,7 +274,7 @@ { int num, b_count; - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -320,7 +320,7 @@ gboolean tracker_indexer_append_word_chunk (Indexer *indexer, const char *word, WordDetails *details, int word_detail_count) { - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -346,7 +346,7 @@ gboolean tracker_indexer_append_word (Indexer *indexer, const char *word, guint32 id, int service, int score) { - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -377,7 +377,7 @@ int tsiz; char *tmp; - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -446,7 +446,7 @@ int tsiz; char *tmp; - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -617,7 +617,7 @@ /* some results might be dud so get an extra 50 to compensate */ int limit = query->limit + 50; - if (shutdown) { + if (tracker_shutdown) { return NULL; } @@ -691,7 +691,7 @@ char *tmp; GHashTable *result; - if (shutdown) { + if (tracker_shutdown) { return NULL; } @@ -775,7 +775,7 @@ rnum = 0; list = NULL; - if (shutdown) { + if (tracker_shutdown) { return NULL; } @@ -876,7 +876,7 @@ SearchWord *word; GSList *lst; - if (shutdown) { + if (tracker_shutdown) { return FALSE; } @@ -990,7 +990,7 @@ GHashTable *table = g_hash_table_new (NULL, NULL); - if (shutdown) { + if (tracker_shutdown) { return NULL; } Index: src/trackerd/tracker-ioprio.c =================================================================== --- src/trackerd/tracker-ioprio.c (revision 738) +++ src/trackerd/tracker-ioprio.c (working copy) @@ -17,6 +17,10 @@ * Boston, MA 02110-1301, USA. */ +#include "config.h" + +#ifdef IOPRIO_SUPPORT + #include #include #include @@ -25,8 +29,6 @@ #include #include "tracker-ioprio.h" -#ifdef IOPRIO_SUPPORT - enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, Index: src/trackerd/tracker-metadata.c =================================================================== --- src/trackerd/tracker-metadata.c (revision 738) +++ src/trackerd/tracker-metadata.c (working copy) @@ -21,7 +21,12 @@ #include #include #include +#include "config.h" +#ifdef OS_WIN32 +#include +#else #include +#endif #include "tracker-metadata.h" #include "tracker-utils.h" @@ -261,7 +266,11 @@ tmp = g_strdup (LIBDIR "/tracker/filters/"); +#ifdef OS_WIN32 + text_filter_file = g_strconcat (tmp, mime, "_filter.bat", NULL); +#else text_filter_file = g_strconcat (tmp, mime, "_filter", NULL); +#endif g_free (tmp); } Index: src/trackerd/tracker-os-dependant-unix.c =================================================================== --- src/trackerd/tracker-os-dependant-unix.c (revision 0) +++ src/trackerd/tracker-os-dependant-unix.c (revision 0) @@ -0,0 +1,95 @@ +#include "tracker-os-dependant.h" + +#include + +#include +#include + +gboolean +check_uri(const char* uri) +{ + return uri != NULL && uri[0] != G_DIR_SEPARATOR_S; +} + +gboolean +tracker_spawn (char **argv, int timeout, char **tmp_stdout, int *exit_status) +{ + GSpawnFlags flags; + + if (!tmp_stdout) { + flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL; + } else { + flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL; + } + + return g_spawn_sync (NULL, + argv, + NULL, + flags, + tracker_child_cb, + GINT_TO_POINTER (timeout), + tmp_stdout, + NULL, + exit_status, + NULL); +} + +char *create_permission_string(struct stat finfo) +{ + char *str; + int n, bit; + + /* create permissions string */ + str = g_strdup ("?rwxrwxrwx"); + + switch (finfo.st_mode & S_IFMT) { + case S_IFSOCK: str[0] = 's'; break; + case S_IFIFO: str[0] = 'p'; break; + case S_IFLNK: str[0] = 'l'; break; + case S_IFCHR: str[0] = 'c'; break; + case S_IFBLK: str[0] = 'b'; break; + case S_IFDIR: str[0] = 'd'; break; + case S_IFREG: str[0] = '-'; break; + } + + for (bit = 0400, n = 1 ; bit ; bit >>= 1, ++n) { + if (!(finfo.st_mode & bit)) { + str[n] = '-'; + } + } + + if (finfo.st_mode & S_ISUID) { + str[3] = (finfo.st_mode & S_IXUSR) ? 's' : 'S'; + } + + if (finfo.st_mode & S_ISGID) { + str[6] = (finfo.st_mode & S_IXGRP) ? 's' : 'S'; + } + + if (finfo.st_mode & S_ISVTX) { + str[9] = (finfo.st_mode & S_IXOTH) ? 't' : 'T'; + } + + return str; +} + +void +tracker_child_cb (gpointer user_data) +{ + struct rlimit mem_limit, cpu_limit; + int timeout = GPOINTER_TO_INT (user_data); + + /* set cpu limit */ + getrlimit (RLIMIT_CPU, &cpu_limit); + cpu_limit.rlim_cur = timeout; + cpu_limit.rlim_max = timeout+1; + + if (setrlimit (RLIMIT_CPU, &cpu_limit) != 0) { + tracker_error ("ERROR: trying to set resource limit for cpu"); + } + + set_memory_rlimits(); + + /* Set child's niceness to 19 */ + nice (19); +} Index: src/trackerd/tracker-os-dependant-win.c =================================================================== --- src/trackerd/tracker-os-dependant-win.c (revision 0) +++ src/trackerd/tracker-os-dependant-win.c (revision 0) @@ -0,0 +1,96 @@ +#include "tracker-os-dependant.h" + +#include +#include + +#include "mingw-compat.h" + +gboolean +check_uri(const char* uri) +{ + return uri != NULL; +} + +gboolean +tracker_spawn (char **argv, int timeout, char **tmp_stdout, int *exit_status) +{ + int length; + + int i = 0; + while (argv[i] != NULL) + ++i; + + length = i; + + char *new_argv[length+3]; + + new_argv[0] = "cmd.exe"; + new_argv[1] = "/c"; + + i = 0; + while (argv[i] != NULL) { + new_argv[i+2] = argv[i]; + ++i; + } + new_argv[i+2] = NULL; + + GSpawnFlags flags; + GError *error = NULL; + + if (!tmp_stdout) { + flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL; + } else { + flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL; + } + + gboolean status = g_spawn_sync (NULL, + new_argv, + NULL, + flags, + NULL, + GINT_TO_POINTER (timeout), + tmp_stdout, + NULL, + exit_status, + &error); + + if (!status) { + tracker_log(error->message); + g_error_free(error); + } + + return status; +} + +char *create_permission_string(struct stat finfo) +{ + char *str; + int n, bit; + + /* create permissions string */ + str = g_strdup ("?rwxrwxrwx"); + + for (bit = 0400, n = 1 ; bit ; bit >>= 1, ++n) { + if (!(finfo.st_mode & bit)) { + str[n] = '-'; + } + } + + if (finfo.st_mode & S_ISUID) { + str[3] = (finfo.st_mode & S_IXUSR) ? 's' : 'S'; + } + + if (finfo.st_mode & S_ISGID) { + str[6] = (finfo.st_mode & S_IXGRP) ? 's' : 'S'; + } + + if (finfo.st_mode & S_ISVTX) { + str[9] = (finfo.st_mode & S_IXOTH) ? 't' : 'T'; + } + + return str; +} + +void +tracker_child_cb (gpointer user_data) +{} Index: src/trackerd/tracker-os-dependant.h =================================================================== --- src/trackerd/tracker-os-dependant.h (revision 0) +++ src/trackerd/tracker-os-dependant.h (revision 0) @@ -0,0 +1,11 @@ +#ifndef _TRACKER_OS_DEPENDANT_H_ +#define _TRACKER_OS_DEPENDANT_H_ + +#include + +gboolean check_uri(const char* uri); +gboolean tracker_spawn (char **argv, int timeout, char **tmp_stdout, int *exit_status); +void tracker_child_cb (gpointer user_data); +char *create_permission_string(struct stat finfo); + +#endif Index: src/trackerd/tracker-utils.c =================================================================== --- src/trackerd/tracker-utils.c (revision 738) +++ src/trackerd/tracker-utils.c (working copy) @@ -17,6 +17,8 @@ * Boston, MA 02110-1301, USA. */ +#include "config.h" + #include #include #include @@ -25,9 +27,7 @@ #include #include #include -#include #include -#include #include #include "tracker-dbus.h" #include "tracker-utils.h" @@ -35,6 +35,15 @@ #include "tracker-stemmer.h" #include "../xdgmime/xdgmime.h" +#include "tracker-os-dependant.h" + +#ifdef OS_WIN32 +#include +#include "mingw-compat.h" +#else +#include +#endif + extern Tracker *tracker; char *tracker_actions[] = { @@ -1062,7 +1071,7 @@ { GSList *lst; - if (!uri || uri[0] != '/') { + if (!check_uri(uri)) { return TRUE; } @@ -1366,8 +1375,7 @@ tracker_get_file_info (FileInfo *info) { struct stat finfo; - char *uri_in_locale, *str; - int n, bit; + char *str, *uri_in_locale; if (!info || !info->uri) { return info; @@ -1415,39 +1423,8 @@ } } - /* create permissions string */ - str = g_strdup ("?rwxrwxrwx"); - - switch (finfo.st_mode & S_IFMT) { - case S_IFSOCK: str[0] = 's'; break; - case S_IFIFO: str[0] = 'p'; break; - case S_IFLNK: str[0] = 'l'; break; - case S_IFCHR: str[0] = 'c'; break; - case S_IFBLK: str[0] = 'b'; break; - case S_IFDIR: str[0] = 'd'; break; - case S_IFREG: str[0] = '-'; break; - } - - for (bit = 0400, n = 1 ; bit ; bit >>= 1, ++n) { - if (!(finfo.st_mode & bit)) { - str[n] = '-'; - } - } - - if (finfo.st_mode & S_ISUID) { - str[3] = (finfo.st_mode & S_IXUSR) ? 's' : 'S'; - } - - if (finfo.st_mode & S_ISGID) { - str[6] = (finfo.st_mode & S_IXGRP) ? 's' : 'S'; - } - - if (finfo.st_mode & S_ISVTX) { - str[9] = (finfo.st_mode & S_IXOTH) ? 't' : 'T'; - } - g_free (info->permissions); - info->permissions = str; + info->permissions = create_permission_string(finfo); info->mtime = finfo.st_mtime; info->atime = finfo.st_atime; @@ -1687,6 +1664,7 @@ g_lstat (uri_in_locale, &finfo); if (S_ISLNK (finfo.st_mode) && S_ISDIR (finfo.st_mode)) { + g_free (uri_in_locale); return g_strdup ("symlink"); } @@ -2234,7 +2212,7 @@ char *stopword_path, *stopword_file; char *stopwords; - stopword_path = g_build_filename (DATADIR, "tracker", "languages", "stopwords", NULL); + stopword_path = g_build_filename (TRACKER_DATADIR, "tracker", "languages", "stopwords", NULL); stopword_file = g_strconcat (stopword_path, ".", language, NULL); g_free (stopword_path); @@ -3396,6 +3374,7 @@ gboolean set_memory_rlimits (void) { +#ifndef OS_WIN32 struct rlimit rl; gboolean fail = FALSE; @@ -3422,56 +3401,10 @@ } return !fail; +#endif } - -void -tracker_child_cb (gpointer user_data) -{ - struct rlimit cpu_limit; - int timeout = GPOINTER_TO_INT (user_data); - - /* set cpu limit */ - getrlimit (RLIMIT_CPU, &cpu_limit); - cpu_limit.rlim_cur = timeout; - cpu_limit.rlim_max = timeout+1; - - if (setrlimit (RLIMIT_CPU, &cpu_limit) != 0) { - tracker_error ("ERROR: trying to set resource limit for cpu"); - } - - set_memory_rlimits(); - - /* Set child's niceness to 19 */ - nice (19); -} - - -gboolean -tracker_spawn (char **argv, int timeout, char **tmp_stdout, int *exit_status) -{ - GSpawnFlags flags; - - if (!tmp_stdout) { - flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL; - } else { - flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL; - } - - return g_spawn_sync (NULL, - argv, - NULL, - flags, - tracker_child_cb, - GINT_TO_POINTER (timeout), - tmp_stdout, - NULL, - exit_status, - NULL); -} - - static inline void output_log (const char *message) { Index: src/trackerd/tracker-utils.h =================================================================== --- src/trackerd/tracker-utils.h (revision 738) +++ src/trackerd/tracker-utils.h (working copy) @@ -555,7 +555,6 @@ char * tracker_get_snippet (const char *txt, char **terms, int length); gboolean tracker_spawn (char **argv, int timeout, char **tmp_stdout, int *exit_status); -void tracker_child_cb (gpointer user_data); char* tracker_string_replace (const char *haystack, char *needle, char *replacement); Index: src/trackerd/tracker-win-fs-changes.c =================================================================== --- src/trackerd/tracker-win-fs-changes.c (revision 0) +++ src/trackerd/tracker-win-fs-changes.c (revision 0) @@ -0,0 +1,260 @@ +/* Tracker - indexer and metadata database engine + * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "tracker-win-fs-changes.h" + +#include + +#include +#include + +#include + +// private stuff + +static GHashTable *watch_table; + +extern Tracker *tracker; +static DBConnection *win_db_con; + +static void +free_watch_func (gpointer user_data) +{ + g_free (user_data); +} + +static DWORD sleep_thread_id; +static HANDLE sleep_thread; + +#define MAX_DIRECTORIES 1024 // should be more than enough +#define MAX_FILENAME_LENGTH 1024 // should be more than enough + +static int dir_id = 0; + +static char buffer[MAX_DIRECTORIES][256]; +static HANDLE monitor_handle[MAX_DIRECTORIES]; +static OVERLAPPED overlapped_buffer[MAX_DIRECTORIES]; +static char dirs[MAX_DIRECTORIES][256]; + +unsigned int __stdcall ThreadProc( LPVOID param ) +{ + while (TRUE) { + SleepEx(INFINITE, TRUE); // 10000 might be better + } +} + +void CALLBACK init_db (DWORD param) +{ + tracker_db_thread_init (); + + win_db_con = tracker_db_connect (); + + win_db_con->blob = tracker_db_connect_full_text (); + win_db_con->cache = tracker_db_connect_cache (); + + win_db_con->thread = "notify"; +} + +// public stuff + +gboolean +tracker_start_watching (void) +{ + if (tracker->watch_limit == 0) { + tracker->watch_limit = 8191; + } + + watch_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, free_watch_func); + + // create a windows thread to synchonize all metadata changes in one thread + sleep_thread = _beginthreadex( NULL, 0, ThreadProc, 0, 0, &sleep_thread_id ); + + QueueUserAPC(init_db, sleep_thread, (DWORD) 0 ); + + return TRUE; +} + +void +tracker_end_watching (void) +{ + // kill thread and call these just before it dies + +#if 0 + tracker_db_close (win_db_con); + tracker_db_thread_end (); +#endif + + // release all watched dirs + + g_hash_table_destroy (watch_table); +} + +gboolean monitor_dir(int dir_id); + +VOID CALLBACK callback(DWORD error_code, + DWORD bytes_transferred, + LPOVERLAPPED overlapped) // I/O information buffer +{ + int callback_dir_id = (int) overlapped->hEvent; + + if (bytes_transferred > 0) { + + FILE_NOTIFY_INFORMATION *p = (FILE_NOTIFY_INFORMATION *) buffer[callback_dir_id]; + + TrackerChangeAction event_type = TRACKER_ACTION_IGNORE; + int counter = 1; + + while (p) { + TrackerChangeAction event_type; + + switch (p->Action) { + case FILE_ACTION_MODIFIED: + event_type = TRACKER_ACTION_CHECK; + counter = 1; + break; + case FILE_ACTION_REMOVED: + event_type = TRACKER_ACTION_DELETE; + counter = 0; + break; + case FILE_ACTION_ADDED: + event_type = TRACKER_ACTION_CREATE; + counter = 1; + break; + default: + break; + } + + if (event_type != TRACKER_ACTION_IGNORE) { + + FileInfo *info; + char file_utf8_uri[MAX_FILENAME_LENGTH]; + + int status = WideCharToMultiByte(CP_UTF8, 0, p->FileName, p->FileNameLength, + file_utf8_uri, MAX_FILENAME_LENGTH, NULL, NULL); + + file_utf8_uri[p->FileNameLength/sizeof(WCHAR)] = '\0'; + + char *file_uri = g_build_filename (dirs[callback_dir_id], file_utf8_uri, NULL); + + info = tracker_create_file_info (file_uri, event_type, counter, WATCH_OTHER); + + if (tracker_file_info_is_valid (info)) { + + tracker_db_insert_pending_file (win_db_con, info->file_id, info->uri, info->mime, + info->counter, info->action, info->is_directory, (event_type == TRACKER_ACTION_CREATE), -1); + tracker_free_file_info (info); + } + + g_free(file_uri); + } + + if (p->NextEntryOffset == 0) + p = NULL; + else + p = (FILE_NOTIFY_INFORMATION *) ((char *) p + p->NextEntryOffset); + } + } + + // reschedule + monitor_dir(callback_dir_id); +} + +gboolean +monitor_dir(int dir_id) +{ + return ReadDirectoryChangesW( monitor_handle[dir_id], buffer[dir_id], sizeof(buffer[dir_id]), + TRUE, + // FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | + FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_FILE_NAME, + NULL, &overlapped_buffer[dir_id], callback); +} + + +void CALLBACK tracker_add_watch_dir_wrapped (DWORD param) +{ + char *dir = (char *) param; + + char *dir_in_locale; + + dir_in_locale = g_filename_from_utf8 (dir, -1, NULL, NULL, NULL); + + if (!dir_in_locale) { + free(dir); + return; + } + + /* check directory permissions are okay */ + if (g_access (dir_in_locale, F_OK) == 0 && g_access (dir_in_locale, R_OK) == 0) { + + monitor_handle[dir_id] = CreateFile( dir_in_locale, FILE_LIST_DIRECTORY, + FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED, + NULL ); + + if (monitor_handle[dir_id] == INVALID_HANDLE_VALUE) { + free(dir); + } else if (monitor_dir(dir_id)) { + g_hash_table_insert (watch_table, g_strdup (dir), monitor_handle[dir_id]); + strcpy(dirs[dir_id], dir); + + g_free (dir_in_locale); + free(dir); + + ++dir_id; + } + } else { + + g_free (dir_in_locale); + free(dir); + } +} + +gboolean +tracker_add_watch_dir (const char *dir, DBConnection *db_con) +{ + // create a copy so that the string is still available when we are called in the file notify thread + char *something = g_strdup(dir); + return QueueUserAPC( tracker_add_watch_dir_wrapped, sleep_thread, (DWORD) something ); +} + +void +tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection *db_con) +{ +#if 0 + char *something = g_strdup(dir); + QueueUserAPC( tracker_remove_watch_dir_wrapped, sleep_thread, (DWORD) something ); +#endif +} + +gboolean +tracker_is_directory_watched (const char *dir, DBConnection *db_con) +{ + if (!dir) { + return FALSE; + } + + return (g_hash_table_lookup (watch_table, dir) != NULL); +} + +int +tracker_count_watch_dirs (void) +{ + return g_hash_table_size (watch_table); +} Index: src/trackerd/tracker-win-fs-changes.h =================================================================== --- src/trackerd/tracker-win-fs-changes.h (revision 0) +++ src/trackerd/tracker-win-fs-changes.h (revision 0) @@ -0,0 +1,35 @@ +/* Tracker - indexer and metadata database engine + * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _TRACKER_WIN_FS_CHANGES_H_ +#define _TRACKER_WIN_FS_CHANGES_H_ + +#include "tracker-db.h" + +gboolean tracker_start_watching (void); +void tracker_end_watching (void); + +gboolean tracker_add_watch_dir (const char *dir, DBConnection *db_con); +void tracker_remove_watch_dir (const char *dir, gboolean delete_subdirs, DBConnection *db_con); + +gboolean tracker_is_directory_watched (const char *dir, DBConnection *db_con); +int tracker_count_watch_dirs (void); + +#endif + Index: src/trackerd/trackerd.c =================================================================== --- src/trackerd/trackerd.c (revision 738) +++ src/trackerd/trackerd.c (working copy) @@ -49,7 +49,9 @@ #ifndef HAVE_INOTIFY # ifndef HAVE_FAM -# define POLL_ONLY +# ifndef OS_WIN32 +# define POLL_ONLY +# endif # endif #endif @@ -60,7 +62,15 @@ #include "tracker-dbus-search.h" #include "tracker-dbus-files.h" #include "tracker-email.h" -#include "tracker-indexer.h" +#include "tracker-indexer.h" +#include "tracker-os-dependant.h" + +#ifdef OS_WIN32 +#include +#include +#include "mingw-compat.h" +#endif + #include "tracker-apps.h" typedef struct { @@ -72,7 +82,7 @@ DBConnection *main_thread_db_con; DBConnection *main_thread_cache_con; -static gboolean shutdown; +static gboolean tracker_shutdown; static DBusConnection *main_connection; @@ -162,9 +172,11 @@ static void my_yield (void) { +#ifndef OS_WIN32 while (g_main_context_iteration (NULL, FALSE)) { ; } +#endif } @@ -244,7 +256,7 @@ /* send signals to each thread to wake them up and then stop them */ - shutdown = TRUE; + tracker_shutdown = TRUE; g_mutex_lock (tracker->request_signal_mutex); @@ -338,7 +350,7 @@ return; } - g_return_if_fail (uri && (uri[0] == '/')); + g_return_if_fail (check_uri(uri)); g_return_if_fail (db_con); tracker_db_insert_pending_file (db_con, 0, uri, "unknown", 0, TRACKER_ACTION_DIRECTORY_REFRESH, TRUE, FALSE, -1); @@ -604,7 +616,7 @@ if (!tracker->is_running) { return; } - g_return_if_fail (uri && (uri[0] == '/')); + g_return_if_fail (check_uri(uri)); g_return_if_fail (db_con); /* keep mainloop responsive */ @@ -649,7 +661,7 @@ return; } - g_return_if_fail (uri && (uri[0] == '/')); + g_return_if_fail (check_uri(uri)); g_return_if_fail (tracker_is_directory (uri)); file_list = tracker_get_files (uri, FALSE); @@ -675,7 +687,7 @@ } g_return_if_fail (db_con); - g_return_if_fail (uri && (uri[0] == '/')); + g_return_if_fail (check_uri(uri)); g_return_if_fail (tracker_is_directory (uri)); /* keep mainloop responsive */ @@ -759,8 +771,8 @@ { char *service_info; - g_return_if_fail (info->uri); - g_return_if_fail (info->uri[0] == '/'); + g_return_if_fail (info); + g_return_if_fail (check_uri(info->uri)); if (!tracker_file_is_valid (info->uri)) { //tracker_debug ("Warning - file %s in not valid or could not be read - abandoning index on this file", info->uri); @@ -877,7 +889,9 @@ /* block all signals in this thread */ sigfillset (&signal_set); +#ifndef OS_WIN32 pthread_sigmask (SIG_BLOCK, &signal_set, NULL); +#endif g_mutex_lock (tracker->files_signal_mutex); g_mutex_lock (tracker->files_stopped_mutex); @@ -933,7 +947,7 @@ g_cond_wait (tracker->file_thread_signal, tracker->files_signal_mutex); /* determine if wake up call is new stuff or a shutdown signal */ - if (!shutdown) { + if (!tracker_shutdown) { continue; } else { @@ -1235,7 +1249,7 @@ /* determine if wake up call is new stuff or a shutdown signal */ - if (!shutdown) { + if (!tracker_shutdown) { } else { break; @@ -1304,7 +1318,7 @@ continue; } - if (!info->uri || (info->uri[0] != '/')) { + if (!check_uri(info->uri)) { tracker_free_file_info (info); continue; } @@ -1493,8 +1507,9 @@ /* block all signals in this thread */ sigfillset (&signal_set); +#ifndef OS_WIN32 pthread_sigmask (SIG_BLOCK, &signal_set, NULL); - +#endif g_mutex_lock (tracker->request_signal_mutex); g_mutex_lock (tracker->request_stopped_mutex); @@ -1526,7 +1541,7 @@ g_cond_wait (tracker->request_thread_signal, tracker->request_signal_mutex); /* determine if wake up call is new stuff or a shutdown signal */ - if (!shutdown) { + if (!tracker_shutdown) { continue; } else { break; @@ -1543,7 +1558,7 @@ g_mutex_unlock (tracker->request_check_mutex); /* determine if wake up call is new stuff or a shutdown signal */ - if (!shutdown) { + if (!tracker_shutdown) { continue; } else { break; @@ -1977,7 +1992,7 @@ tracker->first_flush = TRUE; - tracker->services_dir = g_build_filename (DATADIR, "tracker", "services", NULL); + tracker->services_dir = g_build_filename (TRACKER_DATADIR, "tracker", "services", NULL); /* battery and ac power checks */ const char *battery_filenames[4] = { @@ -2133,8 +2148,10 @@ main (int argc, char **argv) { int lfp; +#ifndef OS_WIN32 struct sigaction act; sigset_t empty_mask; +#endif char *lock_file, *str, *lock_str; GOptionContext *context = NULL; GError *error = NULL; @@ -2186,6 +2203,7 @@ g_print ("Initialising tracker...\n"); +#ifndef OS_WIN32 /* trap signals */ sigemptyset (&empty_mask); act.sa_handler = signal_handler; @@ -2200,6 +2218,7 @@ sigaction (SIGABRT, &act, NULL); sigaction (SIGUSR1, &act, NULL); sigaction (SIGINT, &act, NULL); +#endif dbus_g_thread_init (); @@ -2256,7 +2275,7 @@ need_index = FALSE; need_data = FALSE; - shutdown = FALSE; + tracker_shutdown = FALSE; tracker->files_check_mutex = g_mutex_new (); @@ -2337,6 +2356,7 @@ g_free (lock_file); if (lfp < 0) { + printf("!!!%s!!!\n", lock_file); g_warning ("Cannot open or create lockfile - exiting"); exit (1); } @@ -2510,3 +2530,4 @@ return EXIT_SUCCESS; } + Index: src/xdgmime/fnmatch.c =================================================================== --- src/xdgmime/fnmatch.c (revision 0) +++ src/xdgmime/fnmatch.c (revision 0) @@ -0,0 +1,223 @@ +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +NOTE: This source is derived from an old version taken from the GNU C +Library (glibc). + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else +#include "config.h" +#endif +#endif + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +/* This code to undef const added in libiberty. */ +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include +#include +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) +extern int errno; +#endif + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ +int +fnmatch (pattern, string, flags) + const char *pattern; + const char *string; + int flags; +{ + register const char *p = pattern, *n = string; + register unsigned char c; + +#define FOLD(c) ((flags & FNM_CASEFOLD) ? TOLOWER (c) : (c)) + + while ((c = *p++) != '\0') + { + c = FOLD (c); + + switch (c) + { + case '?': + if (*n == '\0') + return FNM_NOMATCH; + else if ((flags & FNM_FILE_NAME) && *n == '/') + return FNM_NOMATCH; + else if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + break; + + case '\\': + if (!(flags & FNM_NOESCAPE)) + { + c = *p++; + c = FOLD (c); + } + if (FOLD ((unsigned char)*n) != c) + return FNM_NOMATCH; + break; + + case '*': + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) + if (((flags & FNM_FILE_NAME) && *n == '/') || + (c == '?' && *n == '\0')) + return FNM_NOMATCH; + + if (c == '\0') + return 0; + + { + unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; + c1 = FOLD (c1); + for (--p; *n != '\0'; ++n) + if ((c == '[' || FOLD ((unsigned char)*n) == c1) && + fnmatch (p, n, flags & ~FNM_PERIOD) == 0) + return 0; + return FNM_NOMATCH; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + register int not; + + if (*n == '\0') + return FNM_NOMATCH; + + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + not = (*p == '!' || *p == '^'); + if (not) + ++p; + + c = *p++; + for (;;) + { + register unsigned char cstart = c, cend = c; + + if (!(flags & FNM_NOESCAPE) && c == '\\') + cstart = cend = *p++; + + cstart = cend = FOLD (cstart); + + if (c == '\0') + /* [ (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + c = FOLD (c); + + if ((flags & FNM_FILE_NAME) && c == '/') + /* [/] can never match. */ + return FNM_NOMATCH; + + if (c == '-' && *p != ']') + { + cend = *p++; + if (!(flags & FNM_NOESCAPE) && cend == '\\') + cend = *p++; + if (cend == '\0') + return FNM_NOMATCH; + cend = FOLD (cend); + + c = *p++; + } + + if (FOLD ((unsigned char)*n) >= cstart + && FOLD ((unsigned char)*n) <= cend) + goto matched; + + if (c == ']') + break; + } + if (!not) + return FNM_NOMATCH; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + while (c != ']') + { + if (c == '\0') + /* [... (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + if (!(flags & FNM_NOESCAPE) && c == '\\') + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + if (not) + return FNM_NOMATCH; + } + break; + + default: + if (c != FOLD ((unsigned char)*n)) + return FNM_NOMATCH; + } + + ++n; + } + + if (*n == '\0') + return 0; + + if ((flags & FNM_LEADING_DIR) && *n == '/') + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return FNM_NOMATCH; +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ Index: src/xdgmime/fnmatch.h =================================================================== --- src/xdgmime/fnmatch.h (revision 0) +++ src/xdgmime/fnmatch.h (revision 0) @@ -0,0 +1,63 @@ +/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _FNMATCH_H +# define _FNMATCH_H 1 + +# ifdef __cplusplus +extern "C" { +# endif + +/* We #undef these before defining them because some losing systems + (HP-UX A.08.07 for example) define these in . */ +# undef FNM_PATHNAME +# undef FNM_NOESCAPE +# undef FNM_PERIOD + +/* Bits set in the FLAGS argument to `fnmatch'. */ +# define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +# define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +# define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ + +# if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE +# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ +# endif + +/* Value returned by `fnmatch' if STRING does not match PATTERN. */ +# define FNM_NOMATCH 1 + +/* This value is returned if the implementation does not support + `fnmatch'. Since this is not the case here it will never be + returned but the conformance test suites still require the symbol + to be defined. */ +# ifdef _XOPEN_SOURCE +# define FNM_NOSYS (-1) +# endif + +/* Match NAME against the filename pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +extern int fnmatch (const char *__pattern, const char *__name, + int __flags); + +# ifdef __cplusplus +} +# endif + +#endif /* fnmatch.h */ Index: src/xdgmime/Makefile.am =================================================================== --- src/xdgmime/Makefile.am (revision 738) +++ src/xdgmime/Makefile.am (working copy) @@ -1,7 +1,15 @@ noinst_LTLIBRARIES = libxdgmime.la +if OS_WIN32 +xdgmime_win_sources = fnmatch.c \ + fnmatch.h \ + safe-ctype.c \ + safe-ctype.h +endif + libxdgmime_la_SOURCES = \ + $(xdgmime_win_sources) \ xdgmime.c \ xdgmime.h \ xdgmimealias.c \ Index: src/xdgmime/safe-ctype.c =================================================================== --- src/xdgmime/safe-ctype.c (revision 0) +++ src/xdgmime/safe-ctype.c (revision 0) @@ -0,0 +1,163 @@ +/* replacement macros. + + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by Zack Weinberg . + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This is a compatible replacement of the standard C library's + with the following properties: + + - Implements all isxxx() macros required by C99. + - Also implements some character classes useful when + parsing C-like languages. + - Does not change behavior depending on the current locale. + - Behaves properly for all values in the range of a signed or + unsigned char. */ + +#include "ansidecl.h" +#include +#include /* for EOF */ + +/* Shorthand */ +#define bl _sch_isblank +#define cn _sch_iscntrl +#define di _sch_isdigit +#define is _sch_isidst +#define lo _sch_islower +#define nv _sch_isnvsp +#define pn _sch_ispunct +#define pr _sch_isprint +#define sp _sch_isspace +#define up _sch_isupper +#define vs _sch_isvsp +#define xd _sch_isxdigit + +/* Masks. */ +#define L lo|is |pr /* lower case letter */ +#define XL lo|is|xd|pr /* lowercase hex digit */ +#define U up|is |pr /* upper case letter */ +#define XU up|is|xd|pr /* uppercase hex digit */ +#define D di |xd|pr /* decimal digit */ +#define P pn |pr /* punctuation */ +#define _ pn|is |pr /* underscore */ + +#define C cn /* control character */ +#define Z nv |cn /* NUL */ +#define M nv|sp |cn /* cursor movement: \f \v */ +#define V vs|sp |cn /* vertical space: \r \n */ +#define T nv|sp|bl|cn /* tab */ +#define S nv|sp|bl|pr /* space */ + +/* Are we ASCII? */ +#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \ + && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \ + && EOF == -1 + +const unsigned short _sch_istable[256] = +{ + Z, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */ + C, T, V, M, M, V, C, C, /* BS HT LF VT FF CR SO SI */ + C, C, C, C, C, C, C, C, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ + C, C, C, C, C, C, C, C, /* CAN EM SUB ESC FS GS RS US */ + S, P, P, P, P, P, P, P, /* SP ! " # $ % & ' */ + P, P, P, P, P, P, P, P, /* ( ) * + , - . / */ + D, D, D, D, D, D, D, D, /* 0 1 2 3 4 5 6 7 */ + D, D, P, P, P, P, P, P, /* 8 9 : ; < = > ? */ + P, XU, XU, XU, XU, XU, XU, U, /* @ A B C D E F G */ + U, U, U, U, U, U, U, U, /* H I J K L M N O */ + U, U, U, U, U, U, U, U, /* P Q R S T U V W */ + U, U, U, P, P, P, P, _, /* X Y Z [ \ ] ^ _ */ + P, XL, XL, XL, XL, XL, XL, L, /* ` a b c d e f g */ + L, L, L, L, L, L, L, L, /* h i j k l m n o */ + L, L, L, L, L, L, L, L, /* p q r s t u v w */ + L, L, L, P, P, P, P, C, /* x y z { | } ~ DEL */ + + /* high half of unsigned char is locale-specific, so all tests are + false in "C" locale */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +const unsigned char _sch_tolower[256] = +{ + 0, 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, + + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + + 91, 92, 93, 94, 95, 96, + + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + + 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, +}; + +const unsigned char _sch_toupper[256] = +{ + 0, 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, + + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + + 91, 92, 93, 94, 95, 96, + + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + + 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, +}; + +#else + #error "Unsupported host character set" +#endif /* not ASCII */ Index: src/xdgmime/safe-ctype.h =================================================================== --- src/xdgmime/safe-ctype.h (revision 0) +++ src/xdgmime/safe-ctype.h (revision 0) @@ -0,0 +1,100 @@ +/* replacement macros. + + Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Contributed by Zack Weinberg . + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* This is a compatible replacement of the standard C library's + with the following properties: + + - Implements all isxxx() macros required by C99. + - Also implements some character classes useful when + parsing C-like languages. + - Does not change behavior depending on the current locale. + - Behaves properly for all values in the range of a signed or + unsigned char. + + To avoid conflicts, this header defines the isxxx functions in upper + case, e.g. ISALPHA not isalpha. */ + +#ifndef SAFE_CTYPE_H +#define SAFE_CTYPE_H + +#ifdef isalpha + #error "safe-ctype.h and ctype.h may not be used simultaneously" +#else + +/* Categories. */ + +enum { + /* In C99 */ + _sch_isblank = 0x0001, /* space \t */ + _sch_iscntrl = 0x0002, /* nonprinting characters */ + _sch_isdigit = 0x0004, /* 0-9 */ + _sch_islower = 0x0008, /* a-z */ + _sch_isprint = 0x0010, /* any printing character including ' ' */ + _sch_ispunct = 0x0020, /* all punctuation */ + _sch_isspace = 0x0040, /* space \t \n \r \f \v */ + _sch_isupper = 0x0080, /* A-Z */ + _sch_isxdigit = 0x0100, /* 0-9A-Fa-f */ + + /* Extra categories useful to cpplib. */ + _sch_isidst = 0x0200, /* A-Za-z_ */ + _sch_isvsp = 0x0400, /* \n \r */ + _sch_isnvsp = 0x0800, /* space \t \f \v \0 */ + + /* Combinations of the above. */ + _sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */ + _sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */ + _sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */ + _sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */ + _sch_iscppsp = _sch_isvsp|_sch_isnvsp /* isspace + \0 */ +}; + +/* Character classification. */ +extern const unsigned short _sch_istable[256]; + +#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit)) + +#define ISALPHA(c) _sch_test(c, _sch_isalpha) +#define ISALNUM(c) _sch_test(c, _sch_isalnum) +#define ISBLANK(c) _sch_test(c, _sch_isblank) +#define ISCNTRL(c) _sch_test(c, _sch_iscntrl) +#define ISDIGIT(c) _sch_test(c, _sch_isdigit) +#define ISGRAPH(c) _sch_test(c, _sch_isgraph) +#define ISLOWER(c) _sch_test(c, _sch_islower) +#define ISPRINT(c) _sch_test(c, _sch_isprint) +#define ISPUNCT(c) _sch_test(c, _sch_ispunct) +#define ISSPACE(c) _sch_test(c, _sch_isspace) +#define ISUPPER(c) _sch_test(c, _sch_isupper) +#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit) + +#define ISIDNUM(c) _sch_test(c, _sch_isidnum) +#define ISIDST(c) _sch_test(c, _sch_isidst) +#define IS_VSPACE(c) _sch_test(c, _sch_isvsp) +#define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp) +#define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp) + +/* Character transformation. */ +extern const unsigned char _sch_toupper[256]; +extern const unsigned char _sch_tolower[256]; +#define TOUPPER(c) _sch_toupper[(c) & 0xff] +#define TOLOWER(c) _sch_tolower[(c) & 0xff] + +#endif /* no ctype.h */ +#endif /* SAFE_CTYPE_H */ Index: src/xdgmime/xdgmime.c =================================================================== --- src/xdgmime/xdgmime.c (revision 738) +++ src/xdgmime/xdgmime.c (working copy) @@ -29,6 +29,10 @@ #include #endif +#ifdef OS_WIN32 +#include "../trackerd/mingw-compat.h" +#endif + #include "xdgmime.h" #include "xdgmimeint.h" #include "xdgmimeglob.h" Index: src/xdgmime/xdgmimecache.c =================================================================== --- src/xdgmime/xdgmimecache.c (revision 738) +++ src/xdgmime/xdgmimecache.c (working copy) @@ -37,7 +37,12 @@ #include #include -#include /* for ntohl/ntohs */ +/* for ntohl/ntohs */ +#ifdef OS_WIN32 +#include +#else +#include +#endif #ifdef HAVE_MMAP #include Index: src/xdgmime/xdgmimemagic.c =================================================================== --- src/xdgmime/xdgmimemagic.c (revision 738) +++ src/xdgmime/xdgmimemagic.c (working copy) @@ -30,6 +30,9 @@ #endif #include +#ifdef OS_WIN32 +#include "../trackerd/mingw-compat.h" +#endif #include "xdgmimemagic.h" #include "xdgmimeint.h" #include