ICU 50.1.2  50.1.2
uspoof.h
Go to the documentation of this file.
1 /*
2 ***************************************************************************
3 * Copyright (C) 2008-2012, 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 
17 #ifndef USPOOF_H
18 #define USPOOF_H
19 
20 #include "unicode/utypes.h"
21 #include "unicode/uset.h"
22 #include "unicode/parseerr.h"
23 #include "unicode/localpointer.h"
24 
25 #if !UCONFIG_NO_NORMALIZATION
26 
27 
28 #if U_SHOW_CPLUSPLUS_API
29 #include "unicode/unistr.h"
30 #include "unicode/uniset.h"
31 #endif
32 
33 
144 struct USpoofChecker;
145 typedef struct USpoofChecker USpoofChecker;
154 typedef enum USpoofChecks {
161 
171 
182 
190 
196 
204 
210 
211  USPOOF_ALL_CHECKS = 0x7f
212  } USpoofChecks;
213 
214 
225 U_STABLE USpoofChecker * U_EXPORT2
226 uspoof_open(UErrorCode *status);
227 
228 
250 U_STABLE USpoofChecker * U_EXPORT2
251 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
252  UErrorCode *pErrorCode);
253 
285 U_STABLE USpoofChecker * U_EXPORT2
286 uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
287  const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
288  int32_t *errType, UParseError *pe, UErrorCode *status);
289 
290 
296 U_STABLE void U_EXPORT2
298 
299 #if U_SHOW_CPLUSPLUS_API
300 
302 
313 
315 
316 #endif
317 
327 U_STABLE USpoofChecker * U_EXPORT2
328 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
329 
330 
343 U_STABLE void U_EXPORT2
344 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
345 
357 U_STABLE int32_t U_EXPORT2
358 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
359 
402 U_STABLE void U_EXPORT2
403 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
404 
426 U_STABLE const char * U_EXPORT2
428 
429 
448 U_STABLE void U_EXPORT2
449 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
450 
451 
472 U_STABLE const USet * U_EXPORT2
474 
475 
476 #if U_SHOW_CPLUSPLUS_API
477 
495 U_STABLE void U_EXPORT2
497 
498 
519 U_STABLE const icu::UnicodeSet * U_EXPORT2
521 #endif
522 
523 
552 U_STABLE int32_t U_EXPORT2
553 uspoof_check(const USpoofChecker *sc,
554  const UChar *text, int32_t length,
555  int32_t *position,
556  UErrorCode *status);
557 
558 
587 U_STABLE int32_t U_EXPORT2
589  const char *text, int32_t length,
590  int32_t *position,
591  UErrorCode *status);
592 
593 
594 #if U_SHOW_CPLUSPLUS_API
595 
620 U_STABLE int32_t U_EXPORT2
622  const icu::UnicodeString &text,
623  int32_t *position,
624  UErrorCode *status);
625 
626 #endif
627 
628 
668 U_STABLE int32_t U_EXPORT2
670  const UChar *s1, int32_t length1,
671  const UChar *s2, int32_t length2,
672  UErrorCode *status);
673 
674 
675 
701 U_STABLE int32_t U_EXPORT2
703  const char *s1, int32_t length1,
704  const char *s2, int32_t length2,
705  UErrorCode *status);
706 
707 
708 
709 
710 #if U_SHOW_CPLUSPLUS_API
711 
732 U_STABLE int32_t U_EXPORT2
734  const icu::UnicodeString &s1,
735  const icu::UnicodeString &s2,
736  UErrorCode *status);
737 #endif
738 
739 
772 U_STABLE int32_t U_EXPORT2
774  uint32_t type,
775  const UChar *s, int32_t length,
776  UChar *dest, int32_t destCapacity,
777  UErrorCode *status);
778 
814 U_STABLE int32_t U_EXPORT2
816  uint32_t type,
817  const char *s, int32_t length,
818  char *dest, int32_t destCapacity,
819  UErrorCode *status);
820 
821 #if U_SHOW_CPLUSPLUS_API
822 
847 U_I18N_API icu::UnicodeString & U_EXPORT2
849  uint32_t type,
850  const icu::UnicodeString &s,
851  icu::UnicodeString &dest,
852  UErrorCode *status);
853 #endif /* U_SHOW_CPLUSPLUS_API */
854 
855 
874 U_STABLE int32_t U_EXPORT2
876  void *data, int32_t capacity,
877  UErrorCode *status);
878 
879 
880 #endif
881 
882 #endif /* USPOOF_H */
void uspoof_close(USpoofChecker *sc)
Close a Spoof Checker, freeing any memory that was being held by its implementation.
Check an identifier for the presence of invisible characters, such as zero-width spaces, or character sequences that are likely not to display, such as multiple occurrences of the same non-spacing mark.
Definition: uspoof.h:203
Check that an identifier contains only characters from a single script (plus chars from the common an...
Definition: uspoof.h:195
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.
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:209
U_I18N_API icu::UnicodeString & uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, uint32_t type, const icu::UnicodeString &s, icu::UnicodeString &dest, UErrorCode *status)
Get the "skeleton" for an identifier string.
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition: uspoof.h:154
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.
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.
const icu::UnicodeSet * uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status)
Get a UnicodeSet for the characters permitted in an identifier.
C API: Unicode Set.
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
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.
int32_t uspoof_areConfusableUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &s1, const icu::UnicodeString &s2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
Any Case Modifier for confusable identifier tests.
Definition: uspoof.h:189
Whole script confusable test.
Definition: uspoof.h:181
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:290
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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.
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.
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:273
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition: uspoof.h:145
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.
"Smart pointer" class, closes a USpoofChecker via uspoof_close().
Single script confusable test.
Definition: uspoof.h:160
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:278
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.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
struct USet USet
Definition: ucnv.h:67
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:476
Mixed script confusable test.
Definition: uspoof.h:170
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.
void uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
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.
int32_t uspoof_checkUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &text, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
C++ API: Unicode Set.