mirror of
https://github.com/moparisthebest/hexchat
synced 2024-12-23 08:08:54 -05:00
improved command-line argument handling
This commit is contained in:
parent
a98b333a4d
commit
304136efae
106
xchat-wdk.patch
106
xchat-wdk.patch
@ -965,7 +965,7 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/editlist.c xchat-wdk/src
|
||||
#include <sys/stat.h>
|
||||
diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.c xchat-wdk/src/fe-gtk/fe-gtk.c
|
||||
--- xchat-wdk.orig/src/fe-gtk/fe-gtk.c 2010-08-14 03:46:21 +0200
|
||||
+++ xchat-wdk/src/fe-gtk/fe-gtk.c 2010-12-31 05:23:47 +0100
|
||||
+++ xchat-wdk/src/fe-gtk/fe-gtk.c 2011-01-08 09:54:34 +0100
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -991,41 +991,94 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.c xchat-wdk/src/f
|
||||
#include "gtkutil.h"
|
||||
#include "maingui.h"
|
||||
#include "pixmaps.h"
|
||||
@@ -141,6 +143,9 @@
|
||||
@@ -136,11 +138,26 @@
|
||||
{NULL}
|
||||
};
|
||||
|
||||
+#ifdef WIN32
|
||||
+static void
|
||||
+create_msg_dialog (gchar *title, gchar *message)
|
||||
+{
|
||||
+ GtkWidget *dialog;
|
||||
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, message);
|
||||
+ gtk_window_set_title (GTK_WINDOW (dialog), title);
|
||||
+ gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
+ gtk_widget_destroy (dialog);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
int
|
||||
fe_args (int argc, char *argv[])
|
||||
{
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
+#ifdef WIN32
|
||||
+ char buffer[512];
|
||||
+ char *buffer[2048];
|
||||
+#endif
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
@@ -156,7 +161,16 @@
|
||||
@@ -149,22 +166,67 @@
|
||||
#endif
|
||||
|
||||
context = g_option_context_new (NULL);
|
||||
+#ifdef WIN32
|
||||
+ g_option_context_set_help_enabled (context, FALSE); /* disable stdout help as stdout is unavailable for subsystem:windows */
|
||||
+#endif
|
||||
g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
|
||||
g_option_context_add_group (context, gtk_get_option_group (FALSE));
|
||||
g_option_context_parse (context, &argc, &argv, &error);
|
||||
|
||||
+#ifdef WIN32
|
||||
+ if (error) /* workaround for argv not being available when using subsystem:windows */
|
||||
+ {
|
||||
+ if (error->message) /* the error message contains argv so search for patterns in that */
|
||||
+ {
|
||||
+ if (strstr (error->message, "--help-all") != NULL)
|
||||
+ {
|
||||
+ if (snprintf (buffer, 2048, g_option_context_get_help (context, FALSE, NULL)))
|
||||
+ {
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Long Help", buffer);
|
||||
+ }
|
||||
+ return 0;
|
||||
+ } else if (strstr (error->message, "--help") != NULL || strstr (error->message, "-?") != NULL)
|
||||
+ {
|
||||
+ if (snprintf (buffer, 2048, g_option_context_get_help (context, TRUE, NULL)))
|
||||
+ {
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Help", buffer);
|
||||
+ }
|
||||
+ return 0;
|
||||
+ } else
|
||||
+ {
|
||||
+ if (snprintf (buffer, 2048, "%s\n", error->message))
|
||||
+ {
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Error", buffer);
|
||||
+ }
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#else
|
||||
if (error)
|
||||
{
|
||||
if (error->message)
|
||||
+ {
|
||||
+#ifdef WIN32
|
||||
+ if (snprintf (buffer, 512, "%s\n", error->message))
|
||||
+ {
|
||||
+ MessageBox (NULL, buffer, "Error", MB_OK);
|
||||
+ }
|
||||
+#else
|
||||
printf ("%s\n", error->message);
|
||||
+#endif
|
||||
+ }
|
||||
return 1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
@@ -164,7 +178,14 @@
|
||||
g_option_context_free (context);
|
||||
|
||||
if (arg_show_version)
|
||||
{
|
||||
+#ifdef WIN32
|
||||
+ if (snprintf (buffer, 512, DISPLAY_NAME" "PACKAGE_VERSION"\n"))
|
||||
+ if (snprintf (buffer, 2048, DISPLAY_NAME" "PACKAGE_VERSION"\n"))
|
||||
+ {
|
||||
+ MessageBox (NULL, buffer, "Version Information", MB_OK);
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Version Information", buffer);
|
||||
+ }
|
||||
+#else
|
||||
printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
|
||||
@ -1033,32 +1086,35 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.c xchat-wdk/src/f
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -177,7 +198,16 @@
|
||||
@@ -177,7 +239,18 @@
|
||||
if (sl)
|
||||
{
|
||||
*sl = 0;
|
||||
- printf ("%s\\plugins\n", exe);
|
||||
+ if (snprintf (buffer, 512, "%s\\plugins\n", exe))
|
||||
+ if (snprintf (buffer, 2048, "%s\\plugins\n", exe))
|
||||
+ {
|
||||
+ MessageBox (NULL, buffer, "Plugin Auto-load Directory", MB_OK);
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Plugin Auto-load Directory", buffer);
|
||||
+ }
|
||||
+ } else
|
||||
+ {
|
||||
+ if (snprintf (buffer, 512, ".\\plugins\n"))
|
||||
+ if (snprintf (buffer, 2048, ".\\plugins\n"))
|
||||
+ {
|
||||
+ MessageBox (NULL, buffer, "Plugin Auto-load Directory", MB_OK);
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("Plugin Auto-load Directory", buffer);
|
||||
+ }
|
||||
}
|
||||
#else
|
||||
printf ("%s\n", XCHATLIBDIR"/plugins");
|
||||
@@ -187,7 +217,14 @@
|
||||
@@ -187,7 +260,15 @@
|
||||
|
||||
if (arg_show_config)
|
||||
{
|
||||
+#ifdef WIN32
|
||||
+ if (snprintf (buffer, 512, "%s\n", get_xdir_fs ()))
|
||||
+ if (snprintf (buffer, 2048, "%s\n", get_xdir_fs ()))
|
||||
+ {
|
||||
+ MessageBox (NULL, buffer, "User Config Directory", MB_OK);
|
||||
+ gtk_init (&argc, &argv);
|
||||
+ create_msg_dialog ("User Config Directory", buffer);
|
||||
+ }
|
||||
+#else
|
||||
printf ("%s\n", get_xdir_fs ());
|
||||
@ -1066,7 +1122,7 @@ diff -ruN --strip-trailing-cr xchat-wdk.orig/src/fe-gtk/fe-gtk.c xchat-wdk/src/f
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -330,7 +367,7 @@
|
||||
@@ -330,7 +411,7 @@
|
||||
{
|
||||
session *sess;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user