summaryrefslogtreecommitdiff
path: root/src/cmumble.c
diff options
context:
space:
mode:
authorJan Klemkow <j.klemkow@wemelug.de>2011-09-25 01:34:31 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-09-25 12:54:55 +0200
commit98bc17525c76803e5784560ed8c2e0e276d83444 (patch)
tree58d4006144d273d15ab510aafa493a4e9534c4d5 /src/cmumble.c
parentc820c3d4830b2c5db1c026ee332f2d773c366247 (diff)
downloadcmumble-98bc17525c76803e5784560ed8c2e0e276d83444.tar.gz
cmumble-98bc17525c76803e5784560ed8c2e0e276d83444.tar.bz2
cmumble-98bc17525c76803e5784560ed8c2e0e276d83444.zip
Add glib parsing function for argc and argv.
Diffstat (limited to 'src/cmumble.c')
-rw-r--r--src/cmumble.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/cmumble.c b/src/cmumble.c
index 3599f91..82af149 100644
--- a/src/cmumble.c
+++ b/src/cmumble.c
@@ -239,20 +239,43 @@ cmumble_protocol_init(struct cmumble_context *ctx)
g_source_unref(source);
}
+gchar *user = "unkown";
+gchar *host = "localhost";
+gint port = 64738;
+
+static GOptionEntry entries[] = {
+ {
+ "user", 'u', 0, G_OPTION_ARG_STRING, &user,
+ "user name", "N"
+ },
+ {
+ "host", 'h', 0, G_OPTION_ARG_STRING, &host,
+ "Host name or ip address of the mumble server", "N"
+ },
+ {
+ "port", 'p', 0, G_OPTION_ARG_INT, &port,
+ "port of the mumble server", "N"
+ },
+ { NULL }
+};
+
int main(int argc, char **argv)
{
- char *host = "localhost";
- unsigned int port = 64738;
struct cmumble_context ctx;
+ GError *error = NULL;
+ GOptionContext *context;
+
+ context = g_option_context_new ("command line mumble client");
+ g_option_context_add_main_entries (context, entries, "cmumble");
- if (argc >= 3)
- host = argv[2];
- if (argc >= 4)
- port = atoi(argv[3]);
+ if (!g_option_context_parse (context, &argc, &argv, &error)) {
+ g_print("option parsing failed: %s\n", error->message);
+ exit(1);
+ }
memset(&ctx, 0, sizeof(ctx));
- ctx.user_name = argv[1];
+ ctx.user_name = user;
ctx.users = NULL;
g_type_init();