pidgin: 159e73e4: Move struct_size to the beginning of the...

qulogic at pidgin.im qulogic at pidgin.im
Sat Sep 3 19:55:47 EDT 2011


----------------------------------------------------------------------
Revision: 159e73e4e44b95e314f1a751a3ada29f0686a3e4
Parent:   32b1c91416402a0ca95a593eaa0378ff2d9a12f2
Author:   qulogic at pidgin.im
Date:     09/03/11 19:30:40
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/159e73e4e44b95e314f1a751a3ada29f0686a3e4

Changelog: 

Move struct_size to the beginning of the struct. Even if we don't
rewrite this somehow (as a GObject or otherwise), it really belongs at
the start.

Changes against parent 32b1c91416402a0ca95a593eaa0378ff2d9a12f2

  patched  libpurple/protocols/bonjour/bonjour.c
  patched  libpurple/protocols/gg/gg.c
  patched  libpurple/protocols/irc/irc.c
  patched  libpurple/protocols/jabber/libxmpp.c
  patched  libpurple/protocols/msn/msn.c
  patched  libpurple/protocols/mxit/mxit.c
  patched  libpurple/protocols/myspace/myspace.c
  patched  libpurple/protocols/novell/novell.c
  patched  libpurple/protocols/null/nullprpl.c
  patched  libpurple/protocols/oscar/libaim.c
  patched  libpurple/protocols/oscar/libicq.c
  patched  libpurple/protocols/sametime/sametime.c
  patched  libpurple/protocols/simple/simple.c
  patched  libpurple/protocols/yahoo/libyahoo.c
  patched  libpurple/protocols/yahoo/libyahoojp.c
  patched  libpurple/protocols/zephyr/zephyr.c
  patched  libpurple/prpl.h

-------------- next part --------------
============================================================
--- libpurple/prpl.h	d69f4eed50e49ae63c5f38e8ac2ea2b36d7638a9
+++ libpurple/prpl.h	3cc67f2d68294e7554862d17c4da0873d33ace02
@@ -205,6 +205,27 @@ struct _PurplePluginProtocolInfo
  */
 struct _PurplePluginProtocolInfo
 {
+	/**
+	 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
+	 * This allows adding more functions to this struct without requiring a major version bump.
+	 */
+	unsigned long struct_size;
+
+	/* NOTE:
+	 * If more functions are added, they should accessed using the following syntax:
+	 *
+	 *		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
+	 *			prpl->new_function(...);
+	 *
+	 * instead of
+	 *
+	 *		if (prpl->new_function != NULL)
+	 *			prpl->new_function(...);
+	 *
+	 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
+	 * functions (e.g. login, send_im etc.) too.
+	 */
+
 	PurpleProtocolOptions options;  /**< Protocol options.          */
 
 	GList *user_splits;      /**< A GList of PurpleAccountUserSplit */
@@ -517,27 +538,6 @@ struct _PurplePluginProtocolInfo
 	gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
 	GList *(*get_attention_types)(PurpleAccount *acct);
 
-	/**
-	 * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo).
-	 * This allows adding more functions to this struct without requiring a major version bump.
-	 */
-	unsigned long struct_size;
-
-	/* NOTE:
-	 * If more functions are added, they should accessed using the following syntax:
-	 *
-	 *		if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function))
-	 *			prpl->new_function(...);
-	 *
-	 * instead of
-	 *
-	 *		if (prpl->new_function != NULL)
-	 *			prpl->new_function(...);
-	 *
-	 * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member
-	 * functions (e.g. login, send_im etc.) too.
-	 */
-
 	/** This allows protocols to specify additional strings to be used for
 	 * various purposes.  The idea is to stuff a bunch of strings in this hash
 	 * table instead of expanding the struct for every addition.  This hash
@@ -618,8 +618,7 @@ struct _PurplePluginProtocolInfo
 };
 
 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
-	(((G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < G_STRUCT_OFFSET(PurplePluginProtocolInfo, struct_size)) \
-	  || (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size)) && \
+	(G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size && \
 	 prpl->member != NULL)
 
 
============================================================
--- libpurple/protocols/irc/irc.c	82e95390fbeace288253b7f3a1f2d6bc18c02db6
+++ libpurple/protocols/irc/irc.c	29ed48dded6085c8cbac569543e29fa419de47cb
@@ -917,6 +917,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),    /* struct_size */
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
 	OPT_PROTO_SLASH_COMMANDS_NATIVE,
 	NULL,					/* user_splits */
@@ -983,7 +984,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                   /* unregister_user */
 	NULL,                   /* send_attention */
 	NULL,                   /* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),    /* struct_size */
 	NULL,                    /* get_account_text_table */
 	NULL,                    /* initiate_media */
 	NULL,					 /* get_media_caps */
============================================================
--- libpurple/protocols/msn/msn.c	ac5ca7d400290eadc4666af813c9fc2819537e58
+++ libpurple/protocols/msn/msn.c	d58d97d9cab025233d2cb9b11670e7709bd44060
@@ -2930,6 +2930,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),	/* struct_size */
 	OPT_PROTO_MAIL_CHECK|OPT_PROTO_INVITE_MESSAGE,
 	NULL,                               /* user_splits */
 	NULL,                               /* protocol_options */
