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. */
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 */
#define LIBCURL_VERSION "7.7-beta5"
#define LIBCURL_VERSION_NUM 0x070700

View File

@ -36,15 +36,15 @@
#include "memdebug.h"
#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);
unsigned char in;
int newlen = alloc;
int index=0;
while(*string) {
while(length--) {
in = *string;
if(' ' == in)
ns[index++] = '+';

View File

@ -26,7 +26,7 @@
/* 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);
char *curl_escape(char *string, int length);
char *curl_unescape(char *string, int length);
#endif