ICU 4.8.1.1  4.8.1.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-2010, 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 
33 #endif
34 
35 
146 struct USpoofChecker;
147 typedef struct USpoofChecker USpoofChecker;
156 typedef enum USpoofChecks {
163 
173 
184 
192 
198 
206 
212 
213  USPOOF_ALL_CHECKS = 0x7f
214  } USpoofChecks;
215 
216 
228 uspoof_open(UErrorCode *status);
229 
230 
253 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
254  UErrorCode *pErrorCode);
255 
288 uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
289  const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
290  int32_t *errType, UParseError *pe, UErrorCode *status);
291 
292 
298 U_STABLE void U_EXPORT2
300 
301 #if U_SHOW_CPLUSPLUS_API
302 
304 
314 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close);
315 
317 
318 #endif
319 
330 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
331 
332 
345 U_STABLE void U_EXPORT2
346 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
347 
359 U_STABLE int32_t U_EXPORT2
360 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
361 
404 U_STABLE void U_EXPORT2
405 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
406 
428 U_STABLE const char * U_EXPORT2
430 
431 
450 U_STABLE void U_EXPORT2
451 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
452 
453 
474 U_STABLE const USet * U_EXPORT2
476 
477 
478 #if U_SHOW_CPLUSPLUS_API
479 
497 U_STABLE void U_EXPORT2
498 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const UnicodeSet *chars, UErrorCode *status);
499 
500 
522 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
523 #endif
524 
525 
554 U_STABLE int32_t U_EXPORT2
555 uspoof_check(const USpoofChecker *sc,
556  const UChar *text, int32_t length,
557  int32_t *position,
558  UErrorCode *status);
559 
560 
589 U_STABLE int32_t U_EXPORT2
591  const char *text, int32_t length,
592  int32_t *position,
593  UErrorCode *status);
594 
595 
596 #if U_SHOW_CPLUSPLUS_API
597 
622 U_STABLE int32_t U_EXPORT2
623 uspoof_checkUnicodeString(const USpoofChecker *sc,
625  int32_t *position,
626  UErrorCode *status);
627 
628 #endif
629 
630 
670 U_STABLE int32_t U_EXPORT2
672  const UChar *s1, int32_t length1,
673  const UChar *s2, int32_t length2,
674  UErrorCode *status);
675 
676 
677 
703 U_STABLE int32_t U_EXPORT2
705  const char *s1, int32_t length1,
706  const char *s2, int32_t length2,
707  UErrorCode *status);
708 
709 
710 
711 
712 #if U_SHOW_CPLUSPLUS_API
713 
734 U_STABLE int32_t U_EXPORT2
735 uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
738  UErrorCode *status);
739 #endif
740 
741 
774 U_STABLE int32_t U_EXPORT2
776  uint32_t type,
777  const UChar *s, int32_t length,
778  UChar *dest, int32_t destCapacity,
779  UErrorCode *status);
780 
816 U_STABLE int32_t U_EXPORT2
818  uint32_t type,
819  const char *s, int32_t length,
820  char *dest, int32_t destCapacity,
821  UErrorCode *status);
822 
823 #if U_SHOW_CPLUSPLUS_API
824 
853 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
854  uint32_t type,
855  const UnicodeString &s,
856  UnicodeString &dest,
857  UErrorCode *status);
858 #endif /* U_SHOW_CPLUSPLUS_API */
859 
860 
879 U_STABLE int32_t U_EXPORT2
881  void *data, int32_t capacity,
882  UErrorCode *status);
883 
884 
885 #endif
886 
887 #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:205
Check that an identifier contains only characters from a single script (plus chars from the common an...
Definition: uspoof.h:197
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:211
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition: uspoof.h:156
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.
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.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
Any Case Modifier for confusable identifier tests.
Definition: uspoof.h:191
#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:134
Whole script confusable test.
Definition: uspoof.h:183
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#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:133
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.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition: uspoof.h:147
#define U_EXPORT2
Definition: platform.h:314
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.
Single script confusable test.
Definition: uspoof.h:162
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
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:132
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:639
Mixed script confusable test.
Definition: uspoof.h:172
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_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:137
C++ API: Unicode Set.