Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

encode.c File Reference

Functions to encode and decode URLs, and also to encode cookies and HTML text. More...


Functions

char * html_encode (const char *s)
char * html_encode_and_free_original (char *s)
char * cookie_encode (const char *s)
char * url_encode (const char *s)
int xdtoi (const int d)
int xtoi (const char *s)
char * url_decode (const char *s)

Variables

const char encode_rcs [] = "$Id: encode.c,v 2.1 2002/06/04 17:55:24 jongfoster Exp $"
const char encode_h_rcs [] = ENCODE_H_VERSION
const char *const url_code_map [256]
const char *const html_code_map [256]
const char *const cookie_code_map [256]


Detailed Description

Functions to encode and decode URLs, and also to encode cookies and HTML text.

Log:
encode.c,v
Revision 2.1 2002/06/04 17:55:24 jongfoster Adding comments

Revision 2.0 2002/06/04 14:34:21 jongfoster Moving source files to src/

Revision 1.8 2002/03/26 22:29:54 swa we have a new homepage!

Revision 1.7 2002/03/24 13:25:43 swa name change related issues

Revision 1.6 2002/03/13 00:27:04 jongfoster Killing warnings

Revision 1.5 2002/03/07 03:46:53 oes Fixed compiler warnings etc

Revision 1.4 2002/01/22 23:28:07 jongfoster Adding convenience function html_encode_and_free_original() Making all functions accept NULL paramaters - in this case, they simply return NULL. This allows error-checking to be deferred.

Revision 1.3 2001/11/13 00:16:40 jongfoster Replacing references to malloc.h with the standard stdlib.h (See ANSI or K&R 2nd Ed)

Revision 1.2 2001/05/17 22:52:35 oes

Revision 1.1.1.1 2001/05/15 13:58:51 oes Initial import of version 2.9.3 source tree


Function Documentation

char* cookie_encode const char *    s
 

Encodes a string so it can be used in a cookie.

Replaces " ", ",", and ";" with the appropriate codes.

Parameters:
s  String to encode. Null-terminated.
Returns:
Encoded string, newly allocated on the heap. Caller is responsible for freeing it with free(). If s is NULL, or on out-of memory, returns NULL.

char* html_encode const char *    s
 

Encodes a string so it's not interpreted as containing HTML tags or entities.

Replaces <, >, &, and " with the appropriate HTML entities.

Parameters:
s  String to encode. Null-terminated.
Returns:
Encoded string, newly allocated on the heap. Caller is responsible for freeing it with free(). If s is NULL, or on out-of memory, returns NULL.

char* html_encode_and_free_original char *    s
 

Encodes a string so it's not interpreted as containing HTML tags or entities.

Replaces <, >, &, and " with the appropriate HTML entities. Free()s original string. If original string is NULL, simply returns NULL.

Parameters:
s  String to encode. Null-terminated.
Returns:
Encoded string, newly allocated on the heap. Caller is responsible for freeing it with free(). If s is NULL, or on out-of memory, returns NULL.

char* url_decode const char *    s
 

Decodes a URL query string, replacing xx codes with their decoded form.

Parameters:
s  String to decode. Null-terminated.
Returns:
Decoded string, newly allocated on the heap. Caller is responsible for freeing it with free().

char* url_encode const char *    s
 

Encodes a string so it can be used in a URL query string.

Replaces special characters with the appropriate xx codes.

Parameters:
s  String to encode. Null-terminated.
Returns:
Encoded string, newly allocated on the heap. Caller is responsible for freeing it with free(). If s is NULL, or on out-of memory, returns NULL.

int xdtoi const int    d [static]
 

Converts a single hex digit to an integer.

Parameters:
d  in the range of ['0'..'9', 'A'..'F', 'a'..'f']
Returns:
The integer value, or -1 for non-hex characters.

int xtoi const char *    s [static]
 

Hex string to integer conversion.

Parameters:
s  a 2 digit hex string (e.g. "1f"). Only the first two characters will be looked at.
Returns:
The integer value, or 0 for non-hex strings.


Variable Documentation

const char* const cookie_code_map[256] [static]
 

Initial value:

 {
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, "+",  NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, "%2C",NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "%3B",
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL
}
Maps special characters in a cookie to their equivalent % codes.

const char encode_h_rcs[] = ENCODE_H_VERSION
 

Version information about encode.h.

const char encode_rcs[] = "$Id: encode.c,v 2.1 2002/06/04 17:55:24 jongfoster Exp $"
 

Version information about encode.c.

const char* const html_code_map[256] [static]
 

Initial value:

 {
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL,"&quot;",NULL,NULL,NULL,"&amp;",NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   "&lt;",NULL,"&gt;",NULL,NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
   NULL, NULL, NULL, NULL, NULL, NULL
}
Maps special characters in HTML to their equivalent entities.

const char* const url_code_map[256] [static]
 

Initial value:

 {
   NULL, "%01", "%02", "%03", "%04", "%05", "%06", "%07", "%08", "%09",
   "%0A", "%0B", "%0C", "%0D", "%0E", "%0F", "%10", "%11", "%12", "%13",
   "%14", "%15", "%16", "%17", "%18", "%19", "%1A", "%1B", "%1C", "%1D",
   "%1E", "%1F", "+",   "%21", "%22", "%23", "%24", "%25", "%26", "%27",
   "%28", "%29", NULL,  "%2B", "%2C", NULL,  NULL,  "%2F", NULL,  NULL,
   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  "%3A", "%3B",
   "%3C", "%3D", "%3E", "%3F", NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
   NULL,  "%5B", "%5C", "%5D", "%5E", NULL,  "%60", NULL,  NULL,  NULL,
   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
   NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,  NULL,
   NULL,  NULL,  NULL,  "%7B", "%7C", "%7D", "%7E", "%7F", "%80", "%81",
   "%82", "%83", "%84", "%85", "%86", "%87", "%88", "%89", "%8A", "%8B",
   "%8C", "%8D", "%8E", "%8F", "%90", "%91", "%92", "%93", "%94", "%95",
   "%96", "%97", "%98", "%99", "%9A", "%9B", "%9C", "%9D", "%9E", "%9F",
   "%A0", "%A1", "%A2", "%A3", "%A4", "%A5", "%A6", "%A7", "%A8", "%A9",
   "%AA", "%AB", "%AC", "%AD", "%AE", "%AF", "%B0", "%B1", "%B2", "%B3",
   "%B4", "%B5", "%B6", "%B7", "%B8", "%B9", "%BA", "%BB", "%BC", "%BD",
   "%BE", "%BF", "%C0", "%C1", "%C2", "%C3", "%C4", "%C5", "%C6", "%C7",
   "%C8", "%C9", "%CA", "%CB", "%CC", "%CD", "%CE", "%CF", "%D0", "%D1",
   "%D2", "%D3", "%D4", "%D5", "%D6", "%D7", "%D8", "%D9", "%DA", "%DB",
   "%DC", "%DD", "%DE", "%DF", "%E0", "%E1", "%E2", "%E3", "%E4", "%E5",
   "%E6", "%E7", "%E8", "%E9", "%EA", "%EB", "%EC", "%ED", "%EE", "%EF",
   "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7", "%F8", "%F9",
   "%FA", "%FB", "%FC", "%FD", "%FE", "%FF"
}
Maps special characters in a URL to their equivalent % codes.


Generated on Tue Jun 4 18:54:49 2002 for Privoxy 3.1.1 by doxygen1.2.15