intl/icu/source/common/cstring.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 ******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 1997-2012, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 ******************************************************************************
michael@0 8 *
michael@0 9 * File CSTRING.H
michael@0 10 *
michael@0 11 * Contains CString interface
michael@0 12 *
michael@0 13 * @author Helena Shih
michael@0 14 *
michael@0 15 * Modification History:
michael@0 16 *
michael@0 17 * Date Name Description
michael@0 18 * 6/17/98 hshih Created.
michael@0 19 * 05/03/99 stephen Changed from functions to macros.
michael@0 20 * 06/14/99 stephen Added icu_strncat, icu_strncmp, icu_tolower
michael@0 21 *
michael@0 22 ******************************************************************************
michael@0 23 */
michael@0 24
michael@0 25 #ifndef CSTRING_H
michael@0 26 #define CSTRING_H 1
michael@0 27
michael@0 28 #include "unicode/utypes.h"
michael@0 29 #include "cmemory.h"
michael@0 30 #include <string.h>
michael@0 31 #include <stdlib.h>
michael@0 32 #include <ctype.h>
michael@0 33
michael@0 34 #define uprv_strcpy(dst, src) U_STANDARD_CPP_NAMESPACE strcpy(dst, src)
michael@0 35 #define uprv_strlen(str) U_STANDARD_CPP_NAMESPACE strlen(str)
michael@0 36 #define uprv_strcmp(s1, s2) U_STANDARD_CPP_NAMESPACE strcmp(s1, s2)
michael@0 37 #define uprv_strcat(dst, src) U_STANDARD_CPP_NAMESPACE strcat(dst, src)
michael@0 38 #define uprv_strchr(s, c) U_STANDARD_CPP_NAMESPACE strchr(s, c)
michael@0 39 #define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c)
michael@0 40 #define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c)
michael@0 41
michael@0 42 #if U_DEBUG
michael@0 43
michael@0 44 #define uprv_strncpy(dst, src, size) ( \
michael@0 45 uprv_checkValidMemory(src, 1), \
michael@0 46 U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size))
michael@0 47 #define uprv_strncmp(s1, s2, n) ( \
michael@0 48 uprv_checkValidMemory(s1, 1), \
michael@0 49 uprv_checkValidMemory(s2, 1), \
michael@0 50 U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n))
michael@0 51 #define uprv_strncat(dst, src, n) ( \
michael@0 52 uprv_checkValidMemory(src, 1), \
michael@0 53 U_STANDARD_CPP_NAMESPACE strncat(dst, src, n))
michael@0 54
michael@0 55 #else
michael@0 56
michael@0 57 #define uprv_strncpy(dst, src, size) U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size)
michael@0 58 #define uprv_strncmp(s1, s2, n) U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n)
michael@0 59 #define uprv_strncat(dst, src, n) U_STANDARD_CPP_NAMESPACE strncat(dst, src, n)
michael@0 60
michael@0 61 #endif /* U_DEBUG */
michael@0 62
michael@0 63 /**
michael@0 64 * Is c an ASCII-repertoire letter a-z or A-Z?
michael@0 65 * Note: The implementation is specific to whether ICU is compiled for
michael@0 66 * an ASCII-based or EBCDIC-based machine. There just does not seem to be a better name for this.
michael@0 67 */
michael@0 68 U_CAPI UBool U_EXPORT2
michael@0 69 uprv_isASCIILetter(char c);
michael@0 70
michael@0 71 U_CAPI char U_EXPORT2
michael@0 72 uprv_toupper(char c);
michael@0 73
michael@0 74
michael@0 75 U_CAPI char U_EXPORT2
michael@0 76 uprv_asciitolower(char c);
michael@0 77
michael@0 78 U_CAPI char U_EXPORT2
michael@0 79 uprv_ebcdictolower(char c);
michael@0 80
michael@0 81 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
michael@0 82 # define uprv_tolower uprv_asciitolower
michael@0 83 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
michael@0 84 # define uprv_tolower uprv_ebcdictolower
michael@0 85 #else
michael@0 86 # error U_CHARSET_FAMILY is not valid
michael@0 87 #endif
michael@0 88
michael@0 89 #define uprv_strtod(source, end) U_STANDARD_CPP_NAMESPACE strtod(source, end)
michael@0 90 #define uprv_strtoul(str, end, base) U_STANDARD_CPP_NAMESPACE strtoul(str, end, base)
michael@0 91 #define uprv_strtol(str, end, base) U_STANDARD_CPP_NAMESPACE strtol(str, end, base)
michael@0 92
michael@0 93 /* Conversion from a digit to the character with radix base from 2-19 */
michael@0 94 /* May need to use U_UPPER_ORDINAL*/
michael@0 95 #define T_CString_itosOffset(a) ((a)<=9?('0'+(a)):('A'+(a)-10))
michael@0 96
michael@0 97 U_CAPI char* U_EXPORT2
michael@0 98 uprv_strdup(const char *src);
michael@0 99
michael@0 100 /**
michael@0 101 * uprv_malloc n+1 bytes, and copy n bytes from src into the new string.
michael@0 102 * Terminate with a null at offset n. If n is -1, works like uprv_strdup
michael@0 103 * @param src
michael@0 104 * @param n length of the input string, not including null.
michael@0 105 * @return new string (owned by caller, use uprv_free to free).
michael@0 106 * @internal
michael@0 107 */
michael@0 108 U_CAPI char* U_EXPORT2
michael@0 109 uprv_strndup(const char *src, int32_t n);
michael@0 110
michael@0 111 U_CAPI char* U_EXPORT2
michael@0 112 T_CString_toLowerCase(char* str);
michael@0 113
michael@0 114 U_CAPI char* U_EXPORT2
michael@0 115 T_CString_toUpperCase(char* str);
michael@0 116
michael@0 117 U_CAPI int32_t U_EXPORT2
michael@0 118 T_CString_integerToString(char *buffer, int32_t n, int32_t radix);
michael@0 119
michael@0 120 U_CAPI int32_t U_EXPORT2
michael@0 121 T_CString_int64ToString(char *buffer, int64_t n, uint32_t radix);
michael@0 122
michael@0 123 U_CAPI int32_t U_EXPORT2
michael@0 124 T_CString_stringToInteger(const char *integerString, int32_t radix);
michael@0 125
michael@0 126 /**
michael@0 127 * Case-insensitive, language-independent string comparison
michael@0 128 * limited to the ASCII character repertoire.
michael@0 129 */
michael@0 130 U_CAPI int U_EXPORT2
michael@0 131 uprv_stricmp(const char *str1, const char *str2);
michael@0 132
michael@0 133 /**
michael@0 134 * Case-insensitive, language-independent string comparison
michael@0 135 * limited to the ASCII character repertoire.
michael@0 136 */
michael@0 137 U_CAPI int U_EXPORT2
michael@0 138 uprv_strnicmp(const char *str1, const char *str2, uint32_t n);
michael@0 139
michael@0 140 #endif /* ! CSTRING_H */

mercurial