Win32 flags and headers

master
Yevgen Muntyan 2008-01-15 00:43:03 -06:00
parent 39b82940d7
commit c6cd06cfce
14 changed files with 78 additions and 91 deletions

View File

@ -6,7 +6,7 @@ Makefile(\.in)?$
^(autom4te\.cache|build)/ ^(autom4te\.cache|build)/
^(compile|mkinstalldirs|config\..*|configargs\.h|configure|depcomp|install-sh|intltool-(extract|merge|update)|libtool|ltmain\.sh|missing|stamp-h1|aclocal\.m4)$ ^(compile|mkinstalldirs|config\..*|configargs\.h|configure|depcomp|install-sh|intltool-(extract|merge|update)|libtool|ltmain\.sh|missing|stamp-h1|aclocal\.m4)$
^intltool-(extract|merge|update)\.in$ ^intltool-(extract|merge|update)\.in$
^medit/medit(-credits\.h|\.(desktop|iss))?$ ^medit/medit(\.(desktop|iss))?$
^po(-gsv)?/(\.intltool-merge-cache|POTFILES|stamp-it|missing|moo\.pot|notexist|Makefile\.in\.in) ^po(-gsv)?/(\.intltool-merge-cache|POTFILES|stamp-it|missing|moo\.pot|notexist|Makefile\.in\.in)
^tests/pyapp\.py$ ^tests/pyapp\.py$
^moo/moo(-config\.h|\.pc)$ ^moo/moo(-config\.h|\.pc)$

View File

