commit: r260 - in trunk: daemon include

[email protected]
Newsgroups gmane.network.spread.cvs
Message-ID <[email protected]>
Author: jonathan
Date: 2005-08-07 19:38:32 -0400 (Sun, 07 Aug 2005)
New Revision: 260

Modified:
   trunk/daemon/Changelog
   trunk/daemon/sp.c
   trunk/include/sp_func.h
Log:
Add SP_get_local_vs_set_offset_memb_scat() function to get the location
of a local vs set in a membership message if the message body is a 
scatter, rather then a byte array.



Modified: trunk/daemon/Changelog
===================================================================
--- trunk/daemon/Changelog	2005-08-07 22:54:26 UTC (rev 259)
+++ trunk/daemon/Changelog	2005-08-07 23:38:32 UTC (rev 260)
@@ -1,3 +1,9 @@
+Sun Aug  7 19:36:54 2005  Jonathan Stanton  <[email protected]>
+
+	* sp.c (SP_get_local_vs_set_offset_memb_scat): Add function
+	to get local vs set offset if SP_receive_scat() is used
+	to get membership messages.
+
 Wed Jun  1 16:05:34 2005  Jonathan Stanton  <[email protected]>
  
  	* session.c (Sess_init): Change ACTIVATE_PORT_REUSE() from 

Modified: trunk/daemon/sp.c
===================================================================
--- trunk/daemon/sp.c	2005-08-07 22:54:26 UTC (rev 259)
+++ trunk/daemon/sp.c	2005-08-07 23:38:32 UTC (rev 260)
@@ -106,7 +106,7 @@
 static  sp_time         Zero_timeout = { 0, 0 };
 
 static	void    Flip_mess( message_header *head_ptr );
-static  void	SP_kill( mailbox mbox );
+static  void    SP_kill( mailbox mbox );
 static	int	SP_get_session( mailbox mbox );
 static	int	SP_internal_multicast( mailbox mbox, service service_type, 
 				       int num_groups,
@@ -1613,7 +1613,7 @@
         return sizeof(group_id);
 }
 
-int  SP_get_offset_to_local_vs_set_offset(void)
+int     SP_get_offset_to_local_vs_set_offset(void)
 {
         return sizeof(group_id) + sizeof(int32u);
 }
@@ -1642,6 +1642,28 @@
         return offset;
 }
 
+int     SP_get_local_vs_set_offset_memb_scat( const scatter *reg_memb_scat )
+{
+        int32u offset;
+        int     bytes_in = 0;
+        int     i, offset_location;
+        
+        offset_location = SP_get_offset_to_local_vs_set_offset();
+        for (i=0; i < reg_memb_scat->num_elements; i++) 
+        {
+            if ( bytes_in + reg_memb_scat->elements[i].len > offset_location )
+            {
+                /* offset is in this scatter element */
+                memcpy( &offset, &reg_memb_scat->elements[i].buf[offset_location - bytes_in], sizeof(int32u) );
+            } else {
+                bytes_in += reg_memb_scat->elements[i].len;
+            }
+        }
+
+        offset += SP_get_first_vs_set_offset_memb_mess();
+        return offset;
+}
+
 int	SP_query_groups( mailbox mbox, int max_groups, char *groups[MAX_GROUP_NAME] )
 {
 	return( -1 );

Modified: trunk/include/sp_func.h
===================================================================
--- trunk/include/sp_func.h	2005-08-07 22:54:26 UTC (rev 259)
+++ trunk/include/sp_func.h	2005-08-07 23:38:32 UTC (rev 260)
@@ -101,7 +101,8 @@
 int     SP_get_vs_set_members_offset_vs_set(void);
 /* returns value from regular membership message */
 int     SP_get_offset_to_local_vs_set_offset(void);
-int     SP_get_local_vs_set_offset_memb_mess( char *reg_memb_mess );  /* TODO: jonathan we need one for scat's too! */
+int     SP_get_local_vs_set_offset_memb_mess( char *reg_memb_mess );  
+int     SP_get_local_vs_set_offset_memb_scat( const scatter *reg_memb_scat );
 
 int	SP_poll( mailbox mbox );
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.