freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: James K.Lowden <jklowden AT speakeasy.net>
- To: TDS Development Group <freetds AT lists.ibiblio.org>
- Subject: [freetds] pbcb: replacing strcpy(3)
- Date: Thu, 8 May 2003 00:51:02 -0400
Many of the fixme comments to do with iconv regard the "length * 2"
assumption and request, correctly, that iconv be used instead. That is
part of the generalization toward UTF-8 servers and/or clients.
I intend to leverage the TDS_PBCB struct I introduced in bcp.c, adding a
"size" member:
typedef struct _pbcb
{
unsigned char *pb; /* buffer ("pointer to bytes")*/
unsigned int cb; /* count of bytes of data */
unsigned int size; /* size of allocation */
} TDS_PBCB;
These are of course counted strings. I'm planning a family of strcpy-like
functions:
/* allocation */
TDS_PBCB* pbcb_alloc (TDS_PBCB* pbcb, int size);
void pbcb_free(TDS_PBCB*); /* frees pointer and reinitializes */
TDS_PBCB* pbcb_strdup (iconv_t cd, TDS_PBCB* pbcb, const char *s);
/* copy */
TDS_PBCB* pbcb_cpy (iconv_t cd, TDS_PBCB* dest, const TDS_PBCB* src);
TDS_PBCB* pbcb_strcpy (iconv_t cd, TDS_PBCB* pbcb, const char *src);
These would become the standard replacements for string buffer handling in
FreeTDS.
If you have a better idea or intensely dislike this one, please speak up.
My one concern is that there's no way to know the encoding of the buffer.
Unfortunately, neither is there any way to *extract* the encoding from an
iconv_t, nor do we have an enumerated set of encodings. (I suspect this
is one reason Win32 and OS X both use integers, rather than strings, to
identify encodings. Much simpler to pass around and compare.)
--jkl
-
[freetds] pbcb: replacing strcpy(3),
James K . Lowden, 05/08/2003
- Re: [freetds] pbcb: replacing strcpy(3), Frediano Ziglio, 05/08/2003
- <Possible follow-up(s)>
-
RE: [freetds] pbcb: replacing strcpy(3),
Lowden, James K, 05/08/2003
- RE: [freetds] pbcb: replacing strcpy(3), Frediano Ziglio, 05/08/2003
- RE: [freetds] pbcb: replacing strcpy(3), Lowden, James K, 05/08/2003
- RE: [freetds] pbcb: replacing strcpy(3), ZIGLIO Frediano, 05/09/2003
- RE: [freetds] pbcb: replacing strcpy(3), Lowden, James K, 05/09/2003
Archive powered by MHonArc 2.6.24.