/* * Minimal glib.h shim for q3map2 on Windows. * Provides the small subset of glib used by inout.cpp and vfs.cpp: * - g_locale_to_utf8 / g_free (UTF-8 conversion) * - GDir / g_dir_open / g_dir_read_name / g_dir_close (directory traversal) */ #pragma once #include #include #ifdef __cplusplus extern "C" { #endif /* ---- types ---- */ typedef char gchar; typedef int gboolean; #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /* ---- UTF-8 conversion ---- */ /* q3map2 messages are ASCII; just duplicate the string. */ static __inline gchar* g_locale_to_utf8(const char* str, int len, void* bytes_read, void* bytes_written, void* error) { (void)bytes_read; (void)bytes_written; (void)error; if (len < 0) return _strdup(str); else { char* r = (char*)malloc((size_t)len + 1); if (r) { memcpy(r, str, (size_t)len); r[len] = '\0'; } return r; } } static __inline void g_free(void* p) { free(p); } /* ---- directory traversal ---- */ typedef struct _GDir GDir; GDir* g_dir_open(const char* path, unsigned int flags, void* error); const char* g_dir_read_name(GDir* dir); void g_dir_close(GDir* dir); #ifdef __cplusplus } #endif