[sword-cvs] sword/src/modules/filters cipherfil.cpp,1.13,1.14 rtfhtml.cpp,1.4,1.5

sword@www.crosswire.org sword@www.crosswire.org
Fri, 21 Feb 2003 03:30:45 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv7045/src/modules/filters

Modified Files:
	cipherfil.cpp rtfhtml.cpp 
Log Message:
cipherfil and rtfhtml

Index: cipherfil.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/cipherfil.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** cipherfil.cpp	1 Oct 2002 19:52:40 -0000	1.13
--- cipherfil.cpp	21 Feb 2003 10:30:43 -0000	1.14
***************
*** 26,42 ****
  
  
! char CipherFilter::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module) {
  	unsigned int len;
  //	len = strlen(text);
! 	len = maxlen;
  	if (len > 0) {
  		if (!key) {	// hack, using key to determine encipher, or decipher
  			cipher->cipherBuf(&len, text);
! 			memcpy(text, cipher->Buf(), (len < (unsigned int)(maxlen)) ? len : maxlen);
  		}
  		else if ((unsigned long)key == 1) {
  			cipher->Buf(text, len);
! 			cipher->cipherBuf(&len);
! 			memcpy(text, cipher->cipherBuf(&len), (len < (unsigned int)(maxlen)) ? len : maxlen);
  		}
  	}
--- 26,43 ----
  
  
! char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
  	unsigned int len;
  //	len = strlen(text);
! 	len = text.length();
  	if (len > 0) {
  		if (!key) {	// hack, using key to determine encipher, or decipher
  			cipher->cipherBuf(&len, text);
! 			//memcpy(text, cipher->Buf(), (len < (unsigned int)(maxlen)) ? len : maxlen);
! 			text = cipher->Buf();
  		}
  		else if ((unsigned long)key == 1) {
  			cipher->Buf(text, len);
! 			text = cipher->cipherBuf(&len);
! 			//memcpy(text, cipher->cipherBuf(&len), (len < (unsigned int)(maxlen)) ? len : maxlen);
  		}
  	}

Index: rtfhtml.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/rtfhtml.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rtfhtml.cpp	1 Oct 2002 19:52:40 -0000	1.4
--- rtfhtml.cpp	21 Feb 2003 10:30:43 -0000	1.5
***************
*** 27,43 ****
  
  
! char RTFHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
  {
- 	char *to, *from;
- 	int len;
  	bool center = false;
  
! 	len = strlen(text) + 1;						// shift string to right of buffer
! 	if (len < maxlen) {
! 		memmove(&text[maxlen - len], text, len);
! 		from = &text[maxlen - len];
! 	}
! 	else	from = text;							// -------------------------------
! 	for (to = text; *from; from++) {
  		if (*from == '\\') // a RTF command
  		{
--- 27,39 ----
  
  
! char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
  {
  	bool center = false;
  
! 	const char *from;
! 	SWBuf orig = text;
! 	from = orig.c_str();
! 	for (text = ""; *from; from++)
! 	{
  		if (*from == '\\') // a RTF command
  		{
***************
*** 46,58 ****
  				if (center)
  				{
! 					*to++ = '<';
! 					*to++ = '/';
! 					*to++ = 'C';
! 					*to++ = 'E';
! 					*to++ = 'N';
! 					*to++ = 'T';
! 					*to++ = 'E';
! 					*to++ = 'R';
! 					*to++ = '>';
  					center = false;
  				}
--- 42,46 ----
  				if (center)
  				{
! 					text += "</CENTER>";
  					center = false;
  				}
***************
*** 62,69 ****
  			if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
  			{
! 				*to++ = '<';
! 				*to++ = 'P';
! 				*to++ = '>';
! 				*to++ = '\n';
  				from += 3;
  				continue;
--- 50,54 ----
  			if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
  			{
! 				text += "<P>\n";
  				from += 3;
  				continue;
***************
*** 78,89 ****
  				if (!center)
  				{
! 					*to++ = '<';
! 					*to++ = 'C';
! 					*to++ = 'E';
! 					*to++ = 'N';
! 					*to++ = 'T';
! 					*to++ = 'E';
! 					*to++ = 'R';
! 					*to++ = '>';
  					center = true;
  				}
--- 63,67 ----
  				if (!center)
  				{
! 					text += "<CENTER>";
  					center = true;
  				}
***************
*** 93,100 ****
  		}
  
! 		*to++ = *from;
  	}
- 	*to++ = 0;
- 	*to = 0;
  	return 0;
  }
--- 71,76 ----
  		}
  
! 		text += *from;
  	}
  	return 0;
  }