/pidgin/main: 36a1ce60ce7b: MXit: Rather use g_snprintf().
Andrew Victor
andrew.victor at mxit.com
Fri Mar 29 19:03:44 EDT 2013
Changeset: 36a1ce60ce7bf4bc6a2c8cc64833a32832a38e83
Author: Andrew Victor <andrew.victor at mxit.com>
Date: 2013-03-30 01:01 +0200
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/36a1ce60ce7b
Description:
MXit: Rather use g_snprintf().
diffstat:
libpurple/protocols/mxit/protocol.c | 78 ++++++++++++++++++------------------
1 files changed, 39 insertions(+), 39 deletions(-)
diffs (truncated from 321 to 300 lines):
diff --git a/libpurple/protocols/mxit/protocol.c b/libpurple/protocols/mxit/protocol.c
--- a/libpurple/protocols/mxit/protocol.c
+++ b/libpurple/protocols/mxit/protocol.c
@@ -461,23 +461,23 @@ static void mxit_queue_packet( struct MX
packet->headerlen = 0;
/* create generic packet header */
- hlen = snprintf( header, sizeof( header ), "id=%s%c", purple_account_get_username( session->acc ), CP_REC_TERM ); /* client mxitid */
+ hlen = g_snprintf( header, sizeof( header ), "id=%s%c", purple_account_get_username( session->acc ), CP_REC_TERM ); /* client mxitid */
if ( session->http ) {
/* http connection only */
- hlen += snprintf( header + hlen, sizeof( header ) - hlen, "s=" );
+ hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "s=" );
if ( session->http_sesid > 0 ) {
- hlen += snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_sesid, CP_FLD_TERM ); /* http session id */
+ hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_sesid, CP_FLD_TERM ); /* http session id */
}
session->http_seqno++;
- hlen += snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_seqno, CP_REC_TERM ); /* http request sequence id */
+ hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_seqno, CP_REC_TERM ); /* http request sequence id */
}
- hlen += snprintf( header + hlen, sizeof( header ) - hlen, "cm=%i%c", cmd, CP_REC_TERM ); /* packet command */
+ hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "cm=%i%c", cmd, CP_REC_TERM ); /* packet command */
if ( !session->http ) {
/* socket connection only */
- packet->headerlen = snprintf( packet->header, sizeof( packet->header ), "ln=%i%c", ( datalen + hlen ), CP_REC_TERM ); /* packet length */
+ packet->headerlen = g_snprintf( packet->header, sizeof( packet->header ), "ln=%i%c", ( datalen + hlen ), CP_REC_TERM ); /* packet length */
}
/* copy the header to packet */
@@ -716,7 +716,7 @@ void mxit_send_register( struct MXitSess
clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i%c%s%c" /* "ms"=password\1version\1maxreplyLen\1name\1 */
"%s%c%i%c%s%c%s%c" /* dateOfBirth\1gender\1location\1capabilities\1 */
"%s%c%i%c%s%c%s" /* dc\1features\1dialingcode\1locale */
@@ -760,7 +760,7 @@ void mxit_send_login( struct MXitSession
clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i%c" /* "ms"=password\1version\1getContacts\1 */
"%s%c%s%c%i%c" /* capabilities\1dc\1features\1 */
"%s%c%s%c" /* dialingcode\1locale\1 */
@@ -774,7 +774,7 @@ void mxit_send_login( struct MXitSession
/* include "custom resource" information */
splashId = splash_current( session );
if ( splashId != NULL )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%ccr=%s", CP_REC_TERM, splashId );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%ccr=%s", CP_REC_TERM, splashId );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_LOGIN );
@@ -804,7 +804,7 @@ void mxit_send_message( struct MXitSessi
markuped_msg = g_strdup( msg );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i%c%i", /* "ms"=jid\1msg\1type\1flags */
to, CP_FLD_TERM, markuped_msg, CP_FLD_TERM, msgtype, CP_FLD_TERM, CP_MSG_MARKUP | CP_MSG_EMOTICON
);
@@ -831,14 +831,14 @@ void mxit_send_extprofile_request( struc
int datalen;
unsigned int i;
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%i", /* "ms="mxitid\1nr_attributes */
( username ? username : "" ), CP_FLD_TERM, nr_attrib
);
/* add attributes */
for ( i = 0; i < nr_attrib; i++ )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_EXTPROFILE_GET );
@@ -864,7 +864,7 @@ void mxit_send_extprofile_update( struct
parts = g_strsplit( attributes, "\01", 1 + ( nr_attrib * 3 ) );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%i", /* "ms"=password\1nr_attibutes */
( password ) ? password : "", CP_FLD_TERM, nr_attrib
);
@@ -876,7 +876,7 @@ void mxit_send_extprofile_update( struct
g_strfreev( parts );
return;
}
- datalen += snprintf( data + datalen, sizeof( data ) - datalen,
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen,
"%c%s%c%s%c%s", /* \1name\1type\1value */
CP_FLD_TERM, parts[i], CP_FLD_TERM, parts[i + 1], CP_FLD_TERM, parts[i + 2] );
}
@@ -904,13 +904,13 @@ void mxit_send_suggest_friends( struct M
unsigned int i;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%i%c%s%c%i%c%i%c%i", /* inputType \1 input \1 maxSuggestions \1 startIndex \1 numAttributes \1 name0 \1 name1 ... \1 nameN */
CP_SUGGEST_FRIENDS, CP_FLD_TERM, "", CP_FLD_TERM, max, CP_FLD_TERM, 0, CP_FLD_TERM, nr_attrib );
/* add attributes */
for ( i = 0; i < nr_attrib; i++ )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_SUGGESTCONTACTS );
@@ -933,13 +933,13 @@ void mxit_send_suggest_search( struct MX
unsigned int i;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%i%c%s%c%i%c%i%c%i", /* inputType \1 input \1 maxSuggestions \1 startIndex \1 numAttributes \1 name0 \1 name1 ... \1 nameN */
CP_SUGGEST_SEARCH, CP_FLD_TERM, text, CP_FLD_TERM, max, CP_FLD_TERM, 0, CP_FLD_TERM, nr_attrib );
/* add attributes */
for ( i = 0; i < nr_attrib; i++ )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_SUGGESTCONTACTS );
@@ -959,14 +959,14 @@ void mxit_send_presence( struct MXitSess
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%i%c", /* "ms"=show\1status */
presence, CP_FLD_TERM
);
/* append status message (if one is set) */
if ( statusmsg )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%s", statusmsg );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%s", statusmsg );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_STATUS );
@@ -985,7 +985,7 @@ void mxit_send_mood( struct MXitSession*
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%i", /* "ms"=mood */
mood
);
@@ -1011,7 +1011,7 @@ void mxit_send_invite( struct MXitSessio
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%s%c%i%c%s%c%i", /* "ms"=group \1 username \1 alias \1 type \1 msg \1 isuserid */
groupname, CP_FLD_TERM, username, CP_FLD_TERM, alias,
CP_FLD_TERM, MXIT_TYPE_MXIT, CP_FLD_TERM,
@@ -1036,7 +1036,7 @@ void mxit_send_remove( struct MXitSessio
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s", /* "ms"=username */
username
);
@@ -1059,7 +1059,7 @@ void mxit_send_allow_sub( struct MXitSes
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%s", /* "ms"=username\1group\1alias */
username, CP_FLD_TERM, "", CP_FLD_TERM, alias
);
@@ -1082,14 +1082,14 @@ void mxit_send_deny_sub( struct MXitSess
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s", /* "ms"=username */
username
);
/* append reason (if one is set) */
if ( reason )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, reason );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, reason );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_DENY );
@@ -1110,7 +1110,7 @@ void mxit_send_update_contact( struct MX
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%s", /* "ms"=groupname\1username\1alias */
groupname, CP_FLD_TERM, username, CP_FLD_TERM, alias
);
@@ -1132,7 +1132,7 @@ void mxit_send_splashclick( struct MXitS
int datalen;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s", /* "ms"=splashId */
splashid
);
@@ -1158,7 +1158,7 @@ void mxit_send_msgevent( struct MXitSess
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_msgevent: to=%s id=%s event=%i\n", to, id, event );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%s%c%i", /* "ms"=contactAddress \1 id \1 event */
to, CP_FLD_TERM, id, CP_FLD_TERM, event
);
@@ -1183,14 +1183,14 @@ void mxit_send_groupchat_create( struct
int i;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%i", /* "ms"=roomname\1nr_jids\1jid0\1..\1jidN */
groupname, CP_FLD_TERM, nr_usernames
);
/* add usernames */
for ( i = 0; i < nr_usernames; i++ )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_GRPCHAT_CREATE );
@@ -1212,14 +1212,14 @@ void mxit_send_groupchat_invite( struct
int i;
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ),
+ datalen = g_snprintf( data, sizeof( data ),
"ms=%s%c%i", /* "ms"=roomid\1nr_jids\1jid0\1..\1jidN */
roomid, CP_FLD_TERM, nr_usernames
);
/* add usernames */
for ( i = 0; i < nr_usernames; i++ )
- datalen += snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] );
+ datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] );
/* queue packet for transmission */
mxit_queue_packet( session, data, datalen, CP_CMD_GRPCHAT_INVITE );
@@ -1245,7 +1245,7 @@ void mxit_send_file( struct MXitSession*
purple_debug_info( MXIT_PLUGIN_ID, "SENDING FILE '%s' of %i bytes to user '%s'\n", filename, buflen, username );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ), "ms=" );
+ datalen = g_snprintf( data, sizeof( data ), "ms=" );
/* map chunk header over data buffer */
chunk = &data[datalen];
@@ -1281,7 +1281,7 @@ void mxit_send_file_reject( struct MXitS
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_reject\n" );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ), "ms=" );
+ datalen = g_snprintf( data, sizeof( data ), "ms=" );
/* map chunk header over data buffer */
chunk = &data[datalen];
@@ -1319,7 +1319,7 @@ void mxit_send_file_accept( struct MXitS
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_accept\n" );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ), "ms=" );
+ datalen = g_snprintf( data, sizeof( data ), "ms=" );
/* map chunk header over data buffer */
chunk = &data[datalen];
@@ -1355,7 +1355,7 @@ void mxit_send_file_received( struct MXi
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_received\n" );
/* convert the packet to a byte stream */
- datalen = snprintf( data, sizeof( data ), "ms=" );
+ datalen = g_snprintf( data, sizeof( data ), "ms=" );
More information about the Commits
mailing list