CVS: rdesktop xclip.c,1.24,1.25

Peter Åstrand <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30961

Modified Files:
	xclip.c 
Log Message:
Indentation fix

Index: xclip.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xclip.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** xclip.c	2 Jan 2006 15:55:59 -0000	1.24
--- xclip.c	5 Jan 2006 11:56:57 -0000	1.25
***************
*** 147,157 ****
  		return NULL;
  
! 	inptr = (uint16*)data;
! 	outptr = (uint16*)result;
  
  	/* Check for a reversed BOM */
  	Bool swap_endianess = (*inptr == 0xfffe);
  
! 	while ((uint8*)inptr < data + *size)
  	{
  		uint16 uvalue = *inptr;
--- 147,157 ----
  		return NULL;
  
! 	inptr = (uint16 *) data;
! 	outptr = (uint16 *) result;
  
  	/* Check for a reversed BOM */
  	Bool swap_endianess = (*inptr == 0xfffe);
  
! 	while ((uint8 *) inptr < data + *size)
  	{
  		uint16 uvalue = *inptr;
***************
*** 162,167 ****
  		*outptr++ = *inptr++;
  	}
! 	*outptr++ = 0; /* null termination */
! 	*size = (uint8*)outptr - result;
  
  	return result;
--- 162,167 ----
  		*outptr++ = *inptr++;
  	}
! 	*outptr++ = 0;		/* null termination */
! 	*size = (uint8 *) outptr - result;
  
  	return result;
***************
*** 261,270 ****
   */
  static Bool
