1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
******************************************************************************
*
* 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"
#include "uresimp.h" /* for ures_getVersionByKey */
#include "cmemory.h"
/*
* Determines if icustd is in the data.
*/
static UBool hasICUSTDBundle();
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) {
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);
}
ures_close(icudatares);
}
}
U_CAPI UBool U_EXPORT2 u_isDataOlder(UVersionInfo dataVersionFillin, UBool *isModifiedFillin, UErrorCode *status) {
UBool result = TRUE;
UVersionInfo dataVersion;
UVersionInfo wiredVersion;
if (U_FAILURE(*status)) {
return result;
}
u_getDataVersion(dataVersion, status);
if (U_SUCCESS(*status)) {
u_versionFromString(wiredVersion, U_ICU_DATA_VERSION);
if (uprv_memcmp(dataVersion, wiredVersion, sizeof(UVersionInfo)) >= 0) {
result = FALSE;
}
if (dataVersionFillin != NULL) {
uprv_memcpy(dataVersionFillin, dataVersion, sizeof(UVersionInfo));
}
if (hasICUSTDBundle()) {
*isModifiedFillin = FALSE;
} else {
*isModifiedFillin = TRUE;
}
}
return result;
}
|