OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ****************************************************************************** |
| 3 * * |
| 4 * Copyright (C) 2001-2009, International Business Machines * |
| 5 * Corporation and others. All Rights Reserved. * |
| 6 * * |
| 7 ****************************************************************************** |
| 8 * file name: ucln_io.c |
| 9 * encoding: US-ASCII |
| 10 * tab size: 8 (not used) |
| 11 * indentation:4 |
| 12 * |
| 13 * created on: 2006August11 |
| 14 * created by: George Rhoten |
| 15 */ |
| 16 |
| 17 #include "ucln.h" |
| 18 #include "ucln_io.h" |
| 19 #include "umutex.h" |
| 20 #include "uassert.h" |
| 21 |
| 22 /** Auto-client */ |
| 23 #define UCLN_TYPE UCLN_IO |
| 24 #include "ucln_imp.h" |
| 25 |
| 26 /* Leave this copyright notice here! It needs to go somewhere in this library. *
/ |
| 27 static const char copyright[] = U_COPYRIGHT_STRING; |
| 28 |
| 29 static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT]; |
| 30 |
| 31 static UBool io_cleanup(void) |
| 32 { |
| 33 ECleanupIOType libType = UCLN_IO_START; |
| 34 |
| 35 while (++libType<UCLN_IO_COUNT) { |
| 36 if (gCleanupFunctions[libType]) |
| 37 { |
| 38 gCleanupFunctions[libType](); |
| 39 gCleanupFunctions[libType] = NULL; |
| 40 } |
| 41 } |
| 42 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) |
| 43 ucln_unRegisterAutomaticCleanup(); |
| 44 #endif |
| 45 return TRUE; |
| 46 } |
| 47 |
| 48 void ucln_io_registerCleanup(ECleanupIOType type, |
| 49 cleanupFunc *func) |
| 50 { |
| 51 U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT); |
| 52 ucln_registerCleanup(UCLN_IO, io_cleanup); |
| 53 if (UCLN_IO_START < type && type < UCLN_IO_COUNT) |
| 54 { |
| 55 gCleanupFunctions[type] = func; |
| 56 } |
| 57 |
| 58 #if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOC
AL)) |
| 59 ucln_registerAutomaticCleanup(); |
| 60 #endif |
| 61 } |
| 62 |
OLD | NEW |