diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-09-28 13:57:14 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2011-09-28 13:57:14 +0200 |
commit | c1cf0a71cfd8aa3441e57592e17de0d34823d305 (patch) | |
tree | daa9d873d62cad56c5f246d6d4dea618d53bf3a5 /src | |
parent | b83e8c2d09a357b2f06f10a9a41169c6c4061d46 (diff) | |
download | cmumble-c1cf0a71cfd8aa3441e57592e17de0d34823d305.tar.gz cmumble-c1cf0a71cfd8aa3441e57592e17de0d34823d305.tar.bz2 cmumble-c1cf0a71cfd8aa3441e57592e17de0d34823d305.zip |
find_by_id: Fix lookup
The offset should be taken from the (GList *)::data pointer,
not the list directly..
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.c | 31 | ||||
-rw-r--r-- | src/commands.h | 3 | ||||
-rw-r--r-- | src/io.c | 2 | ||||
-rw-r--r-- | src/util.c | 2 |
4 files changed, 30 insertions, 8 deletions
diff --git a/src/commands.c b/src/commands.c index b89c5a4..31cc263 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1,5 +1,6 @@ #include "../config.h" #include "commands.h" +#include "util.h" #include "cmumble.h" #include <glib.h> @@ -9,7 +10,8 @@ #include <readline/history.h> static void -list_users(struct cmumble_context *ctx) +list_users(struct cmumble_context *ctx, + int argc, const char *argv) { struct cmumble_user *user = NULL; GList *l; @@ -22,7 +24,8 @@ list_users(struct cmumble_context *ctx) } static void -list_channels(struct cmumble_context *ctx) +list_channels(struct cmumble_context *ctx, + int argc, const char *argv) { struct cmumble_channel *channel = NULL; GList *l; @@ -35,14 +38,16 @@ list_channels(struct cmumble_context *ctx) } static void -quit(struct cmumble_context *ctx) +quit(struct cmumble_context *ctx, + int argc, const char *argv) { rl_already_prompted = 1; g_main_loop_quit(ctx->loop); } static void -clear(struct cmumble_context *ctx) +clear(struct cmumble_context *ctx, + int argc, const char *argv) { rl_clear_screen(0,0); rl_reset_line_state(); @@ -50,7 +55,8 @@ clear(struct cmumble_context *ctx) } static void -help(struct cmumble_context *ctx) +help(struct cmumble_context *ctx, + int argc, const char *argv) { int i; @@ -59,12 +65,27 @@ help(struct cmumble_context *ctx) ctx->commands[i].name, ctx->commands[i].description); } +static void +msg(struct cmumble_context *ctx, + int argc, const char *argv) +{ +} + +static void +test(struct cmumble_context *ctx, + int argc, const char *argv) +{ + g_print("find user 1: %p\n", find_user(ctx, 1)); +} + static const struct cmumble_command commands[] = { { "lu", list_users, "list users" }, { "lc", list_channels, "list channels" }, { "clear", clear, "clear screen" }, + { "msg", msg, "Send broadcast message" }, { "help", help, "show this help" }, { "quit", quit, "quit " PACKAGE }, + { "test", test, "test" }, { NULL, NULL , NULL} }; diff --git a/src/commands.h b/src/commands.h index 6ea8c67..a348f17 100644 --- a/src/commands.h +++ b/src/commands.h @@ -5,7 +5,8 @@ struct cmumble_context; struct cmumble_command { const char *name; - void (*callback)(struct cmumble_context *); + void (*callback)(struct cmumble_context *, + int argc, const char *argv); const char *description; }; @@ -105,7 +105,7 @@ process_line(char *line) cmd[strlen(ctx->commands[i].name)] != ' ') continue; - ctx->commands[i].callback(ctx); + ctx->commands[i].callback(ctx, 0, NULL); break; } } @@ -8,7 +8,7 @@ cmumble_find_by_id(GList *list, gsize member_offset, guint id) GList *l; for (l = list; l; l = l->next) { - if (G_STRUCT_MEMBER(uint32_t, l, member_offset) == id) { + if (G_STRUCT_MEMBER(uint32_t, l->data, member_offset) == id) { el = l->data; break; } |