26 #ifndef _UTF8REWIND_INTERNAL_BASE_H_
27 #define _UTF8REWIND_INTERNAL_BASE_H_
38 #if defined(__GNUC__) && !defined(COMPILER_ICC)
39 #define UTF8_UNUSED(_parameter) _parameter __attribute__ ((unused))
41 #define UTF8_UNUSED(_parameter) _parameter
44 #define UTF8_RETURN(_error, _result) \
45 if (errors != 0) { *errors = UTF8_ERR_ ## _error; } \
51 #define UTF8_VALIDATE_PARAMETERS(_inputType, _targetType, _result) \
52 if (input == 0 || inputSize < sizeof(_inputType)) { UTF8_RETURN(INVALID_DATA, _result); } \
53 if (target != 0 && targetSize < sizeof(_targetType)) { UTF8_RETURN(NOT_ENOUGH_SPACE, _result); } \
54 if ((char*)input == (char*)target) { UTF8_RETURN(OVERLAPPING_PARAMETERS, _result); } \
56 char* input_center = (char*)input + (inputSize / 2); \
57 char* target_center = (char*)target + (targetSize / 2); \
58 size_t delta = (size_t)((input_center > target_center) ? (input_center - target_center) : (target_center - input_center)); \
59 if (delta < (inputSize + targetSize) / 2) { UTF8_RETURN(OVERLAPPING_PARAMETERS, _result); } \
Public interface for UTF-8 functions.