! xclip_send_data_with_convert(uint8* source, size_t source_size, Atom target)
  {
! 	#ifdef USE_UNICODE_CLIPBOARD
  	if (target == format_string_atom ||
! 	    target == format_unicode_atom ||
! 	    target == format_utf8_string_atom)
  	{
  		if (rdp_clipboard_request_format != RDP_CF_TEXT)
--- 261,269 ----
   */
  static Bool
! xclip_send_data_with_convert(uint8 * source, size_t source_size, Atom target)
  {
! #ifdef USE_UNICODE_CLIPBOARD
  	if (target == format_string_atom ||
! 	    target == format_unicode_atom || target == format_utf8_string_atom)
  	{
  		if (rdp_clipboard_request_format != RDP_CF_TEXT)
***************
*** 277,288 ****
  		 */
  		size_t unicode_buffer_size;
! 		char* unicode_buffer;
  		iconv_t cd;
  
  		if (target == format_string_atom)
  		{
! 			char* locale_charset = nl_langinfo(CODESET);
  			cd = iconv_open(WINDOWS_CODEPAGE, locale_charset);
! 			if (cd == (iconv_t)-1)
  			{
  				DEBUG_CLIPBOARD(("Locale charset %s not found in iconv. Unable to convert clipboard text.\n", locale_charset));
--- 276,287 ----
  		 */
  		size_t unicode_buffer_size;
! 		char *unicode_buffer;
  		iconv_t cd;
  
  		if (target == format_string_atom)
  		{
! 			char *locale_charset = nl_langinfo(CODESET);
  			cd = iconv_open(WINDOWS_CODEPAGE, locale_charset);
! 			if (cd == (iconv_t) - 1)
  			{
  				DEBUG_CLIPBOARD(("Locale charset %s not found in iconv. Unable to convert clipboard text.\n", locale_charset));
***************
*** 294,298 ****
  		{
  			cd = iconv_open(WINDOWS_CODEPAGE, "UCS-2");
! 			if (cd == (iconv_t)-1)
  			{
  				return False;
--- 293,297 ----
  		{
  			cd = iconv_open(WINDOWS_CODEPAGE, "UCS-2");
! 			if (cd == (iconv_t) - 1)
  			{
  				return False;
***************
*** 303,307 ****
  		{
  			cd = iconv_open(WINDOWS_CODEPAGE, "UTF-8");
! 			if (cd == (iconv_t)-1)
  			{
  				return False;
--- 302,306 ----
  		{
  			cd = iconv_open(WINDOWS_CODEPAGE, "UTF-8");
! 			if (cd == (iconv_t) - 1)
  			{
  				return False;
***************
*** 319,334 ****
  		unicode_buffer = xmalloc(unicode_buffer_size);
  		size_t unicode_buffer_size_remaining = unicode_buffer_size;
! 		char* unicode_buffer_remaining = unicode_buffer;
! 		char* data_remaining = (char*)source;
  		size_t data_size_remaining = source_size;
! 		iconv(cd, &data_remaining, &data_size_remaining, &unicode_buffer_remaining, &unicode_buffer_size_remaining);
  		iconv_close(cd);
  
  		/* translate linebreaks */
  		uint32 translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining;
! 		uint8* translated_data = utf16_lf2crlf((uint8*)unicode_buffer, &translated_data_size);
  		if (translated_data != NULL)
  		{
! 			DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n", translated_data_size));
  			cliprdr_send_data(translated_data, translated_data_size);
  			xfree(translated_data);	/* Not the same thing as XFree! */
--- 318,336 ----
  		unicode_buffer = xmalloc(unicode_buffer_size);
  		size_t unicode_buffer_size_remaining = unicode_buffer_size;
! 		char *unicode_buffer_remaining = unicode_buffer;
! 		char *data_remaining = (char *) source;
  		size_t data_size_remaining = source_size;
! 		iconv(cd, &data_remaining, &data_size_remaining, &unicode_buffer_remaining,
! 		      &unicode_buffer_size_remaining);
  		iconv_close(cd);
  
  		/* translate linebreaks */
  		uint32 translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining;
! 		uint8 *translated_data =
! 			utf16_lf2crlf((uint8 *) unicode_buffer, &translated_data_size);
  		if (translated_data != NULL)
  		{
! 			DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n",
! 					 translated_data_size));
  			cliprdr_send_data(translated_data, translated_data_size);
  			xfree(translated_data);	/* Not the same thing as XFree! */
***************
*** 339,343 ****
  		return True;
  	}
! 	#else
  	if (target == format_string_atom)
  	{
--- 341,345 ----
  		return True;
  	}
! #else
  	if (target == format_string_atom)
  	{
***************
*** 358,362 ****
  		return True;
  	}
! 	#endif
  	else if (target == rdesktop_clipboard_formats_atom)
  	{
--- 360,364 ----
  		return True;
  	}
! #endif
  	else if (target == rdesktop_clipboard_formats_atom)
  	{
***************
*** 433,437 ****
  		 */
  		int text_target_satisfaction = 0;
! 		Atom best_text_target = 0; /* measures how much we're satisfied with what we found */
  		if (type != None)
  		{
--- 435,439 ----
  		 */
  		int text_target_satisfaction = 0;
! 		Atom best_text_target = 0;	/* measures how much we're satisfied with what we found */
  		if (type != None)
  		{
***************
*** 450,454 ****
  					}
  				}
! 				#ifdef USE_UNICODE_CLIPBOARD
  				else if (supported_targets[i] == format_unicode_atom)
  				{
--- 452,456 ----
  					}
  				}
! #ifdef USE_UNICODE_CLIPBOARD
  				else if (supported_targets[i] == format_unicode_atom)
  				{
***************
*** 469,473 ****
  					}
  				}
! 				#endif
  			}
  		}
--- 471,475 ----
  					}
  				}
! #endif
  			}
  		}
***************
*** 478,482 ****
  		if (best_text_target != 0)
  		{
! 			XConvertSelection(g_display, clipboard_atom, best_text_target, rdesktop_clipboard_target_atom, g_wnd, event->time);
  			return;
  		}
--- 480,485 ----
  		if (best_text_target != 0)
  		{
! 			XConvertSelection(g_display, clipboard_atom, best_text_target,
! 					  rdesktop_clipboard_target_atom, g_wnd, event->time);
  			return;
  		}
***************
*** 551,562 ****
  			 */
  			res = XGetWindowProperty(g_display, event->requestor,
! 						 rdesktop_clipboard_target_atom, 0, 1, True, XA_INTEGER,
! 						 &type, &format, &nitems, &bytes_left, &prop_return);
  			wanted_format = (uint32 *) prop_return;
  			format = (res == Success) ? *wanted_format : RDP_CF_TEXT;
  			XFree(prop_return);
  		}
! 		else if (event->target == format_string_atom ||
! 			 event->target == XA_STRING)
  		{
  			/* STRING and XA_STRING are defined to be ISO8859-1 */
--- 554,565 ----
  			 */
  			res = XGetWindowProperty(g_display, event->requestor,
! 						 rdesktop_clipboard_target_atom, 0, 1, True,
! 						 XA_INTEGER, &type, &format, &nitems, &bytes_left,
! 						 &prop_return);
  			wanted_format = (uint32 *) prop_return;
  			format = (res == Success) ? *wanted_format : RDP_CF_TEXT;
  			XFree(prop_return);
  		}
! 		else if (event->target == format_string_atom || event->target == XA_STRING)
  		{
  			/* STRING and XA_STRING are defined to be ISO8859-1 */
***************
*** 565,575 ****
  		else if (event->target == format_utf8_string_atom)
  		{
! 			#ifdef USE_UNICODE_CLIPBOARD
  			format = CF_UNICODETEXT;
! 			#else
  			DEBUG_CLIPBOARD(("Requested target unavailable due to lack of Unicode support. (It was not in TARGETS, so why did you ask for it?!)\n"));
  			xclip_refuse_selection(event);
  			return;
! 			#endif
  		}
  		else if (event->target == format_unicode_atom)
--- 568,578 ----
  		else if (event->target == format_utf8_string_atom)
  		{
! #ifdef USE_UNICODE_CLIPBOARD
  			format = CF_UNICODETEXT;
! #else
  			DEBUG_CLIPBOARD(("Requested target unavailable due to lack of Unicode support. (It was not in TARGETS, so why did you ask for it?!)\n"));
  			xclip_refuse_selection(event);
  			return;
! #endif
  		}
  		else if (event->target == format_unicode_atom)
***************
*** 588,592 ****
  		selection_request = *event;
  		has_selection_request = True;
! 		return;	/* wait for data */
  	}
  }
--- 591,595 ----
  		selection_request = *event;
  		has_selection_request = True;
! 		return;		/* wait for data */
  	}
  }
***************
*** 652,656 ****
  				if (g_clip_buflen > 0)
  				{
! 					if (!xclip_send_data_with_convert(g_clip_buffer, g_clip_buflen, g_incr_target))
  					{
  						helper_cliprdr_send_empty_response();
--- 655,660 ----
  				if (g_clip_buflen > 0)
  				{
! 					if (!xclip_send_data_with_convert
! 					    (g_clip_buffer, g_clip_buflen, g_incr_target))
  					{
  						helper_cliprdr_send_empty_response();
***************
*** 664,668 ****
  			{
  				/* Another chunk in the INCR transfer */
! 				offset += (nitems / 4); /* offset at which to begin the next slurp */
  				g_clip_buffer = xrealloc(g_clip_buffer, g_clip_buflen + nitems);
  				memcpy(g_clip_buffer + g_clip_buflen, data, nitems);
--- 668,672 ----
  			{
  				/* Another chunk in the INCR transfer */
! 				offset += (nitems / 4);	/* offset at which to begin the next slurp */
  				g_clip_buffer = xrealloc(g_clip_buffer, g_clip_buflen + nitems);
  				memcpy(g_clip_buffer + g_clip_buflen, data, nitems);
***************
*** 678,682 ****
  	if ((event->atom == rdesktop_clipboard_formats_atom) &&
  	    (event->window == DefaultRootWindow(g_display)) &&
! 	    !have_primary /* not interested in our own events */)
  	{
  		if (event->state == PropertyNewValue)
--- 682,686 ----
  	if ((event->atom == rdesktop_clipboard_formats_atom) &&
  	    (event->window == DefaultRootWindow(g_display)) &&
! 	    !have_primary /* not interested in our own events */ )
  	{
  		if (event->state == PropertyNewValue)
***************
*** 686,691 ****
  			res = XGetWindowProperty(g_display, DefaultRootWindow(g_display),
  						 rdesktop_clipboard_formats_atom, 0,
! 						 XMaxRequestSize(g_display), False, XA_STRING, &type,
! 						 &format, &nitems, &bytes_left, &data);
  
  			if ((res == Success) && (nitems > 0))
--- 690,695 ----
  			res = XGetWindowProperty(g_display, DefaultRootWindow(g_display),
  						 rdesktop_clipboard_formats_atom, 0,
! 						 XMaxRequestSize(g_display), False, XA_STRING,
! 						 &type, &format, &nitems, &bytes_left, &data);
  
  			if ((res == Success) && (nitems > 0))
***************
*** 736,755 ****
  	BOOL free_data = False;
  
! 	if (selection_request.target == format_string_atom ||
! 	    selection_request.target == XA_STRING)
!  	{
  		/* We're expecting a CF_TEXT response */
!  		uint8 *firstnull;
  
!  		/* translate linebreaks */
!  		crlf2lf(data, &length);
  
!  		/* Only send data up to null byte, if any */
!  		firstnull = (uint8 *) strchr((char *) data, '\0');
!  		if (firstnull)
!  		{
!  			length = firstnull - data + 1;
!  		}
!  	}
  #ifdef USE_UNICODE_CLIPBOARD
  	else if (selection_request.target == format_utf8_string_atom)
--- 740,758 ----
  	BOOL free_data = False;
  
! 	if (selection_request.target == format_string_atom || selection_request.target == XA_STRING)
! 	{
  		/* We're expecting a CF_TEXT response */
! 		uint8 *firstnull;
  
! 		/* translate linebreaks */
! 		crlf2lf(data, &length);
  
! 		/* Only send data up to null byte, if any */
! 		firstnull = (uint8 *) strchr((char *) data, '\0');
! 		if (firstnull)
! 		{
! 			length = firstnull - data + 1;
! 		}
! 	}
  #ifdef USE_UNICODE_CLIPBOARD
  	else if (selection_request.target == format_utf8_string_atom)
***************
*** 757,768 ****
  		/* We're expecting a CF_UNICODETEXT response */
  		iconv_t cd = iconv_open("UTF-8", WINDOWS_CODEPAGE);
! 		if (cd != (iconv_t)-1)
  		{
  			size_t utf8_length = length * 2;
! 			char* utf8_data = malloc(utf8_length);
  			size_t utf8_length_remaining = utf8_length;
! 			char* utf8_data_remaining = utf8_data;
! 			char* data_remaining = (char*)data;
! 			size_t length_remaining = (size_t)length;
  			if (utf8_data == NULL)
  			{
--- 760,771 ----
  		/* We're expecting a CF_UNICODETEXT response */
  		iconv_t cd = iconv_open("UTF-8", WINDOWS_CODEPAGE);
! 		if (cd != (iconv_t) - 1)
  		{
  			size_t utf8_length = length * 2;
! 			char *utf8_data = malloc(utf8_length);
  			size_t utf8_length_remaining = utf8_length;
! 			char *utf8_data_remaining = utf8_data;
! 			char *data_remaining = (char *) data;
! 			size_t length_remaining = (size_t) length;
  			if (utf8_data == NULL)
  			{
***************
*** 770,777 ****
  				return;
  			}
! 			iconv(cd, &data_remaining, &length_remaining, &utf8_data_remaining, &utf8_length_remaining);
  			iconv_close(cd);
  			free_data = True;
! 			data = (uint8*)utf8_data;
  			length = utf8_length - utf8_length_remaining;
  		}
--- 773,781 ----
  				return;
  			}
! 			iconv(cd, &data_remaining, &length_remaining, &utf8_data_remaining,
! 			      &utf8_length_remaining);
  			iconv_close(cd);
  			free_data = True;
! 			data = (uint8 *) utf8_data;
  			length = utf8_length - utf8_length_remaining;
  		}
***************
*** 869,875 ****
  	targets[num_targets++] = rdesktop_clipboard_formats_atom;
  	targets[num_targets++] = format_string_atom;
! 	#ifdef USE_UNICODE_CLIPBOARD
  	targets[num_targets++] = format_utf8_string_atom;
! 	#endif
  	targets[num_targets++] = format_unicode_atom;
  	targets[num_targets++] = XA_STRING;
--- 873,879 ----
  	targets[num_targets++] = rdesktop_clipboard_formats_atom;
  	targets[num_targets++] = format_string_atom;
! #ifdef USE_UNICODE_CLIPBOARD
  	targets[num_targets++] = format_utf8_string_atom;
! #endif
  	targets[num_targets++] = format_unicode_atom;
  	targets[num_targets++] = XA_STRING;



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
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.