summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2015-06-07 19:17:12 -0400
committerSimon Howard2015-06-07 19:17:12 -0400
commitef4c73fc8157ee3be6a41bf1f8bdce82657d715b (patch)
tree945e431ba1a0aed6620757232ef7a5d95e285bd9
parentf69c5a10071b9ac231fd2edfeb49fa6afd7c3948 (diff)
downloadchocolate-doom-ef4c73fc8157ee3be6a41bf1f8bdce82657d715b.tar.gz
chocolate-doom-ef4c73fc8157ee3be6a41bf1f8bdce82657d715b.tar.bz2
chocolate-doom-ef4c73fc8157ee3be6a41bf1f8bdce82657d715b.zip
textscreen: Refactor TXT_OpenURL() to simplify.
In the Windows scenario we don't need to allocate any buffers; it's just a thin wrapper around ShellExecute().
-rw-r--r--textscreen/txt_window.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c
index 41b8c8ef..48d01f79 100644
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -513,6 +513,15 @@ void TXT_SetWindowHelpURL(txt_window_t *window, char *help_url)
window->help_url = help_url;
}
+#ifdef _WIN32
+
+void TXT_OpenURL(char *url)
+{
+ ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
+}
+
+#else
+
void TXT_OpenURL(char *url)
{
char *cmd;
@@ -523,7 +532,7 @@ void TXT_OpenURL(char *url)
#if defined(__MACOSX__)
TXT_snprintf(cmd, cmd_len, "open \"%s\"", url);
-#elif !defined(_WIN32)
+#else
// The Unix situation sucks as usual, but the closest thing to a
// standard that exists is the xdg-utils package.
if (system("xdg-open --version 2>/dev/null") != 0)
@@ -536,14 +545,12 @@ void TXT_OpenURL(char *url)
TXT_snprintf(cmd, cmd_len, "xdg-open \"%s\"", url);
#endif
-#if defined(_WIN32)
- ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
-#else
system(cmd);
-#endif
free(cmd);
}
+#endif /* #ifndef _WIN32 */
+
void TXT_OpenWindowHelpURL(txt_window_t *window)
{
if (window->help_url != NULL)