2001-08-11 00:29:58 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* *
|
2003-05-06 01:37:52 +00:00
|
|
|
* Copyright (C) 2001-2003, International Business Machines *
|
2001-08-11 00:29:58 +00:00
|
|
|
* Corporation and others. All Rights Reserved. *
|
|
|
|
* *
|
|
|
|
******************************************************************************
|
|
|
|
* file name: ucln_cmn.c
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2001July05
|
|
|
|
* created by: George Rhoten
|
|
|
|
*/
|
|
|
|
|
2003-05-06 01:37:52 +00:00
|
|
|
#include "unicode/utypes.h"
|
2001-08-11 00:29:58 +00:00
|
|
|
#include "unicode/uclean.h"
|
2003-05-06 01:37:52 +00:00
|
|
|
#include "ustr_imp.h"
|
2003-05-02 21:33:17 +00:00
|
|
|
#include "unormimp.h"
|
2001-08-11 00:29:58 +00:00
|
|
|
#include "ucln_cmn.h"
|
|
|
|
#include "umutex.h"
|
2001-08-30 02:59:19 +00:00
|
|
|
#include "ucln.h"
|
|
|
|
|
|
|
|
static cleanupFunc *gCleanupFunctions[UCLN_COMMON] = {
|
2003-06-06 22:50:26 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2001-08-30 02:59:19 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
ucln_registerCleanup(ECleanupLibraryType type,
|
|
|
|
cleanupFunc *func)
|
|
|
|
{
|
|
|
|
if (UCLN_START < type && type < UCLN_COMMON)
|
|
|
|
{
|
|
|
|
gCleanupFunctions[type] = func;
|
|
|
|
}
|
|
|
|
}
|
2001-08-11 00:29:58 +00:00
|
|
|
|
2003-03-20 00:08:40 +00:00
|
|
|
/************************************************
|
|
|
|
The cleanup order is important in this function.
|
|
|
|
Please be sure that you have read ucln.h
|
|
|
|
************************************************/
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
u_cleanup(void)
|
2001-08-11 00:29:58 +00:00
|
|
|
{
|
2001-10-08 23:26:58 +00:00
|
|
|
|
2001-08-30 02:59:19 +00:00
|
|
|
ECleanupLibraryType libType = UCLN_START;
|
|
|
|
while (++libType < UCLN_COMMON)
|
|
|
|
{
|
|
|
|
if (gCleanupFunctions[libType])
|
|
|
|
{
|
|
|
|
gCleanupFunctions[libType]();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2003-05-06 01:37:52 +00:00
|
|
|
#if !UCONFIG_NO_IDNA
|
2003-07-24 23:23:19 +00:00
|
|
|
usprep_cleanup();
|
2003-05-06 01:37:52 +00:00
|
|
|
#endif
|
2002-12-05 19:28:09 +00:00
|
|
|
#if !UCONFIG_NO_BREAK_ITERATION
|
2002-11-08 18:07:48 +00:00
|
|
|
breakiterator_cleanup();
|
2002-12-05 19:28:09 +00:00
|
|
|
#endif
|
2002-12-06 00:22:10 +00:00
|
|
|
#if !UCONFIG_NO_SERVICE
|
|
|
|
service_cleanup();
|
|
|
|
#endif
|
2003-03-20 00:08:40 +00:00
|
|
|
ures_cleanup();
|
|
|
|
locale_cleanup();
|
|
|
|
uloc_cleanup();
|
2003-05-06 01:37:52 +00:00
|
|
|
#if !UCONFIG_NO_NORMALIZATION
|
2003-03-20 00:08:40 +00:00
|
|
|
unorm_cleanup();
|
2003-05-06 01:37:52 +00:00
|
|
|
#endif
|
2003-03-20 00:08:40 +00:00
|
|
|
uset_cleanup();
|
|
|
|
unames_cleanup();
|
|
|
|
pname_cleanup();
|
|
|
|
uchar_cleanup();
|
2001-08-25 01:13:21 +00:00
|
|
|
ucnv_cleanup();
|
|
|
|
ucnv_io_cleanup();
|
2001-08-17 00:18:49 +00:00
|
|
|
udata_cleanup();
|
2001-08-31 02:14:47 +00:00
|
|
|
putil_cleanup();
|
2001-10-04 20:58:06 +00:00
|
|
|
/*
|
|
|
|
* WARNING! Destroying the global mutex can cause synchronization
|
|
|
|
* problems. ICU must be reinitialized from a single thread
|
|
|
|
* before the library is used again. You never want two
|
|
|
|
* threads trying to initialize the global mutex at the same
|
|
|
|
* time. The global mutex is being destroyed so that heap and
|
|
|
|
* resource checkers don't complain. [grhoten]
|
|
|
|
*/
|
|
|
|
umtx_destroy(NULL);
|
2001-08-17 00:18:49 +00:00
|
|
|
}
|
|
|
|
|
2003-04-30 00:09:18 +00:00
|
|
|
|
2003-05-02 21:33:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* ICU Initialization Function. Force loading and/or initialization of
|
|
|
|
* any shared data that could potentially be used concurrently
|
2003-05-07 00:02:29 +00:00
|
|
|
* by multiple threads.
|
2003-05-02 21:33:17 +00:00
|
|
|
*/
|
2003-04-30 00:09:18 +00:00
|
|
|
|
|
|
|
U_CAPI void U_EXPORT2
|
|
|
|
u_init(UErrorCode *status) {
|
2003-06-12 22:48:09 +00:00
|
|
|
/* Make sure the global mutexes are initialized. */
|
|
|
|
/*
|
|
|
|
* NOTE: This section of code replicates functionality from GlobalMutexInitialize()
|
|
|
|
* in the file mutex.cpp. Any changes must be made in both places.
|
|
|
|
* TODO: combine them.
|
|
|
|
*/
|
2003-06-06 22:50:26 +00:00
|
|
|
umtx_init(NULL);
|
|
|
|
ucnv_init(status);
|
|
|
|
ures_init(status);
|
2003-05-07 00:02:29 +00:00
|
|
|
|
|
|
|
/* Do any required init for services that don't have open operations
|
|
|
|
* and use "only" the double-check initialization method for performance
|
|
|
|
* reasons (avoiding a mutex lock even for _checking_ whether the
|
|
|
|
* initialization had occurred).
|
2003-04-30 00:09:18 +00:00
|
|
|
*/
|
2003-05-02 21:33:17 +00:00
|
|
|
|
2003-04-30 00:09:18 +00:00
|
|
|
/* Char Properties */
|
2003-05-02 21:33:17 +00:00
|
|
|
uprv_haveProperties(status);
|
2003-04-30 00:09:18 +00:00
|
|
|
|
2003-05-06 01:37:52 +00:00
|
|
|
#if !UCONFIG_NO_NORMALIZATION
|
2003-05-02 21:33:17 +00:00
|
|
|
/* Normalization */
|
|
|
|
unorm_haveData(status);
|
2003-05-06 01:37:52 +00:00
|
|
|
#endif
|
2003-04-30 00:09:18 +00:00
|
|
|
}
|