@@ -2995,7 +2996,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                               /* unregister_user */
 	msn_send_attention,                 /* send_attention */
 	msn_attention_types,                /* attention_types */
-	sizeof(PurplePluginProtocolInfo),	/* struct_size */
 	msn_get_account_text_table,         /* get_account_text_table */
 	NULL,                               /* initiate_media */
 	NULL,                               /* get_media_caps */
============================================================
--- libpurple/protocols/zephyr/zephyr.c	e960de5abf5a5749cb889e960e97dfd633cea579
+++ libpurple/protocols/zephyr/zephyr.c	32d7db8e45e6820b4d1853a51c88671d5749fda0
@@ -2853,6 +2853,7 @@ static PurplePluginProtocolInfo prpl_inf
 static PurplePlugin *my_protocol = NULL;
 
 static PurplePluginProtocolInfo prpl_info = {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
 	NULL,					/* ??? user_splits */
 	NULL,					/* ??? protocol_options */
@@ -2919,7 +2920,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,
 	NULL,
 	NULL,
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,					/* get_account_text_table */
 	NULL,					/* initate_media */
 	NULL,					/* get_media_caps */
============================================================
--- libpurple/protocols/gg/gg.c	059ec9afa93ef7363eaece26fe97e6ff17fbaaed
+++ libpurple/protocols/gg/gg.c	474d78a2ee570335bb8e6c93c3c0dc46b8ea64ac
@@ -2655,6 +2655,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_IM_IMAGE,
 	NULL,				/* user_splits */
 	NULL,				/* protocol_options */
@@ -2720,7 +2721,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,				/* unregister_user */
 	NULL,				/* send_attention */
 	NULL,				/* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,                           /* get_account_text_table */
 	NULL,                           /* initiate_media */
 	NULL,                            /* can_do_media */
============================================================
--- libpurple/protocols/novell/novell.c	b89f8046fb1222695054b93da085157a4d2841ee
+++ libpurple/protocols/novell/novell.c	3d1faa12262d0130d7f6ed2b39a7bd0d996153b8
@@ -3474,6 +3474,7 @@ static PurplePluginProtocolInfo prpl_inf
 }
 
 static PurplePluginProtocolInfo prpl_info = {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	0,
 	NULL,						/* user_splits */
 	NULL,						/* protocol_options */
@@ -3539,7 +3540,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,						/* unregister_user */
 	NULL,						/* send_attention */
 	NULL,						/* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,						/* get_account_text_table */
 	NULL,						/* initiate_media */
 	NULL,						/* get_media_caps */
============================================================
--- libpurple/protocols/sametime/sametime.c	a8baff7c95c3ba2c6541def127776820b705370f
+++ libpurple/protocols/sametime/sametime.c	1cdcaf0539f6d2805130a66bd6cec4626ada8eb3
@@ -5154,6 +5154,7 @@ static PurplePluginProtocolInfo mw_prpl_
 
 
 static PurplePluginProtocolInfo mw_prpl_info = {
+  .struct_size               = sizeof(PurplePluginProtocolInfo),
   .options                   = OPT_PROTO_IM_IMAGE,
   .user_splits               = NULL, /*< set in mw_plugin_init */
   .protocol_options          = NULL, /*< set in mw_plugin_init */
@@ -5213,8 +5214,7 @@ static PurplePluginProtocolInfo mw_prpl_
   .new_xfer                  = mw_prpl_new_xfer,
   .offline_message           = NULL,
   .whiteboard_prpl_ops       = NULL,
-  .send_raw                  = NULL,
-  .struct_size               = sizeof(PurplePluginProtocolInfo)
+  .send_raw                  = NULL
 };
 
 
============================================================
--- libpurple/protocols/simple/simple.c	8b8cca8e422771b9f48ba70ab7fc57fb572f04e6
+++ libpurple/protocols/simple/simple.c	af69f3218a3bdd9cfe8eccc3cf71d035e38a3ed2
@@ -2046,6 +2046,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	0,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
@@ -2111,7 +2112,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* unregister_user */
 	NULL,					/* send_attention */
 	NULL,					/* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,					/* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* get_media_caps */
============================================================
--- libpurple/protocols/bonjour/bonjour.c	14a27c5e9a35520bf83d9613a6fca0e68e13f1ae
+++ libpurple/protocols/bonjour/bonjour.c	608930293765e2aaaa1d02489473e876d0a12214
@@ -484,6 +484,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),                        /* struct_size */
 	OPT_PROTO_NO_PASSWORD,
 	NULL,                                                    /* user_splits */
 	NULL,                                                    /* protocol_options */
