2006-08-12 09:47:38 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
* *
|
2014-01-10 02:24:54 +00:00
|
|
|
* Copyright (C) 2001-2014, International Business Machines *
|
2006-08-12 09:47:38 +00:00
|
|
|
* Corporation and others. All Rights Reserved. *
|
|
|
|
* *
|
|
|
|
******************************************************************************
|
2014-04-23 23:22:13 +00:00
|
|
|
* file name: ucln_io.cpp
|
2006-08-12 09:47:38 +00:00
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2006August11
|
|
|
|
* created by: George Rhoten
|
|
|
|
*/
|
|
|
|
|
2014-04-25 17:27:53 +00:00
|
|
|
#include "mutex.h"
|
2006-08-12 09:47:38 +00:00
|
|
|
#include "ucln.h"
|
|
|
|
#include "ucln_io.h"
|
|
|
|
#include "uassert.h"
|
|
|
|
|
2011-10-26 23:02:14 +00:00
|
|
|
#ifndef U_IO_IMPLEMENTATION
|
|
|
|
#error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/ - see http://userguide.icu-project.org/howtouseicu
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-09-03 20:40:02 +00:00
|
|
|
/** Auto-client */
|
|
|
|
#define UCLN_TYPE UCLN_IO
|
|
|
|
#include "ucln_imp.h"
|
|
|
|
|
2006-08-12 09:47:38 +00:00
|
|
|
/* Leave this copyright notice here! It needs to go somewhere in this library. */
|
|
|
|
static const char copyright[] = U_COPYRIGHT_STRING;
|
|
|
|
|
|
|
|
static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT];
|
|
|
|
|
|
|
|
static UBool io_cleanup(void)
|
|
|
|
{
|
2014-04-23 23:22:13 +00:00
|
|
|
int32_t libType = UCLN_IO_START;
|
2006-08-12 09:47:38 +00:00
|
|
|
|
2014-01-10 02:24:54 +00:00
|
|
|
(void)copyright; // Suppress unused variable warning.
|
2006-08-24 18:51:49 +00:00
|
|
|
while (++libType<UCLN_IO_COUNT) {
|
2006-08-12 09:47:38 +00:00
|
|
|
if (gCleanupFunctions[libType])
|
|
|
|
{
|
|
|
|
gCleanupFunctions[libType]();
|
|
|
|
gCleanupFunctions[libType] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-09-03 20:40:02 +00:00
|
|
|
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
|
|
|
|
ucln_unRegisterAutomaticCleanup();
|
|
|
|
#endif
|
2006-08-12 09:47:38 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ucln_io_registerCleanup(ECleanupIOType type,
|
2014-04-25 17:27:53 +00:00
|
|
|
cleanupFunc *func) {
|
2006-08-12 09:47:38 +00:00
|
|
|
U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT);
|
|
|
|
{
|
2014-04-25 17:27:53 +00:00
|
|
|
icu::Mutex m; // See ticket 10295 for discussion.
|
|
|
|
ucln_registerCleanup(UCLN_IO, io_cleanup);
|
|
|
|
if (UCLN_IO_START < type && type < UCLN_IO_COUNT) {
|
|
|
|
gCleanupFunctions[type] = func;
|
|
|
|
}
|
2006-08-12 09:47:38 +00:00
|
|
|
}
|
2009-09-03 20:40:02 +00:00
|
|
|
|
|
|
|
#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
|
|
|
|
ucln_registerAutomaticCleanup();
|
|
|
|
#endif
|
2006-08-12 09:47:38 +00:00
|
|
|
}
|
|
|
|
|