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)/
^(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$
^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)
^tests/pyapp\.py$
^moo/moo(-config\.h|\.pc)$

View File

@ -61,6 +61,12 @@ AC_DEFUN_ONCE([MOO_AC_FLAGS],[
MOO_LIBS="$MOO_LIBS $GTKHTML_LIBS"
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
#
@ -69,6 +75,7 @@ AC_DEFUN_ONCE([MOO_AC_FLAGS],[
MOO_LIBS="$MOO_LIBS $XML_LIBS"
fi
AC_SUBST(MOO_WIN32_CFLAGS)
AC_SUBST(MOO_CFLAGS)
AC_SUBST(MOO_LIBS)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -201,11 +201,8 @@ G_END_DECLS
G_BEGIN_DECLS
#define fnmatch _moo_win32_fnmatch
#define gettimeofday _moo_win32_gettimeofday
char *moo_win32_get_app_dir (void);
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,
const char *prefix);
@ -216,25 +213,6 @@ gboolean _moo_win32_open_uri (const char *uri);
void _moo_win32_show_fatal_error (const char *domain,
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

View File

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

View File

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