Uri.h | Uri.h | |||
---|---|---|---|---|
skipping to change at line 185 | skipping to change at line 185 | |||
void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); | void URI_FUNC(FreeUriMembers)(URI_TYPE(Uri) * uri); | |||
/** | /** | |||
* Percent-encodes all unreserved characters from the input string and | * Percent-encodes all unreserved characters from the input string and | |||
* writes the encoded version to the output string. | * writes the encoded version to the output string. | |||
* Be sure to allocate <b>3 times</b> the space of the input buffer for | * Be sure to allocate <b>3 times</b> the space of the input buffer for | |||
* the output buffer for <c>normalizeBreaks == URI_FALSE</c> and <b>6 times </b> | * the output buffer for <c>normalizeBreaks == URI_FALSE</c> and <b>6 times </b> | |||
* the space for <c>normalizeBreaks == URI_FALSE</c> | * the space for <c>normalizeBreaks == URI_FALSE</c> | |||
* (since e.g. "\x0d" becomes "%0D%0A" in that case) | * (since e.g. "\x0d" becomes "%0D%0A" in that case) | |||
* | * | |||
* @param inFirst Pointer to first character of the input text | ||||
* @param inAfterLast Pointer after the last character of the input t | ||||
ext | ||||
* @param out Encoded text destination | ||||
* @param spaceToPlus Wether to convert ' ' to '+' or not | ||||
* @param normalizeBreaks Wether to convert CR and LF to CR-LF or not. | ||||
* @return Position of terminator in output string | ||||
*/ | ||||
URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, | ||||
const URI_CHAR * inAfterLast, URI_CHAR * out, | ||||
UriBool spaceToPlus, UriBool normalizeBreaks); | ||||
/** | ||||
* Percent-encodes all unreserved characters from the input string and | ||||
* writes the encoded version to the output string. | ||||
* Be sure to allocate <b>3 times</b> the space of the input buffer for | ||||
* the output buffer for <c>normalizeBreaks == URI_FALSE</c> and <b>6 times | ||||
</b> | ||||
* the space for <c>normalizeBreaks == URI_FALSE</c> | ||||
* (since e.g. "\x0d" becomes "%0D%0A" in that case) | ||||
* | ||||
* @param in Text source | * @param in Text source | |||
* @param out Encoded text destination | * @param out Encoded text destination | |||
* @param spaceToPlus Wether to convert ' ' to '+' or not | * @param spaceToPlus Wether to convert ' ' to '+' or not | |||
* @param normalizeBreaks Wether to convert CR and LF to CR-LF or not. | * @param normalizeBreaks Wether to convert CR and LF to CR-LF or not. | |||
* @return Position of terminator in output string | * @return Position of terminator in output string | |||
*/ | */ | |||
const URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, | URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, | |||
UriBool spaceToPlus, UriBool normalizeBreaks); | UriBool spaceToPlus, UriBool normalizeBreaks); | |||
/** | /** | |||
* Unescapes percent-encoded groups in a given string. | * Unescapes percent-encoded groups in a given string. | |||
* E.g. "%20" will become " ". Unescaping is done in place. | * E.g. "%20" will become " ". Unescaping is done in place. | |||
* The return value will be point to the new position | * The return value will be point to the new position | |||
* of the terminating zero. Use this value to get the new | * of the terminating zero. Use this value to get the new | |||
* length of the string. NULL is only returned if <code>inout</code> | * length of the string. NULL is only returned if <code>inout</code> | |||
* is NULL. | * is NULL. | |||
* | * | |||
skipping to change at line 240 | skipping to change at line 259 | |||
* @param absoluteDest Result %URI | * @param absoluteDest Result %URI | |||
* @param relativeSource Reference to resolve | * @param relativeSource Reference to resolve | |||
* @param absoluteBase Base %URI to apply | * @param absoluteBase Base %URI to apply | |||
* @return Error code or 0 on success | * @return Error code or 0 on success | |||
*/ | */ | |||
int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, | int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest, | |||
const URI_TYPE(Uri) * relativeSource, | const URI_TYPE(Uri) * relativeSource, | |||
const URI_TYPE(Uri) * absoluteBase); | const URI_TYPE(Uri) * absoluteBase); | |||
/** | /** | |||
* Tries to make a relative %URI (a reference) from an | ||||
* absolute %URI and a given base %URI. This can only work if | ||||
* the absolute %URI shares scheme and authority with | ||||
* the base %URI. If it does not the result will still be | ||||
* an absolute URI (with scheme part if necessary). | ||||
* | ||||
* @param dest Result %URI | ||||
* @param absoluteSource Absolute %URI to make relative | ||||
* @param absoluteBase Base %URI | ||||
* @param domainRootMode Create %URI with path relative to domain root | ||||
* @return Error code or 0 on success | ||||
*/ | ||||
int URI_FUNC(RemoveBaseUri)(URI_TYPE(Uri) * dest, | ||||
const URI_TYPE(Uri) * absoluteSource, | ||||
const URI_TYPE(Uri) * absoluteBase, | ||||
UriBool domainRootMode); | ||||
/** | ||||
* Checks two URIs for equivalence. Comparison is done | * Checks two URIs for equivalence. Comparison is done | |||
* the naive way, without prior normalization. | * the naive way, without prior normalization. | |||
* NOTE: Two <code>NULL</code> URIs are equal as well. | * NOTE: Two <code>NULL</code> URIs are equal as well. | |||
* | * | |||
* @param a First %URI | * @param a First %URI | |||
* @param b Second %URI | * @param b Second %URI | |||
* @return <code>URI_TRUE</code> when equal, <code>URI_FAlSE</code> else | * @return <code>URI_TRUE</code> when equal, <code>URI_FAlSE</code> else | |||
*/ | */ | |||
UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, const URI_TYPE(Uri) * b); | UriBool URI_FUNC(EqualsUri)(const URI_TYPE(Uri) * a, const URI_TYPE(Uri) * b); | |||
skipping to change at line 306 | skipping to change at line 343 | |||
* Normalizes all components of a %URI. | * Normalizes all components of a %URI. | |||
* | * | |||
* NOTE: If necessary the %URI becomes owner of all memory | * NOTE: If necessary the %URI becomes owner of all memory | |||
* behind the text pointed to. Text is duplicated in that case. | * behind the text pointed to. Text is duplicated in that case. | |||
* | * | |||
* @param uri %URI to normalize | * @param uri %URI to normalize | |||
* @return Error code or 0 on success | * @return Error code or 0 on success | |||
*/ | */ | |||
int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); | int URI_FUNC(NormalizeSyntax)(URI_TYPE(Uri) * uri); | |||
/** | ||||
* Converts an absolute Unix filename to a %URI string. | ||||
* The destination buffer must be large enough to hold | ||||
* 7 + 3 * len(filename) + 1 characters. | ||||
* | ||||
* EXAMPLE | ||||
* Input: "/bin/bash" | ||||
* Output: "file:///bin/bash" | ||||
* | ||||
* @param filename Unix filename to convert | ||||
* @param uriString Destination to write %URI string to | ||||
* @return Error code or 0 on success | ||||
*/ | ||||
int URI_FUNC(UnixFilenameToUriString)(const URI_CHAR * filename, | ||||
URI_CHAR * uriString); | ||||
/** | ||||
* Converts an absolute Windows filename to a %URI string. | ||||
* The destination buffer must be large enough to hold | ||||
* 8 + 3 * len(filename) + 1 characters. | ||||
* | ||||
* EXAMPLE | ||||
* Input: "E:\\Documents and Settings" | ||||
* Output: "file:///E:/Documents%20and%20Settings" | ||||
* | ||||
* @param filename Windows filename to convert | ||||
* @param uriString Destination to write %URI string to | ||||
* @return Error code or 0 on success | ||||
*/ | ||||
int URI_FUNC(WindowsFilenameToUriString)(const URI_CHAR * filename, | ||||
URI_CHAR * uriString); | ||||
/** | ||||
* Extracts an absolute Unix filename from a %URI string. | ||||
* The destination buffer must be large enough to hold | ||||
* len(uriString) + 1 - 7 characters. | ||||
* | ||||
* @param uriString %URI string to convert | ||||
* @param filename Destination to write filename to | ||||
* @return Error code or 0 on success | ||||
*/ | ||||
int URI_FUNC(UriStringToUnixFilename)(const URI_CHAR * uriString, | ||||
URI_CHAR * filename); | ||||
/** | ||||
* Extracts an absolute Windows filename from a %URI string. | ||||
* The destination buffer must be large enough to hold | ||||
* len(uriString) + 1 - 8 characters. | ||||
* | ||||
* @param uriString %URI string to convert | ||||
* @param filename Destination to write filename to | ||||
* @return Error code or 0 on success | ||||
*/ | ||||
int URI_FUNC(UriStringToWindowsFilename)(const URI_CHAR * uriString, | ||||
URI_CHAR * filename); | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 4 change blocks. | ||||
1 lines changed or deleted | 96 lines changed or added | |||
UriBase.h | UriBase.h | |||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
#ifndef URI_BASE_H | #ifndef URI_BASE_H | |||
#define URI_BASE_H 1 | #define URI_BASE_H 1 | |||
/* Version helper macro */ | /* Version helper macro */ | |||
#define URI_ANSI_TO_UNICODE(x) L##x | #define URI_ANSI_TO_UNICODE(x) L##x | |||
/* Version */ | /* Version */ | |||
#define URI_VER_MAJOR 0 | #define URI_VER_MAJOR 0 | |||
#define URI_VER_MINOR 5 | #define URI_VER_MINOR 5 | |||
#define URI_VER_RELEASE 1 | #define URI_VER_RELEASE 2 | |||
#define URI_VER_SUFFIX_ANSI "" | #define URI_VER_SUFFIX_ANSI "" | |||
#define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) | #define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) | |||
/* More version helper macros */ | /* More version helper macros */ | |||
#define URI_INT_TO_ANSI_HELPER(x) #x | #define URI_INT_TO_ANSI_HELPER(x) #x | |||
#define URI_INT_TO_ANSI(x) URI_INT_TO_ANSI_HELPER(x) | #define URI_INT_TO_ANSI(x) URI_INT_TO_ANSI_HELPER(x) | |||
#define URI_INT_TO_UNICODE_HELPER(x) URI_ANSI_TO_UNICODE(#x) | #define URI_INT_TO_UNICODE_HELPER(x) URI_ANSI_TO_UNICODE(#x) | |||
#define URI_INT_TO_UNICODE(x) URI_INT_TO_UNICODE_HELPER(x) | #define URI_INT_TO_UNICODE(x) URI_INT_TO_UNICODE_HELPER(x) | |||
skipping to change at line 94 | skipping to change at line 94 | |||
#else | #else | |||
# define URI_UNUSED(x) x | # define URI_UNUSED(x) x | |||
#endif | #endif | |||
typedef int UriBool; /**< Boolean type */ | typedef int UriBool; /**< Boolean type */ | |||
#define URI_TRUE 1 | #define URI_TRUE 1 | |||
#define URI_FALSE 0 | #define URI_FALSE 0 | |||
/* Shared errors */ | /* Shared errors */ | |||
#define URI_SUCCESS 0 | #define URI_SUCCESS 0 | |||
#define URI_ERROR_SYNTAX 1 /* Parsed text violates expected for | #define URI_ERROR_SYNTAX 1 /* Parsed text violates expected | |||
mat */ | format */ | |||
#define URI_ERROR_NULL 2 /* One of the params passed was NULL | #define URI_ERROR_NULL 2 /* One of the params passed was | |||
although it mustn't be */ | NULL | |||
#define URI_ERROR_MALLOC 3 /* Requested memory could not be all | although it mustn't be */ | |||
ocated */ | #define URI_ERROR_MALLOC 3 /* Requested memory could not be | |||
allocated */ | ||||
/* Errors specific to ToSting */ | /* Errors specific to ToSting */ | |||
#define URI_ERROR_TOSTRING_TOO_LONG 4 /* URI too long for target buffer */ | #define URI_ERROR_TOSTRING_TOO_LONG 4 /* URI too long for target buffe r */ | |||
/* Errors specific to AddBaseUri */ | /* Errors specific to AddBaseUri */ | |||
#define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */ | #define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */ | |||
/* Errors specific to RemoveBaseUri */ | ||||
#define URI_ERROR_REMOVEBASE_REL_BASE 6 /* Given base is not absolute */ | ||||
#define URI_ERROR_REMOVEBASE_REL_SOURCE 7 /* Given base is not absolute */ | ||||
#ifndef URI_DOXYGEN | #ifndef URI_DOXYGEN | |||
# include <stdio.h> /* For NULL, snprintf */ | # include <stdio.h> /* For NULL, snprintf */ | |||
# include <ctype.h> /* For wchar_t */ | # include <ctype.h> /* For wchar_t */ | |||
# include <string.h> /* For strlen, memset, memcpy */ | # include <string.h> /* For strlen, memset, memcpy */ | |||
# include <stdlib.h> /* For malloc */ | # include <stdlib.h> /* For malloc */ | |||
#endif /* URI_DOXYGEN */ | #endif /* URI_DOXYGEN */ | |||
/** | /** | |||
* Holds an IPv4 address. | * Holds an IPv4 address. | |||
End of changes. 4 change blocks. | ||||
10 lines changed or deleted | 15 lines changed or added | |||