AC_DEFINE(TARGET_WIN32, 1, [Target Platform is Win32])
fi
+# Defined for all targets/platforms using classic Windows API support.
+AC_DEFINE(HAVE_CLASSIC_WINAPI_SUPPORT, 1, [Use classic Windows API support])
+AC_DEFINE(HAVE_UWP_WINAPI_SUPPORT, 0, [Don't use UWP Windows API support])
+
AC_SUBST(extra_runtime_ldflags)
AM_CONDITIONAL(HOST_WIN32, test x$host_win32 = xyes)
AM_CONDITIONAL(TARGET_WIN32, test x$target_win32 = xyes)
AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
+# Defined for all targets/platforms using classic Windows API support.
+AC_DEFINE(HAVE_CLASSIC_WINAPI_SUPPORT, 1, [Use classic Windows API support])
+AC_DEFINE(HAVE_UWP_WINAPI_SUPPORT, 0, [Don't use UWP Windows API support])
+
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
#define _EGLIB_MINOR 0
#define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
+
+#define G_HAVE_API_SUPPORT(x) (x)
+#define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__
+#define g_unsupported_api(name) G_STMT_START { g_warning (G_UNSUPPORTED_API, name); } G_STMT_END
G_END_DECLS
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <config.h>
+
#include <stdlib.h>
#include <glib.h>
#include <windows.h>
-#ifdef _MSC_VER
+#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
#include <shlobj.h>
#endif
#include <direct.h>
#include <io.h>
+#include <assert.h>
const gchar *
g_getenv(const gchar *variable)
g_free(var);
}
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
gchar*
g_win32_getlocale(void)
{
return g_strdup (buf);
}
+#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+gchar*
+g_win32_getlocale(void)
+{
+ gunichar2 buf[19];
+ gint ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO639LANGNAME, buf, 9);
+ assert (ccBuf <= 9);
+ if (ccBuf != 0) {
+ buf[ccBuf - 1] = L'-';
+ ccBuf = GetLocaleInfoEx (LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buf + ccBuf, 9);
+ assert (ccBuf <= 9);
+ }
+
+ // Check for GetLocaleInfoEx failure.
+ if (ccBuf == 0)
+ buf[0] = L'\0';
+
+ return u16to8 (buf);
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
gboolean
g_path_is_absolute (const char *filename)
{
{
gchar *home_dir = NULL;
-#ifdef _MSC_VER
+#if _MSC_VER && G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
PWSTR profile_path = NULL;
HRESULT hr = SHGetKnownFolderPath (&FOLDERID_Profile, KF_FLAG_DEFAULT, NULL, &profile_path);
if (SUCCEEDED(hr)) {
}
return tmp_dir;
}
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <config.h>
#include <glib.h>
#include <gmodule.h>
#include <windows.h>
return module;
}
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
static gpointer
w32_find_symbol (const gchar *symbol_name)
{
return NULL;
}
+#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+static gpointer
+w32_find_symbol (const gchar *symbol_name)
+{
+ g_unsupported_api ("EnumProcessModules");
+ SetLastError (ERROR_NOT_SUPPORTED);
+ return NULL;
+}
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
gboolean
g_module_symbol (GModule *module, const gchar *symbol_name, gpointer *symbol)
{
}
}
+#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
const gchar *
g_module_error (void)
{
return ret;
}
+#elif G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
+const gchar *
+g_module_error (void)
+{
+ gchar* ret = NULL;
+ TCHAR buf[1024];
+ DWORD code = GetLastError ();
+
+ if (!FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
+ code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, G_N_ELEMENTS(buf) - 1, NULL) )
+ buf[0] = TEXT('\0');
+
+ ret = u16to8 (buf);
+ return ret;
+}
+
+#else
+
+const gchar *
+g_module_error (void)
+{
+ g_unsupported_api ("FormatMessage");
+ SetLastError (ERROR_NOT_SUPPORTED);
+ return NULL;
+}
+
+#endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */
+
gboolean
g_module_close (GModule *module)
{
return res;
}
+#ifdef G_OS_WIN32
+extern WINBASEAPI UINT WINAPI GetACP(void);
gboolean
g_get_charset (G_CONST_RETURN char **charset)
{
if (my_charset == NULL) {
-#ifdef G_OS_WIN32
static char buf [14];
+#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
+ CPINFOEXA cp_info;
+ GetCPInfoExA (CP_ACP, 0, &cp_info);
+ sprintf (buf, "CP%u", cp_info.CodePage);
+#else
sprintf (buf, "CP%u", GetACP ());
+#endif
my_charset = buf;
is_utf8 = FALSE;
-#else
+ }
+
+ if (charset != NULL)
+ *charset = my_charset;
+
+ return is_utf8;
+}
+
+#else /* G_OS_WIN32 */
+
+gboolean
+g_get_charset (G_CONST_RETURN char **charset)
+{
+ if (my_charset == NULL) {
/* These shouldn't be heap allocated */
#if defined(HAVE_LOCALCHARSET_H)
my_charset = locale_charset ();
my_charset = "UTF-8";
#endif
is_utf8 = strcmp (my_charset, "UTF-8") == 0;
-#endif
}
if (charset != NULL)
return is_utf8;
}
+#endif /* G_OS_WIN32 */
gchar *
g_locale_to_utf8 (const gchar *opsysstring, gssize len, gsize *bytes_read, gsize *bytes_written, GError **error)
#define VERSION "0.1"
#define HAVE_STRTOK_R 1
+
+#ifndef HAVE_WINAPI_FAMILY_SUPPORT
+
+#define HAVE_WINAPI_FAMILY_SUPPORT
+
+/* WIN API Family support */
+#include <winapifamily.h>
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 1
+ #define HAVE_UWP_WINAPI_SUPPORT 0
+#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 0
+ #define HAVE_UWP_WINAPI_SUPPORT 1
+#else
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 0
+ #define HAVE_UWP_WINAPI_SUPPORT 0
+#endif
+
+#endif
#endif
/* Version number of package */
#define VERSION "#MONO_VERSION#"
+
+#ifndef HAVE_WINAPI_FAMILY_SUPPORT
+
+#define HAVE_WINAPI_FAMILY_SUPPORT
+
+/* WIN API Family support */
+#include <winapifamily.h>
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 1
+ #define HAVE_UWP_WINAPI_SUPPORT 0
+#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 0
+ #define HAVE_UWP_WINAPI_SUPPORT 1
+#else
+ #define HAVE_CLASSIC_WINAPI_SUPPORT 0
+ #define HAVE_UWP_WINAPI_SUPPORT 0
+#endif
+
+#endif
#endif