summaryrefslogtreecommitdiff
path: root/gwin32.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2001-03-09 21:31:21 +0000
committerTor Lillqvist <tml@src.gnome.org>2001-03-09 21:31:21 +0000
commit754d8ddad85ef7054bf262bbc57ee67a0278f493 (patch)
treeb582eb1be9315427e894cf6f75f83c5d1adf7114 /gwin32.c
parent31c5b1899ddd9eecea5065f5b9004413b72a0f2c (diff)
Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>.
2001-02-21 Tor Lillqvist <tml@iki.fi> Cygwin support contributed by Stefan Ondrejicka <ondrej@idata.sk>. Hopefully I got it all in while simultaneously adding support for auto*/libtool for mingw. * Makefile.am: Changes for auto* support on Cygwin and Win32. Do still distribute the hand-written makefiles and *.win32.in files, though. Use GIO, GSPAWN and PLATFORMDEP macros set by configure. Use -no-undefined. Pass -export-symbols glib.def to libtool. * configure.in: Define G_PLATFORM_WIN32 on both pure Win32 (mingw) and Cygwin. Add AC_CYGWIN, AC_EXEEXT and AC_LIBTOOL_WIN32_DLL calls for Cygwin and mingw support. Check for %I64u guint64 format (in MS C library). Set G_MODULE_IMPL on mingw and Cygwin. Use ac_object and ac_exeext. Set GIO, GSPAWN, PLATFORMDEP and G_LIBS_EXTRA. Compile timeloop only on Unix. Define OS_WIN32 automake conditional on Win32. * glib.h: Include gwin32.h also on Cygwin. * gfileutils.c (get_contents_posix): Use O_BINARY (defined as 0 on Unix) for Cygwin's sake. * gtimer.c (GETTIME): Reduce #ifdefs, use a macro GETTIME(). * gconvert.c * gthread.c * gutf8.c * gutils.c: For code needed both on Cygwin and native Win32, test for G_PLATFORM_WIN32. * gmarkup.h: Use G_BEGIN_DECLS and G_END_DECLS. * gtypes.h: Refine GLIB_VAR definition. Also check for DLL_EXPORT in case compiling a static library on Win32 or Cygwin. * gwin32.c: No <direct.h> on Cygwin. No need for ftruncate() or dirent emulation on Cygwin. (get_package_directory_from_module) Convert return value from GetModuleFileName() to POSIX path on Cygwin. * tests/Makefile.am (progs_LDADD): Link with libglib, libgthread and libgmodule as appropriate. Use -no-undefined. * gbacktrace.c: Move #ifdefs around a bit on Win32. * gshell.c (unquote_string_inplace): Make static. * testglib.c: Make some vars static. Add Cygwin path tests.
Diffstat (limited to 'gwin32.c')
-rw-r--r--gwin32.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/gwin32.c b/gwin32.c
index 473071168..1a9481807 100644
--- a/gwin32.c
+++ b/gwin32.c
@@ -42,7 +42,10 @@
#define STRICT /* Strict typing, please */
#include <windows.h>
+#undef STRICT
+#ifndef G_WITH_CYGWIN
#include <direct.h>
+#endif
#include <errno.h>
#include <ctype.h>
#ifdef _MSC_VER
@@ -51,7 +54,13 @@
#include "glib.h"
-int
+#ifdef G_WITH_CYGWIN
+#include <sys/cygwin.h>
+#endif
+
+#ifndef G_WITH_CYGWIN
+
+gint
g_win32_ftruncate (gint fd,
guint size)
{
@@ -214,8 +223,9 @@ g_win32_closedir (DIR *dir)
return 0;
}
+#endif
-/* Mingw32 headers don't have latest language and sublanguage codes */
+/* Mingw headers don't have latest language and sublanguage codes */
#ifndef LANG_AFRIKAANS
#define LANG_AFRIKAANS 0x36
#endif
@@ -873,12 +883,23 @@ get_package_directory_from_module (gchar *module_name)
if (!GetModuleFileName (hmodule, fn, MAX_PATH))
return NULL;
- if ((p = strrchr (fn, '\\')) != NULL)
+#ifdef G_WITH_CYGWIN
+ /* In Cygwin we need to have POSIX paths */
+ {
+ gchar tmp[MAX_PATH];
+
+ cygwin_conv_to_posix_path(fn, tmp);
+ g_free(fn);
+ fn = g_strdup(tmp);
+ }
+#endif
+
+ if ((p = strrchr (fn, G_DIR_SEPARATOR)) != NULL)
*p = '\0';
if (module_name)
{
- p = strrchr (fn, '\\');
+ p = strrchr (fn, G_DIR_SEPARATOR);
if (p && (g_strcasecmp (p + 1, "bin") == 0 ||
g_strcasecmp (p + 1, "lib") == 0))
*p = '\0';
@@ -927,7 +948,6 @@ g_win32_get_package_installation_directory (gchar *package,
static GHashTable *package_dirs = NULL;
gchar *result = NULL;
gchar *key;
- char win_dir[MAX_PATH];
HKEY reg_key = NULL;
DWORD type;
DWORD nbytes;
@@ -1001,7 +1021,8 @@ g_win32_get_package_installation_subdirectory (gchar *package,
prefix = g_win32_get_package_installation_directory (package, dll_name);
- sep = (prefix[strlen (prefix) - 1] == '\\' ? "" : "\\");
+ sep = (prefix[strlen (prefix) - 1] == G_DIR_SEPARATOR ?
+ "" : G_DIR_SEPARATOR_S);
return g_strconcat (prefix, sep, subdir, NULL);
}