| 1 | /* | |
| 2 | * Copyright 1999-2006 University of Chicago | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | ||
| 18 | #include "globus_common.h" | |
| 19 | #include "version.h" | |
| 20 | #include "libxml/xmlschemastypes.h" | |
| 21 | #include "globus_xio.h" | |
| 22 | #include "globus_xio_buffer.h" | |
| 23 | #include "globus_i_soap_message.h" | |
| 24 | #include "globus_soap_message_utils.h" | |
| 25 | #include "globus_xsd_type_registry.h" | |
| 26 | ||
| 27 | globus_xsd_type_registry_t GLOBUS_XSD_BASE_REGISTRY = NULL; | |
| 28 | globus_xsd_type_registry_t GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; | |
| 29 | ||
| 30 | static int | |
| 31 | globus_l_soap_message_activate(); | |
| 32 | ||
| 33 | static int | |
| 34 | globus_l_soap_message_deactivate(); | |
| 35 | ||
| 36 | globus_module_descriptor_t | |
| 37 | globus_i_soap_message_module = | |
| 38 | { | |
| 39 | "globus_soap_message_module", | |
| 40 | globus_l_soap_message_activate, | |
| 41 | globus_l_soap_message_deactivate, | |
| 42 | NULL, | |
| 43 | NULL, | |
| 44 | &local_version | |
| 45 | }; | |
| 46 | ||
| 47 | 0 | GlobusDebugDefine(GLOBUS_SOAP_MESSAGE); |
| 48 | ||
| 49 | globus_xio_stack_t globus_i_soap_message_xio_stack; | |
| 50 | globus_xio_driver_t globus_i_soap_message_tcp_driver; | |
| 51 | globus_xio_driver_t globus_i_soap_message_http_driver; | |
| 52 | globus_xio_driver_t globus_i_soap_message_buffer_driver; | |
| 53 | ||
| 54 | globus_xio_stack_t globus_i_soap_message_xio_file_stack; | |
| 55 | globus_xio_driver_t globus_i_soap_message_file_driver; | |
| 56 | ||
| 57 | globus_xio_stack_t globus_i_soap_message_xio_https_stack; | |
| 58 | globus_xio_driver_t globus_i_soap_message_gsi_driver; | |
| 59 | ||
| 60 | ||
| 61 | static int | |
| 62 | globus_l_soap_message_activate() | |
| 63 | { | |
| 64 | 301 | globus_result_t result = GLOBUS_SUCCESS; |
| 65 | 301 | int rc = 0; |
| 66 | 301 | GlobusFuncName(globus_l_soap_message_activate); |
| 67 | ||
| 68 | 301 | globus_i_soap_message_xio_stack = NULL; |
| 69 | 301 | globus_i_soap_message_tcp_driver = NULL; |
| 70 | 301 | globus_i_soap_message_http_driver = NULL; |
| 71 | 301 | globus_i_soap_message_buffer_driver = NULL; |
| 72 | ||
| 73 | 301 | globus_i_soap_message_xio_file_stack = NULL; |
| 74 | 301 | globus_i_soap_message_file_driver = NULL; |
| 75 | ||
| 76 | 301 | globus_i_soap_message_xio_https_stack = NULL; |
| 77 | 301 | globus_i_soap_message_gsi_driver = NULL; |
| 78 | ||
| 79 | 301 | rc = globus_module_activate(GLOBUS_COMMON_MODULE); |
| 80 | 301 | if(rc != GLOBUS_SUCCESS) |
| 81 | { | |
| 82 | 0 | return rc; |
| 83 | } | |
| 84 | ||
| 85 | 301 | GlobusDebugInit(GLOBUS_SOAP_MESSAGE, |
| 86 | MESSAGES INFO DEBUG TRACE WARN REGISTRY WILDCARDS); | |
| 87 | 301 | GlobusSoapMessageDebugEnter(); |
| 88 | ||
| 89 | 301 | rc = globus_module_activate(GLOBUS_XIO_MODULE); |
| 90 | 301 | if(rc != GLOBUS_SUCCESS) |
| 91 | { | |
| 92 | 0 | return rc; |
| 93 | } | |
| 94 | ||
| 95 | 301 | result = globus_xio_stack_init( |
| 96 | &globus_i_soap_message_xio_stack, NULL); | |
| 97 | 301 | if(result != GLOBUS_SUCCESS) |
| 98 | { | |
| 99 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 100 | result, "Failed xio stack initialization"); | |
| 101 | 0 | goto error; |
| 102 | } | |
| 103 | ||
| 104 | 301 | result = globus_xio_driver_load( |
| 105 | "tcp", &globus_i_soap_message_tcp_driver); | |
| 106 | 301 | if(result != GLOBUS_SUCCESS) |
| 107 | { | |
| 108 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 109 | result, "Failed to load tcp driver"); | |
| 110 | 0 | goto error; |
| 111 | } | |
| 112 | ||
| 113 | 301 | result = globus_xio_stack_push_driver( |
| 114 | globus_i_soap_message_xio_stack, globus_i_soap_message_tcp_driver); | |
| 115 | 301 | if(result != GLOBUS_SUCCESS) |
| 116 | { | |
| 117 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 118 | result, "Failed to push tcp driver onto stack"); | |
| 119 | 0 | goto error; |
| 120 | } | |
| 121 | ||
| 122 | 301 | result = globus_xio_driver_load( |
| 123 | "http", &globus_i_soap_message_http_driver); | |
| 124 | 301 | if(result != GLOBUS_SUCCESS) |
| 125 | { | |
| 126 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 127 | result, "Failed to load http driver"); | |
| 128 | 0 | goto error; |
| 129 | } | |
| 130 | ||
| 131 | 301 | result = globus_xio_driver_load( |
| 132 | "buffer", &globus_i_soap_message_buffer_driver); | |
| 133 | 301 | if(result != GLOBUS_SUCCESS) |
| 134 | { | |
| 135 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 136 | result, "Failed to load buffer driver"); | |
| 137 | 0 | goto error; |
| 138 | } | |
| 139 | ||
| 140 | 301 | result = globus_xio_stack_push_driver( |
| 141 | globus_i_soap_message_xio_stack, globus_i_soap_message_http_driver); | |
| 142 | 301 | if(result != GLOBUS_SUCCESS) |
| 143 | { | |
| 144 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 145 | result, "Failed to push http driver"); | |
| 146 | 0 | goto error; |
| 147 | } | |
| 148 | ||
| 149 | 301 | result = globus_xio_stack_push_driver( |
| 150 | globus_i_soap_message_xio_stack, globus_i_soap_message_buffer_driver); | |
| 151 | 301 | if(result != GLOBUS_SUCCESS) |
| 152 | { | |
| 153 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 154 | result, "Failed to push buffer driver"); | |
| 155 | 0 | goto error; |
| 156 | } | |
| 157 | ||
| 158 | 301 | result = globus_xio_stack_init( |
| 159 | &globus_i_soap_message_xio_file_stack, NULL); | |
| 160 | 301 | if(result != GLOBUS_SUCCESS) |
| 161 | { | |
| 162 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 163 | result, "Failed xio stack initialization"); | |
| 164 | 0 | goto error; |
| 165 | } | |
| 166 | ||
| 167 | 301 | result = globus_xio_driver_load( |
| 168 | "file", &globus_i_soap_message_file_driver); | |
| 169 | 301 | if(result != GLOBUS_SUCCESS) |
| 170 | { | |
| 171 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 172 | result, "Failed to load file driver"); | |
| 173 | 0 | goto error; |
| 174 | } | |
| 175 | ||
| 176 | 301 | result = globus_xio_stack_push_driver( |
| 177 | globus_i_soap_message_xio_file_stack, | |
| 178 | globus_i_soap_message_file_driver); | |
| 179 | 301 | if(result != GLOBUS_SUCCESS) |
| 180 | { | |
| 181 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 182 | result, "Failed to push file driver onto stack"); | |
| 183 | 0 | goto error; |
| 184 | } | |
| 185 | ||
| 186 | 301 | result = globus_xio_stack_init( |
| 187 | &globus_i_soap_message_xio_https_stack, NULL); | |
| 188 | 301 | if(result != GLOBUS_SUCCESS) |
| 189 | { | |
| 190 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 191 | result, "Failed xio stack initialization"); | |
| 192 | 0 | goto error; |
| 193 | } | |
| 194 | ||
| 195 | 301 | result = globus_xio_driver_load( |
| 196 | "gsi", &globus_i_soap_message_gsi_driver); | |
| 197 | 301 | if(result != GLOBUS_SUCCESS) |
| 198 | { | |
| 199 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 200 | result, "Failed to load gsi driver"); | |
| 201 | 0 | goto error; |
| 202 | } | |
| 203 | ||
| 204 | 301 | result = globus_xio_stack_push_driver( |
| 205 | globus_i_soap_message_xio_https_stack, | |
| 206 | globus_i_soap_message_tcp_driver); | |
| 207 | 301 | if(result != GLOBUS_SUCCESS) |
| 208 | { | |
| 209 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 210 | result, "Failed to push gsi driver onto stack"); | |
| 211 | 0 | goto error; |
| 212 | } | |
| 213 | ||
| 214 | 301 | result = globus_xio_stack_push_driver( |
| 215 | globus_i_soap_message_xio_https_stack, | |
| 216 | globus_i_soap_message_gsi_driver); | |
| 217 | 301 | if(result != GLOBUS_SUCCESS) |
| 218 | { | |
| 219 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 220 | result, "Failed to push gsi driver onto stack"); | |
| 221 | 0 | goto error; |
| 222 | } | |
| 223 | ||
| 224 | 301 | result = globus_xio_stack_push_driver( |
| 225 | globus_i_soap_message_xio_https_stack, | |
| 226 | globus_i_soap_message_http_driver); | |
| 227 | 301 | if(result != GLOBUS_SUCCESS) |
| 228 | { | |
| 229 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 230 | result, "Failed to push gsi driver onto stack"); | |
| 231 | 0 | goto error; |
| 232 | } | |
| 233 | ||
| 234 | 301 | result = globus_xio_stack_push_driver( |
| 235 | globus_i_soap_message_xio_https_stack, | |
| 236 | globus_i_soap_message_buffer_driver); | |
| 237 | 301 | if(result != GLOBUS_SUCCESS) |
| 238 | { | |
| 239 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 240 | result, "Failed to push gsi driver onto stack"); | |
| 241 | 0 | goto error; |
| 242 | } | |
| 243 | ||
| 244 | 301 | xmlSchemaInitTypes(); |
| 245 | ||
| 246 | 301 | GLOBUS_XSD_BASE_REGISTRY = NULL; |
| 247 | 301 | globus_xsd_type_registry_init(&GLOBUS_XSD_BASE_REGISTRY); |
| 248 | 301 | globus_xsd_type_registry_add_base_types(GLOBUS_XSD_BASE_REGISTRY); |
| 249 | ||
| 250 | 301 | GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; |
| 251 | 301 | globus_xsd_type_registry_init(&GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 252 | 301 | globus_xsd_type_registry_add_base_types(GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 253 | ||
| 254 | 301 | goto exit; |
| 255 | ||
| 256 | error: | |
| 257 | ||
| 258 | 0 | if(globus_i_soap_message_xio_stack) |
| 259 | { | |
| 260 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_stack); |
| 261 | } | |
| 262 | ||
| 263 | 0 | if(globus_i_soap_message_buffer_driver) |
| 264 | { | |
| 265 | 0 | globus_xio_driver_unload(globus_i_soap_message_buffer_driver); |
| 266 | } | |
| 267 | ||
| 268 | 0 | if(globus_i_soap_message_http_driver) |
| 269 | { | |
| 270 | 0 | globus_xio_driver_unload(globus_i_soap_message_http_driver); |
| 271 | } | |
| 272 | ||
| 273 | 0 | if(globus_i_soap_message_tcp_driver) |
| 274 | { | |
| 275 | 0 | globus_xio_driver_unload(globus_i_soap_message_tcp_driver); |
| 276 | } | |
| 277 | ||
| 278 | 0 | if(globus_i_soap_message_file_driver) |
| 279 | { | |
| 280 | 0 | globus_xio_driver_unload(globus_i_soap_message_file_driver); |
| 281 | } | |
| 282 | ||
| 283 | 0 | if(globus_i_soap_message_xio_file_stack) |
| 284 | { | |
| 285 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_file_stack); |
| 286 | } | |
| 287 | ||
| 288 | 0 | if(globus_i_soap_message_gsi_driver) |
| 289 | { | |
| 290 | 0 | globus_xio_driver_unload(globus_i_soap_message_gsi_driver); |
| 291 | } | |
| 292 | ||
| 293 | 0 | if(globus_i_soap_message_xio_https_stack) |
| 294 | { | |
| 295 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_https_stack); |
| 296 | } | |
| 297 | ||
| 298 | exit: | |
| 299 | ||
| 300 | 301 | GlobusSoapMessageDebugExit(); |
| 301 | 301 | return (int) result; |
| 302 | } | |
| 303 | ||
| 304 | static int | |
| 305 | globus_l_soap_message_deactivate() | |
| 306 | 228 | { |
| 307 | 228 | int rc = 0; |
| 308 | 228 | GlobusFuncName(globus_l_soap_message_deactivate); |
| 309 | 228 | GlobusSoapMessageDebugEnter(); |
| 310 | ||
| 311 | 228 | if(GLOBUS_XSD_BASE_REGISTRY) |
| 312 | { | |
| 313 | 228 | globus_xsd_type_registry_destroy(GLOBUS_XSD_BASE_REGISTRY); |
| 314 | 228 | GLOBUS_XSD_BASE_REGISTRY = NULL; |
| 315 | } | |
| 316 | ||
| 317 | 228 | if(GLOBUS_GLOBAL_TYPE_REGISTRY) |
| 318 | { | |
| 319 | 228 | globus_xsd_type_registry_destroy(GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 320 | 228 | GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; |
| 321 | } | |
| 322 | ||
| 323 | 228 | xmlSchemaCleanupTypes(); |
| 324 | ||
| 325 | 228 | if(globus_i_soap_message_file_driver) |
| 326 | { | |
| 327 | 228 | globus_xio_driver_unload(globus_i_soap_message_file_driver); |
| 328 | } | |
| 329 | ||
| 330 | 228 | if(globus_i_soap_message_xio_https_stack) |
| 331 | { | |
| 332 | 228 | globus_xio_stack_destroy(globus_i_soap_message_xio_https_stack); |
| 333 | } | |
| 334 | ||
| 335 | 228 | if(globus_i_soap_message_xio_file_stack) |
| 336 | { | |
| 337 | 228 | globus_xio_stack_destroy(globus_i_soap_message_xio_file_stack); |
| 338 | } | |
| 339 | ||
| 340 | 228 | if(globus_i_soap_message_xio_stack) |
| 341 | { | |
| 342 | 228 | globus_xio_stack_destroy(globus_i_soap_message_xio_stack); |
| 343 | } | |
| 344 | ||
| 345 | 228 | if(globus_i_soap_message_buffer_driver) |
| 346 | { | |
| 347 | 228 | globus_xio_driver_unload(globus_i_soap_message_buffer_driver); |
| 348 | } | |
| 349 | ||
| 350 | 228 | if(globus_i_soap_message_http_driver) |
| 351 | { | |
| 352 | 228 | globus_xio_driver_unload(globus_i_soap_message_http_driver); |
| 353 | } | |
| 354 | ||
| 355 | 228 | if(globus_i_soap_message_tcp_driver) |
| 356 | { | |
| 357 | 228 | globus_xio_driver_unload(globus_i_soap_message_tcp_driver); |
| 358 | } | |
| 359 | ||
| 360 | 228 | if(globus_i_soap_message_gsi_driver) |
| 361 | { | |
| 362 | 228 | globus_xio_driver_unload(globus_i_soap_message_gsi_driver); |
| 363 | } | |
| 364 | ||
| 365 | 228 | rc = globus_module_deactivate(GLOBUS_XIO_MODULE); |
| 366 | 228 | if(rc != GLOBUS_SUCCESS) |
| 367 | { | |
| 368 | 0 | return rc; |
| 369 | } | |
| 370 | ||
| 371 | 228 | rc = globus_module_deactivate(GLOBUS_COMMON_MODULE); |
| 372 | 228 | if(rc != GLOBUS_SUCCESS) |
| 373 | { | |
| 374 | 0 | return rc; |
| 375 | } | |
| 376 | ||
| 377 | 228 | return GLOBUS_SUCCESS; |