Grid Community Toolkit  6.2.1567772254 (tag: v6.2.20190906)
Macros | Functions
modp_burl.h File Reference

Go to the source code of this file.

Macros

#define modp_burl_encode_len(A)   (3*A + 1)
 
#define modp_burl_decode_len(A)   (A + 1)
 

Functions

BEGIN_C int modp_burl_encode (char *dest, const char *str, int len)
 
int modp_burl_min_encode (char *dest, const char *str, int len)
 
int modp_burl_min_encode_strlen (const char *src, const int len)
 get size of output string w/o doing actual encoding More...
 
int modp_burl_encode_strlen (const char *str, const int len)
 
int modp_burl_decode (char *dest, const char *str, int len)
 

Detailed Description

High Performance URL Encoder/Decoder
Copyright © 2006, 2007  Nick Galbreath -- nickg [at] modp [dot] com
All rights reserved.
http://code.google.com/p/stringencoders/
Released under bsd license.  See bfast64.c for details.

Macro Definition Documentation

◆ modp_burl_decode_len

#define modp_burl_decode_len (   A)    (A + 1)

Returns memory required to decoded a url-encoded string of length A.

◆ modp_burl_encode_len

#define modp_burl_encode_len (   A)    (3*A + 1)

Provides the maximum size for output string given and input size of A bytes.

Function Documentation

◆ modp_burl_decode()

int modp_burl_decode ( char *  dest,
const char *  str,
int  len 
)

URL Decode a string

Parameters
[out]destThe output string. Must be at least (len + 1) bytes allocated. This may be the same as the input buffer.
[in]strThe input string that is URL encoded.
[in]lenThe length of the input string (excluding final null byte)
Returns
the strlen of the output string.

◆ modp_burl_encode()

BEGIN_C int modp_burl_encode ( char *  dest,
const char *  str,
int  len 
)

Url encode a string. This uses a very strict definition of url encoding. The only characters NOT encoded are A-Z, a-z, 0-9, "-", "_", ".", along with the space char getting mapped to "+". Everything else is escaped using "%HEXHEX" format. This is identical to the implementation of php's urlencode and nearly identical to Java's UrlEncoder class (they do not escape '*' for some reason).

Parameters
[out]destoutput string. Must
[in]strThe input string
[in]lenThe length of the input string, excluding any final null byte.

◆ modp_burl_encode_strlen()

int modp_burl_encode_strlen ( const char *  str,
const int  len 
)

Given the exact size of output string.

Can be used to allocate the right amount of memory for modp_burl_encode. Be sure to add 1 byte for final null.

This is somewhat expensive since it examines every character in the input string

Parameters
[in]strThe input string
[in]lenTHe length of the input string, excluding any final null byte (i.e. strlen(str))
Returns
the size of the output string, excluding the final null byte.

◆ modp_burl_min_encode()

int modp_burl_min_encode ( char *  dest,
const char *  str,
int  len 
)

Url encode a string. This uses a minimal definition of url encoding. This works similar to the previous function except '~', '!', '$', '\'', '(', ')', '*', ',', ';', ':', '@', '/', '?' are NOT escaped. This will allow decoding by standard url-decoders and make the encoded urls more readable.

Parameters
[out]destoutput string. Must
[in]strThe input string
[in]lenThe length of the input string, excluding any final null byte.

◆ modp_burl_min_encode_strlen()

int modp_burl_min_encode_strlen ( const char *  src,
const int  len 
)

get size of output string w/o doing actual encoding

Parameters
[in]srcinput string, not null
[in]lenlength of input string
Returns
length of output string NOT including any final null byte