[freetds] pbcb: replacing strcpy(3)

Lowden, James K LowdenJK at bernstein.com
Fri May 9 11:52:23 EDT 2003


> From: ZIGLIO Frediano [mailto:Frediano.Ziglio at vodafoneomnitel.it]
> Sent: May 9, 2003 5:42 AM
> > 
> > Of course, for cases where you *know* no conversion is 
> > warranted, you still
> > have memcpy(3) or some iconv-less library function at your 
> disposal.  
> > 
> 
> Well two function like
> 
> pbcb_copy(PBCB,PBCB)
> pbcb_convert(iconv_t cd, PBCB,PBCB)  (handling cd == -1 like 
> pbcb_copy)
> 
> Should fix both problems...

Yes, as long as the second behaves like the first if cd == -1.  

> There are a lot of functions that seem to do the same job. 
> Convert string using chunk. Perhaps using callback can help. 
> Think a function like this
> 
> typedef int (*tds_iconv_read)(void *param, char* buffer, 
> size_t max_read);
> typedef void (*tds_iconv_write)(void *param, char* buffer, 
> size_t max_read);
> void tds_convert(iconv_t cd, tds_iconv_read f_read, void * 
> param_read, tds_iconv_write f_write, void * param_write)
> {
> 	char buf[256];
> 	...
> 	while(...) {
> 		...
> 		f_read(param_read, buf, to_be_readed);
> 		... (convert chunk) ...
> 		f_write(param_write, buf, to_be_written);
> 		...
> 	}
> 	...
> }

I like this idea very much.  

--jkl


The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above.  If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. Please note that we do not accept account orders and/or
instructions by e-mail, and therefore will not be responsible for carrying
out such orders and/or instructions.





More information about the FreeTDS mailing list