[Spread-cvs] cvs commit: spread/daemon sp_func.h sp.c user.c
jonathan@spread.org
jonathan@spread.org
Tue, 17 Sep 2002 00:48:08 -0400
jonathan 02/09/17 04:48:07
Modified: daemon sp_func.h sp.c user.c
Log:
Add Cristina's membership body accessor functions to locate various fields
in the body of a membership message.
int SP_get_gid_offset_memb_mess();
int SP_get_num_vs_offset_memb_mess();
int SP_get_vs_set_offset_memb_mess();
All applications should start using these so they do not break when we
change the membership body layout.
Revision Changes Path
1.2 +5 -0 spread/daemon/sp_func.h
Index: sp_func.h
===================================================================
RCS file: /storage/cvsroot/spread/daemon/sp_func.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sp_func.h 21 Aug 2001 14:28:21 -0000 1.1
+++ sp_func.h 17 Sep 2002 04:48:07 -0000 1.2
@@ -88,6 +88,11 @@
int16 *mess_type, int *endian_mismatch,
scatter *scat_mess );
+/* returns offset in memb. message of gid (group id), num_vs and vs_set */
+int SP_get_gid_offset_memb_mess();
+int SP_get_num_vs_offset_memb_mess();
+int SP_get_vs_set_offset_memb_mess();
+
int SP_poll( mailbox mbox );
int SP_equal_group_ids( group_id g1, group_id g2 );
1.5 +15 -0 spread/daemon/sp.c
Index: sp.c
===================================================================
RCS file: /storage/cvsroot/spread/daemon/sp.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sp.c 16 Sep 2002 16:59:06 -0000 1.4
+++ sp.c 17 Sep 2002 04:48:07 -0000 1.5
@@ -1503,6 +1503,21 @@
else return( 0 );
}
+int SP_get_gid_offset_memb_mess()
+{
+ return 0;
+}
+
+int SP_get_num_vs_offset_memb_mess()
+{
+ return sizeof(group_id);
+}
+
+int SP_get_vs_set_offset_memb_mess()
+{
+ return sizeof(group_id) + sizeof(int32);
+}
+
int SP_query_groups( mailbox mbox, int max_groups, char *groups[MAX_GROUP_NAME] )
{
return( -1 );
1.4 +3 -3 spread/daemon/user.c
Index: user.c
===================================================================
RCS file: /storage/cvsroot/spread/daemon/user.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- user.c 26 Aug 2002 22:57:41 -0000 1.3
+++ user.c 17 Sep 2002 04:48:07 -0000 1.4
@@ -430,11 +430,11 @@
{
if ( Is_reg_memb_mess( service_type ) )
{
- num_bytes = 0;
+ num_bytes = SP_get_gid_offset_memb_mess();
grp_id = (group_id *)&mess[num_bytes];
- num_bytes += sizeof( group_id );
+ num_bytes = SP_get_num_vs_offset_memb_mess();
num_vs = (int32 *)&mess[num_bytes];
- num_bytes += sizeof( int32 );
+ num_bytes = SP_get_vs_set_offset_memb_mess();
vs_members = &mess[num_bytes];
printf("Received REGULAR membership for group %s with %d members, where I am member %d:\n",
sender, num_groups, mess_type );