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