Unify coding style
@sjaeckel integrated clang-format with formal coding style. Run his script and commit changes. There are pros and cons of this commit. Mixed coding style is a "broken window". A good single style simplifies reading and writing code. On the other hand, this is a big change which will lead to conflicts.
This commit is contained in:
@@ -19,23 +19,23 @@
|
||||
|
||||
#include <strophe.h>
|
||||
|
||||
int handle_reply(xmpp_conn_t * const conn,
|
||||
xmpp_stanza_t * const stanza,
|
||||
void * const userdata)
|
||||
int handle_reply(xmpp_conn_t *const conn,
|
||||
xmpp_stanza_t *const stanza,
|
||||
void *const userdata)
|
||||
{
|
||||
xmpp_stanza_t *query, *item;
|
||||
const char *type;
|
||||
|
||||
type = xmpp_stanza_get_type(stanza);
|
||||
if (strcmp(type, "error") == 0)
|
||||
fprintf(stderr, "ERROR: query failed\n");
|
||||
fprintf(stderr, "ERROR: query failed\n");
|
||||
else {
|
||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||
printf("Active Sessions:\n");
|
||||
for (item = xmpp_stanza_get_children(query); item;
|
||||
item = xmpp_stanza_get_next(item))
|
||||
printf("\t %s\n", xmpp_stanza_get_attribute(item, "jid"));
|
||||
printf("END OF LIST\n");
|
||||
query = xmpp_stanza_get_child_by_name(stanza, "query");
|
||||
printf("Active Sessions:\n");
|
||||
for (item = xmpp_stanza_get_children(query); item;
|
||||
item = xmpp_stanza_get_next(item))
|
||||
printf("\t %s\n", xmpp_stanza_get_attribute(item, "jid"));
|
||||
printf("END OF LIST\n");
|
||||
}
|
||||
|
||||
/* disconnect */
|
||||
@@ -44,41 +44,43 @@ int handle_reply(xmpp_conn_t * const conn,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||
const int error, xmpp_stream_error_t * const stream_error,
|
||||
void * const userdata)
|
||||
void conn_handler(xmpp_conn_t *const conn,
|
||||
const xmpp_conn_event_t status,
|
||||
const int error,
|
||||
xmpp_stream_error_t *const stream_error,
|
||||
void *const userdata)
|
||||
{
|
||||
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
|
||||
xmpp_stanza_t *iq, *query;
|
||||
|
||||
if (status == XMPP_CONN_CONNECT) {
|
||||
fprintf(stderr, "DEBUG: connected\n");
|
||||
fprintf(stderr, "DEBUG: connected\n");
|
||||
|
||||
/* create iq stanza for request */
|
||||
iq = xmpp_iq_new(ctx, "get", "active1");
|
||||
xmpp_stanza_set_to(iq, "xxxxxxxxx.com");
|
||||
/* create iq stanza for request */
|
||||
iq = xmpp_iq_new(ctx, "get", "active1");
|
||||
xmpp_stanza_set_to(iq, "xxxxxxxxx.com");
|
||||
|
||||
query = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(query, "query");
|
||||
xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
|
||||
xmpp_stanza_set_attribute(query, "node", "sessions");
|
||||
query = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(query, "query");
|
||||
xmpp_stanza_set_ns(query, XMPP_NS_DISCO_ITEMS);
|
||||
xmpp_stanza_set_attribute(query, "node", "sessions");
|
||||
|
||||
xmpp_stanza_add_child(iq, query);
|
||||
xmpp_stanza_add_child(iq, query);
|
||||
|
||||
/* we can release the stanza since it belongs to iq now */
|
||||
xmpp_stanza_release(query);
|
||||
/* we can release the stanza since it belongs to iq now */
|
||||
xmpp_stanza_release(query);
|
||||
|
||||
/* set up reply handler */
|
||||
xmpp_id_handler_add(conn, handle_reply, "active1", ctx);
|
||||
/* set up reply handler */
|
||||
xmpp_id_handler_add(conn, handle_reply, "active1", ctx);
|
||||
|
||||
/* send out the stanza */
|
||||
xmpp_send(conn, iq);
|
||||
/* send out the stanza */
|
||||
xmpp_send(conn, iq);
|
||||
|
||||
/* release the stanza */
|
||||
xmpp_stanza_release(iq);
|
||||
/* release the stanza */
|
||||
xmpp_stanza_release(iq);
|
||||
} else {
|
||||
fprintf(stderr, "DEBUG: disconnected\n");
|
||||
xmpp_stop(ctx);
|
||||
fprintf(stderr, "DEBUG: disconnected\n");
|
||||
xmpp_stop(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +90,8 @@ int main(int argc, char **argv)
|
||||
xmpp_conn_t *conn;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: active <jid> <pass>\n\n");
|
||||
return 1;
|
||||
fprintf(stderr, "Usage: active <jid> <pass>\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* initialize lib */
|
||||
|
||||
Reference in New Issue
Block a user