ICU 49.1.1
49.1.1
|
00001 /* 00002 *************************************************************************** 00003 * Copyright (C) 2008-2012, International Business Machines Corporation 00004 * and others. All Rights Reserved. 00005 *************************************************************************** 00006 * file name: uspoof.h 00007 * encoding: US-ASCII 00008 * tab size: 8 (not used) 00009 * indentation:4 00010 * 00011 * created on: 2008Feb13 00012 * created by: Andy Heninger 00013 * 00014 * Unicode Spoof Detection 00015 */ 00016 00017 #ifndef USPOOF_H 00018 #define USPOOF_H 00019 00020 #include "unicode/utypes.h" 00021 #include "unicode/uset.h" 00022 #include "unicode/parseerr.h" 00023 #include "unicode/localpointer.h" 00024 00025 #if !UCONFIG_NO_NORMALIZATION 00026 00027 00028 #if U_SHOW_CPLUSPLUS_API 00029 #include "unicode/unistr.h" 00030 #include "unicode/uniset.h" 00031 #endif 00032 00033 00144 struct USpoofChecker; 00145 typedef struct USpoofChecker USpoofChecker; 00154 typedef enum USpoofChecks { 00160 USPOOF_SINGLE_SCRIPT_CONFUSABLE = 1, 00161 00170 USPOOF_MIXED_SCRIPT_CONFUSABLE = 2, 00171 00181 USPOOF_WHOLE_SCRIPT_CONFUSABLE = 4, 00182 00189 USPOOF_ANY_CASE = 8, 00190 00195 USPOOF_SINGLE_SCRIPT = 16, 00196 00203 USPOOF_INVISIBLE = 32, 00204 00209 USPOOF_CHAR_LIMIT = 64, 00210 00211 USPOOF_ALL_CHECKS = 0x7f 00212 } USpoofChecks; 00213 00214 00225 U_STABLE USpoofChecker * U_EXPORT2 00226 uspoof_open(UErrorCode *status); 00227 00228 00250 U_STABLE USpoofChecker * U_EXPORT2 00251 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength, 00252 UErrorCode *pErrorCode); 00253 00285 U_STABLE USpoofChecker * U_EXPORT2 00286 uspoof_openFromSource(const char *confusables, int32_t confusablesLen, 00287 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen, 00288 int32_t *errType, UParseError *pe, UErrorCode *status); 00289 00290 00296 U_STABLE void U_EXPORT2 00297 uspoof_close(USpoofChecker *sc); 00298 00299 #if U_SHOW_CPLUSPLUS_API 00300 00301 U_NAMESPACE_BEGIN 00302 00312 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); 00313 00314 U_NAMESPACE_END 00315 00316 #endif 00317 00327 U_STABLE USpoofChecker * U_EXPORT2 00328 uspoof_clone(const USpoofChecker *sc, UErrorCode *status); 00329 00330 00343 U_STABLE void U_EXPORT2 00344 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status); 00345 00357 U_STABLE int32_t U_EXPORT2 00358 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status); 00359 00402 U_STABLE void U_EXPORT2 00403 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status); 00404 00426 U_STABLE const char * U_EXPORT2 00427 uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status); 00428 00429 00448 U_STABLE void U_EXPORT2 00449 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status); 00450 00451 00472 U_STABLE const USet * U_EXPORT2 00473 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status); 00474 00475 00476 #if U_SHOW_CPLUSPLUS_API 00477 00495 U_STABLE void U_EXPORT2 00496 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status); 00497 00498 00519 U_STABLE const icu::UnicodeSet * U_EXPORT2 00520 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); 00521 #endif 00522 00523 00552 U_STABLE int32_t U_EXPORT2 00553 uspoof_check(const USpoofChecker *sc, 00554 const UChar *text, int32_t length, 00555 int32_t *position, 00556 UErrorCode *status); 00557 00558 00587 U_STABLE int32_t U_EXPORT2 00588 uspoof_checkUTF8(const USpoofChecker *sc, 00589 const char *text, int32_t length, 00590 int32_t *position, 00591 UErrorCode *status); 00592 00593 00594 #if U_SHOW_CPLUSPLUS_API 00595 00620 U_STABLE int32_t U_EXPORT2 00621 uspoof_checkUnicodeString(const USpoofChecker *sc, 00622 const icu::UnicodeString &text, 00623 int32_t *position, 00624 UErrorCode *status); 00625 00626 #endif 00627 00628 00668 U_STABLE int32_t U_EXPORT2 00669 uspoof_areConfusable(const USpoofChecker *sc, 00670 const UChar *s1, int32_t length1, 00671 const UChar *s2, int32_t length2, 00672 UErrorCode *status); 00673 00674 00675 00701 U_STABLE int32_t U_EXPORT2 00702 uspoof_areConfusableUTF8(const USpoofChecker *sc, 00703 const char *s1, int32_t length1, 00704 const char *s2, int32_t length2, 00705 UErrorCode *status); 00706 00707 00708 00709 00710 #if U_SHOW_CPLUSPLUS_API 00711 00732 U_STABLE int32_t U_EXPORT2 00733 uspoof_areConfusableUnicodeString(const USpoofChecker *sc, 00734 const icu::UnicodeString &s1, 00735 const icu::UnicodeString &s2, 00736 UErrorCode *status); 00737 #endif 00738 00739 00772 U_STABLE int32_t U_EXPORT2 00773 uspoof_getSkeleton(const USpoofChecker *sc, 00774 uint32_t type, 00775 const UChar *s, int32_t length, 00776 UChar *dest, int32_t destCapacity, 00777 UErrorCode *status); 00778 00814 U_STABLE int32_t U_EXPORT2 00815 uspoof_getSkeletonUTF8(const USpoofChecker *sc, 00816 uint32_t type, 00817 const char *s, int32_t length, 00818 char *dest, int32_t destCapacity, 00819 UErrorCode *status); 00820 00821 #if U_SHOW_CPLUSPLUS_API 00822 00850 U_STABLE icu::UnicodeString & U_EXPORT2 00851 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, 00852 uint32_t type, 00853 const icu::UnicodeString &s, 00854 icu::UnicodeString &dest, 00855 UErrorCode *status); 00856 #endif /* U_SHOW_CPLUSPLUS_API */ 00857 00858 00877 U_STABLE int32_t U_EXPORT2 00878 uspoof_serialize(USpoofChecker *sc, 00879 void *data, int32_t capacity, 00880 UErrorCode *status); 00881 00882 00883 #endif 00884 00885 #endif /* USPOOF_H */