ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 *************************************************************************** 00003 * Copyright (C) 2008-2010, 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 00032 U_NAMESPACE_USE 00033 #endif 00034 00035 00146 struct USpoofChecker; 00147 typedef struct USpoofChecker USpoofChecker; 00156 typedef enum USpoofChecks { 00162 USPOOF_SINGLE_SCRIPT_CONFUSABLE = 1, 00163 00172 USPOOF_MIXED_SCRIPT_CONFUSABLE = 2, 00173 00183 USPOOF_WHOLE_SCRIPT_CONFUSABLE = 4, 00184 00191 USPOOF_ANY_CASE = 8, 00192 00197 USPOOF_SINGLE_SCRIPT = 16, 00198 00205 USPOOF_INVISIBLE = 32, 00206 00211 USPOOF_CHAR_LIMIT = 64, 00212 00213 USPOOF_ALL_CHECKS = 0x7f 00214 } USpoofChecks; 00215 00216 00227 U_STABLE USpoofChecker * U_EXPORT2 00228 uspoof_open(UErrorCode *status); 00229 00230 00252 U_STABLE USpoofChecker * U_EXPORT2 00253 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength, 00254 UErrorCode *pErrorCode); 00255 00287 U_STABLE USpoofChecker * U_EXPORT2 00288 uspoof_openFromSource(const char *confusables, int32_t confusablesLen, 00289 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen, 00290 int32_t *errType, UParseError *pe, UErrorCode *status); 00291 00292 00298 U_STABLE void U_EXPORT2 00299 uspoof_close(USpoofChecker *sc); 00300 00301 #if U_SHOW_CPLUSPLUS_API 00302 00303 U_NAMESPACE_BEGIN 00304 00314 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close); 00315 00316 U_NAMESPACE_END 00317 00318 #endif 00319 00329 U_STABLE USpoofChecker * U_EXPORT2 00330 uspoof_clone(const USpoofChecker *sc, UErrorCode *status); 00331 00332 00345 U_STABLE void U_EXPORT2 00346 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status); 00347 00359 U_STABLE int32_t U_EXPORT2 00360 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status); 00361 00404 U_STABLE void U_EXPORT2 00405 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status); 00406 00428 U_STABLE const char * U_EXPORT2 00429 uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status); 00430 00431 00450 U_STABLE void U_EXPORT2 00451 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status); 00452 00453 00474 U_STABLE const USet * U_EXPORT2 00475 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status); 00476 00477 00478 #if U_SHOW_CPLUSPLUS_API 00479 00497 U_STABLE void U_EXPORT2 00498 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCode *status); 00499 00500 00521 U_STABLE const UnicodeSet * U_EXPORT2 00522 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status); 00523 #endif 00524 00525 00554 U_STABLE int32_t U_EXPORT2 00555 uspoof_check(const USpoofChecker *sc, 00556 const UChar *text, int32_t length, 00557 int32_t *position, 00558 UErrorCode *status); 00559 00560 00589 U_STABLE int32_t U_EXPORT2 00590 uspoof_checkUTF8(const USpoofChecker *sc, 00591 const char *text, int32_t length, 00592 int32_t *position, 00593 UErrorCode *status); 00594 00595 00596 #if U_SHOW_CPLUSPLUS_API 00597 00622 U_STABLE int32_t U_EXPORT2 00623 uspoof_checkUnicodeString(const USpoofChecker *sc, 00624 const U_NAMESPACE_QUALIFIER UnicodeString &text, 00625 int32_t *position, 00626 UErrorCode *status); 00627 00628 #endif 00629 00630 00670 U_STABLE int32_t U_EXPORT2 00671 uspoof_areConfusable(const USpoofChecker *sc, 00672 const UChar *s1, int32_t length1, 00673 const UChar *s2, int32_t length2, 00674 UErrorCode *status); 00675 00676 00677 00703 U_STABLE int32_t U_EXPORT2 00704 uspoof_areConfusableUTF8(const USpoofChecker *sc, 00705 const char *s1, int32_t length1, 00706 const char *s2, int32_t length2, 00707 UErrorCode *status); 00708 00709 00710 00711 00712 #if U_SHOW_CPLUSPLUS_API 00713 00734 U_STABLE int32_t U_EXPORT2 00735 uspoof_areConfusableUnicodeString(const USpoofChecker *sc, 00736 const U_NAMESPACE_QUALIFIER UnicodeString &s1, 00737 const U_NAMESPACE_QUALIFIER UnicodeString &s2, 00738 UErrorCode *status); 00739 #endif 00740 00741 00774 U_STABLE int32_t U_EXPORT2 00775 uspoof_getSkeleton(const USpoofChecker *sc, 00776 uint32_t type, 00777 const UChar *s, int32_t length, 00778 UChar *dest, int32_t destCapacity, 00779 UErrorCode *status); 00780 00816 U_STABLE int32_t U_EXPORT2 00817 uspoof_getSkeletonUTF8(const USpoofChecker *sc, 00818 uint32_t type, 00819 const char *s, int32_t length, 00820 char *dest, int32_t destCapacity, 00821 UErrorCode *status); 00822 00823 #if U_SHOW_CPLUSPLUS_API 00824 00852 U_STABLE UnicodeString & U_EXPORT2 00853 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, 00854 uint32_t type, 00855 const UnicodeString &s, 00856 UnicodeString &dest, 00857 UErrorCode *status); 00858 #endif /* U_SHOW_CPLUSPLUS_API */ 00859 00860 00879 U_STABLE int32_t U_EXPORT2 00880 uspoof_serialize(USpoofChecker *sc, 00881 void *data, int32_t capacity, 00882 UErrorCode *status); 00883 00884 00885 #endif 00886 00887 #endif /* USPOOF_H */