diff options
author | Tor Lillqvist <tml@iki.fi> | 2009-05-29 17:07:52 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2009-05-29 17:07:52 +0300 |
commit | c9df6469d1a38b6e3d71b1a271917ef7f2767fd7 (patch) | |
tree | a7a3606c4b0f2ac3ec9c08da5dd77210271b4e0f | |
parent | 5cb8c99d190c30cd6a75e2db91a88e67b7c43bd0 (diff) | |
download | libgweather-c9df6469d1a38b6e3d71b1a271917ef7f2767fd7.tar.gz |
Further Windows work
Based on Fridrich Strba's work in the openSUSE build service's
cross-compiled Windows package.
Don't include gweather-win32.h in individual .c files, instead include
it in weather-priv.h.
Include <glib.h> in gweather-win32.c to get proper prototypes and
G_OS_WIN32 definition.
Add redirection also for GWEATHER_XML_LOCATION_DIR.
Test _WIN32 in gweather-win32.h instead of G_OS_WIN32 as that is not
necessarily defined if <glib.h> has not been included.
-rw-r--r-- | libgweather/gweather-timezone.c | 4 | ||||
-rw-r--r-- | libgweather/gweather-win32.c | 24 | ||||
-rw-r--r-- | libgweather/gweather-win32.h | 10 | ||||
-rw-r--r-- | libgweather/parser.c | 6 | ||||
-rw-r--r-- | libgweather/weather-metar.c | 4 | ||||
-rw-r--r-- | libgweather/weather-priv.h | 4 | ||||
-rw-r--r-- | libgweather/weather-sun.c | 4 | ||||
-rw-r--r-- | libgweather/weather.c | 4 |
8 files changed, 37 insertions, 23 deletions
diff --git a/libgweather/gweather-timezone.c b/libgweather/gweather-timezone.c index 00cb0aa..c17d192 100644 --- a/libgweather/gweather-timezone.c +++ b/libgweather/gweather-timezone.c @@ -28,10 +28,6 @@ #include "gweather-timezone.h" #include "parser.h" -#ifdef G_OS_WIN32 -#include "gweather-win32.h" -#endif - /** * GWeatherTimezone: * diff --git a/libgweather/gweather-win32.c b/libgweather/gweather-win32.c index 096db7c..3c37607 100644 --- a/libgweather/gweather-win32.c +++ b/libgweather/gweather-win32.c @@ -22,6 +22,8 @@ #include <config.h> #endif +#include <glib.h> + #ifdef G_OS_WIN32 #include <windows.h> @@ -30,6 +32,12 @@ static HMODULE dll = NULL; +/* Prototype first to silence gcc warning */ +BOOL WINAPI +DllMain (HINSTANCE hinstDLL, + DWORD fdwReason, + LPVOID lpvReserved); + BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, @@ -73,4 +81,20 @@ _gweather_win32_get_locale_dir (void) return retval; } +char * +_gweather_win32_get_xml_location_dir (void) +{ + static char *retval = NULL; + char *root; + + if (retval) + return retval; + + root = g_win32_get_package_installation_directory_of_module (dll); + retval = g_build_filename (root, "share/libgweather", NULL); + g_free (root); + + return retval; +} + #endif diff --git a/libgweather/gweather-win32.h b/libgweather/gweather-win32.h index b9766d1..8cd1f63 100644 --- a/libgweather/gweather-win32.h +++ b/libgweather/gweather-win32.h @@ -21,9 +21,7 @@ #ifndef __GWEATHER_WIN32_H__ #define __GWEATHER_WIN32_H__ -G_BEGIN_DECLS - -#ifdef G_OS_WIN32 +#ifdef _WIN32 #define localtime_r(t,tmp) (localtime (t) ? ((*tmp) = *localtime (t), tmp) : NULL) @@ -33,11 +31,13 @@ G_BEGIN_DECLS #undef ZONEINFO_DIR #define ZONEINFO_DIR _gweather_win32_get_zoneinfo_dir () +#undef GWEATHER_XML_LOCATION_DIR +#define GWEATHER_XML_LOCATION_DIR _gweather_win32_get_xml_location_dir () + char *_gweather_win32_get_locale_dir (void); char *_gweather_win32_get_zoneinfo_dir (void); +char *_gweather_win32_get_xml_location_dir (void); #endif -G_END_DECLS - #endif /* __GWEATHER_WIN32_H__ */ diff --git a/libgweather/parser.c b/libgweather/parser.c index c41a4f1..9a5dd6f 100644 --- a/libgweather/parser.c +++ b/libgweather/parser.c @@ -23,6 +23,8 @@ #endif #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE +#include "weather-priv.h" + #include "parser.h" #include <string.h> @@ -199,11 +201,11 @@ gweather_parser_new (gboolean use_regions) * the english names (depending on the configure flags). */ if (!filename) - filename = g_strdup (GWEATHER_XML_LOCATION_DIR "/Locations.xml"); + filename = g_build_filename (GWEATHER_XML_LOCATION_DIR, "Locations.xml", NULL); if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR) && zlib_support) { g_free (filename); - filename = g_strdup (GWEATHER_XML_LOCATION_DIR "/Locations.xml.gz"); + filename = g_build_filename (GWEATHER_XML_LOCATION_DIR, "Locations.xml.gz", NULL); } /* Open the xml file containing the different locations */ diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c index d2936ff..325dbe8 100644 --- a/libgweather/weather-metar.c +++ b/libgweather/weather-metar.c @@ -29,10 +29,6 @@ #include "weather.h" #include "weather-priv.h" -#ifdef G_OS_WIN32 -#include "gweather-win32.h" -#endif - enum { TIME_RE, WIND_RE, diff --git a/libgweather/weather-priv.h b/libgweather/weather-priv.h index f50b388..ff0eb32 100644 --- a/libgweather/weather-priv.h +++ b/libgweather/weather-priv.h @@ -33,6 +33,10 @@ #include "weather.h" #include "gweather-location.h" +#ifdef _WIN32 +#include "gweather-win32.h" +#endif + const char *gweather_gettext (const char *str) G_GNUC_FORMAT (1); const char *gweather_dpgettext (const char *context, const char *str) G_GNUC_FORMAT (2); #define _(str) (gweather_gettext (str)) diff --git a/libgweather/weather-sun.c b/libgweather/weather-sun.c index 843284d..950a1d2 100644 --- a/libgweather/weather-sun.c +++ b/libgweather/weather-sun.c @@ -37,10 +37,6 @@ #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE #include "weather-priv.h" -#ifdef G_OS_WIN32 -#include "gweather-win32.h" -#endif - #define EPOCH_TO_J2000(t) (t - 946728000) #define MEAN_ECLIPTIC_LONGITUDE 280.46435 #define PERIGEE_LONGITUDE 282.94719 diff --git a/libgweather/weather.c b/libgweather/weather.c index 6e90e42..d0aeb7b 100644 --- a/libgweather/weather.c +++ b/libgweather/weather.c @@ -41,10 +41,6 @@ #include "weather.h" #include "weather-priv.h" -#ifdef G_OS_WIN32 -#include "gweather-win32.h" -#endif - static void _weather_internal_check (void); |