/*
* Geeqie
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Authors: Vladimir Nadvornik / Laurent Monin
*
gint len;
if (!text) return NULL;
-
+
len = strlen(text);
if (!g_utf8_validate(text, len, NULL))
return g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
s1_t = g_utf8_casefold(s1, -1);
s2_t = g_utf8_casefold(s2, -1);
}
+ else
+ {
+ s1_t = (gchar *) s1;
+ s2_t = (gchar *) s2;
+ }
s1_key = g_utf8_collate_key(s1_t, -1);
s2_key = g_utf8_collate_key(s2_t, -1);
return g_build_filename(home, G_DIR_SEPARATOR_S, NULL);
#endif
}
+
+
+/* Run a command like system() but may output debug messages. */
+int runcmd(gchar *cmd)
+{
+#if 1
+ return system(cmd);
+ return 0;
+#else
+ /* For debugging purposes */
+ int retval = -1;
+ FILE *in;
+
+ DEBUG_1("Running command: %s", cmd);
+
+ in = popen(cmd, "r");
+ if (in)
+ {
+ int status;
+ const gchar *msg;
+ gchar buf[2048];
+
+ while (fgets(buf, sizeof(buf), in) != NULL )
+ {
+ DEBUG_1("Output: %s", buf);
+ }
+
+ status = pclose(in);
+
+ if (WIFEXITED(status))
+ {
+ msg = "Command terminated with exit code";
+ retval = WEXITSTATUS(status);
+ }
+ else if (WIFSIGNALED(status))
+ {
+ msg = "Command was killed by signal";
+ retval = WTERMSIG(status);
+ }
+ else
+ {
+ msg = "pclose() returned";
+ retval = status;
+ }
+
+ DEBUG_1("%s : %d\n", msg, retval);
+ }
+
+ return retval;
+#endif
+}
+
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */