From: Carl Worth Date: Thu, 10 Jan 2008 06:02:16 +0000 (-0800) Subject: Rename UserInfo to loudgame_t X-Git-Url: https://git.cworth.org/git?p=loudgame;a=commitdiff_plain;h=e995240ce8748861317919d3ac98efece67076da Rename UserInfo to loudgame_t --- diff --git a/lm-echo.c b/lm-echo.c index 22291d3..661949e 100644 --- a/lm-echo.c +++ b/lm-echo.c @@ -25,40 +25,40 @@ #include #endif -typedef struct { +typedef struct _loudgame { gchar *server; gchar *name; gchar *passwd; LmConnection *connection; GMainLoop *main_loop; int return_value; -} UserInfo; +} loudgame_t; static void -loudgame_quit (UserInfo *info, int return_value) +loudgame_quit (loudgame_t *lg, int return_value) { GError *error; - info->return_value = return_value; + lg->return_value = return_value; - if (! lm_connection_close (info->connection, &error)) + if (! lm_connection_close (lg->connection, &error)) g_print ("An error occurred during lm_connection_close: %s\n", error->message); - lm_connection_unref (info->connection); + lm_connection_unref (lg->connection); - g_main_loop_quit (info->main_loop); + g_main_loop_quit (lg->main_loop); } static void authentication_cb (LmConnection *connection, gboolean result, gpointer closure) { LmMessage *m; - UserInfo *info = closure; + loudgame_t *lg = closure; if (! result) { - g_print ("Authentication for %s failed\n", info->name); - loudgame_quit (info, 1); + g_print ("Authentication for %s failed\n", lg->name); + loudgame_quit (lg, 1); return; } @@ -71,18 +71,18 @@ authentication_cb (LmConnection *connection, gboolean result, gpointer closure) } static void -connection_open_cb (LmConnection *connection, gboolean result, UserInfo *info) +connection_open_cb (LmConnection *connection, gboolean result, loudgame_t *lg) { lm_connection_authenticate (connection, - info->name, info->passwd, "TestLM", - authentication_cb, info, FALSE, NULL); + lg->name, lg->passwd, "TestLM", + authentication_cb, lg, FALSE, NULL); } static void send_reply (LmConnection *connection, const char *peer, const char *message, - UserInfo *info) + loudgame_t *lg) { LmMessage *reply; gboolean result; @@ -97,7 +97,7 @@ send_reply (LmConnection *connection, if (! result) { g_error ("lm_connection_send failed: error->message"); - loudgame_quit (info, 1); + loudgame_quit (lg, 1); } } @@ -105,17 +105,17 @@ static void handle_command (LmConnection *connection, const char *peer, const char *command, - UserInfo *info) + loudgame_t *lg) { char *error; if (strcmp (command, "quit") == 0) { - loudgame_quit (info, 0); + loudgame_quit (lg, 0); return; } error = g_strdup_printf ("Unknown command: '%s'", command); - send_reply (connection, peer, error, info); + send_reply (connection, peer, error, lg); free (error); } @@ -125,7 +125,7 @@ handle_messages (LmMessageHandler *handler, LmMessage *m, gpointer closure) { - UserInfo *info = closure; + loudgame_t *lg = closure; LmMessageNode *body; const char *peer; const char *body_str; @@ -137,9 +137,9 @@ handle_messages (LmMessageHandler *handler, body_str = lm_message_node_get_value (body); if (body_str && body_str[0] == '%') - handle_command (connection, peer, body_str + 1, info); + handle_command (connection, peer, body_str + 1, lg); else - send_reply (connection, peer, body_str, info); + send_reply (connection, peer, body_str, lg); } return LM_HANDLER_RESULT_REMOVE_MESSAGE; @@ -148,33 +148,33 @@ handle_messages (LmMessageHandler *handler, static gboolean make_connection (gpointer closure) { - UserInfo *info; + loudgame_t *lg; LmMessageHandler *handler; gchar *jid; GError *error; - info = closure; + lg = closure; - info->connection = lm_connection_new (info->server); + lg->connection = lm_connection_new (lg->server); - jid = g_strdup_printf ("%s@%s", info->name, info->server); - lm_connection_set_jid (info->connection, jid); + jid = g_strdup_printf ("%s@%s", lg->name, lg->server); + lm_connection_set_jid (lg->connection, jid); g_free (jid); - handler = lm_message_handler_new (handle_messages, info, NULL); - lm_connection_register_message_handler (info->connection, + handler = lm_message_handler_new (handle_messages, lg, NULL); + lm_connection_register_message_handler (lg->connection, handler, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_NORMAL); lm_message_handler_unref (handler); - if (! lm_connection_open (info->connection, + if (! lm_connection_open (lg->connection, (LmResultFunction) connection_open_cb, - info, NULL, &error)) + lg, NULL, &error)) { g_print ("Opening connection failed: %s\n", error->message); - loudgame_quit (info, 1); + loudgame_quit (lg, 1); } /* Return false to not schedule another call. */ @@ -184,26 +184,26 @@ make_connection (gpointer closure) int main (int argc, char **argv) { - UserInfo info; + loudgame_t lg; if (argc != 4) { g_print ("Usage: %s \n", argv[0]); return 1; } - info.server = argv[1]; - info.name = argv[2]; - info.passwd = argv[3]; + lg.server = argv[1]; + lg.name = argv[2]; + lg.passwd = argv[3]; - info.connection = NULL; + lg.connection = NULL; - info.main_loop = g_main_loop_new (NULL, FALSE); + lg.main_loop = g_main_loop_new (NULL, FALSE); - g_idle_add (make_connection, &info); + g_idle_add (make_connection, &lg); - g_main_loop_run (info.main_loop); + g_main_loop_run (lg.main_loop); - g_main_loop_unref (info.main_loop); + g_main_loop_unref (lg.main_loop); - return info.return_value; + return lg.return_value; }