summaryrefslogtreecommitdiffstats
path: root/windows.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-06 21:04:25 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-06 21:04:25 -0700
commit475e058d40690803a4114f5aa9055023af6e6b4b (patch)
tree352b9ccb4fd147dd098135fa70145358dc0b6387 /windows.c
parent34db6dc2bea6173c070c9820a2e57a511b9ca0b1 (diff)
downloadsubsurface-475e058d40690803a4114f5aa9055023af6e6b4b.tar.gz
Make Windows cross compile again
But this is broken as the utf8/utf16 conversions in windows.c are gone without glib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'windows.c')
-rw-r--r--windows.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/windows.c b/windows.c
index 731ef2448..cd1acf368 100644
--- a/windows.c
+++ b/windows.c
@@ -14,7 +14,8 @@ const char *system_default_filename(void)
char *buffer;
int len;
- user = g_get_user_name();
+ /* I don't think this works on Windows */
+ user = getenv("LOGNAME");
if (! SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, datapath))) {
datapath[0] = '.';
datapath[1] = '\0';
@@ -29,14 +30,14 @@ const char *system_default_filename(void)
extern int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
/* expand-convert the UTF-16 argument list to a list of UTF-8 strings */
-void subsurface_command_line_init(gint *argc, gchar ***argv)
+void subsurface_command_line_init(int *argc, char ***argv)
{
wchar_t **wargv, **wenviron, *p, path[MAX_PATH] = {0};
- gchar **argv_new;
- gchar *s;
+ char **argv_new;
+ char *s;
/* for si we assume that a struct address will equal the address
* of its first and only int member */
- gint i, n, ret, si;
+ int i, n, ret, si;
/* change the current process path to the module path, so that we can
* access relative folders such as ./share and ./xslt */
@@ -51,23 +52,25 @@ void subsurface_command_line_init(gint *argc, gchar ***argv)
* lifespan as the process heap. */
ret = __wgetmainargs(&n, &wargv, &wenviron, TRUE, &si);
if (ret < 0) {
- g_warning("Cannot convert command line");
+ fprintf(stderr, "Cannot convert command line");
return;
}
- argv_new = g_malloc(sizeof(gchar *) * (n + 1));
+ argv_new = malloc(sizeof(char *) * (n + 1));
+#if MISSING_GLIB_FUNCTIONS
for (i = 0; i < n; ++i) {
s = g_utf16_to_utf8((gunichar2 *)wargv[i], -1, NULL, NULL, NULL);
if (!s) {
- g_warning("Cannot convert command line argument (%d) to UTF-8", (i + 1));
+ fprintf(stderr, "Cannot convert command line argument (%d) to UTF-8", (i + 1));
s = "\0";
- } else if (!g_utf8_validate(s, -1, NULL)) {
- g_warning("Cannot validate command line argument '%s' (%d)", s, (i + 1));
- g_free(s);
+ } else if (!g_utf8_validate(s, -1, NULL)) {
+ fprintf(stderr,"Cannot validate command line argument '%s' (%d)", s, (i + 1));
+ free(s);
s = "\0";
}
argv_new[i] = s;
}
+#endif
argv_new[n] = NULL;
/* update the argument list and count */
@@ -78,12 +81,12 @@ void subsurface_command_line_init(gint *argc, gchar ***argv)
}
/* once done, free the argument list */
-void subsurface_command_line_exit(gint *argc, gchar ***argv)
+void subsurface_command_line_exit(int *argc, char ***argv)
{
int i;
for (i = 0; i < *argc; i++)
- g_free((*argv)[i]);
- g_free(*argv);
+ free((*argv)[i]);
+ free(*argv);
}
/* check if we are running a newer OS version */