@ -61,6 +61,12 @@ AC_DEFUN_ONCE([MOO_AC_FLAGS],[
MOO_LIBS="$MOO_LIBS $GTKHTML_LIBS" MOO_LIBS="$MOO_LIBS $GTKHTML_LIBS"
fi fi
if test "x$MOO_OS_MINGW" = xyes; then
MOO_CFLAGS="$MOO_CFLAGS -DWIN32_LEAN_AND_MEAN -DUNICODE"
MOO_WIN32_CFLAGS="-I$moo_top_src_dir/$1/mooutils/moowin32/mingw"
AC_DEFINE(HAVE_MMAP, [1], [using fake mmap on windows])
fi
################################################################################ ################################################################################
# MooEdit stuff # MooEdit stuff
# #
@ -69,6 +75,7 @@ AC_DEFUN_ONCE([MOO_AC_FLAGS],[
MOO_LIBS="$MOO_LIBS $XML_LIBS" MOO_LIBS="$MOO_LIBS $XML_LIBS"
fi fi
AC_SUBST(MOO_WIN32_CFLAGS)
AC_SUBST(MOO_CFLAGS) AC_SUBST(MOO_CFLAGS)
AC_SUBST(MOO_LIBS) AC_SUBST(MOO_LIBS)

View File

@ -26,7 +26,6 @@
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif

View File

@ -22,8 +22,6 @@
#include "eggsmclient-private.h" #include "eggsmclient-private.h"
#include <gdk/gdk.h> #include <gdk/gdk.h>
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#include <windows.h> #include <windows.h>
#define EGG_TYPE_SM_CLIENT_WIN32 (egg_sm_client_win32_get_type ()) #define EGG_TYPE_SM_CLIENT_WIN32 (egg_sm_client_win32_get_type ())

View File

@ -19,9 +19,7 @@
#include "mooutils/mooutils-debug.h" #include "mooutils/mooutils-debug.h"
#include <glib/gregex.h> #include <glib/gregex.h>
#include <string.h> #include <string.h>
#ifndef __WIN32__
#include <fnmatch.h> #include <fnmatch.h>
#endif
MOO_DEBUG_INIT(filters, FALSE) MOO_DEBUG_INIT(filters, FALSE)

View File

@ -17,7 +17,7 @@
#define MOOEDIT_COMPILATION #define MOOEDIT_COMPILATION
#include "mooedit/mooprintpreview.h" #include "mooedit/mooprintpreview.h"
#include "mooedit/mootextprint-private.h" #include "mooedit/mootextprint-private.h"
#include "mooedit/mooprintpreview-glade.h" #include "mooprintpreview-glade.h"
#include "mooutils/mooutils-gobject.h" #include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h" #include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h" #include "mooutils/mooutils-debug.h"
@ -26,7 +26,6 @@
MOO_DEBUG_INIT(printing, TRUE) MOO_DEBUG_INIT(printing, TRUE)
#ifdef __WIN32__ #ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <cairo-win32.h> #include <cairo-win32.h>
#endif #endif

View File

@ -13,7 +13,6 @@
#define MOOTERM_COMPILATION #define MOOTERM_COMPILATION
#ifdef __WIN32__ #ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif

View File

@ -160,6 +160,9 @@ EXTRA_DIST = \
$(thread_sources) \ $(thread_sources) \
$(win32_sources) \ $(win32_sources) \
$(objc_sources) \ $(objc_sources) \
moowin32/mingw/fnmatch.h \
moowin32/mingw/netinet/in.h \
moowin32/mingw/sys/mman.h \
pixmaps/medit.png \ pixmaps/medit.png \
pixmaps/medit.ico \ pixmaps/medit.ico \
pixmaps/hide.png \ pixmaps/hide.png \

View File

@ -23,7 +23,6 @@
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#include "mooutils/mooutils-thread.h"
#include <windows.h> #include <windows.h>
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
@ -43,6 +42,7 @@
#include "mooutils/mooutils-misc.h" #include "mooutils/mooutils-misc.h"
#include "mooutils/moofilewatch.h" #include "mooutils/moofilewatch.h"
#include "mooutils/moomarshals.h" #include "mooutils/moomarshals.h"
#include "mooutils/mooutils-thread.h"
#if 1 #if 1

View File

@ -22,7 +22,6 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#else #else
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif

View File

@ -27,12 +27,15 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#ifdef __WIN32__ #ifdef __WIN32__
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <io.h> #include <io.h>
#include <direct.h> #include <direct.h>
#endif #endif
#ifndef S_IRWXU
#define S_IRWXU 0
#endif
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif

View File

@ -201,11 +201,8 @@ G_END_DECLS
G_BEGIN_DECLS G_BEGIN_DECLS
#define fnmatch _moo_win32_fnmatch char *moo_win32_get_app_dir (void);
#define gettimeofday _moo_win32_gettimeofday char *moo_win32_get_dll_dir (const char *dll);
char *moo_win32_get_app_dir (void);
char *moo_win32_get_dll_dir (const char *dll);
void _moo_win32_add_data_dirs (GPtrArray *list, void _moo_win32_add_data_dirs (GPtrArray *list,
const char *prefix); const char *prefix);
@ -216,25 +213,6 @@ gboolean _moo_win32_open_uri (const char *uri);
void _moo_win32_show_fatal_error (const char *domain, void _moo_win32_show_fatal_error (const char *domain,
const char *logmsg); const char *logmsg);
int _moo_win32_fnmatch (const char *pattern,
const char *string,
int flags);
int _moo_win32_gettimeofday (struct timeval *tp,
gpointer tzp);
void *_moo_win32_mmap (gpointer start,
guint64 length,
int prot,
int flags,
int fd,
guint64 offset);
int _moo_win32_munmap (gpointer start,
gsize length);
#define PROT_READ 1
#define MAP_SHARED 1
#define MAP_FAILED ((gpointer) -1)
G_END_DECLS G_END_DECLS

View File

@ -23,9 +23,7 @@
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#include <windows.h> #include <windows.h>
#endif #include <io.h>
#ifdef __WIN32__
#ifndef pipe #ifndef pipe
#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) #define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
#endif #endif

View File

@ -14,14 +14,15 @@
#include "config.h" #include "config.h"
#endif #endif
#define WIN32_LEAN_AND_MEAN
#include "mooutils/mooutils-misc.h" #include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-fs.h" #include "mooutils/mooutils-fs.h"
#include <fnmatch.h>
#include <windows.h> #include <windows.h>
#include <shellapi.h> #include <shellapi.h>
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/mman.h>
#include <io.h> #include <io.h>
@ -35,16 +36,19 @@ DllMain (HINSTANCE hinstDLL,
DWORD fdwReason, DWORD fdwReason,
G_GNUC_UNUSED LPVOID lpvReserved) G_GNUC_UNUSED LPVOID lpvReserved)
{ {
char *tem; char *name = NULL;
wchar_t wcbfr[1000]; wchar_t buf[MAX_PATH+1];
switch (fdwReason) switch (fdwReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
GetModuleFileNameW ((HMODULE) hinstDLL, wcbfr, G_N_ELEMENTS (wcbfr)); if (GetModuleFileNameW ((HMODULE) hinstDLL, buf, G_N_ELEMENTS (buf)))
tem = g_utf16_to_utf8 (wcbfr, -1, NULL, NULL, NULL); name = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
libmoo_dll_name = g_path_get_basename (tem); if (name)
g_free (tem); libmoo_dll_name = g_path_get_basename (name);
if (!libmoo_dll_name)
libmoo_dll_name = g_strdup ("libmoo.dll");
g_free (name);
break; break;
} }
@ -140,38 +144,40 @@ moo_win32_get_app_dir (void)
char * char *
moo_win32_get_dll_dir (const char *dll) moo_win32_get_dll_dir (const char *dll)
{ {
wchar_t *dll_utf16 = NULL;
char *dir; char *dir;
char *dllname = NULL; char *dllname = NULL;
HMODULE handle; HMODULE handle;
wchar_t buf[MAX_PATH+1];
handle = GetModuleHandle (dll); if (dll)
{
GError *error = NULL;
dll_utf16 = g_utf8_to_utf16 (dll, -1, NULL, NULL, &error);
if (!dll_utf16)
{
g_critical ("could not convert name '%s' to UTF16: %s",
dll, error ? error->message : "");
g_error_free (error);
return g_strdup (".");
}
}
handle = GetModuleHandleW (dll_utf16);
g_return_val_if_fail (handle != NULL, g_strdup (".")); g_return_val_if_fail (handle != NULL, g_strdup ("."));
if (G_WIN32_HAVE_WIDECHAR_API ()) if (GetModuleFileNameW (handle, buf, G_N_ELEMENTS (buf)) > 0)
{ dllname = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
wchar_t buf[MAX_PATH+1];
if (GetModuleFileNameW (handle, buf, G_N_ELEMENTS (buf)) > 0)
dllname = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
}
else
{
gchar buf[MAX_PATH+1];
if (GetModuleFileNameA (handle, buf, G_N_ELEMENTS (buf)) > 0)
dllname = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
}
if (dllname) if (dllname)
{
dir = g_path_get_dirname (dllname); dir = g_path_get_dirname (dllname);
g_free (dllname);
}
else else
{
dir = g_strdup ("."); dir = g_strdup (".");
}
g_free (dllname);
g_free (dll_utf16);
return dir; return dir;
} }
@ -183,7 +189,7 @@ _moo_win32_open_uri (const char *uri)
g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (uri != NULL, FALSE);
h = ShellExecute (NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL); h = ShellExecuteA (NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL);
if ((int)h <= 32) if ((int)h <= 32)
{ {
@ -214,35 +220,35 @@ _moo_win32_show_fatal_error (const char *domain,
PLEASE_REPORT, logmsg); PLEASE_REPORT, logmsg);
#undef PLEASE_REPORT #undef PLEASE_REPORT
MessageBox (NULL, msg, "Error", MessageBoxA (NULL, msg, "Error",
MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND); MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
g_free (msg); g_free (msg);
} }
int // int
_moo_win32_gettimeofday (struct timeval *tp, // _moo_win32_gettimeofday (struct timeval *tp,
G_GNUC_UNUSED gpointer tzp) // G_GNUC_UNUSED gpointer tzp)
{ // {
time_t sec; // time_t sec;
//
if (tp == NULL || tzp != NULL) // if (tp == NULL || tzp != NULL)
{ // {
errno = EINVAL; // errno = EINVAL;
return -1; // return -1;
} // }
//
sec = time (NULL); // sec = time (NULL);
//
if (sec == (time_t) -1) // if (sec == (time_t) -1)
return -1; // return -1;
//
tp->tv_sec = sec; // tp->tv_sec = sec;
tp->tv_usec = 0; // tp->tv_usec = 0;
//
return 0; // return 0;
} // }
int int