cURL / Mailing Lists / curl-library / Single Mail

curl-library

feedback needed on curl_escape and curl_unescape changes

From: David McCreedy <mccreedytpf_at_msn.com>
Date: Mon, 13 Mar 2006 23:01:05 +0000

I have one item that needs to be resolved before I can finalize the EBCDIC
patches for libcurl.

The curl_escape and curl_unescape functions currently take two parms:
     char *curl_escape(const char *string, int inlength)
     char *curl_unescape(const char *string, int length)

But on EBCDIC platforms the functions will need the SessionHandle in order
to do the conversions between ASCII and EBCDIC.

At present, I rely on #ifdef's everywhere libcurl calls curl_[un]escape:

     #ifdef CURL_ON_EBCDIC_PLATFORM
         conn->proxyuser = curl_unescape(data,proxyuser,0);
     #else
         conn->proxyuser = curl_unescape(proxyuser,0);
     #endif /* CURL_ON_EBCDIC_PLATFORM */

A more elegant solution might be to rename the functions to something like
curl_[un]escape2 and use a #define in curl.h to make the change transparent
to existing callers outside of libcurl:

     #define curl_escape(a, b) curl_escape2((void *)0, a, b)
     #define curl_unescape(a, b) curl_unescape2((void *)0, a, b)

That will allow libcurl to call the new API without any #ifdefs:
    conn->proxyuser = curl_unescape2(data,proxyuser,0);

And curl_[un]escape2 can be added to the API docs with the note that EBCDIC
platforms need to use it instead of curl_[un]escape.

Below is a summary of the changes I'll make along with the EBCDIC patches to
implement this change.
Please give me feedback on this approach.

Thank you,

-David McCreedy

include/curl/curl.h:
#define curl_unescape(a, b) curl_unescape2((void *)0, a, b)
CURL_EXTERN char *curl_unescape2(void *handle, const char *string, int
length);

lib/escape.h:
char *curl_unescape2(void* handle, const char *string, int length);

lib/escape.c:
char *curl_unescape2(void *handle, const char *string, int length)

All libcurl calls to curl_unescape(a, b) will be changed to
                     curl_unescape2(sessionhandle, a, b)

All of the above changes will also be made for curl_escape.
Received on 2006-03-14