intl/icu/source/common/ucln_imp.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 ******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2009-2011, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 ******************************************************************************
michael@0 8 * file name: ucln_imp.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * This file contains the platform specific implementation of per-library cleanup.
michael@0 14 *
michael@0 15 */
michael@0 16
michael@0 17
michael@0 18 #ifndef __UCLN_IMP_H__
michael@0 19 #define __UCLN_IMP_H__
michael@0 20
michael@0 21 #include "ucln.h"
michael@0 22 #include <stdlib.h>
michael@0 23
michael@0 24 /**
michael@0 25 * Auto cleanup of ICU libraries
michael@0 26 * There are several methods in per library cleanup of icu libraries:
michael@0 27 * 1) Compiler/Platform based cleanup:
michael@0 28 * a) Windows MSVC uses DllMain()
michael@0 29 * b) GCC uses destructor function attribute
michael@0 30 * c) Sun Studio, AIX VA, and HP-UX aCC uses a linker option to set the exit function
michael@0 31 * 2) Using atexit()
michael@0 32 * 3) Implementing own automatic cleanup functions
michael@0 33 *
michael@0 34 * For option 1, ensure that UCLN_NO_AUTO_CLEANUP is set to 0 by using --enable-auto-cleanup
michael@0 35 * configure option or by otherwise setting UCLN_NO_AUTO_CLEANUP to 0
michael@0 36 * For option 2, follow option 1 and also define UCLN_AUTO_ATEXIT
michael@0 37 * For option 3, follow option 1 and also define UCLN_AUTO_LOCAL (see below for more information)
michael@0 38 */
michael@0 39
michael@0 40 #if !UCLN_NO_AUTO_CLEANUP
michael@0 41
michael@0 42 /*
michael@0 43 * The following declarations are for when UCLN_AUTO_LOCAL or UCLN_AUTO_ATEXIT
michael@0 44 * are defined. They are commented out because they are static and will be defined
michael@0 45 * later. The information is still here to provide some guidance for the developer
michael@0 46 * who chooses to use UCLN_AUTO_LOCAL.
michael@0 47 */
michael@0 48 /**
michael@0 49 * Give the library an opportunity to register an automatic cleanup.
michael@0 50 * This may be called more than once.
michael@0 51 */
michael@0 52 /*static void ucln_registerAutomaticCleanup();*/
michael@0 53 /**
michael@0 54 * Unregister an automatic cleanup, if possible. Called from cleanup.
michael@0 55 */
michael@0 56 /*static void ucln_unRegisterAutomaticCleanup();*/
michael@0 57
michael@0 58 #ifdef UCLN_TYPE_IS_COMMON
michael@0 59 # define UCLN_CLEAN_ME_UP u_cleanup()
michael@0 60 #else
michael@0 61 # define UCLN_CLEAN_ME_UP ucln_cleanupOne(UCLN_TYPE)
michael@0 62 #endif
michael@0 63
michael@0 64 /* ------------ automatic cleanup: registration. Choose ONE ------- */
michael@0 65 #if defined(UCLN_AUTO_LOCAL)
michael@0 66 /* To use:
michael@0 67 * 1. define UCLN_AUTO_LOCAL,
michael@0 68 * 2. create ucln_local_hook.c containing implementations of
michael@0 69 * static void ucln_registerAutomaticCleanup()
michael@0 70 * static void ucln_unRegisterAutomaticCleanup()
michael@0 71 */
michael@0 72 #include "ucln_local_hook.c"
michael@0 73
michael@0 74 #elif defined(UCLN_AUTO_ATEXIT)
michael@0 75 /*
michael@0 76 * Use the ANSI C 'atexit' function. Note that this mechanism does not
michael@0 77 * guarantee the order of cleanup relative to other users of ICU!
michael@0 78 */
michael@0 79 static UBool gAutoCleanRegistered = FALSE;
michael@0 80
michael@0 81 static void ucln_atexit_handler()
michael@0 82 {
michael@0 83 UCLN_CLEAN_ME_UP;
michael@0 84 }
michael@0 85
michael@0 86 static void ucln_registerAutomaticCleanup()
michael@0 87 {
michael@0 88 if(!gAutoCleanRegistered) {
michael@0 89 gAutoCleanRegistered = TRUE;
michael@0 90 atexit(&ucln_atexit_handler);
michael@0 91 }
michael@0 92 }
michael@0 93
michael@0 94 static void ucln_unRegisterAutomaticCleanup () {
michael@0 95 }
michael@0 96 /* ------------end of automatic cleanup: registration. ------- */
michael@0 97
michael@0 98 #elif defined (UCLN_FINI)
michael@0 99 /**
michael@0 100 * If UCLN_FINI is defined, it is the (versioned, etc) name of a cleanup
michael@0 101 * entrypoint. Add a stub to call ucln_cleanupOne
michael@0 102 * Used on AIX, Solaris, and HP-UX
michael@0 103 */
michael@0 104 U_CAPI void U_EXPORT2 UCLN_FINI (void);
michael@0 105
michael@0 106 U_CAPI void U_EXPORT2 UCLN_FINI ()
michael@0 107 {
michael@0 108 /* This function must be defined, if UCLN_FINI is defined, else link error. */
michael@0 109 UCLN_CLEAN_ME_UP;
michael@0 110 }
michael@0 111
michael@0 112 /* Windows: DllMain */
michael@0 113 #elif U_PLATFORM_HAS_WIN32_API
michael@0 114 /*
michael@0 115 * ICU's own DllMain.
michael@0 116 */
michael@0 117
michael@0 118 /* these are from putil.c */
michael@0 119 /* READ READ READ READ! Are you getting compilation errors from windows.h?
michael@0 120 Any source file which includes this (ucln_imp.h) header MUST
michael@0 121 be defined with language extensions ON. */
michael@0 122 # define WIN32_LEAN_AND_MEAN
michael@0 123 # define VC_EXTRALEAN
michael@0 124 # define NOUSER
michael@0 125 # define NOSERVICE
michael@0 126 # define NOIME
michael@0 127 # define NOMCX
michael@0 128 # include <windows.h>
michael@0 129 /*
michael@0 130 * This is a stub DllMain function with icu specific process handling code.
michael@0 131 */
michael@0 132 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
michael@0 133 {
michael@0 134 BOOL status = TRUE;
michael@0 135
michael@0 136 switch(fdwReason) {
michael@0 137 case DLL_PROCESS_ATTACH:
michael@0 138 /* ICU does not trap process attach, but must pass these through properly. */
michael@0 139 /* ICU specific process attach could go here */
michael@0 140 break;
michael@0 141
michael@0 142 case DLL_PROCESS_DETACH:
michael@0 143 /* Here is the one we actually care about. */
michael@0 144
michael@0 145 UCLN_CLEAN_ME_UP;
michael@0 146
michael@0 147 break;
michael@0 148
michael@0 149 case DLL_THREAD_ATTACH:
michael@0 150 /* ICU does not trap thread attach, but must pass these through properly. */
michael@0 151 /* ICU specific thread attach could go here */
michael@0 152 break;
michael@0 153
michael@0 154 case DLL_THREAD_DETACH:
michael@0 155 /* ICU does not trap thread detach, but must pass these through properly. */
michael@0 156 /* ICU specific thread detach could go here */
michael@0 157 break;
michael@0 158
michael@0 159 }
michael@0 160 return status;
michael@0 161 }
michael@0 162
michael@0 163 #elif defined(__GNUC__)
michael@0 164 /* GCC - use __attribute((destructor)) */
michael@0 165 static void ucln_destructor() __attribute__((destructor)) ;
michael@0 166
michael@0 167 static void ucln_destructor()
michael@0 168 {
michael@0 169 UCLN_CLEAN_ME_UP;
michael@0 170 }
michael@0 171
michael@0 172 #endif
michael@0 173
michael@0 174 #endif /* UCLN_NO_AUTO_CLEANUP */
michael@0 175
michael@0 176 #else
michael@0 177 #error This file can only be included once.
michael@0 178 #endif

mercurial