| 1 | /* | |
| 2 | * Portions of this file Copyright 1999-2005 University of Chicago | |
| 3 | * Portions of this file Copyright 1999-2005 The University of Southern California. | |
| 4 | * | |
| 5 | * This file or a portion of this file is licensed under the | |
| 6 | * terms of the Globus Toolkit Public License, found at | |
| 7 | * http://www.globus.org/toolkit/download/license.html. | |
| 8 | * If you redistribute this file, with or without | |
| 9 | * modifications, you must include this notice in the file. | |
| 10 | */ | |
| 11 | ||
| 12 | ||
| 13 | #include "xsd_QName.h" | |
| 14 | #include "globus_soap_message.h" | |
| 15 | #include "globus_i_xsd.h" | |
| 16 | ||
| 17 | GLOBUS_I_XSD_DEFINE_QNAME(xsd, QName); | |
| 18 | ||
| 19 | GLOBUS_I_XSD_DEFINE_TYPE_INFO(xsd_QName); | |
| 20 | ||
| 21 | 778086 | GLOBUS_I_XSD_DEFINE_TYPE_INIT(xsd_QName); |
| 22 | 2025302 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY(xsd_QName); |
| 23 | 1247301 | GLOBUS_I_XSD_DEFINE_TYPE_COPY(xsd_QName); |
| 24 | 495406 | GLOBUS_I_XSD_DEFINE_TYPE_DESERIALIZE(xsd_QName); |
| 25 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_DESERIALIZE_POINTER(xsd_QName); |
| 26 | 0 | GLOBUS_I_XSD_DEFINE_TYPE_INIT_ARRAY(xsd_QName); |
| 27 | 6326 | GLOBUS_I_XSD_DEFINE_TYPE_DESTROY_ARRAY(xsd_QName); |
| 28 | 4459 | GLOBUS_I_XSD_DEFINE_TYPE_COPY_ARRAY(xsd_QName); |
| 29 | 2674 | GLOBUS_I_XSD_DEFINE_TYPE_SERIALIZE_ARRAY(xsd_QName); |
| 30 | 1793 | GLOBUS_I_XSD_DEFINE_TYPE_DESERIALIZE_ARRAY(xsd_QName); |
| 31 | 513324 | GLOBUS_I_XSD_DEFINE_TYPE_ARRAY_PUSH(xsd_QName) |
| 32 | ||
| 33 | 3166 | GLOBUS_I_XSD_DEFINE_ATTR_FUNCTIONS(xsd_QName, QName); |
| 34 | 934 | GLOBUS_I_XSD_DEFINE_INIT_CONTENTS_GENERIC(xsd_QName); |
| 35 | 0 | GLOBUS_I_XSD_DEFINE_LIST_FUNCTIONS(xsd_QName, QName); |
| 36 | 0 | GLOBUS_I_XSD_DEFINE_LIST_ATTR_FUNCTIONS(xsd_QName, QName); |
| 37 | ||
| 38 | globus_result_t | |
| 39 | xsd_QName_copy_contents( | |
| 40 | xsd_QName * dest, | |
| 41 | const xsd_QName * src) | |
| 42 | 2479790 | { |
| 43 | 2479790 | globus_result_t result = GLOBUS_SUCCESS; |
| 44 | GlobusFuncName(xsd_QName_copy_contents); | |
| 45 | 2479790 | GlobusSoapMessageDebugEnter(); |
| 46 | ||
| 47 | 2479790 | if(dest && src) |
| 48 | { | |
| 49 | 2479790 | if(src->Namespace) |
| 50 | { | |
| 51 | 2479774 | dest->Namespace = globus_libc_strdup(src->Namespace); |
| 52 | 2479774 | if(!dest->Namespace) |
| 53 | { | |
| 54 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 55 | 0 | goto error; |
| 56 | } | |
| 57 | } | |
| 58 | else | |
| 59 | { | |
| 60 | 16 | dest->Namespace = NULL; |
| 61 | } | |
| 62 | ||
| 63 | 2479790 | if(src->local) |
| 64 | { | |
| 65 | 2479790 | dest->local = globus_libc_strdup(src->local); |
| 66 | 2479790 | if(!dest->local) |
| 67 | { | |
| 68 | 0 | result = GlobusSoapMessageErrorOutOfMemory; |
| 69 | 0 | if(dest->Namespace) |
| 70 | { | |
| 71 | 0 | globus_free(dest->Namespace); |
| 72 | } | |
| 73 | goto error; | |
| 74 | } | |
| 75 | } | |
| 76 | else | |
| 77 | { | |
| 78 | 0 | dest->local = NULL; |
| 79 | } | |
| 80 | } | |
| 81 | ||
| 82 | 2479790 | error: |
| 83 | 2479790 | GlobusSoapMessageDebugExit(); |
| 84 | 2479790 | return result; |
| 85 | } | |
| 86 | ||
| 87 | void | |
| 88 | xsd_QName_destroy_contents( | |
| 89 | xsd_QName * instance) | |
| 90 | 3778587 | { |
| 91 | GlobusFuncName(xsd_QName_destroy_contents); | |
| 92 | 3778587 | GlobusSoapMessageDebugEnter(); |
| 93 | ||
| 94 | 3778587 | if(instance) |
| 95 | { | |
| 96 | 3778587 | if(instance->Namespace) |
| 97 | { | |
| 98 | 3769043 | free(instance->Namespace); |
| 99 | 3769043 | instance->Namespace = NULL; |
| 100 | } | |
| 101 | ||
| 102 | 3778587 | if(instance->local) |
| 103 | { | |
| 104 | 3770017 | free(instance->local); |
| 105 | 3770017 | instance->local = NULL; |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 109 | 3778587 | GlobusSoapMessageDebugExit(); |
| 110 | } | |
| 111 | ||
| 112 | globus_result_t | |
| 113 | xsd_QName_serialize( | |
| 114 | xsd_QName * element_qname, | |
| 115 | xsd_QName * instance, | |
| 116 | globus_soap_message_handle_t message_handle, | |
| 117 | globus_xsd_element_options_t options) | |
| 118 | 740108 | { |
| 119 | 740108 | globus_result_t result = GLOBUS_SUCCESS; |
| 120 | GlobusFuncName(xsd_QName_serialize); | |
| 121 | 740108 | GlobusSoapMessageDebugEnter(); |
| 122 | ||
| 123 | 740108 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 124 | { | |
| 125 | /* add begin element */ | |
| 126 | 740106 | result = globus_soap_message_invoke_ns_callouts( |
| 127 | message_handle, | |
| 128 | element_qname, | |
| 129 | GLOBUS_SOAP_MESSAGE_CALLOUT_NS_SET, | |
| 130 | &options); | |
| 131 | 740106 | if(result != GLOBUS_SUCCESS) |
| 132 | { | |
| 133 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 134 | result, NULL, element_qname); | |
| 135 | 0 | goto exit; |
| 136 | } | |
| 137 | ||
| 138 | 740106 | if(options & GLOBUS_XSD_ELEMENT_TYPE_ATTR && |
| 139 | !message_handle->c14n_subset) | |
| 140 | { | |
| 141 | 0 | result = globus_soap_message_attribute_ns_set( |
| 142 | message_handle, | |
| 143 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 144 | &options); | |
| 145 | 0 | if(result != GLOBUS_SUCCESS) |
| 146 | { | |
| 147 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 148 | result, NULL, element_qname); | |
| 149 | 0 | goto exit; |
| 150 | } | |
| 151 | ||
| 152 | 0 | result = globus_soap_message_attribute_ns_set( |
| 153 | message_handle, | |
| 154 | xsd_QName_qname.Namespace, | |
| 155 | &options); | |
| 156 | 0 | if(result != GLOBUS_SUCCESS) |
| 157 | { | |
| 158 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 159 | result, NULL, element_qname); | |
| 160 | 0 | goto exit; |
| 161 | } | |
| 162 | } | |
| 163 | ||
| 164 | 740106 | result = globus_soap_message_element_ns_set( |
| 165 | message_handle, | |
| 166 | element_qname->Namespace, | |
| 167 | &options); | |
| 168 | 740106 | if(result != GLOBUS_SUCCESS) |
| 169 | { | |
| 170 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 171 | result, NULL, element_qname); | |
| 172 | 0 | goto exit; |
| 173 | } | |
| 174 | } | |
| 175 | ||
| 176 | 740108 | result = globus_soap_message_attribute_ns_set( |
| 177 | message_handle, | |
| 178 | instance->Namespace, | |
| 179 | &options); | |
| 180 | 740108 | if(result != GLOBUS_SUCCESS) |
| 181 | { | |
| 182 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 183 | result, NULL, element_qname); | |
| 184 | 0 | goto exit; |
| 185 | } | |
| 186 | ||
| 187 | 740108 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 188 | { | |
| 189 | 740106 | result = globus_soap_message_invoke_callouts( |
| 190 | message_handle, | |
| 191 | element_qname, | |
| 192 | GLOBUS_SOAP_MESSAGE_CALLOUT_BEGIN); | |
| 193 | 740106 | if(result != GLOBUS_SUCCESS) |
| 194 | { | |
| 195 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 196 | result, NULL, element_qname); | |
| 197 | 0 | goto exit; |
| 198 | } | |
| 199 | ||
| 200 | 740106 | result = globus_soap_message_serialize_element( |
| 201 | message_handle, | |
| 202 | element_qname, | |
| 203 | options, | |
| 204 | &xsd_QName_qname); | |
| 205 | 740106 | if(result != GLOBUS_SUCCESS) |
| 206 | { | |
| 207 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 208 | result, NULL, element_qname); | |
| 209 | 0 | goto exit; |
| 210 | } | |
| 211 | ||
| 212 | 740106 | result = globus_soap_message_invoke_ns_callouts( |
| 213 | message_handle, | |
| 214 | element_qname, | |
| 215 | GLOBUS_SOAP_MESSAGE_CALLOUT_NS_ADD, | |
| 216 | &options); | |
| 217 | 740106 | if(result != GLOBUS_SUCCESS) |
| 218 | { | |
| 219 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 220 | result, NULL, element_qname); | |
| 221 | 0 | goto exit; |
| 222 | } | |
| 223 | 740106 | if(options & GLOBUS_XSD_ELEMENT_TYPE_ATTR && |
| 224 | !message_handle->c14n_subset) | |
| 225 | { | |
| 226 | 0 | result = globus_soap_message_attribute_ns_add( |
| 227 | message_handle, | |
| 228 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 229 | &options); | |
| 230 | 0 | if(result != GLOBUS_SUCCESS) |
| 231 | { | |
| 232 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 233 | result, NULL, element_qname); | |
| 234 | 0 | goto exit; |
| 235 | } | |
| 236 | } | |
| 237 | ||
| 238 | 740106 | result = globus_soap_message_element_ns_add( |
| 239 | message_handle, | |
| 240 | element_qname->Namespace, | |
| 241 | &options); | |
| 242 | 740106 | if(result != GLOBUS_SUCCESS) |
| 243 | { | |
| 244 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 245 | result, NULL, element_qname); | |
| 246 | 0 | goto exit; |
| 247 | } | |
| 248 | } | |
| 249 | ||
| 250 | 740108 | result = globus_soap_message_attribute_ns_add( |
| 251 | message_handle, | |
| 252 | instance->Namespace, | |
| 253 | &options); | |
| 254 | 740108 | if(result != GLOBUS_SUCCESS) |
| 255 | { | |
| 256 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 257 | result, NULL, instance); | |
| 258 | 0 | goto exit; |
| 259 | } | |
| 260 | ||
| 261 | 740108 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 262 | { | |
| 263 | 740106 | if(options & GLOBUS_XSD_ELEMENT_TYPE_ATTR && |
| 264 | !message_handle->c14n_subset) | |
| 265 | { | |
| 266 | xsd_QName type_attr; | |
| 267 | 0 | type_attr.local = "type"; |
| 268 | 0 | type_attr.Namespace = |
| 269 | "http://www.w3.org/2001/XMLSchema-instance"; | |
| 270 | ||
| 271 | 0 | result = globus_soap_message_attribute_ns_add( |
| 272 | message_handle, | |
| 273 | type_attr.Namespace, | |
| 274 | &options); | |
| 275 | 0 | if(result != GLOBUS_SUCCESS) |
| 276 | { | |
| 277 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 278 | result, NULL, element_qname); | |
| 279 | 0 | goto exit; |
| 280 | } | |
| 281 | ||
| 282 | 0 | result = globus_soap_message_attribute_ns_add( |
| 283 | message_handle, | |
| 284 | xsd_QName_qname.Namespace, | |
| 285 | &options); | |
| 286 | 0 | if(result != GLOBUS_SUCCESS) |
| 287 | { | |
| 288 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 289 | result, NULL, element_qname); | |
| 290 | 0 | goto exit; |
| 291 | } | |
| 292 | ||
| 293 | 0 | result = globus_soap_message_serialize_QName_attribute( |
| 294 | message_handle, | |
| 295 | &type_attr, | |
| 296 | &xsd_QName_qname); | |
| 297 | 0 | if(result != GLOBUS_SUCCESS) |
| 298 | { | |
| 299 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 300 | result, NULL, element_qname); | |
| 301 | 0 | goto exit; |
| 302 | } | |
| 303 | } | |
| 304 | 740106 | result = globus_soap_message_invoke_callouts( |
| 305 | message_handle, | |
| 306 | element_qname, | |
| 307 | GLOBUS_SOAP_MESSAGE_CALLOUT_ATTR); | |
| 308 | 740106 | if(result != GLOBUS_SUCCESS) |
| 309 | { | |
| 310 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 311 | result, NULL, element_qname); | |
| 312 | 0 | goto exit; |
| 313 | } | |
| 314 | ||
| 315 | 740106 | result = globus_soap_message_serialize_element_begin_close( |
| 316 | message_handle); | |
| 317 | 740106 | if(result != GLOBUS_SUCCESS) |
| 318 | { | |
| 319 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 320 | result, NULL, element_qname); | |
| 321 | 0 | goto exit; |
| 322 | } | |
| 323 | } | |
| 324 | ||
| 325 | /* serialize contents of type */ | |
| 326 | 740108 | result = globus_soap_message_serialize_QName( |
| 327 | message_handle, instance); | |
| 328 | 740108 | if(result != GLOBUS_SUCCESS) |
| 329 | { | |
| 330 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 331 | result, NULL, element_qname); | |
| 332 | 0 | goto exit; |
| 333 | } | |
| 334 | ||
| 335 | 740108 | if(!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 336 | { | |
| 337 | /* add end element */ | |
| 338 | 740106 | result = globus_soap_message_serialize_element_end( |
| 339 | message_handle, | |
| 340 | element_qname, | |
| 341 | options, | |
| 342 | &xsd_QName_qname); | |
| 343 | 740106 | if(result != GLOBUS_SUCCESS) |
| 344 | { | |
| 345 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 346 | result, NULL, element_qname); | |
| 347 | 0 | goto exit; |
| 348 | } | |
| 349 | ||
| 350 | } | |
| 351 | ||
| 352 | 740108 | globus_soap_message_attribute_ns_remove( |
| 353 | message_handle, instance->Namespace, &options); | |
| 354 | ||
| 355 | 740108 | if (!(options & GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)) |
| 356 | { | |
| 357 | 740106 | globus_soap_message_element_ns_remove( |
| 358 | message_handle, element_qname->Namespace, &options); | |
| 359 | ||
| 360 | 740106 | if(options & GLOBUS_XSD_ELEMENT_TYPE_ATTR && |
| 361 | !message_handle->c14n_subset) | |
| 362 | { | |
| 363 | 0 | globus_soap_message_attribute_ns_remove( |
| 364 | message_handle, | |
| 365 | "http://www.w3.org/2001/XMLSchema-instance", | |
| 366 | &options); | |
| 367 | ||
| 368 | 0 | globus_soap_message_attribute_ns_remove( |
| 369 | message_handle, xsd_QName_qname.Namespace, &options); | |
| 370 | } | |
| 371 | 740106 | result = globus_soap_message_invoke_ns_callouts( |
| 372 | message_handle, | |
| 373 | element_qname, | |
| 374 | GLOBUS_SOAP_MESSAGE_CALLOUT_NS_REMOVE, | |
| 375 | &options); | |
| 376 | 740106 | if(result != GLOBUS_SUCCESS) |
| 377 | { | |
| 378 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 379 | result, NULL, element_qname); | |
| 380 | 0 | goto exit; |
| 381 | } | |
| 382 | 740106 | result = globus_soap_message_invoke_callouts( |
| 383 | message_handle, | |
| 384 | element_qname, | |
| 385 | GLOBUS_SOAP_MESSAGE_CALLOUT_END); | |
| 386 | 740106 | if(result != GLOBUS_SUCCESS) |
| 387 | { | |
| 388 | 0 | result = GlobusSoapMessageErrorSerializeFailed( |
| 389 | result, NULL, element_qname); | |
| 390 | goto exit; | |
| 391 | } | |
| 392 | } | |
| 393 | ||
| 394 | 740108 | exit: |
| 395 | ||
| 396 | 740108 | GlobusSoapMessageDebugExit(); |
| 397 | 740108 | return result; |
| 398 | } | |
| 399 | ||
| 400 | globus_result_t | |
| 401 | xsd_QName_serialize_contents( | |
| 402 | xsd_QName * element, | |
| 403 | xsd_QName * instance, | |
| 404 | globus_soap_message_handle_t message_handle, | |
| 405 | globus_xsd_element_options_t options) | |
| 406 | 2 | { |
| 407 | 2 | globus_result_t result = GLOBUS_SUCCESS; |
| 408 | GlobusFuncName(xsd_QName_serialize_contents); | |
| 409 | 2 | GlobusSoapMessageDebugEnter(); |
| 410 | ||
| 411 | /* serialize contents of type */ | |
| 412 | 2 | result = xsd_QName_serialize( |
| 413 | element, instance, message_handle, | |
| 414 | (options | GLOBUS_XSD_ELEMENT_CONTENTS_ONLY)); | |
| 415 | ||
| 416 | 2 | GlobusSoapMessageDebugExit(); |
| 417 | 2 | return result; |
| 418 | } | |
| 419 | ||
| 420 | globus_result_t | |
| 421 | xsd_QName_deserialize_contents( | |
| 422 | xsd_QName * eqn, | |
| 423 | xsd_QName * instance, | |
| 424 | globus_soap_message_handle_t message_handle, | |
| 425 | globus_xsd_element_options_t options) | |
| 426 | 493613 | { |
| 427 | 493613 | globus_result_t result = GLOBUS_SUCCESS; |
| 428 | GlobusFuncName(xsd_QName_deserialize_contents); | |
| 429 | 493613 | GlobusSoapMessageDebugEnter(); |
| 430 | ||
| 431 | 493613 | result = globus_soap_message_deserialize_QName( |
| 432 | message_handle, instance); | |
| 433 | ||
| 434 | 493613 | GlobusSoapMessageDebugExit(); |
| 435 | 493613 | return result; |
| 436 | } | |
| 437 | ||
| 438 | int | |
| 439 | xsd_QName_strcmp( | |
| 440 | char * s1, | |
| 441 | char * s2) | |
| 442 | 2546907 | { |
| 443 | GlobusFuncName(globus_l_xsd_safe_strcmp); | |
| 444 | 2546907 | return (s1 == s2 || |
| 445 | (s1 && s2 && strcmp(s1, s2) == 0)); | |
| 446 | } | |
| 447 | ||
| 448 | int | |
| 449 | xsd_QName_keyeq( | |
| 450 | void * qname1, | |
| 451 | void * qname2) | |
| 452 | 1294577 | { |
| 453 | 1294577 | xsd_QName * q1 = qname1; |
| 454 | 1294577 | xsd_QName * q2 = qname2; |
| 455 | GlobusFuncName(xsd_QName_keyeq); | |
| 456 | ||
| 457 | 1294577 | return (q1 == q2) || (q1 && q2 && |
| 458 | xsd_QName_strcmp(q1->Namespace, q2->Namespace) && | |
| 459 | xsd_QName_strcmp(q1->local, q2->local)); | |
| 460 | } | |
| 461 | ||
| 462 | int | |
| 463 | xsd_QName_hash( | |
| 464 | void * qname, | |
| 465 | int limit) | |
| 466 | 1355877 | { |
| 467 | 1355877 | unsigned long h = 0; |
| 468 | unsigned long g; | |
| 469 | char * key; | |
| 470 | 1355877 | xsd_QName * q = qname; |
| 471 | GlobusFuncName(xsd_QName_hash); | |
| 472 | ||
| 473 | 1355877 | key = q->Namespace; |
| 474 | ||
| 475 | 1355877 | if (key) |
| 476 | { | |
| 477 | 107702396 | while (*key) |
| 478 | { | |
| 479 | 106347490 | h = (h << 4) + *key++; |
| 480 | ||
| 481 | 106347490 | if ((g = (h & 0xF0000000UL))) |
| 482 | { | |
| 483 | 91741099 | h ^= g >> 24; |
| 484 | 91741099 | h ^= g; |
| 485 | } | |
| 486 | } | |
| 487 | } | |
| 488 | 1355877 | key = q->local; |
| 489 | 1355877 | if (key) |
| 490 | { | |
| 491 | 21633176 | while (*key) |
| 492 | { | |
| 493 | 20277300 | h = (h << 4) + *key++; |
| 494 | ||
| 495 | 20277300 | if ((g = (h & 0xF0000000UL))) |
| 496 | { | |
| 497 | 20178996 | h ^= g >> 24; |
| 498 | 20178996 | h ^= g; |
| 499 | } | |
| 500 | } | |
| 501 | } | |
| 502 | ||
| 503 | 1355877 | return h % limit; |
| 504 | } | |
| 505 | ||
| 506 | globus_result_t | |
| 507 | xsd_QName_serialize_wrapper( | |
| 508 | xsd_QName * element_qname, | |
| 509 | void * instance, | |
| 510 | globus_soap_message_handle_t message_handle, | |
| 511 | globus_xsd_element_options_t options) | |
| 512 | 0 | { |
| 513 | 0 | return xsd_QName_serialize( |
| 514 | element_qname, (xsd_QName *) instance, message_handle, options); | |
| 515 | } | |
| 516 | ||
| 517 | globus_result_t | |
| 518 | xsd_QName_serialize_contents_wrapper( | |
| 519 | xsd_QName * element_qname, | |
| 520 | void * instance, | |
| 521 | globus_soap_message_handle_t message_handle, | |
| 522 | globus_xsd_element_options_t options) | |
| 523 | 2 | { |
| 524 | 2 | return xsd_QName_serialize_contents( |
| 525 | element_qname, (xsd_QName *) instance, message_handle, options); |