@@ -549,7 +550,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                                                    /* unregister_user */
 	NULL,                                                    /* send_attention */
 	NULL,                                                    /* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),                        /* struct_size */
 	NULL,                                                    /* get_account_text_table */
 	NULL,                                                    /* initiate_media */
 	NULL,                                                    /* get_media_caps */
============================================================
--- libpurple/protocols/oscar/libaim.c	60af7e783b69ac2615d58ff4ef11d5307363a248
+++ libpurple/protocols/oscar/libaim.c	d2b7278d20a96b8afc32f08c437b75c460071ba2
@@ -29,6 +29,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
@@ -94,7 +95,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* unregister_user */
 	NULL,					/* send_attention */
 	NULL,					/* get_attention_types */
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,					/* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* get_media_caps */
============================================================
--- libpurple/protocols/oscar/libicq.c	f236af256f39f0129d4500c153dfb9014bd03e6a
+++ libpurple/protocols/oscar/libicq.c	5d9b147d4c96c32b38b2878634f2e7a147bf4055
@@ -38,6 +38,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
@@ -103,8 +104,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* unregister_user */
 	NULL,					/* send_attention */
 	NULL,					/* get_attention_types */
-
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	icq_get_account_text_table, /* get_account_text_table */
 	NULL,					/* initiate_media */
 	NULL,					/* can_do_media */
============================================================
--- libpurple/protocols/jabber/libxmpp.c	f12525287822786cc0ab9b107822d2d51a554055
+++ libpurple/protocols/jabber/libxmpp.c	15347a1b7f547807edf5d0a2a71eec54e8bbca17
@@ -53,6 +53,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK |
 #ifdef HAVE_CYRUS_SASL
 	OPT_PROTO_PASSWORD_OPTIONAL |
@@ -122,8 +123,6 @@ static PurplePluginProtocolInfo prpl_inf
 	jabber_unregister_account,		/* unregister_user */
 	jabber_send_attention,			/* send_attention */
 	jabber_attention_types,			/* attention_types */
-
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL, /* get_account_text_table */
 	jabber_initiate_media,          /* initiate_media */
 	jabber_get_media_caps,                  /* get_media_caps */
