--- a/libpurple/protocols/mxit/chunk.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/chunk.c Fri Jun 03 12:07:21 2016 -0500
@@ -168,7 +168,7 @@
* @param value The 16-bit value
* @return The number of bytes extracted
-static int get_int16( const char* chunkdata, short* value )
+static int get_int16( const char* chunkdata, unsigned short* value ) *value = ntohs( *( (const short*) chunkdata ) ); /* host byte-order */
@@ -182,7 +182,7 @@
* @param value The 32-bit value
* @return The number of bytes extracted
-static int get_int32( const char* chunkdata, int* value )
+static int get_int32( const char* chunkdata, unsigned int* value ) *value = ntohl( *( (const int*) chunkdata ) ); /* host byte-order */
@@ -230,9 +230,9 @@
static int get_utf8_string( const char* chunkdata, char* str, int maxstrlen )
/* string length [2 bytes] */
pos += get_int16( &chunkdata[pos], &len );
@@ -263,9 +263,9 @@
* @param fileid A unique ID that identifies this file
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_reject( char* chunkdata, const char* fileid )
+size_t mxit_chunk_create_reject( char* chunkdata, const char* fileid )
pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -289,9 +289,9 @@
* @param offset The start offset in the file
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_get( char* chunkdata, const char* fileid, int filesize, int offset )
+size_t mxit_chunk_create_get( char* chunkdata, const char* fileid, size_t filesize, size_t offset )
pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -314,9 +314,9 @@
* @param status The status of the file transfer (see chunk.h)
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status )
+size_t mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status )
pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -338,9 +338,9 @@
* @param datalen The size of the file contents
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, int datalen )
+size_t mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, size_t datalen )
/* data length [4 bytes] */
@@ -380,10 +380,10 @@
* @param datalen The size of the avatar data
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, int datalen )
+size_t mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, size_t datalen ) char fileid[MXIT_CHUNK_FILEID_LEN];
memset( &fileid, 0, sizeof( fileid ) ); /* set to 0 for file upload */
@@ -410,9 +410,9 @@
* @param avatarId The Id of the avatar image (as string)
* @return The number of bytes encoded in the buffer
-int mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId )
+size_t mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId )
/* number of avatars [4 bytes] */
pos += add_int32( &chunkdata[pos], 1 );
@@ -450,11 +450,11 @@
* @param datalen The length of the chunked data
* @param offer Decoded offerfile information
-void mxit_chunk_parse_offer( char* chunkdata, int datalen, struct offerfile_chunk* offer )
+void mxit_chunk_parse_offer( char* chunkdata, size_t datalen, struct offerfile_chunk* offer )
- purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_offer (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_offer (%zu bytes)\n", datalen ); pos += get_data( &chunkdata[pos], offer->fileid, 8);
@@ -493,11 +493,11 @@
* @param datalen The length of the chunked data
* @param offer Decoded getfile information
-void mxit_chunk_parse_get( char* chunkdata, int datalen, struct getfile_chunk* getfile )
+void mxit_chunk_parse_get( char* chunkdata, size_t datalen, struct getfile_chunk* getfile ) - purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_file (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_file (%zu bytes)\n", datalen ); pos += get_data( &chunkdata[pos], getfile->fileid, 8 );
@@ -523,11 +523,11 @@
* @param datalen The length of the chunked data
* @param splash Decoded splash image information
-static void mxit_chunk_parse_splash( char* chunkdata, int datalen, struct splash_chunk* splash )
+static void mxit_chunk_parse_splash( char* chunkdata, size_t datalen, struct splash_chunk* splash ) - purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_splash (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_splash (%zu bytes)\n", datalen ); pos += get_int8( &chunkdata[pos], &(splash->anchor) );
@@ -553,12 +553,12 @@
* @param datalen The length of the chunked data
* @param offer Decoded custom resource
-void mxit_chunk_parse_cr( char* chunkdata, int datalen, struct cr_chunk* cr )
+void mxit_chunk_parse_cr( char* chunkdata, size_t datalen, struct cr_chunk* cr )
+ unsigned int chunklen = 0; - purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_cr (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_cr (%zu bytes)\n", datalen ); pos += get_utf8_string( &chunkdata[pos], cr->id, sizeof( cr->id ) );
@@ -614,12 +614,12 @@
* @param datalen The length of the chunked data
* @param sendfile Decoded sendfile information
-void mxit_chunk_parse_sendfile( char* chunkdata, int datalen, struct sendfile_chunk* sendfile )
+void mxit_chunk_parse_sendfile( char* chunkdata, size_t datalen, struct sendfile_chunk* sendfile )
+ unsigned short entries = 0; - purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_sendfile (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_sendfile (%zu bytes)\n", datalen ); /* number of entries [2 bytes] */
pos += get_int16( &chunkdata[pos], &entries );
@@ -645,12 +645,12 @@
* @param datalen The length of the chunked data
* @param avatar Decoded avatar information
-void mxit_chunk_parse_get_avatar( char* chunkdata, int datalen, struct getavatar_chunk* avatar )
+void mxit_chunk_parse_get_avatar( char* chunkdata, size_t datalen, struct getavatar_chunk* avatar )
+ unsigned int numfiles = 0; - purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_get_avatar (%i bytes)\n", datalen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_get_avatar (%zu bytes)\n", datalen ); /* number of files [4 bytes] */
pos += get_int32( &chunkdata[pos], &numfiles );
--- a/libpurple/protocols/mxit/filexfer.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/filexfer.c Fri Jun 03 12:07:21 2016 -0500
@@ -357,7 +357,7 @@
* @param filesize The size of the file being offered
* @param fileid A unique ID that identifies this file
-void mxit_xfer_rx_offer( struct MXitSession* session, const char* username, const char* filename, int filesize, const char* fileid )
+void mxit_xfer_rx_offer( struct MXitSession* session, const char* username, const char* filename, unsigned int filesize, const char* fileid ) struct mxitxfer* mx = NULL;
@@ -373,7 +373,7 @@
purple_xfer_set_filename( xfer, filename );
purple_xfer_set_size( xfer, filesize );
/* register file transfer callback functions */
@@ -429,7 +429,7 @@
* @param data The file data
* @param datalen The size of the data
-void mxit_xfer_rx_file( struct MXitSession* session, const char* fileid, const char* data, int datalen )
+void mxit_xfer_rx_file( struct MXitSession* session, const char* fileid, const char* data, unsigned int datalen ) --- a/libpurple/protocols/mxit/protocol.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/protocol.c Fri Jun 03 12:07:21 2016 -0500
@@ -1223,14 +1223,14 @@
* @param buf The content of the file
* @param buflen The length of the file contents
-void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, int buflen )
+void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, size_t buflen ) char data[CP_MAX_PACKET];
- purple_debug_info( MXIT_PLUGIN_ID, "SENDING FILE '%s' of %i bytes to user '%s'\n", filename, buflen, username );
+ purple_debug_info( MXIT_PLUGIN_ID, "SENDING FILE '%s' of %zu bytes to user '%s'\n", filename, buflen, username ); /* convert the packet to a byte stream */
datalen = g_snprintf( data, sizeof( data ), "ms=" );
@@ -1238,15 +1238,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_senddirect( chunk_data( chunk ), username, filename, buf, buflen );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating senddirect chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_senddirect( chunk_data( chunk ), username, filename, buf, buflen ); set_chunk_type( chunk, CP_CHUNK_DIRECT_SND );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
@@ -1264,7 +1260,7 @@
char data[CP_MAX_PACKET];
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_reject\n" );
@@ -1274,15 +1270,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_reject( chunk_data( chunk ), fileid );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating reject chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_reject( chunk_data( chunk ), fileid ); set_chunk_type( chunk, CP_CHUNK_REJECT );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
@@ -1297,12 +1289,12 @@
* @param filesize The number of bytes to retrieve
* @param offset Offset in file at which to start retrieving
-void mxit_send_file_accept( struct MXitSession* session, const char* fileid, int filesize, int offset )
+void mxit_send_file_accept( struct MXitSession* session, const char* fileid, size_t filesize, size_t offset ) char data[CP_MAX_PACKET];
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_accept\n" );
@@ -1312,15 +1304,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_get( chunk_data(chunk), fileid, filesize, offset );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating getfile chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_get( chunk_data(chunk), fileid, filesize, offset ); set_chunk_type( chunk, CP_CHUNK_GET );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
@@ -1338,7 +1326,7 @@
char data[CP_MAX_PACKET];
purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_received\n" );
@@ -1348,15 +1336,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_received( chunk_data(chunk), fileid, status );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating received chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_received( chunk_data(chunk), fileid, status ); set_chunk_type( chunk, CP_CHUNK_RECEIVED );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
@@ -1370,14 +1354,14 @@
* @param data The avatar data
* @param buflen The length of the avatar data
-void mxit_set_avatar( struct MXitSession* session, const unsigned char* avatar, int avatarlen )
+void mxit_set_avatar( struct MXitSession* session, const unsigned char* avatar, size_t avatarlen ) char data[CP_MAX_PACKET];
- purple_debug_info( MXIT_PLUGIN_ID, "mxit_set_avatar: %i bytes\n", avatarlen );
+ purple_debug_info( MXIT_PLUGIN_ID, "mxit_set_avatar: %zu bytes\n", avatarlen ); /* convert the packet to a byte stream */
datalen = g_snprintf( data, sizeof( data ), "ms=" );
@@ -1385,15 +1369,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_set_avatar( chunk_data(chunk), avatar, avatarlen );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating set avatar chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_set_avatar( chunk_data(chunk), avatar, avatarlen ); set_chunk_type( chunk, CP_CHUNK_SET_AVATAR );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
@@ -1414,7 +1394,7 @@
char data[CP_MAX_PACKET];
purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_avatar: %s\n", mxitId );
@@ -1424,15 +1404,11 @@
/* map chunk header over data buffer */
- size = mxit_chunk_create_get_avatar( chunk_data(chunk), mxitId, avatarId );
- purple_debug_error( MXIT_PLUGIN_ID, "Error creating get avatar chunk (%i)\n", size );
+ chunksize = mxit_chunk_create_get_avatar( chunk_data(chunk), mxitId, avatarId ); set_chunk_type( chunk, CP_CHUNK_GET_AVATAR );
- set_chunk_length( chunk, size );
- datalen += MXIT_CHUNK_HEADER_SIZE + size;
+ set_chunk_length( chunk, chunksize ); + datalen += MXIT_CHUNK_HEADER_SIZE + chunksize; /* send the byte stream to the mxit server */
mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA );
--- a/libpurple/protocols/mxit/protocol.h Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/protocol.h Fri Jun 03 12:07:21 2016 -0500
@@ -332,11 +332,11 @@
void mxit_send_splashclick( struct MXitSession* session, const char* splashid );
void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event);
-void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, int buflen );
+void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, size_t buflen ); void mxit_send_file_reject( struct MXitSession* session, const char* fileid );
-void mxit_send_file_accept( struct MXitSession* session, const char* fileid, int filesize, int offset );
+void mxit_send_file_accept( struct MXitSession* session, const char* fileid, size_t filesize, size_t offset ); void mxit_send_file_received( struct MXitSession* session, const char* fileid, short status );
-void mxit_set_avatar( struct MXitSession* session, const unsigned char* avatar, int avatarlen );
+void mxit_set_avatar( struct MXitSession* session, const unsigned char* avatar, size_t avatarlen ); void mxit_get_avatar( struct MXitSession* session, const char* mxitId, const char* avatarId );
void mxit_send_groupchat_create( struct MXitSession* session, const char* groupname, int nr_usernames, const char* usernames[] );