2009-08-13 17:21:33 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/icudataver.h"
|
|
|
|
#include "unicode/uversion.h"
|
|
|
|
#include "unicode/ures.h"
|
2009-09-14 16:48:42 +00:00
|
|
|
#include "uresimp.h" /* for ures_getVersionByKey */
|
2009-09-30 20:16:24 +00:00
|
|
|
#include "cmemory.h"
|
2009-08-13 17:21:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determines if icustd is in the data.
|
|
|
|
*/
|
2009-09-14 16:48:42 +00:00
|
|
|
static UBool hasICUSTDBundle();
|
2009-08-13 17:21:33 +00:00
|
|
|
|
2009-09-14 16:48:42 +00:00
|
|
|
static UBool hasICUSTDBundle() {
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
UBool result = TRUE;
|
|
|
|
|
|
|
|
UResourceBundle *icustdbundle = ures_openDirect(NULL, U_ICU_STD_BUNDLE, &status);
|
|
|
|
if (U_SUCCESS(status)) {
|
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ures_close(icustdbundle);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2 u_getDataVersion(UVersionInfo dataVersionFillin, UErrorCode *status) {
|
2009-08-13 17:21:33 +00:00
|
|
|
UResourceBundle *icudatares = NULL;
|
|
|
|
|
|
|
|
if (U_FAILURE(*status)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataVersionFillin != NULL) {
|
|
|
|
icudatares = ures_openDirect(NULL, U_ICU_VERSION_BUNDLE , status);
|
|
|
|
if (U_SUCCESS(*status)) {
|
|
|
|
ures_getVersionByKey(icudatares, U_ICU_DATA_KEY, dataVersionFillin, status);
|
|
|
|
}
|
2009-09-18 21:52:02 +00:00
|
|
|
ures_close(icudatares);
|
2009-08-13 17:21:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:48:42 +00:00
|
|
|
U_CAPI UBool U_EXPORT2 u_isDataOlder(UVersionInfo dataVersionFillin, UBool *isModifiedFillin, UErrorCode *status) {
|
2009-08-13 17:21:33 +00:00
|
|
|
UBool result = TRUE;
|
|
|
|
UVersionInfo dataVersion;
|
|
|
|
UVersionInfo wiredVersion;
|
|
|
|
|
|
|
|
if (U_FAILURE(*status)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-14 16:48:42 +00:00
|
|
|
u_getDataVersion(dataVersion, status);
|
2009-08-13 17:21:33 +00:00
|
|
|
if (U_SUCCESS(*status)) {
|
|
|
|
u_versionFromString(wiredVersion, U_ICU_DATA_VERSION);
|
|
|
|
|
2009-10-02 19:21:27 +00:00
|
|
|
if (uprv_memcmp(dataVersion, wiredVersion, sizeof(UVersionInfo)) >= 0) {
|
2009-08-13 17:21:33 +00:00
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataVersionFillin != NULL) {
|
2009-09-30 20:16:24 +00:00
|
|
|
uprv_memcpy(dataVersionFillin, dataVersion, sizeof(UVersionInfo));
|
2009-08-13 17:21:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hasICUSTDBundle()) {
|
|
|
|
*isModifiedFillin = FALSE;
|
|
|
|
} else {
|
|
|
|
*isModifiedFillin = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|