1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

the new escape/unescape function setup

This commit is contained in:
Daniel Stenberg 2001-03-22 11:40:58 +00:00
parent c23df41d83
commit f8d883355d
3 changed files with 66 additions and 61 deletions

View File

@ -475,6 +475,11 @@ char *curl_getenv(char *variable);
/* Returns a static ascii string of the libcurl version. */ /* Returns a static ascii string of the libcurl version. */
char *curl_version(void); char *curl_version(void);
/* Escape and unescape URL encoding in strings. The functions return a new
* allocated string or NULL if an error occurred. */
char *curl_escape(char *string, int length);
char *curl_unescape(char *string, int length);
/* This is the version number */ /* This is the version number */
#define LIBCURL_VERSION "7.7-beta5" #define LIBCURL_VERSION "7.7-beta5"
#define LIBCURL_VERSION_NUM 0x070700 #define LIBCURL_VERSION_NUM 0x070700

View File

@ -36,15 +36,15 @@
#include "memdebug.h" #include "memdebug.h"
#endif #endif
char *curl_escape(char *string) char *curl_escape(char *string, int length)
{ {
int alloc=strlen(string)+1; int alloc = (length?length:strlen(string))+1;
char *ns = malloc(alloc); char *ns = malloc(alloc);
unsigned char in; unsigned char in;
int newlen = alloc; int newlen = alloc;
int index=0; int index=0;
while(*string) { while(length--) {
in = *string; in = *string;
if(' ' == in) if(' ' == in)
ns[index++] = '+'; ns[index++] = '+';

View File

@ -26,7 +26,7 @@
/* Escape and unescape URL encoding in strings. The functions return a new /* Escape and unescape URL encoding in strings. The functions return a new
* allocated string or NULL if an error occurred. */ * allocated string or NULL if an error occurred. */
char *curl_escape(char *string); char *curl_escape(char *string, int length);
char *curl_unescape(char *string, int length); char *curl_unescape(char *string, int length);
#endif #endif