ICU 4.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
uspoof.h
Go to the documentation of this file.
1 /*
2 ***************************************************************************
3 * Copyright (C) 2008-2009, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ***************************************************************************
6 * file name: uspoof.h
7 * encoding: US-ASCII
8 * tab size: 8 (not used)
9 * indentation:4
10 *
11 * created on: 2008Feb13
12 * created by: Andy Heninger
13 *
14 * Unicode Spoof Detection
15 */
16 
22 #ifndef USPOOF_H
23 #define USPOOF_H
24 
25 #include "unicode/utypes.h"
26 #include "unicode/uset.h"
27 #include "unicode/parseerr.h"
28 
29 
30 #if !UCONFIG_NO_NORMALIZATION
31 
32 
33 #ifdef XP_CPLUSPLUS
34 #include "unicode/unistr.h"
35 #include "unicode/uniset.h"
36 
38 #endif
39 
40 
138 struct USpoofChecker;
139 typedef struct USpoofChecker USpoofChecker;
148 typedef enum USpoofChecks {
155 
165 
176 
184 
190 
198 
204 
205  USPOOF_ALL_CHECKS = 0x7f
206  } USpoofChecks;
207 
208 
220 uspoof_open(UErrorCode *status);
221 
222 
245 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
246  UErrorCode *pErrorCode);
247 
280 uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
281  const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
282  int32_t *errType, UParseError *pe, UErrorCode *status);
283 
284 
290 U_DRAFT void U_EXPORT2
292 
303 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
304 
305 
318 U_DRAFT void U_EXPORT2
319 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
320 
333 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
334 
377 U_DRAFT void U_EXPORT2
378 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
379 
401 U_DRAFT const char * U_EXPORT2
403 
404 
423 U_DRAFT void U_EXPORT2
424 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
425 
426 
447 U_DRAFT const USet * U_EXPORT2
449 
450 
451 #ifdef XP_CPLUSPLUS
452 
470 U_DRAFT void U_EXPORT2
471 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCode *status);
472 
473 
495 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
496 #endif
497 
498 
528 uspoof_check(const USpoofChecker *sc,
529  const UChar *text, int32_t length,
530  int32_t *position,
531  UErrorCode *status);
532 
533 
564  const char *text, int32_t length,
565  int32_t *position,
566  UErrorCode *status);
567 
568 
569 #ifdef XP_CPLUSPLUS
570 
596 uspoof_checkUnicodeString(const USpoofChecker *sc,
598  int32_t *position,
599  UErrorCode *status);
600 
601 #endif
602 
603 
645  const UChar *s1, int32_t length1,
646  const UChar *s2, int32_t length2,
647  UErrorCode *status);
648 
649 
650 
678  const char *s1, int32_t length1,
679  const char *s2, int32_t length2,
680  UErrorCode *status);
681 
682 
683 
684 
685 #ifdef XP_CPLUSPLUS
686 
708 uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
711  UErrorCode *status);
712 #endif
713 
714 
749  uint32_t type,
750  const UChar *s, int32_t length,
751  UChar *dest, int32_t destCapacity,
752  UErrorCode *status);
753 
791  uint32_t type,
792  const char *s, int32_t length,
793  char *dest, int32_t destCapacity,
794  UErrorCode *status);
795 
796 #ifdef XP_CPLUSPLUS
797 
826 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
827  uint32_t type,
828  const UnicodeString &s,
829  UnicodeString &dest,
830  UErrorCode *status);
831 #endif /* XP_CPLUSPLUS */
832 
833 
854  void *data, int32_t capacity,
855  UErrorCode *status);
856 
857 
858 #endif
859 
860 #endif /* USPOOF_H */
void uspoof_close(USpoofChecker *sc)
Close a Spoof Checker, freeing any memory that was being held by its implementation.
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:115
Check an identifier for the presence of invisble characters, such as zero-width spaces, or character sequences that are likely not to display, such as multiple occurences of the same non-spacing mark.
Definition: uspoof.h:197
Check that an identifer contains only characters from a single script (plus chars from the common and...
Definition: uspoof.h:189
int32_t uspoof_checkUTF8(const USpoofChecker *sc, const char *text, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
void uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status)
Specify the set of checks that will be performed by the check functions of this Spoof Checker...
USpoofChecker * uspoof_clone(const USpoofChecker *sc, UErrorCode *status)
Clone a Spoof Checker.
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:272
int32_t uspoof_getSkeleton(const USpoofChecker *sc, uint32_t type, const UChar *s, int32_t length, UChar *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier string.
Check that an identifier contains only characters from a specified set of acceptable characters...
Definition: uspoof.h:203
U_CAPI USpoofChecker * uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength, UErrorCode *pErrorCode)
Open a Spoof checker from its serialized from, stored in 32-bit-aligned memory.
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition: uspoof.h:148
C++ API: Unicode String.
USpoofChecker * uspoof_open(UErrorCode *status)
Create a Unicode Spoof Checker, configured to perform all checks except for USPOOF_LOCALE_LIMIT and U...
int32_t uspoof_areConfusableUTF8(const USpoofChecker *sc, const char *s1, int32_t length1, const char *s2, int32_t length2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
void uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status)
Limit characters that are acceptable in identifiers being checked to those normally used with the lan...
int32_t uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status)
Get the set of checks that this Spoof Checker has been configured to perform.
unsigned int uint32_t
Define 64 bit limits.
Definition: pwin32.h:147
C API: Unicode Set.
int32_t uspoof_areConfusable(const USpoofChecker *sc, const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
Any Case Modifier for confusable identifier tests.
Definition: uspoof.h:183
#define U_NAMESPACE_QUALIFIER
This is used to qualify that a function or class is part of the public ICU C++ API namespace...
Definition: uversion.h:186
Whole script confusable test.
Definition: uspoof.h:175
U_CAPI int32_t uspoof_serialize(USpoofChecker *sc, void *data, int32_t capacity, UErrorCode *status)
Serialize the data for a spoof detector into a chunk of memory.
U_CAPI USpoofChecker * uspoof_openFromSource(const char *confusables, int32_t confusablesLen, const char *confusablesWholeScript, int32_t confusablesWholeScriptLen, int32_t *errType, UParseError *pe, UErrorCode *status)
Open a Spoof Checker from the source form of the spoof data.
#define U_NAMESPACE_USE
This is used to specify that the rest of the code uses the public ICU C++ API namespace.
Definition: uversion.h:185
void uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
const USet * uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status)
Get a USet for the characters permitted in an identifier.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:187
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition: uspoof.h:139
#define U_EXPORT2
Definition: platform.h:338
Single script confusable test.
Definition: uspoof.h:154
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:299
int32_t uspoof_getSkeletonUTF8(const USpoofChecker *sc, uint32_t type, const char *s, int32_t length, char *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier string.
struct USet USet
Definition: ucnv.h:66
C API: Parse Error Information.
const char * uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status)
Get a list of locales for the scripts that are acceptable in strings to be checked.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:593
Mixed script confusable test.
Definition: uspoof.h:164
int32_t uspoof_check(const USpoofChecker *sc, const UChar *text, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
Basic definitions for ICU, for both C and C++ APIs.
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:119
signed int int32_t
Define 64 bit limits.
Definition: pwin32.h:143
C++ API: Unicode Set.