============================================================
--- libpurple/protocols/myspace/myspace.c	a0b33c361fe7da70f91c012acb4ad72f8342d588
+++ libpurple/protocols/myspace/myspace.c	9123f3dc1c127fb04a484cf5cafd93d9ce5753ec
@@ -3007,6 +3007,7 @@ static PurplePluginProtocolInfo prpl_inf
  * Callbacks called by Purple, to access this plugin.
  */
 static PurplePluginProtocolInfo prpl_info = {
+	sizeof(PurplePluginProtocolInfo), /* struct_size */
 	/* options */
 	  OPT_PROTO_USE_POINTSIZE        /* specify font size in sane point size */
 	| OPT_PROTO_MAIL_CHECK,
@@ -3076,7 +3077,6 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,                  /* unregister_user */
 	msim_send_attention,   /* send_attention */
 	msim_attention_types,  /* attention_types */
-	sizeof(PurplePluginProtocolInfo), /* struct_size */
 	msim_get_account_text_table,              /* get_account_text_table */
 	NULL,                   /* initiate_media */
 	NULL,                   /* get_media_caps */
============================================================
--- libpurple/protocols/null/nullprpl.c	c781b36cc42fab75b29b3359e70ce319732807be
+++ libpurple/protocols/null/nullprpl.c	a1195e402a3aa53cdbc67fb5cd00622ef2a444dd
@@ -1052,6 +1052,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+  sizeof(PurplePluginProtocolInfo),    /* struct_size */
   OPT_PROTO_NO_PASSWORD | OPT_PROTO_CHAT_TOPIC,  /* options */
   NULL,               /* user_splits, initialized in nullprpl_init() */
   NULL,               /* protocol_options, initialized in nullprpl_init() */
@@ -1125,7 +1126,6 @@ static PurplePluginProtocolInfo prpl_inf
   NULL,                                /* unregister_user */
   NULL,                                /* send_attention */
   NULL,                                /* get_attention_types */
-  sizeof(PurplePluginProtocolInfo),    /* struct_size */
   NULL,                                /* get_account_text_table */
   NULL,                                /* initiate_media */
   NULL,                                /* get_media_caps */
============================================================
--- libpurple/protocols/yahoo/libyahoo.c	875b38564e0465d1d3f278991eb20e9cc118127e
+++ libpurple/protocols/yahoo/libyahoo.c	d7d59925c82b555f075c998b505a3e867c0ec233
@@ -194,6 +194,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC,
 	NULL, /* user_splits */
 	NULL, /* protocol_options */
@@ -257,11 +258,8 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL, /* send_raw */
 	NULL, /* roomlist_room_serialize */
 	NULL, /* unregister_user */
-
 	yahoo_send_attention,
 	yahoo_attention_types,
-
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	yahoo_get_account_text_table,    /* get_account_text_table */
 	NULL, /* initiate_media */
 	NULL,  /* get_media_caps */
============================================================
--- libpurple/protocols/yahoo/libyahoojp.c	3a6cf95dce97904c0262b7e9401fda5e4460913f
+++ libpurple/protocols/yahoo/libyahoojp.c	7e8629a3f9e86d986345912f413ee7a97c5f1c5e
@@ -90,6 +90,7 @@ static PurplePluginProtocolInfo prpl_inf
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC,
 	NULL, /* user_splits */
 	NULL, /* protocol_options */
@@ -157,7 +158,6 @@ static PurplePluginProtocolInfo prpl_inf
 	yahoo_send_attention,
 	yahoo_attention_types,
 
-	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	yahoojp_get_account_text_table,    /* get_account_text_table */
 	NULL, /* initiate_media */
 	NULL, /* get_media_caps */
============================================================
--- libpurple/protocols/mxit/mxit.c	e5d5d8f94d5a00b322983290d9e1a8dfef69da74
+++ libpurple/protocols/mxit/mxit.c	9275355f92c6e11f0076e7a8dfd7f60ba9551dc1
@@ -668,6 +668,7 @@ static PurplePluginProtocolInfo proto_in
 /*========================================================================================================================*/
 
 static PurplePluginProtocolInfo proto_info = {
+	sizeof( PurplePluginProtocolInfo ),		/* struct_size */
 	OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE,			/* options */
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
@@ -740,7 +741,6 @@ static PurplePluginProtocolInfo proto_in
 	NULL,					/* unregister_user */
 	NULL,					/* send_attention */
 	NULL,					/* attention_types */
-	sizeof( PurplePluginProtocolInfo ),		/* struct_size */
 	mxit_get_text_table,	/* get_account_text_table */
 	mxit_media_initiate,	/* initiate_media */
 	mxit_media_caps,		/* get_media_caps */


More information about the Commits mailing list