CVS: rdesktop scard.c,1.20,1.21 tcp.c,1.38,1.39

Michael Gernoth <[email protected]> Tue, 20 Feb 2007 08:51:48 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16635

Modified Files:
	scard.c tcp.c 
Log Message:
always make g_out an array
this removes duplicated code from scard.c


Index: scard.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/scard.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** scard.c	8 Jan 2007 12:38:34 -0000	1.20
--- scard.c	20 Feb 2007 16:51:45 -0000	1.21
***************
*** 43,50 ****
  #define SCARD_AUTOALLOCATE -1
  #define	OUT_STREAM_SIZE	4096
- #define STREAM_COUNT 8
  
- static struct stream out[STREAM_COUNT];
- static int cur_stream_id = 0;
  static pthread_mutex_t **scard_mutex = NULL;
  
--- 43,47 ----
***************
*** 2664,2710 ****
  	pthread_mutex_unlock(scard_mutex[lock]);
  }
- 
- STREAM
- scard_tcp_init(void)
- {
- 	STREAM result = NULL;
- 
- 	result = &out[cur_stream_id];
- 	cur_stream_id = (cur_stream_id + 1) % STREAM_COUNT;
- 
- 	return result;
- }
- 
- void
- scard_tcp_connect(void)
- {
- 	int i;
- 
- 	for (i = 0; i < STREAM_COUNT; i++)
- 	{
- 		out[i].size = 4096;
- 		out[i].data = (uint8 *) xmalloc(out[i].size);
- 	}
- }
- 
- void
- scard_tcp_reset_state(void)
- {
- 	int i;
- 	struct stream *p;
- 
- 	for (i = 0, p = out; i < STREAM_COUNT; i++, p++)
- 	{
- 		if (p->data != NULL)
- 			xfree(p->data);
- 		p->p = NULL;
- 		p->end = NULL;
- 		p->data = NULL;
- 		p->size = 0;
- 		p->iso_hdr = NULL;
- 		p->mcs_hdr = NULL;
- 		p->sec_hdr = NULL;
- 		p->rdp_hdr = NULL;
- 		p->channel_hdr = NULL;
- 	}
- }
--- 2661,2662 ----

Index: tcp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/tcp.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** tcp.c	8 Jan 2007 04:47:06 -0000	1.38
--- tcp.c	20 Feb 2007 16:51:46 -0000	1.39
***************
*** 47,55 ****
  #endif
  
  static int g_sock;
  static struct stream g_in;
! #ifndef WITH_SCARD
! static struct stream g_out;
! #endif
  int g_tcp_port_rdp = TCP_PORT_RDP;
  
--- 47,59 ----
  #endif
  
+ #ifdef WITH_SCARD
+ #define STREAM_COUNT 8
+ #else
+ #define STREAM_COUNT 1
+ #endif
+ 
  static int g_sock;
  static struct stream g_in;
! static struct stream g_out[STREAM_COUNT];
  int g_tcp_port_rdp = TCP_PORT_RDP;
  
***************
*** 78,89 ****
  tcp_init(uint32 maxlen)
  {
  	STREAM result = NULL;
  
  #ifdef WITH_SCARD
  	scard_lock(SCARD_LOCK_TCP);
- 	result = scard_tcp_init();
- #else
- 	result = &g_out;
  #endif
  
  	if (maxlen > result->size)
--- 82,93 ----
  tcp_init(uint32 maxlen)
  {
+ 	static int cur_stream_id = 0;
  	STREAM result = NULL;
  
  #ifdef WITH_SCARD
  	scard_lock(SCARD_LOCK_TCP);
  #endif
+ 	result = &g_out[cur_stream_id];
+ 	cur_stream_id = (cur_stream_id + 1) % STREAM_COUNT;
  
  	if (maxlen > result->size)
***************
*** 205,208 ****
--- 209,213 ----
  	socklen_t option_len;
  	uint32 option_value;
+ 	int i;
  
  #ifdef IPv6
***************
*** 297,306 ****
  	g_in.data = (uint8 *) xmalloc(g_in.size);
  
! #ifdef WITH_SCARD
! 	scard_tcp_connect();
! #else
! 	g_out.size = 4096;
! 	g_out.data = (uint8 *) xmalloc(g_out.size);
! #endif
  
  	return True;
--- 302,310 ----
  	g_in.data = (uint8 *) xmalloc(g_in.size);
  
! 	for (i = 0; i < STREAM_COUNT; i++)
! 	{
! 		g_out[i].size = 4096;
! 		g_out[i].data = (uint8 *) xmalloc(g_out[i].size);
! 	}
  
  	return True;
***************
*** 335,338 ****
--- 339,344 ----
  tcp_reset_state(void)
  {
+ 	int i;
+ 
  	g_sock = -1;		/* reset socket */
  
***************
*** 351,368 ****
  
  	/* Clear the outgoing stream(s) */
! #ifdef WITH_SCARD
! 	scard_tcp_reset_state();
! #else
! 	if (g_out.data != NULL)
! 		xfree(g_out.data);
! 	g_out.p = NULL;
! 	g_out.end = NULL;
! 	g_out.data = NULL;
! 	g_out.size = 0;
! 	g_out.iso_hdr = NULL;
! 	g_out.mcs_hdr = NULL;
! 	g_out.sec_hdr = NULL;
! 	g_out.rdp_hdr = NULL;
! 	g_out.channel_hdr = NULL;
! #endif
  }
--- 357,373 ----
  
  	/* Clear the outgoing stream(s) */
! 	for (i = 0; i < STREAM_COUNT; i++)
! 	{
! 		if (g_out[i].data != NULL)
! 			xfree(g_out[i].data);
! 		g_out[i].p = NULL;
! 		g_out[i].end = NULL;
! 		g_out[i].data = NULL;
! 		g_out[i].size = 0;
! 		g_out[i].iso_hdr = NULL;
! 		g_out[i].mcs_hdr = NULL;
! 		g_out[i].sec_hdr = NULL;
! 		g_out[i].rdp_hdr = NULL;
! 		g_out[i].channel_hdr = NULL;
! 	}
  }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV