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 "globus_soap_message.h"
20 #include "globus_i_soap_message.h"
21 #include "globus_soap_message_markers.h"
22 #include "globus_soap_message_handle.h"
23 #include "globus_soap_message_fault.h"
24 #include "globus_xml_buffer.h"
25 #include "openssl/evp.h"
26 #include "globus_xio_buffer.h"
27 #include <math.h>
28
29 #include "libxml/xmlschemastypes.h"
30
31 /* Tru64 Unix and ARM Net+OS do not define these */
32 #if defined(__alpha) || defined(TARGET_ARCH_NETOS)
33 #ifndef        INT16_MIN
34 #define        INT16_MIN       (-32768)
35 #endif
36 #ifndef        INT16_MAX
37 #define        INT16_MAX       (32767)
38 #endif
39 #ifndef        INT32_MIN
40 #define        INT32_MIN       INT_MIN
41 #endif
42 #ifndef        INT32_MAX
43 #define        INT32_MAX       INT_MAX
44 #endif
45 #ifndef        INT64_MIN
46 #define        INT64_MIN       LONG_MIN
47 #endif
48 #ifndef        INT64_MAX
49 #define        INT64_MAX       LONG_MAX
50 #endif
51 #ifndef        UINT16_MAX
52 #define        UINT16_MAX      (65535)
53 #endif
54 #ifndef        UINT32_MAX
55 #define        UINT32_MAX      UINT_MAX
56 #endif
57 #ifndef        UINT64_MAX
58 #define        UINT64_MAX      ULONG_MAX
59 #endif
60 #endif /* __alpha */
61
62 #define XSI_NS "http://www.w3.org/2001/XMLSchema-instance"
63 #define XSI_NIL "nil"
64
65 static
66 xmlChar *
67 globus_l_soap_message_numeric_content(
68     const xmlChar *                     content,
69     globus_bool_t                       negative_ok);
70
71 static
72 char *
73 globus_l_soap_message_my_strtok(
74     const char *                        str,
75     size_t                              str_length,
76     int *                               token_start_index,
77     int *                               token_end_index,
78     const char *                        delims)
79 517492 {
80 517492     const char *                        locator;
81 517492     const char *                        start_token;
82 517492     int                                 delim_count, 
83 517492                                         ind, 
84 517492                                         i, 
85 517492                                         between_tokens, 
86 517492                                         len;
87 517492     char *                              new_token = NULL;
88 517492     ind = 0;
89 517492     i = 0;
90 517492     between_tokens = 0;
91 517492     delim_count = strlen(delims);
92 517492     locator = str;
93     
94 2070069     for(i = 0; i < delim_count; ++i)
95     {
96 1552577         if(*locator == delims[i])
97         {
98 276             between_tokens = 1;
99         }
100     }
101
102 522052     while(between_tokens && locator && ind < str_length)
103     {
104 14355         for(i = 0; i < delim_count; ++i)
105         {
106 14098             if(*locator == delims[i])
107             {
108 4560                 break;
109             }
110         }
111
112 4817         if(i == delim_count)
113         {
114 257             between_tokens = 0;
115 257             break;
116         }
117
118 4560         locator++;
119 4560         ind++;
120     }
121
122 517492     start_token = locator;
123 517492     if(token_start_index)
124     {
125 517492         *token_start_index = ind;
126     }
127
128 11857951     while(!between_tokens && *locator && ind < str_length)
129     {
130 45362000         for(i = 0; i < delim_count; ++i)
131         {
132 34021798             if(*locator == delims[i])
133             {
134 257                 if(token_end_index)
135                 {
136 257                     *token_end_index = ind;
137                 }
138 257                 between_tokens = 1;
139 257                 break;
140             }
141         }
142
143 11340459         locator++;
144 11340459         ind++;
145     }
146
147 517492     if(ind == str_length)
148     {
149 517235         *token_end_index = -1;
150     }
151     else
152     {
153 257         ind--;
154     }
155
156 517492     len = ind + (str - start_token);
157 517492     if(len > 0)
158     {
159 517473         new_token = malloc(len+1);
160 517473         memcpy(new_token, start_token, len + 1);
161 517473         new_token[len] = '\0';
162     }
163
164 517492     return new_token;
165 }
166
167 static
168 int
169 globus_i_soap_message_split_qnames(
170     const xmlChar *                     qname_string,
171     globus_list_t **                    qnames)
172 10 {
173 10     char *                              tmpstr;
174 10     char *                              newstr;
175 10     int                                 start_token;
176 10     int                                 end_token;
177 10     char *                              token;
178 10     globus_fifo_t                       qname_fifo;
179
180 10     newstr = globus_libc_strdup((const char *) qname_string);
181 10     globus_fifo_init(&qname_fifo);
182 10     tmpstr = newstr;
183 14     do
184     {
185 14         token = globus_l_soap_message_my_strtok(
186             tmpstr, strlen(tmpstr), &start_token, &end_token, "\n\t ");
187 14         tmpstr += end_token;
188         
189 14         globus_fifo_enqueue(&qname_fifo, token);
190 14     }
191     while (token != NULL && end_token != -1);
192 10     *qnames = globus_fifo_convert_to_list(&qname_fifo);
193 10     globus_fifo_destroy(&qname_fifo);
194
195 10     globus_free(newstr);
196 10     return 0;
197 }
198
199 void
200 globus_soap_message_deserialize_push_element(
201     globus_soap_message_handle_t        handle)
202 2048939 {
203 2048939     GlobusFuncName(globus_soap_message_deserialize_push_element);
204 2048939     GlobusSoapMessageDebugEnter();
205
206 2048939     handle->next_ready++;
207
208 2048939     GlobusSoapMessageDebugExit();
209 }
210
211 globus_result_t
212 globus_i_soap_message_deserialize_read(
213     globus_soap_message_handle_t        handle)
214 0 {
215 0     globus_result_t                     result = GLOBUS_SUCCESS;
216 0     GlobusFuncName(globus_i_soap_message_deserialize_next_element);
217 0     GlobusSoapMessageDebugEnter();
218
219 0     if(xmlTextReaderNodeType(handle->reader) != XML_READER_TYPE_NONE &&
220        xmlTextReaderIsEmptyElement(handle->reader))
221     {
222 0         if(handle->next_ready > 0)
223         {
224 0             handle->next_ready--;
225         }
226         else
227         {
228 0             result = GLOBUS_SOAP_MESSAGE_STATUS_FAILED_ELEMENT;
229         }
230
231 0         goto exit;
232     }
233
234 0     if(handle->next_ready > 0)
235     {
236 0 handle->next_ready--;
237     }
238     else
239     {
240 0 if(xmlTextReaderRead(handle->reader) <= 0)
241 {
242 0     result = GlobusSoapMessageErrorFailedNextNode(handle->result);
243     goto exit;
244 }
245     }
246
247 exit:
248 0     GlobusSoapMessageDebugExit();
249 0     return result;
250 }
251     
252 globus_result_t
253 globus_i_soap_message_deserialize_next_element(
254     globus_soap_message_handle_t        handle)
255 3338372 {
256 3338372     globus_result_t                     result = GLOBUS_SUCCESS;
257 3338372     xmlChar *                           idval = NULL;
258 3338372     GlobusFuncName(globus_i_soap_message_deserialize_next_element);
259 3338372     xmlReaderTypes                      type = XML_READER_TYPE_NONE;
260     
261 3338372     GlobusSoapMessageDebugEnter();
262
263 3338372     if(xmlTextReaderNodeType(handle->reader) != type &&
264        xmlTextReaderIsEmptyElement(handle->reader))
265     {
266 722         if(handle->next_ready > 0)
267         {
268 698             handle->next_ready--;
269         }
270         else
271         {
272 24             result = GLOBUS_SOAP_MESSAGE_STATUS_FAILED_ELEMENT;
273         }
274
275 24         goto exit;
276     }
277
278 6650302     while(type != XML_READER_TYPE_ELEMENT)
279     {
280 3341333         if(handle->next_ready > 0)
281         {
282 2028526             handle->next_ready--;
283         }
284         else
285         {
286 1312807     if(xmlTextReaderRead(handle->reader) <= 0)
287             {
288 0                 result = GlobusSoapMessageErrorFailedNextNode(handle->result);
289 0                 goto exit;
290             }
291         }
292         
293 3341333         type = xmlTextReaderNodeType(handle->reader);
294 3341333         if(type == XML_READER_TYPE_END_ELEMENT)
295         {
296 28329             result = GLOBUS_SOAP_MESSAGE_STATUS_FAILED_ELEMENT;
297 28329             goto exit;
298         }
299 3313004         else if(type == XML_READER_TYPE_TEXT)
300         {
301 352             xmlChar *                   str = NULL;
302 352             if (handle->verbose)
303             {
304 79                 str = xmlTextReaderValue(handle->reader);
305             }
306 352             result = GlobusSoapMessageErrorFailedWithText(handle->verbose, str);
307
308 352             if (str)
309             {
310 79                 xmlFree(str);
311             }
312
313 79             goto exit;
314         }
315     }
316
317 3308969     if(type == XML_READER_TYPE_ELEMENT)
318     {
319 3308969         if(handle->callout_table)
320         {
321 0             xsd_QName               qn;
322             
323 0             qn.local = (char *)
324             xmlTextReaderConstLocalName(handle->reader);
325 0             qn.Namespace = (char *)
326             xmlTextReaderConstNamespaceUri(handle->reader);
327             
328 0             result = globus_soap_message_invoke_callouts(
329                 handle, 
330                 &qn,
331                 GLOBUS_SOAP_MESSAGE_CALLOUT_BEGIN);
332 0             if(result != GLOBUS_SUCCESS)
333             {
334 0                 result = GlobusSoapMessageErrorFailedNextNode(result);
335 0                 goto exit;
336             }
337         }
338
339 3308969         if((idval = xmlTextReaderGetAttribute(
340                 handle->reader, 
341                 (xmlChar *) "Id")) != NULL)
342         {
343 0             result = globus_soap_message_deserialize_mark(
344                 handle,
345                 (char *) idval);
346 0             if(result != GLOBUS_SUCCESS)
347             {
348 0                 result = GlobusSoapMessageErrorSettingId(
349                     result);
350 0                 goto exit;
351             }
352 0     xmlFree(idval);
353         }
354     }
355
356  exit:
357
358 3338372     GlobusSoapMessageDebugExit();
359 3338372     return result;
360 }
361
362 globus_result_t
363 globus_soap_message_deserialize_element_end(
364     globus_soap_message_handle_t        handle,
365     const xsd_QName *                   qname)
366 1289464 {
367 1289464     char *                              idval = NULL;
368 1289464     globus_result_t                     result = GLOBUS_SUCCESS;
369 1289464     xmlReaderTypes                      type = XML_READER_TYPE_NONE;
370 1289464     int                                 res = 0;
371 1289464     GlobusFuncName(globus_soap_message_deserialize_element_end);
372 1289464     GlobusSoapMessageDebugEnter();
373
374 1289464     if(xmlTextReaderIsEmptyElement(handle->reader))
375     {
376 590         if (qname)
377         {
378 590             xsd_QName                   tmp;
379 590             const xmlChar *             qname_ns;
380 590             const xmlChar *             qname_local;
381
382 590             tmp.Namespace = (char *)
383                     xmlTextReaderConstString(handle->reader,
384                             xmlTextReaderConstNamespaceUri(handle->reader));
385 590             tmp.local = (char *)
386                     xmlTextReaderConstString(handle->reader,
387                         xmlTextReaderConstLocalName(handle->reader));
388 590             qname_ns = xmlTextReaderConstString(handle->reader,
389                     (xmlChar *) qname->Namespace);
390 590             qname_local = xmlTextReaderConstString(handle->reader,
391                     (xmlChar *) qname->local);
392 590             if (qname_ns != (xmlChar *) tmp.Namespace ||
393                 qname_local != (xmlChar *) tmp.local)
394             {
395 0                 result = GlobusSoapMessageErrorFailedEndElement(
396                         handle->verbose,
397                         &tmp);
398 0                 goto exit;
399             }
400         }
401 590         res = xmlTextReaderRead(handle->reader);
402 590         if(res < 0)
403         {
404 0             result = GlobusSoapMessageErrorFailedNextNode(handle->result);
405 0             goto exit;
406         }
407 590         handle->next_ready++;    
408
409 590         goto exit;
410     }
411
412 2577850     while(type != XML_READER_TYPE_END_ELEMENT)
413     {
414 1288976         if(handle->next_ready > 0)
415         {
416 16738             handle->next_ready--;
417         }
418         else
419         {
420 1272238     res = xmlTextReaderRead(handle->reader);
421 1272238             if(res < 0)
422             {
423 0                 result = GlobusSoapMessageErrorFailedNextNode(handle->result);
424 0                 goto exit;
425             }
426 1272238             else if(res == 0)
427             {
428 0                 goto exit;
429             }
430         }
431
432 1288976         type = xmlTextReaderNodeType(handle->reader);
433 1288976         if(type == XML_READER_TYPE_ELEMENT)
434         {
435 0             xsd_QName                   unexpected_qn;
436
437 0             if (handle->verbose)
438             {
439 0                 unexpected_qn.Namespace = (char *)
440                         xmlTextReaderConstNamespaceUri(handle->reader);
441 0                 unexpected_qn.local = (char *)
442                         xmlTextReaderConstLocalName(handle->reader);
443             }
444 0             result = GlobusSoapMessageErrorFailedEndElement(
445                     handle->verbose,
446                     &unexpected_qn);
447
448 0             goto exit;
449         }
450 1288976         else if (type == XML_READER_TYPE_TEXT)
451         {
452 0             xmlChar *                   str = NULL;
453 0             if (handle->verbose)
454             {
455 0                 str = xmlTextReaderValue(handle->reader);
456             }
457 0             result = GlobusSoapMessageErrorFailedWithText(handle->verbose, str);
458
459 0             goto exit;
460         }
461     }
462
463 1288874     if(type == XML_READER_TYPE_END_ELEMENT)
464     {
465 1288874         xsd_QName               qn;
466         
467 1288874         if(handle->callout_table)
468         {
469 0             qn.local = (char *)
470             xmlTextReaderConstLocalName(handle->reader);
471 0             qn.Namespace = (char *)
472             xmlTextReaderConstNamespaceUri(handle->reader);
473
474 0             result = globus_soap_message_invoke_callouts(
475                 handle,
476                 &qn,
477                 GLOBUS_SOAP_MESSAGE_CALLOUT_END);
478         }
479                     
480 1288874         if((idval = (char *) xmlTextReaderGetAttribute(
481                 handle->reader, 
482                 (xmlChar *) "Id")) != NULL)
483         {
484 0             char * end_idval = 
485 0             globus_common_create_string("%s-end", idval);
486
487 0     if(handle->next_ready == 0)
488     {
489 0 result = globus_i_soap_message_deserialize_read(handle);
490 0 if(result != GLOBUS_SUCCESS &&
491    !GlobusSoapMessageStatusFailedElementCheck(result))
492 {
493 0     result = GLOBUS_SUCCESS;
494 0     goto exit;
495 }
496
497 0 globus_soap_message_deserialize_push_element(handle);
498     }
499
500 0     result = globus_soap_message_deserialize_mark(
501                 handle, end_idval);
502 0             if(result != GLOBUS_SUCCESS)
503             {
504 0                 result = GlobusSoapMessageErrorSettingId(
505                     result);
506 0                 goto exit;
507             }
508 0     xmlFree(idval);
509 0             globus_free(end_idval);
510         }
511     }
512
513  exit:
514
515 1289464     GlobusSoapMessageDebugExit();
516 1289464     return result;
517 }
518
519 globus_result_t
520 globus_soap_message_deserialize_skip(
521     globus_soap_message_handle_t        handle)
522 0 {
523 0     globus_result_t                     result = GLOBUS_SUCCESS;
524 0     GlobusFuncName(globus_soap_message_deserialize_skip);
525 0     GlobusSoapMessageDebugEnter();
526
527 0     if(xmlTextReaderSkip(handle->reader, handle->next_ready) <= 0)
528     {
529 0         result = GlobusSoapMessageErrorFailedNextNode(handle->result);
530 0         goto exit;
531     }
532
533 0     if(!handle->next_ready)
534     {
535 0         handle->next_ready++;
536     }
537
538  exit:
539
540 0     GlobusSoapMessageDebugExit();
541 0     return result;
542 }
543
544 globus_result_t
545 globus_i_soap_message_deserialize_next_content(
546     globus_soap_message_handle_t             handle)
547 1260908 {
548 1260908     globus_result_t                     result = GLOBUS_SUCCESS;
549 1260908     xmlReaderTypes                      type = XML_READER_TYPE_NONE;
550 1260908     GlobusFuncName(globus_i_soap_message_deserialize_next_content);
551 1260908     GlobusSoapMessageDebugEnter();
552
553 1260908     if(xmlTextReaderIsEmptyElement(handle->reader))
554     {
555 0         goto exit;
556     }
557
558 2521815     while(type != XML_READER_TYPE_TEXT)
559     {
560 1260908         if(handle->next_ready > 0)
561         {
562 287             handle->next_ready--;
563         }
564 1260621         else if(xmlTextReaderRead(handle->reader) <= 0)
565         {
566 0             result = GlobusSoapMessageErrorFailedNextNode(handle->result);
567 0             goto exit;
568         }
569
570 1260908         type = xmlTextReaderNodeType(handle->reader);
571 1260908         if(type == XML_READER_TYPE_END_ELEMENT)
572         {
573             /* no content in between nodes */
574 1             globus_soap_message_deserialize_push_element(handle);
575 1             goto exit;
576         }
577
578 1260907         if(type != XML_READER_TYPE_TEXT &&
579            type != XML_READER_TYPE_ATTRIBUTE)
580         {
581 0             result = GlobusSoapMessageErrorFailedContent();
582             goto exit;
583         }
584     }
585
586  exit:
587
588 1260908     GlobusSoapMessageDebugExit();
589 1260908     return result;
590 }
591         
592 globus_result_t
593 globus_i_soap_message_deserialize_next_attribute(
594     globus_soap_message_handle_t        handle)
595 0 {
596 0     globus_result_t                     result = GLOBUS_SUCCESS;
597 0     xmlReaderTypes                      type = XML_READER_TYPE_NONE;
598 0     GlobusFuncName(globus_i_soap_message_deserialize_next_attribute);
599 0     GlobusSoapMessageDebugEnter();
600
601 0     if(xmlTextReaderRead(handle->reader) <= 0)
602     {
603 0         result = GlobusSoapMessageErrorFailedNextNode(handle->result);
604 0         goto exit;
605     }
606
607 0     type = xmlTextReaderNodeType(handle->reader);
608 0     if(type != XML_READER_TYPE_ATTRIBUTE)
609     {
610 0         result = GlobusSoapMessageErrorFailedAttribute();
611         goto exit;
612     }
613
614  exit:
615
616 0     GlobusSoapMessageDebugExit();
617 0     return result;
618 }
619
620 globus_result_t
621 globus_soap_message_deserialize_envelope(
622     globus_soap_message_handle_t        handle)
623 5580 {
624 5580     xsd_QName                           local_qn;
625 5580     const xmlChar *                     local;
626 5580     const xmlChar *                     soap_env;
627 5580     globus_result_t                     result = GLOBUS_SUCCESS;
628
629 5580     GlobusFuncName(globus_soap_message_deserialize_envelope);
630 5580     GlobusSoapMessageDebugEnter();
631
632 5580     result = globus_soap_message_set_marker(
633 handle,
634 GLOBUS_SOAP_MESSAGE_MARKER_ENVELOPE);
635 5580     if(result != GLOBUS_SUCCESS)
636     {
637 0 result = GlobusSoapMessageErrorDeserializeFailed(
638     result, &soap_env_qname);
639 0 goto exit;
640     }
641     
642 5580     result = globus_i_soap_message_deserialize_next_element(handle);
643 5580     if(result != GLOBUS_SUCCESS)
644     {
645 0         result = GlobusSoapMessageErrorDeserializeFailed(
646             result, &soap_env_qname);
647 0         goto exit;
648     }
649
650 5580     soap_env = xmlTextReaderConstString(handle->reader, (xmlChar *) SOAP_ENV);
651 5580     local = xmlTextReaderConstLocalName(handle->reader);
652 5580     if(soap_env != local)
653     {
654 0         if (handle->verbose)
655         {
656 0             local_qn.Namespace = (char *)
657                 xmlTextReaderConstNamespaceUri(handle->reader);
658 0             local_qn.local = (char *) local;
659         }
660 0         result = GlobusSoapMessageErrorElementNotFound(
661                 handle->verbose,
662                 &soap_env_qname,
663                 &local_qn);
664         goto exit;
665     }
666
667  exit:
668
669 5580     GlobusSoapMessageDebugExit();
670 5580     return result;
671 }
672
673 globus_result_t
674 globus_soap_message_deserialize_envelope_end(
675     globus_soap_message_handle_t        handle)
676 5579 {
677 5579     globus_result_t                     result = GLOBUS_SUCCESS;
678 5579     GlobusFuncName(globus_soap_message_deserialize_envelope_end);
679 5579     GlobusSoapMessageDebugEnter();
680
681 5579     result = globus_soap_message_deserialize_element_end(
682             handle,
683             &soap_env_qname);
684 5579     if(result != GLOBUS_SUCCESS)
685     {
686 0         result = GlobusSoapMessageErrorDeserializeFailed(
687             result, &soap_env_qname);
688 0         goto exit;
689     }
690
691 5579     result = globus_xio_handle_cntl(
692 handle->xio_handle, globus_i_soap_message_buffer_driver,
693 GLOBUS_XIO_BUFFER_SET_READ_MARKER_AT_INDEX,
694 GLOBUS_SOAP_MESSAGE_MARKER_ENVELOPE_END,
695 xmlTextReaderReadPosition(handle->reader));
696 5579     if(result != GLOBUS_SUCCESS)
697     {
698 0 result = GlobusSoapMessageErrorWithMarker(
699     result, "Failed to set read marker: %s", 
700     GLOBUS_SOAP_MESSAGE_MARKER_ENVELOPE_END);
701 goto exit;
702     }
703    
704  exit:
705
706 5579     GlobusSoapMessageDebugExit();
707 5579     return result;
708 }
709     
710 globus_result_t
711 globus_soap_message_deserialize_header(
712     globus_soap_message_handle_t        handle)
713 5580 {
714 5580     const xmlChar *                     local;
715 5580     const xmlChar *                     soap_header;
716 5580     globus_result_t                     result = GLOBUS_SUCCESS;
717
718 5580     GlobusFuncName(globus_soap_message_deserialize_header);
719 5580     GlobusSoapMessageDebugEnter();
720
721 5580     result = globus_i_soap_message_deserialize_next_element(handle);
722 5580     if(result != GLOBUS_SUCCESS)
723     {
724 0         result = GlobusSoapMessageErrorDeserializeFailed(
725             result, &soap_header_qname);
726 0         goto exit;
727     }
728     
729 5580     soap_header = xmlTextReaderConstString(handle->reader, (xmlChar *) SOAP_HEADER);
730 5580     local = xmlTextReaderConstLocalName(handle->reader);
731 5580     if(soap_header != local)
732     {
733 1         xsd_QName                       local_qn =  { NULL, NULL };
734 1         if (handle->verbose)
735         {
736 0             local_qn.Namespace = (char *)
737                 xmlTextReaderNamespaceUri(handle->reader);
738 0             local_qn.local = (char *) local;
739         }
740
741 1         result = GlobusSoapMessageErrorElementNotFound(
742                     handle->verbose,
743                     &soap_body_qname,
744                     &local_qn);
745         goto exit;
746     }
747
748  exit:
749     
750 5580     GlobusSoapMessageDebugExit();
751 5580     return result;
752 }
753
754 globus_result_t
755 globus_soap_message_deserialize_header_end(
756     globus_soap_message_handle_t        handle)
757 5579 {
758 5579     globus_result_t                     result = GLOBUS_SUCCESS;
759 5579     GlobusFuncName(globus_soap_message_deserialize_header_end);
760 5579     GlobusSoapMessageDebugEnter();
761
762 5579     result = globus_soap_message_deserialize_element_end(
763             handle,
764             &soap_header_qname);
765 5579     if(result != GLOBUS_SUCCESS)
766     {
767 0         GlobusSoapMessageErrorDeserializeFailed(
768             result, &soap_header_qname);
769 5579         goto exit;
770     }
771
772  exit:
773
774 5579     GlobusSoapMessageDebugExit();
775 5579     return result;
776 }
777
778 globus_result_t
779 globus_soap_message_add_required_header_element(
780     globus_soap_message_handle_t        handle,
781     const xsd_QName *                   qn)
782 0 {
783 0     globus_result_t                     result = GLOBUS_SUCCESS;
784 0     xsd_QName *                         value;
785 0     GlobusFuncName(globus_soap_message_add_required_header_element);
786 0     GlobusSoapMessageDebugEnter();
787
788 0     if(!handle->mustUnderstand_hash)
789     {
790 0         globus_hashtable_init(
791             &handle->mustUnderstand_hash,
792             10,
793             xsd_QName_hash,
794             xsd_QName_keyeq);
795     }
796
797 0     xsd_QName_copy(&value, qn);
798
799 0     globus_hashtable_insert(
800         &handle->mustUnderstand_hash,
801         value, value);
802
803 0     GlobusSoapMessageDebugExit();
804 0     return result;
805 }
806
807 globus_result_t
808 globus_soap_message_remove_required_header_element(
809     globus_soap_message_handle_t        handle,
810     const xsd_QName *                   qn)
811 9332 {
812 9332     xsd_QName *                         entry;
813 9332     if(handle->mustUnderstand_hash)
814     {
815 0         entry = globus_hashtable_remove(
816             &handle->mustUnderstand_hash, (void *)qn);
817 0 xsd_QName_destroy(entry);
818     }
819 9332     return GLOBUS_SUCCESS;
820 }
821
822 globus_result_t
823 globus_soap_message_check_required_headers(
824     globus_soap_message_handle_t        handle)
825 5500 {
826 5500     if(!handle->mustUnderstand_hash)
827     {
828 5500         return GLOBUS_SUCCESS;
829     }
830
831 0     if(globus_hashtable_empty(&handle->mustUnderstand_hash))
832     {
833 0         return GLOBUS_SUCCESS;
834     }
835     else
836     {
837 0         xsd_QName *                     element;
838 0         globus_result_t                 result = GLOBUS_SUCCESS;
839
840 0         element = globus_hashtable_first(&handle->mustUnderstand_hash);
841
842 0         while(element)
843         {
844 0             result = GlobusSoapMessageErrorMustUnderstand(
845                 result, element);
846 0             element = globus_hashtable_next(&handle->mustUnderstand_hash);
847         }
848         
849 0         return result;
850     }
851 }
852
853 globus_result_t
854 globus_soap_message_deserialize_body(
855     globus_soap_message_handle_t        handle)
856 5580 {
857 5580     const xmlChar *                     local;
858 5580     const xmlChar *                     soap_body;
859 5580     xsd_QName                           local_qn;
860 5580     globus_result_t                     result = GLOBUS_SUCCESS;
861
862 5580     GlobusFuncName(globus_soap_message_deserialize_body);
863 5580     GlobusSoapMessageDebugEnter();
864
865 5580     result = globus_i_soap_message_deserialize_next_element(handle);
866 5580     if(result != GLOBUS_SUCCESS)
867     {
868 0         result = GlobusSoapMessageErrorDeserializeFailed(
869             result, &soap_body_qname);
870 0         goto exit;
871     }
872
873 5580     soap_body = xmlTextReaderConstString(handle->reader, (xmlChar *) SOAP_BODY);
874 5580     local = xmlTextReaderConstLocalName(handle->reader);
875 5580     if(soap_body != local)
876     {
877 0         if (handle->verbose)
878         {
879 0             local_qn.Namespace = (char *)
880                 xmlTextReaderNamespaceUri(handle->reader);
881 0             local_qn.local = (char *) local;
882         }
883
884 0         result = GlobusSoapMessageErrorElementNotFound(
885                     handle->verbose,
886                     &soap_body_qname,
887                     &local_qn);
888         goto exit;
889     }
890         
891  exit:
892     
893 5580     GlobusSoapMessageDebugExit();
894 5580     return result;
895 }
896
897 globus_result_t
898 globus_soap_message_deserialize_fault(
899     globus_soap_message_handle_t        handle,
900     globus_soap_message_fault_t *       soap_fault_handle,
901     globus_soap_fault_callback_func_t   fault_callback,
902     xsd_any **                          fault_any,
903     void *                              user_data)
904 3247 {
905 3247     const xmlChar *                     local;
906 3247     const xmlChar *                     soap_fault;
907 3247     const xmlChar *                     element_name;
908 3247     const xmlChar *                     faultcode_name;
909 3247     const xmlChar *                     faultstring_name;
910 3247     const xmlChar *                     faultactor_name;
911 3247     const xmlChar *                     detail_name;
912 3247     globus_xml_buffer *                 detail_buffer;
913 3247     globus_result_t                     result = GLOBUS_SUCCESS;
914 3247     globus_soap_message_fault_t         fault = NULL;
915
916 3247     GlobusFuncName(globus_soap_message_deserialize_fault);
917 3247     GlobusSoapMessageDebugEnter();
918
919 3247     result = globus_i_soap_message_deserialize_next_element(handle);
920 3247     if(result != GLOBUS_SUCCESS)
921     {
922 0         result = GlobusSoapMessageErrorDeserializeFailed(
923             result, &soap_fault_qname);
924 0         goto exit;
925     }
926
927 3247     soap_fault = xmlTextReaderConstString(handle->reader, (xmlChar *) SOAP_FAULT);
928 3247     local = xmlTextReaderConstLocalName(handle->reader);
929 3247     if(soap_fault != local)
930     {
931 3167         globus_soap_message_deserialize_push_element(handle);
932 3167         goto exit;
933     }
934
935 80     globus_soap_message_fault_init(&fault);
936
937 80     faultcode_name = xmlTextReaderConstString(
938         handle->reader, (xmlChar *) SOAP_FAULTCODE);
939 80     faultactor_name = xmlTextReaderConstString(
940         handle->reader, (xmlChar *) SOAP_FAULTACTOR);
941 80     faultstring_name = xmlTextReaderConstString(
942         handle->reader, (xmlChar *) SOAP_FAULTSTRING);
943 80     detail_name = xmlTextReaderConstString(
944         handle->reader, (xmlChar *) SOAP_FAULT_DETAIL);
945
946 240     while(result == GLOBUS_SUCCESS)
947     {
948 240         result = globus_i_soap_message_deserialize_next_element(handle);
949 240         if(result != GLOBUS_SUCCESS)
950         {
951 3             if(GlobusSoapMessageStatusFailedElementCheck(result) ||
952                GlobusSoapMessageStatusFailedWithTextCheck(result))
953             {
954 3                 globus_soap_message_deserialize_push_element(handle);
955 3                 result = GLOBUS_SUCCESS;
956 3                 break;
957             }
958         
959 0             result = GlobusSoapMessageErrorDeserializeFailed(
960                 result, &soap_fault_qname);
961 0             goto exit;
962         }
963
964 237         element_name = xmlTextReaderConstLocalName(handle->reader);
965 237         if(element_name == faultcode_name)
966         {
967 80             result = globus_i_soap_message_deserialize_next_content(handle);
968 80             if(result != GLOBUS_SUCCESS)
969             {
970 0                 result = GlobusSoapMessageErrorDeserializeFailed(
971                     result, &soap_fault_qname);
972 0                 goto exit;
973             }
974
975 80             fault->faultcode = (char *) xmlTextReaderValue(handle->reader);
976         }
977 157         else if(element_name == faultstring_name)
978         {
979 80             result = globus_i_soap_message_deserialize_next_content(handle);
980 80             if(result != GLOBUS_SUCCESS)
981             {
982 0                 result = GlobusSoapMessageErrorDeserializeFailed(
983                     result, &soap_faultstring_qname);
984 0                 goto exit;
985             }
986
987 80             fault->faultstring = (char *) xmlTextReaderValue(handle->reader);
988         }
989 77         else if(element_name == faultactor_name)
990         {
991 0             result = globus_i_soap_message_deserialize_next_content(handle);
992 0             if(result != GLOBUS_SUCCESS)
993             {
994 0                 result = GlobusSoapMessageErrorDeserializeFailed(
995                     result, &soap_fault_qname);
996 0                 goto exit;
997             }
998
999 0             fault->faultactor = (char *) xmlTextReaderValue(handle->reader);
1000         }
1001 77         else if(element_name == detail_name)
1002         {
1003 77             xsd_any *                   dummy_any = NULL;
1004 77             xsd_QName                   fault_qname;
1005
1006 77             result = globus_soap_message_deserialize_element_unknown(
1007                 handle, &fault_qname);
1008 77             if(result != GLOBUS_SUCCESS)
1009             {
1010 0                 result = GlobusSoapMessageErrorDeserializeFailed(
1011                     result, &soap_fault_detail_qname);
1012 0                 goto exit;
1013             }
1014
1015 77             globus_soap_message_deserialize_push_element(handle);
1016
1017 77             globus_soap_message_set_marker(handle, "FAULT_DETAIL_BEGIN");
1018
1019 77             xsd_any_init(fault_any);
1020
1021 77             result = xsd_any_deserialize(
1022                 NULL, (*fault_any), handle, 0);
1023 77             if(result != GLOBUS_SUCCESS)
1024             {
1025 0                 result = GlobusSoapMessageErrorDeserializeFailed(
1026                     result, &soap_fault_detail_qname);
1027 0                 goto exit;
1028             }
1029             
1030 77             globus_soap_message_set_marker(handle, "FAULT_DETAIL_END");
1031
1032 77             xsd_any_init(&fault->detail);
1033 77             fault->detail->any_info = (&globus_xml_buffer_contents_info);
1034
1035 77             globus_xml_buffer_init(&detail_buffer);
1036 77             result = globus_soap_message_get_marked_buffers(
1037                 handle, 
1038                 "FAULT_DETAIL_BEGIN",
1039                 "FAULT_DETAIL_END",
1040                 &detail_buffer->buffer,
1041                 (size_t *)&detail_buffer->length);
1042 77             if(result != GLOBUS_SUCCESS)
1043             {
1044 0                 globus_xml_buffer_destroy(detail_buffer);
1045 0                 result = GlobusSoapMessageErrorDeserializeFailed(
1046                     result, &soap_fault_detail_qname);
1047 0                 goto exit;
1048             }
1049             
1050 77             fault->detail->value = detail_buffer;
1051
1052 77             fault_callback(handle, 
1053                            (*fault_any)->any_info->type, 
1054                            user_data, 
1055                            NULL);
1056
1057 77             do
1058             {
1059 77                 result = xsd_any_deserialize_pointer(
1060                     NULL, &dummy_any, handle, 0);
1061 77                 if(result != GLOBUS_SUCCESS)
1062                 {
1063 77                     if(GlobusSoapMessageStatusFailedElementCheck(result))
1064                     {
1065 77                         result = GLOBUS_SUCCESS;
1066 77                         goto exit;
1067                     }
1068
1069 0                     result = GlobusSoapMessageErrorDeserializeFailed(
1070                         result, &soap_fault_detail_qname);
1071 0                     goto exit;
1072                 }
1073 0                 xsd_any_destroy(dummy_any);
1074 0                 dummy_any = NULL;
1075
1076 0             } while(result == GLOBUS_SUCCESS);
1077
1078 0             break;
1079         }
1080         else
1081         {
1082 0             result = GlobusSoapMessageErrorUnexpectedElement(
1083                 &soap_fault_qname);
1084 0             goto exit;
1085         }
1086
1087 160         result = globus_soap_message_deserialize_element_end(
1088                 handle,
1089                 &soap_fault_qname);
1090 160         if(result != GLOBUS_SUCCESS)
1091         {
1092 0             result = GlobusSoapMessageErrorDeserializeFailed(
1093                 result, &soap_fault_qname);
1094             goto exit;
1095         }        
1096     }
1097     
1098  exit:
1099     
1100 3247     *soap_fault_handle = fault;
1101
1102 3247     GlobusSoapMessageDebugExit();
1103 3247     return result;
1104 }
1105
1106 globus_bool_t
1107 globus_soap_message_deserialize_element_is_nil(
1108     globus_soap_message_handle_t        handle)
1109 1239418 {
1110 1239418     xmlChar *                           nil_value;
1111 1239418     GlobusFuncName(globus_soap_message_deserialize_element_is_nil);
1112 1239418     GlobusSoapMessageDebugEnter();
1113
1114 1239418     nil_value = xmlTextReaderGetAttributeNs(
1115         handle->reader, 
1116         (xmlChar *) XSI_NIL,
1117         (xmlChar *) XSI_NS);
1118 1239418     if(nil_value && !(xmlStrcmp(nil_value, (xmlChar *) "true")))
1119     {
1120 0         xmlFree(nil_value);
1121 0         return GLOBUS_TRUE;
1122     }
1123     
1124 1239418     if(!nil_value)
1125     {
1126 1239418         xmlFree(nil_value);
1127     }
1128
1129 1239418     return GLOBUS_FALSE;
1130 }    
1131         
1132 globus_result_t
1133 globus_soap_message_deserialize_element_unknown(
1134     globus_soap_message_handle_t        handle,
1135     xsd_QName  *                        qname)
1136 34463 {
1137 34463     globus_result_t                     result = GLOBUS_SUCCESS;
1138
1139 34463     GlobusFuncName(globus_soap_message_deserialize_element);
1140 34463     GlobusSoapMessageDebugEnter();
1141
1142 34463     result = globus_i_soap_message_deserialize_next_element(handle);
1143 34463     if(result != GLOBUS_SUCCESS)
1144     {
1145 5579         xsd_QName *                     q = NULL;
1146
1147 5579         if(GlobusSoapMessageStatusFailedElementCheck(result) ||
1148            GlobusSoapMessageStatusFailedWithTextCheck(result))
1149         {
1150 5579             globus_soap_message_deserialize_push_element(handle);
1151 5579             goto exit;
1152         }
1153         else
1154         {
1155 0             result = GlobusSoapMessageErrorDeserializeFailed(
1156                 result, q);
1157         }
1158 0         goto exit;
1159     }
1160
1161 28884     qname->local = (char *) xmlTextReaderLocalName(handle->reader);
1162 28884     qname->Namespace = (char *) xmlTextReaderNamespaceUri(handle->reader);
1163
1164  exit:
1165
1166 34463     GlobusSoapMessageDebugExit();
1167 34463     return result;
1168 }
1169
1170 globus_bool_t
1171 globus_soap_message_deserialize_element_is_empty(
1172     globus_soap_message_handle_t        handle)
1173 4978 {
1174 4978     return ((handle->next_ready == 0) &&
1175             xmlTextReaderIsEmptyElement(handle->reader));
1176 }
1177
1178 globus_result_t
1179 globus_soap_message_deserialize_element(
1180     globus_soap_message_handle_t        handle,
1181     const xsd_QName *                   qname)
1182 3277948 {
1183 3277948     const xmlChar *                     local;
1184 3277948     const xmlChar *                     local_ns;
1185 3277948     const xmlChar *                     element;
1186 3277948     const xmlChar *                     element_ns;
1187 3277948     xsd_QName                           local_qn;
1188 3277948     globus_result_t                     result = GLOBUS_SUCCESS;
1189
1190 3277948     GlobusFuncName(globus_soap_message_deserialize_element);
1191 3277948     GlobusSoapMessageDebugEnter();
1192
1193 3277948     result = globus_i_soap_message_deserialize_next_element(handle);
1194 3277948     if(result != GLOBUS_SUCCESS)
1195     {
1196 23046         if(GlobusSoapMessageStatusFailedElementCheck(result) ||
1197            GlobusSoapMessageStatusFailedWithTextCheck(result))
1198         {
1199 23046             if (!xmlTextReaderIsEmptyElement(handle->reader))
1200             {
1201 23022                 globus_soap_message_deserialize_push_element(handle);
1202             }
1203
1204 23022             goto exit;
1205         }
1206         else
1207         {
1208 0             result = GlobusSoapMessageErrorDeserializeFailed(
1209                 result, qname);
1210         }
1211 0         goto exit;
1212     }
1213
1214 3254902     if(qname)
1215     {
1216 1270444         element = xmlTextReaderConstString(handle->reader, (xmlChar *) qname->local);
1217 1270444         local = xmlTextReaderConstString(
1218             handle->reader, xmlTextReaderConstLocalName(handle->reader));
1219 1270444         if(element != local)
1220         {
1221 140             if (handle->verbose)
1222             {
1223 41                 local_qn.Namespace = (char *) xmlTextReaderConstString(
1224                         handle->reader,
1225                         xmlTextReaderConstNamespaceUri(handle->reader));
1226 41                 local_qn.local = (char *) local;
1227             }
1228 140             globus_soap_message_deserialize_push_element(handle);
1229
1230 140             result = GlobusSoapMessageErrorElementNotFound(
1231                     handle->verbose,
1232                     qname,
1233                     &local_qn);
1234 140             goto exit;
1235         }
1236         
1237 1270304         element_ns = xmlTextReaderConstString(
1238             handle->reader, (xmlChar *) qname->Namespace);
1239 1270304         local_ns = xmlTextReaderConstString(
1240             handle->reader, xmlTextReaderConstNamespaceUri(handle->reader));
1241 1270304         if(local_ns && element_ns != local_ns)
1242         {
1243 0             if (handle->verbose)
1244             {
1245 0                 local_qn.Namespace = (char *) local_ns;
1246 0                 local_qn.local = (char *) local;
1247             }
1248 0             result = GlobusSoapMessageErrorElementNotFound(
1249                     handle->verbose,
1250                     qname,
1251                     &local_qn);
1252             goto exit;
1253         }
1254     }
1255
1256  exit:
1257
1258 3277948     GlobusSoapMessageDebugExit();
1259 3277948     return result;
1260 }
1261
1262 globus_result_t
1263 globus_soap_message_deserialize_anyURI(
1264     globus_soap_message_handle_t        handle,
1265     xsd_anyURI *                        str)
1266 23400 {
1267 23400     const xmlChar *                     constval;
1268 23400     globus_result_t                     result = GLOBUS_SUCCESS;
1269 23400     int                                 start_token, end_token;
1270 23400     GlobusFuncName(globus_soap_message_deserialize_anyURI);
1271 23400     GlobusSoapMessageDebugEnter();
1272
1273 23400     result = globus_i_soap_message_deserialize_next_content(handle);
1274 23400     if(result != GLOBUS_SUCCESS)
1275     {
1276 0         result = GlobusSoapMessageErrorDeserializeFailed(
1277             result, &xsd_string_qname);
1278 0         goto exit;
1279     }
1280
1281 23400     constval = xmlTextReaderConstValue(handle->reader);
1282 23400     if(constval)
1283     {
1284 23399 *str = globus_l_soap_message_my_strtok(
1285     (char *) constval,
1286             strlen((char *) constval),
1287             &start_token,
1288             &end_token,
1289             "\n\t ");
1290 23399 if (*str == NULL)
1291 {
1292 0     result = GlobusSoapMessageErrorDeserializeFailed(
1293 result, &xsd_anyURI_qname);
1294 0     goto exit;
1295 }
1296     }
1297     else
1298     {
1299 1 *str = NULL;
1300     }
1301     
1302  exit:
1303     
1304 23400     GlobusSoapMessageDebugExit();
1305 23400     return result;
1306 }
1307
1308 globus_result_t
1309 globus_soap_message_deserialize_string(
1310     globus_soap_message_handle_t        handle,
1311     xsd_string *                        str)
1312 2897 {
1313 2897     globus_result_t                     result = GLOBUS_SUCCESS;
1314 2897     GlobusFuncName(globus_soap_message_deserialize_string);
1315 2897     GlobusSoapMessageDebugEnter();
1316
1317 2897     result = globus_i_soap_message_deserialize_next_content(handle);
1318 2897     if(result != GLOBUS_SUCCESS)
1319     {
1320 0         result = GlobusSoapMessageErrorDeserializeFailed(
1321             result, &xsd_string_qname);
1322 0         goto exit;
1323     }
1324
1325 2897     *str = (xsd_string) xmlTextReaderValue(handle->reader);
1326     
1327  exit:
1328     
1329 2897     GlobusSoapMessageDebugExit();
1330 2897     return result;
1331 }
1332
1333 globus_result_t
1334 globus_soap_message_deserialize_string_attribute(
1335     globus_soap_message_handle_t        handle,
1336     const xsd_QName *                   attr_name,
1337     xsd_string *                        str)
1338 839 {
1339 839     const xmlChar *                     attr_ns;
1340 839     const xmlChar *                     local_ns;
1341 839     globus_result_t                     result = GLOBUS_SUCCESS;
1342 839     GlobusFuncName(globus_soap_message_deserialize_string_attribute);
1343 839     GlobusSoapMessageDebugEnter();
1344
1345 839     attr_ns = xmlTextReaderConstString(
1346         handle->reader, (xmlChar *) attr_name->Namespace);
1347 839     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1348
1349 839     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1350     {
1351 0         *str = (char *) xmlTextReaderGetAttributeNs(
1352             handle->reader,
1353             (xmlChar *) attr_name->local,
1354             (xmlChar *) attr_name->Namespace);
1355     }
1356     else
1357     {
1358 839         *str = (char *) xmlTextReaderGetAttribute(
1359             handle->reader, (xmlChar *) attr_name->local);
1360     }
1361 839     if(!*str)
1362     {
1363 145         result = GlobusSoapMessageErrorAttributeNotFound(
1364                 handle->verbose,
1365                 attr_name);
1366         goto exit;
1367     }
1368     
1369  exit:
1370     
1371 839     GlobusSoapMessageDebugExit();
1372 839     return result;
1373 }
1374
1375
1376 globus_result_t
1377 globus_soap_message_deserialize_string_list(
1378     globus_soap_message_handle_t        handle,
1379     xsd_string_array *                  inst)
1380 0 {
1381 0     const char *                        tmp_value = NULL;
1382 0     char *                              newstr;
1383 0     char *                              tmpstr;
1384 0     char *                              token;
1385 0     int                                 start_token, end_token;
1386 0     xsd_string *                        new_element = NULL;
1387 0     globus_result_t                     result = GLOBUS_SUCCESS;
1388 0     GlobusFuncName(globus_soap_message_deserialize_string_list);
1389 0     GlobusSoapMessageDebugEnter();
1390
1391 0     result = globus_i_soap_message_deserialize_next_content(handle);
1392 0     if(result != GLOBUS_SUCCESS)
1393     {
1394 0         result = GlobusSoapMessageErrorDeserializeFailed(
1395             result, &xsd_QName_qname);
1396 0         goto exit;
1397     }
1398     
1399 0     tmp_value = (char *) xmlTextReaderConstValue(handle->reader);
1400 0     if(!tmp_value)
1401     {
1402 0         result = GlobusSoapMessageErrorDeserializeFailed(
1403             result, &xsd_QName_qname);
1404 0         goto exit;
1405     }
1406
1407 0     newstr = globus_libc_strdup(tmp_value);
1408 0     tmpstr = newstr;
1409 0     token = globus_l_soap_message_my_strtok(
1410         tmpstr, strlen(tmpstr), &start_token, &end_token, "\n\t ");
1411 0     tmpstr += end_token;
1412         
1413 0     while(token)
1414     {
1415 0         new_element = xsd_string_array_push(inst);
1416 0         *new_element = token;
1417
1418 0         if(end_token < 0)
1419         {
1420 0             break;
1421         }
1422
1423 0         token = globus_l_soap_message_my_strtok(
1424             tmpstr, strlen(tmpstr), &start_token, &end_token, "\n\t ");
1425 0         tmpstr += end_token;
1426     }
1427
1428 0     globus_free(newstr);
1429
1430  exit:
1431
1432 0     GlobusSoapMessageDebugExit();
1433 0     return result;
1434 }
1435
1436 globus_result_t
1437 globus_soap_message_deserialize_string_attribute_list(
1438     globus_soap_message_handle_t        handle,
1439     const xsd_QName *                   attr_qname,
1440     xsd_string_array *                  inst)
1441 0 {
1442 0     const xmlChar *                     attr_ns = NULL;
1443 0     const xmlChar *                     local_ns = NULL;
1444 0     xmlChar *                           tmp_value = NULL;
1445 0     char *                              newstr;
1446 0     char *                              tmpstr;
1447 0     char *                              token;
1448 0     int                                 start_token, end_token;
1449 0     xsd_string *                        new_element = NULL;
1450 0     globus_result_t                     result = GLOBUS_SUCCESS;
1451 0     GlobusFuncName(globus_soap_message_deserialize_string_attribute_list);
1452 0     GlobusSoapMessageDebugEnter();
1453
1454 0     attr_ns = xmlTextReaderConstString(
1455         handle->reader, (xmlChar *) attr_qname->Namespace);
1456 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1457
1458 0     if(attr_ns != local_ns  && (attr_ns != NULL) && (*attr_ns != '\0'))
1459     {
1460 0         tmp_value = xmlTextReaderGetAttributeNs(
1461             handle->reader,
1462             (xmlChar *) attr_qname->local,
1463             (xmlChar *) attr_qname->Namespace);
1464     }
1465     else
1466     {
1467 0         tmp_value = xmlTextReaderGetAttribute(
1468             handle->reader, (xmlChar *) attr_qname->local);
1469     }
1470
1471 0     if(!tmp_value)
1472     {
1473 0         goto exit;
1474     }
1475
1476 0     if(!(*tmp_value))
1477     {
1478 0         result = GlobusSoapMessageErrorDeserializeFailed(
1479             result, &xsd_string_qname);
1480 0         goto exit;
1481     }
1482
1483 0     newstr = globus_libc_strdup((char *) tmp_value);
1484 0     tmpstr = newstr;
1485 0     token = globus_l_soap_message_my_strtok(
1486         tmpstr, strlen(tmpstr), &start_token, &end_token, "\n\t ");
1487 0     tmpstr += end_token;
1488         
1489 0     while(token)
1490     {
1491 0         new_element = xsd_string_array_push(inst);
1492 0         *new_element = token;
1493
1494 0         if(end_token < 0)
1495         {
1496 0             break;
1497         }
1498
1499 0         token = globus_l_soap_message_my_strtok(
1500             tmpstr, strlen(tmpstr), &start_token, &end_token, "\n\t ");
1501 0         tmpstr += end_token;
1502     }
1503
1504 0     globus_free(newstr);
1505
1506  exit:
1507
1508 0     if(tmp_value)
1509     {
1510 0 xmlFree(tmp_value);
1511     }
1512     
1513 0     GlobusSoapMessageDebugExit();
1514 0     return result;
1515 }
1516
1517 globus_result_t
1518 globus_soap_message_deserialize_duration_attribute(
1519     globus_soap_message_handle_t        handle,
1520     const xsd_QName *                   attr_name,
1521     xsd_duration *                      val)
1522 0 {
1523 0     const xmlChar *                     attr_ns;
1524 0     const xmlChar *                     local_ns;
1525 0     xmlChar *                           tmp_value;
1526 0     xmlSchemaValPtr                     schema_val = NULL;
1527 0     long                                secs;
1528 0     int                                 res;
1529 0     globus_result_t                     result = GLOBUS_SUCCESS;
1530 0     GlobusFuncName(globus_soap_message_deserialize_duration_attribute);
1531 0     GlobusSoapMessageDebugEnter();
1532
1533 0     attr_ns = xmlTextReaderConstString(
1534         handle->reader, (xmlChar *) attr_name->Namespace);
1535 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1536
1537 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1538     {
1539 0         tmp_value = xmlTextReaderGetAttributeNs(
1540             handle->reader,
1541             (xmlChar *) attr_name->local,
1542             (xmlChar *) attr_name->Namespace);
1543     }
1544     else
1545     {
1546 0         tmp_value = xmlTextReaderGetAttribute(
1547             handle->reader, (xmlChar *) attr_name->local);
1548     }
1549
1550 0     if(!tmp_value)
1551     {
1552 0         result = GlobusSoapMessageErrorAttributeNotFound(
1553                 handle->verbose,
1554                 attr_name);
1555 0         goto exit;
1556     }
1557
1558 0     res = xmlSchemaValidatePredefinedType(
1559         xmlSchemaGetBuiltInType(XML_SCHEMAS_DURATION),
1560         tmp_value,
1561         &schema_val);
1562 0     if(res != 0)
1563     {
1564 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1565             &xsd_duration_qname, tmp_value);
1566 0         goto exit;
1567     }
1568
1569 0     secs = schema_val->value.dur.sec;
1570
1571 0     val->hour = secs / (60 * 60);
1572 0     secs = secs % (60 * 60);
1573
1574 0     val->min = secs / 60;
1575 0     secs = secs % 60;
1576
1577 0     if (schema_val->value.dur.sec > 0)
1578     {
1579 0         val->sec = secs + schema_val->value.dur.sec -
1580                             floor(schema_val->value.dur.sec);
1581     }
1582     else
1583     {
1584 0         val->sec = secs + schema_val->value.dur.sec -
1585                             ceil(schema_val->value.dur.sec);
1586     }
1587
1588 0     val->day += val->hour / 24;
1589 0     val->hour = val->hour % 24;
1590     
1591 0     xmlSchemaFreeValue(schema_val);
1592     
1593  exit:
1594
1595 0     if(tmp_value)
1596     {
1597 0         xmlFree(tmp_value);
1598     }
1599     
1600 0     GlobusSoapMessageDebugExit();
1601 0     return result;
1602 }
1603
1604 globus_result_t
1605 globus_soap_message_deserialize_dateTime_attribute(
1606     globus_soap_message_handle_t        handle,
1607     const xsd_QName *                   attr_name,
1608     xsd_dateTime *                      val)
1609 0 {
1610 0     const xmlChar *                     attr_ns;
1611 0     const xmlChar *                     local_ns;
1612 0     xmlChar *                           tmp_value = NULL;
1613 0     xmlSchemaValPtr                     schema_val = NULL;
1614 0     int                                 res;
1615 0     globus_result_t                     result = GLOBUS_SUCCESS;
1616 0     GlobusFuncName(globus_soap_message_deserialize_dateTime_attribute);
1617 0     GlobusSoapMessageDebugEnter();
1618
1619 0     attr_ns = xmlTextReaderConstString(
1620         handle->reader, (xmlChar *) attr_name->Namespace);
1621 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1622
1623 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1624     {
1625 0         tmp_value = xmlTextReaderGetAttributeNs(
1626             handle->reader,
1627             (xmlChar *) attr_name->local,
1628             (xmlChar *) attr_name->Namespace);
1629     }
1630     else
1631     {
1632 0         tmp_value = xmlTextReaderGetAttribute(
1633             handle->reader,
1634             (xmlChar *) attr_name->local);
1635     }
1636 0     if(!tmp_value)
1637     {
1638 0         result = GlobusSoapMessageErrorAttributeNotFound(
1639                 handle->verbose,
1640                 attr_name);
1641 0         goto exit;
1642     }
1643
1644 0     res = xmlSchemaValidatePredefinedType(
1645         xmlSchemaGetBuiltInType(XML_SCHEMAS_DATETIME),
1646         tmp_value,
1647         &schema_val);
1648 0     if(res != 0)
1649     {
1650 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1651             &xsd_dateTime_qname, tmp_value);
1652 0         goto exit;
1653     }
1654
1655 0     val->tm_year = schema_val->value.date.year - 1900;
1656 0     val->tm_mon = schema_val->value.date.mon;
1657 0     val->tm_mday = schema_val->value.date.day;
1658 0     val->tm_hour = schema_val->value.date.hour;
1659 0     val->tm_min = schema_val->value.date.min;
1660 0     val->tm_sec = schema_val->value.date.sec;
1661 0     if(schema_val->value.date.tz_flag)
1662     {
1663 0         val->tm_min += schema_val->value.date.tzo;
1664     }
1665
1666 0     xmlSchemaFreeValue(schema_val);
1667     
1668  exit:
1669
1670 0     if(tmp_value)
1671     {
1672 0         xmlFree(tmp_value);
1673     }
1674     
1675 0     GlobusSoapMessageDebugExit();
1676 0     return result;
1677 }
1678
1679 globus_result_t
1680 globus_soap_message_deserialize_date_attribute(
1681     globus_soap_message_handle_t        handle,
1682     const xsd_QName *                   attr_name,
1683     xsd_date *                          val)
1684 0 {
1685 0     const xmlChar *                     attr_ns;
1686 0     const xmlChar *                     local_ns;
1687 0     xmlChar *                           tmp_value = NULL;
1688 0     xmlSchemaValPtr                     schema_val = NULL;
1689 0     int                                 res;
1690 0     globus_result_t                     result = GLOBUS_SUCCESS;
1691 0     GlobusFuncName(globus_soap_message_deserialize_date_attribute);
1692 0     GlobusSoapMessageDebugEnter();
1693
1694 0     attr_ns = xmlTextReaderConstString(
1695         handle->reader, (xmlChar *) attr_name->Namespace);
1696 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1697
1698 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1699     {
1700 0         tmp_value = xmlTextReaderGetAttributeNs(
1701             handle->reader, 
1702             (xmlChar *) attr_name->local,
1703             (xmlChar *) attr_name->Namespace);
1704     }
1705     else
1706     {
1707 0         tmp_value = xmlTextReaderGetAttribute(
1708             handle->reader, (xmlChar *) attr_name->local);
1709     }
1710 0     if(!tmp_value)
1711     {
1712 0         result = GlobusSoapMessageErrorAttributeNotFound(
1713                 handle->verbose,
1714                 attr_name);
1715 0         goto exit;
1716     }
1717
1718
1719 0     res = xmlSchemaValidatePredefinedType(
1720         xmlSchemaGetBuiltInType(XML_SCHEMAS_DATE),
1721         tmp_value,
1722         &schema_val);
1723 0     if(res != 0)
1724     {
1725 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1726             &xsd_date_qname, tmp_value);
1727 0         goto exit;
1728     }
1729
1730 0     val->tm_year = schema_val->value.date.year - 1900;
1731 0     val->tm_mon = schema_val->value.date.mon - 1;
1732 0     val->tm_mday = schema_val->value.date.day;
1733
1734 0     xmlSchemaFreeValue(schema_val);
1735     
1736  exit:
1737
1738 0     if(tmp_value)
1739     {
1740 0         xmlFree(tmp_value);
1741     }
1742     
1743 0     GlobusSoapMessageDebugExit();
1744 0     return result;
1745 }
1746
1747 globus_result_t
1748 globus_soap_message_deserialize_int_attribute(
1749     globus_soap_message_handle_t        handle,
1750     const xsd_QName *                   attr_name,
1751     xsd_int *                           val)
1752 25508 {
1753 25508     const xmlChar *                     attr_ns;
1754 25508     const xmlChar *                     local_ns;
1755 25508     xmlChar *                           tmp_value;
1756 25508     xmlChar *                           tmp_start;
1757 25508     globus_result_t                     result = GLOBUS_SUCCESS;
1758 25508     GlobusFuncName(globus_soap_message_deserialize_int_attribute);
1759 25508     GlobusSoapMessageDebugEnter();
1760
1761 25508     attr_ns = xmlTextReaderConstString(
1762         handle->reader, (xmlChar *) attr_name->Namespace);
1763 25508     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1764
1765 25508     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1766     {
1767 25508         tmp_value = xmlTextReaderGetAttributeNs(
1768             handle->reader,
1769             (xmlChar *) attr_name->local,
1770             (xmlChar *) attr_name->Namespace);
1771     }
1772     else
1773     {
1774 0         tmp_value = xmlTextReaderGetAttribute(
1775             handle->reader, (xmlChar *) attr_name->local);
1776     }
1777 25508     if(!tmp_value)
1778     {
1779 25508         result = GlobusSoapMessageErrorAttributeNotFound(
1780                 handle->verbose,
1781                 attr_name);
1782 25508         goto exit;
1783     }
1784
1785 0     tmp_start = globus_l_soap_message_numeric_content(
1786             tmp_value, GLOBUS_TRUE);
1787
1788 0     if (tmp_start == NULL)
1789     {
1790 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1791             &xsd_int_qname, tmp_value);
1792 0         goto exit;
1793     }
1794
1795 0     *val = strtol((const char *)tmp_value, NULL, 0);
1796 0     if(*val == INT32_MAX || *val == INT32_MIN)
1797     {
1798 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1799             &xsd_int_qname, tmp_start);
1800 0         goto exit;
1801     }
1802 0     free(tmp_start);
1803     
1804  exit:
1805
1806 25508     if(tmp_value)
1807     {
1808 0         xmlFree(tmp_value);
1809     }
1810     
1811 25508     GlobusSoapMessageDebugExit();
1812 25508     return result;
1813 }
1814 /* globus_soap_message_deserialize_int_attribute() */
1815
1816 globus_result_t
1817 globus_soap_message_deserialize_integer_attribute(
1818     globus_soap_message_handle_t        handle,
1819     const xsd_QName *                   attr_name,
1820     xsd_integer *                       val)
1821 0 {
1822 0     int                                 rc;
1823 0     xmlChar *                           tmp_value = NULL;
1824 0     char *                              tmp = NULL;
1825 0     char *                              tmp_start;
1826 0     globus_result_t                     result = GLOBUS_SUCCESS;
1827 0     GlobusFuncName(globus_soap_message_deserialize_integer_attribute);
1828 0     GlobusSoapMessageDebugEnter();
1829
1830 0     tmp_value = xmlTextReaderGetAttributeNs(
1831         handle->reader, (xmlChar *) attr_name->local, (xmlChar *) attr_name->Namespace);
1832 0     if(!tmp_value)
1833     {
1834 0         result = GlobusSoapMessageErrorDeserializeFailed(
1835             result, &xsd_integer_qname);
1836 0         goto exit;
1837     }
1838
1839 0     tmp_start = (char *) globus_l_soap_message_numeric_content(
1840             tmp_value,
1841             GLOBUS_TRUE);
1842
1843 0     if (tmp_start == NULL)
1844     {
1845 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1846             &xsd_int_qname, tmp_value);
1847 0         goto exit;
1848     }
1849 0     rc = BN_dec2bn(val, tmp_start);
1850 0     if (rc == 0)
1851     {
1852 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1853             &xsd_integer_qname, tmp_start);
1854 0         goto exit;
1855     }
1856 0     free(tmp_start);
1857     
1858  exit:
1859
1860 0     if(tmp_value)
1861     {
1862 0         xmlFree(tmp_value);
1863     }
1864 0     if(tmp)
1865     {
1866 0         free(tmp);
1867     }
1868     
1869 0     GlobusSoapMessageDebugExit();
1870 0     return result;
1871 }
1872 /* globus_soap_message_deserialize_integer_attribute() */
1873
1874 globus_result_t
1875 globus_soap_message_deserialize_long_attribute(
1876     globus_soap_message_handle_t        handle,
1877     const xsd_QName *                   attr_name,
1878     xsd_long *                          val)
1879 0 {
1880 0     const xmlChar *                     attr_ns;
1881 0     const xmlChar *                     local_ns;
1882 0     xmlChar *                           tmp_value;
1883 0     xmlChar *                           tmp_start;
1884 0     globus_result_t                     result = GLOBUS_SUCCESS;
1885 0     GlobusFuncName(globus_soap_message_deserialize_long_attribute);
1886 0     GlobusSoapMessageDebugEnter();
1887
1888 0     attr_ns = xmlTextReaderConstString(
1889         handle->reader, (xmlChar *) attr_name->Namespace);
1890 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1891
1892 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1893     {
1894 0         tmp_value = xmlTextReaderGetAttributeNs(
1895             handle->reader,
1896             (xmlChar *) attr_name->local,
1897             (xmlChar *) attr_name->Namespace);
1898     }
1899     else
1900     {
1901 0         tmp_value = xmlTextReaderGetAttribute(
1902             handle->reader, (xmlChar *) attr_name->local);
1903     }
1904 0     if(!tmp_value)
1905     {
1906 0         result = GlobusSoapMessageErrorAttributeNotFound(
1907                 handle->verbose,
1908                 attr_name);
1909 0         goto exit;
1910     }
1911
1912 0     tmp_start = globus_l_soap_message_numeric_content(
1913             tmp_value,
1914             GLOBUS_TRUE);
1915 0     if (tmp_start == NULL)
1916     {
1917 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
1918             &xsd_long_qname, tmp_value);
1919 0         goto exit;
1920     }
1921
1922 0     *val = strtoll((char *) tmp_value, NULL, 0);
1923 0     if(*val == INT64_MAX || *val == INT64_MIN)
1924     {
1925 0         if(errno == ERANGE)
1926         {
1927 0             result = GlobusSoapMessageErrorDeserializeContentFailed(
1928                 &xsd_long_qname, tmp_value);
1929 0             goto exit;
1930         }
1931     }
1932 0     free(tmp_start);
1933     
1934  exit:
1935     
1936 0     if(tmp_value)
1937     {
1938 0         xmlFree(tmp_value);
1939     }
1940
1941 0     GlobusSoapMessageDebugExit();
1942 0     return result;
1943 }
1944 /* globus_soap_message_deserialize_long_attribute() */
1945
1946 globus_result_t
1947 globus_soap_message_deserialize_float_attribute(
1948     globus_soap_message_handle_t        handle,
1949     const xsd_QName *                   attr_name,
1950     xsd_float *                         val)
1951 0 {
1952 0     const xmlChar *                     attr_ns;
1953 0     const xmlChar *                     local_ns;
1954 0     xmlChar *                           tmp_value = NULL;
1955 0     globus_result_t                     result = GLOBUS_SUCCESS;
1956 0     GlobusFuncName(globus_soap_message_deserialize_float_attribute);
1957 0     GlobusSoapMessageDebugEnter();
1958
1959 0     attr_ns = xmlTextReaderConstString(
1960         handle->reader, (xmlChar *) attr_name->Namespace);
1961 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
1962
1963 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
1964     {
1965 0         tmp_value = xmlTextReaderGetAttributeNs(
1966             handle->reader, (xmlChar *) attr_name->local, (xmlChar *) attr_name->Namespace);
1967     }
1968     else
1969     {
1970 0         tmp_value = xmlTextReaderGetAttribute(
1971             handle->reader, (xmlChar *) attr_name->local);
1972     }
1973 0     if(!tmp_value)
1974     {
1975 0         result = GlobusSoapMessageErrorAttributeNotFound(
1976                 handle->verbose,
1977                 attr_name);
1978 0         goto exit;
1979     }
1980
1981 0     *val = (float) strtod((char *) tmp_value, NULL);
1982
1983  exit:
1984     
1985 0     if(tmp_value)
1986     {
1987 0         xmlFree(tmp_value);
1988     }
1989
1990 0     GlobusSoapMessageDebugExit();
1991 0     return result;
1992 }
1993
1994 globus_result_t
1995 globus_soap_message_deserialize_gDay_attribute(
1996     globus_soap_message_handle_t        handle,
1997     const xsd_QName *                   attr_name,
1998     xsd_gDay *                          val)
1999 0 {
2000 0     const xmlChar *                     attr_ns;
2001 0     const xmlChar *                     local_ns;
2002 0     xmlChar *                           tmp_value = NULL;
2003 0     xmlSchemaValPtr                     schema_val = NULL;
2004 0     int                                 res;
2005 0     globus_result_t                     result = GLOBUS_SUCCESS;
2006 0     GlobusFuncName(globus_soap_message_deserialize_gDay_attribute);
2007 0     GlobusSoapMessageDebugEnter();
2008
2009 0     attr_ns = xmlTextReaderConstString(
2010         handle->reader, (xmlChar *) attr_name->Namespace);
2011 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2012
2013 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
2014     {
2015 0         tmp_value = xmlTextReaderGetAttributeNs(
2016             handle->reader,
2017             (xmlChar *) attr_name->local,
2018             (xmlChar *) attr_name->Namespace);
2019     }
2020     else
2021     {
2022 0         tmp_value = xmlTextReaderGetAttribute(
2023             handle->reader,
2024             (xmlChar *) attr_name->local);
2025     }
2026 0     if(!tmp_value)
2027     {
2028 0         result = GlobusSoapMessageErrorAttributeNotFound(
2029                 handle->verbose,
2030                 attr_name);
2031 0         goto exit;
2032     }
2033
2034 0     res = xmlSchemaValidatePredefinedType(
2035         xmlSchemaGetBuiltInType(XML_SCHEMAS_GDAY),
2036         tmp_value,
2037         &schema_val);
2038 0     if(res != 0)
2039     {
2040 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2041             &xsd_gDay_qname, tmp_value);
2042 0         goto exit;
2043     }
2044
2045 0     memset(val, 0, sizeof(xsd_gDay));
2046 0     val->tm_mday = schema_val->value.date.day;
2047 0     if(schema_val->value.date.tz_flag)
2048     {
2049 0         val->tm_min += schema_val->value.date.tzo;
2050     }
2051
2052 0     xmlSchemaFreeValue(schema_val);
2053     
2054  exit:
2055
2056 0     if(tmp_value)
2057     {
2058 0         xmlFree(tmp_value);
2059     }
2060     
2061 0     GlobusSoapMessageDebugExit();
2062 0     return result;
2063 }
2064
2065 globus_result_t
2066 globus_soap_message_deserialize_gMonth_attribute(
2067     globus_soap_message_handle_t        handle,
2068     const xsd_QName *                   attr_name,
2069     xsd_gMonth *                        val)
2070 0 {
2071 0     const xmlChar *                     attr_ns;
2072 0     const xmlChar *                     local_ns;
2073 0     xmlChar *                           tmp_value = NULL;
2074 0     xmlSchemaValPtr                     schema_val = NULL;
2075 0     int                                 res;
2076 0     globus_result_t                     result = GLOBUS_SUCCESS;
2077 0     GlobusFuncName(globus_soap_message_deserialize_gMonth_attribute);
2078 0     GlobusSoapMessageDebugEnter();
2079
2080 0     attr_ns = xmlTextReaderConstString(
2081         handle->reader, (xmlChar *) attr_name->Namespace);
2082 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2083
2084 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
2085     {
2086 0         tmp_value = xmlTextReaderGetAttributeNs(
2087             handle->reader,
2088             (xmlChar *) attr_name->local,
2089             (xmlChar *) attr_name->Namespace);
2090     }
2091     else
2092     {
2093 0         tmp_value = xmlTextReaderGetAttribute(
2094             handle->reader,
2095             (xmlChar *) attr_name->local);
2096     }
2097 0     if(!tmp_value)
2098     {
2099 0         result = GlobusSoapMessageErrorAttributeNotFound(
2100                 handle->verbose,
2101                 attr_name);
2102 0         goto exit;
2103     }
2104
2105 0     res = xmlSchemaValidatePredefinedType(
2106         xmlSchemaGetBuiltInType(XML_SCHEMAS_GMONTH),
2107         tmp_value,
2108         &schema_val);
2109 0     if(res != 0)
2110     {
2111 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2112             &xsd_gMonth_qname, tmp_value);
2113 0         goto exit;
2114     }
2115
2116 0     memset(val, 0, sizeof(xsd_gMonthDay));
2117 0     val->tm_mon = schema_val->value.date.mon - 1;
2118 0     if(schema_val->value.date.tz_flag)
2119     {
2120 0         val->tm_min += schema_val->value.date.tzo;
2121     }
2122
2123 0     xmlSchemaFreeValue(schema_val);
2124     
2125  exit:
2126
2127 0     if(tmp_value)
2128     {
2129 0         xmlFree(tmp_value);
2130     }
2131     
2132 0     GlobusSoapMessageDebugExit();
2133 0     return result;
2134 }
2135
2136 globus_result_t
2137 globus_soap_message_deserialize_gMonthDay_attribute(
2138     globus_soap_message_handle_t        handle,
2139     const xsd_QName *                   attr_name,
2140     xsd_gMonthDay *                     val)
2141 0 {
2142 0     const xmlChar *                     attr_ns;
2143 0     const xmlChar *                     local_ns;
2144 0     xmlChar *                           tmp_value = NULL;
2145 0     xmlSchemaValPtr                     schema_val = NULL;
2146 0     int                                 res;
2147 0     globus_result_t                     result = GLOBUS_SUCCESS;
2148 0     GlobusFuncName(globus_soap_message_deserialize_gMonthDay_attribute);
2149 0     GlobusSoapMessageDebugEnter();
2150
2151 0     attr_ns = xmlTextReaderConstString(
2152         handle->reader, (xmlChar *) attr_name->Namespace);
2153 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2154
2155 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
2156     {
2157 0         tmp_value = xmlTextReaderGetAttributeNs(
2158             handle->reader,
2159             (xmlChar *) attr_name->local,
2160             (xmlChar *) attr_name->Namespace);
2161     }
2162     else
2163     {
2164 0         tmp_value = xmlTextReaderGetAttribute(
2165             handle->reader,
2166             (xmlChar *) attr_name->local);
2167     }
2168 0     if(!tmp_value)
2169     {
2170 0         result = GlobusSoapMessageErrorAttributeNotFound(
2171                 handle->verbose,
2172                 attr_name);
2173 0         goto exit;
2174     }
2175
2176 0     res = xmlSchemaValidatePredefinedType(
2177         xmlSchemaGetBuiltInType(XML_SCHEMAS_GMONTHDAY),
2178         tmp_value,
2179         &schema_val);
2180 0     if(res != 0)
2181     {
2182 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2183             &xsd_gMonthDay_qname, tmp_value);
2184 0         goto exit;
2185     }
2186
2187 0     memset(val, 0, sizeof(xsd_gMonthDay));
2188 0     val->tm_mon = schema_val->value.date.mon - 1;
2189 0     val->tm_mday = schema_val->value.date.day;
2190 0     if(schema_val->value.date.tz_flag)
2191     {
2192 0         val->tm_min += schema_val->value.date.tzo;
2193     }
2194
2195 0     xmlSchemaFreeValue(schema_val);
2196     
2197  exit:
2198
2199 0     if(tmp_value)
2200     {
2201 0         xmlFree(tmp_value);
2202     }
2203     
2204 0     GlobusSoapMessageDebugExit();
2205 0     return result;
2206 }
2207
2208 globus_result_t
2209 globus_soap_message_deserialize_gYearMonth_attribute(
2210     globus_soap_message_handle_t        handle,
2211     const xsd_QName *                   attr_name,
2212     xsd_gYearMonth *                    val)
2213 0 {
2214 0     const xmlChar *                     attr_ns;
2215 0     const xmlChar *                     local_ns;
2216 0     xmlChar *                           tmp_value = NULL;
2217 0     xmlSchemaValPtr                     schema_val = NULL;
2218 0     int                                 res;
2219 0     globus_result_t                     result = GLOBUS_SUCCESS;
2220 0     GlobusFuncName(globus_soap_message_deserialize_gYearMonth_attribute);
2221 0     GlobusSoapMessageDebugEnter();
2222
2223 0     attr_ns = xmlTextReaderConstString(
2224         handle->reader, (xmlChar *) attr_name->Namespace);
2225 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2226
2227 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
2228     {
2229 0         tmp_value = xmlTextReaderGetAttributeNs(
2230             handle->reader,
2231             (xmlChar *) attr_name->local,
2232             (xmlChar *) attr_name->Namespace);
2233     }
2234     else
2235     {
2236 0         tmp_value = xmlTextReaderGetAttribute(
2237             handle->reader,
2238             (xmlChar *) attr_name->local);
2239     }
2240 0     if(!tmp_value)
2241     {
2242 0         result = GlobusSoapMessageErrorAttributeNotFound(
2243                 handle->verbose,
2244                 attr_name);
2245 0         goto exit;
2246     }
2247
2248 0     res = xmlSchemaValidatePredefinedType(
2249         xmlSchemaGetBuiltInType(XML_SCHEMAS_GYEARMONTH),
2250         tmp_value,
2251         &schema_val);
2252 0     if(res != 0)
2253     {
2254 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2255             &xsd_gYearMonth_qname, tmp_value);
2256 0         goto exit;
2257     }
2258
2259 0     memset(val, 0, sizeof(xsd_gYearMonth));
2260 0     val->tm_year = schema_val->value.date.year - 1900;
2261 0     val->tm_mon = schema_val->value.date.mon - 1;
2262 0     if(schema_val->value.date.tz_flag)
2263     {
2264 0         val->tm_min += schema_val->value.date.tzo;
2265     }
2266
2267 0     xmlSchemaFreeValue(schema_val);
2268     
2269  exit:
2270
2271 0     if(tmp_value)
2272     {
2273 0         xmlFree(tmp_value);
2274     }
2275     
2276 0     GlobusSoapMessageDebugExit();
2277 0     return result;
2278 }
2279
2280 globus_result_t
2281 globus_soap_message_deserialize_gYear_attribute(
2282     globus_soap_message_handle_t        handle,
2283     const xsd_QName *                   attr_name,
2284     xsd_gYear *                         val)
2285 0 {
2286 0     const xmlChar *                     attr_ns;
2287 0     const xmlChar *                     local_ns;
2288 0     xmlChar *                           tmp_value = NULL;
2289 0     xmlSchemaValPtr                     schema_val = NULL;
2290 0     int                                 res;
2291 0     globus_result_t                     result = GLOBUS_SUCCESS;
2292 0     GlobusFuncName(globus_soap_message_deserialize_gYear_attribute);
2293 0     GlobusSoapMessageDebugEnter();
2294
2295 0     attr_ns = xmlTextReaderConstString(
2296         handle->reader, (xmlChar *) attr_name->Namespace);
2297 0     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2298
2299 0     if(attr_ns != local_ns && (attr_ns != NULL) && (*attr_ns != '\0'))
2300     {
2301 0         tmp_value = xmlTextReaderGetAttributeNs(
2302             handle->reader,
2303             (xmlChar *) attr_name->local,
2304             (xmlChar *) attr_name->Namespace);
2305     }
2306     else
2307     {
2308 0         tmp_value = xmlTextReaderGetAttribute(
2309             handle->reader,
2310             (xmlChar *) attr_name->local);
2311     }
2312 0     if(!tmp_value)
2313     {
2314 0         result = GlobusSoapMessageErrorAttributeNotFound(
2315                 handle->verbose,
2316                 attr_name);
2317 0         goto exit;
2318     }
2319
2320 0     res = xmlSchemaValidatePredefinedType(
2321         xmlSchemaGetBuiltInType(XML_SCHEMAS_GYEAR),
2322         tmp_value,
2323         &schema_val);
2324 0     if(res != 0)
2325     {
2326 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2327             &xsd_gYear_qname, tmp_value);
2328 0         goto exit;
2329     }
2330
2331 0     memset(val, 0, sizeof(xsd_gYear));
2332 0     val->tm_year = schema_val->value.date.year - 1900;
2333 0     if(schema_val->value.date.tz_flag)
2334     {
2335 0         val->tm_min += schema_val->value.date.tzo;
2336     }
2337
2338 0     xmlSchemaFreeValue(schema_val);
2339     
2340  exit:
2341
2342 0     if(tmp_value)
2343     {
2344 0         xmlFree(tmp_value);
2345     }
2346     
2347 0     GlobusSoapMessageDebugExit();
2348 0     return result;
2349 }
2350
2351 globus_result_t
2352 globus_soap_message_deserialize_base64Binary_attribute(
2353     globus_soap_message_handle_t        handle,
2354     const xsd_QName *                   attr_qname,
2355     xsd_base64Binary *                  val)
2356 0 {
2357 0     xmlChar *                           tmp_value = NULL;
2358 0     int                                 length;
2359 0     globus_result_t                     result = GLOBUS_SUCCESS;
2360     
2361 0     GlobusFuncName(globus_soap_message_deserialize_base64Binary_attribute);
2362 0     GlobusSoapMessageDebugEnter();
2363
2364 0     tmp_value = xmlTextReaderGetAttributeNs(
2365         handle->reader, (xmlChar *) attr_qname->local, (xmlChar *) attr_qname->Namespace);
2366 0     if(!tmp_value)
2367     {
2368 0         result = GlobusSoapMessageErrorDeserializeFailed(
2369             result, &xsd_base64Binary_qname);
2370 0         goto exit;
2371     }
2372
2373 0     length = strlen((char *) tmp_value);
2374
2375 0     val->length = (int)ceil((length * 3) / 4) + 1;
2376 0     val->value = globus_malloc(val->length);
2377 0     if(!val->value)
2378     {
2379 0 result = GlobusSoapMessageErrorOutOfMemory;
2380 0 goto exit;
2381     }
2382     
2383 0     if(xmlBase64Decode(
2384         tmp_value, 
2385 (unsigned long *)&length, 
2386 (xmlChar *) val->value, 
2387 (unsigned long *)&val->length) < 0)
2388     {
2389 0 result = GlobusSoapMessageErrorDeserializeContentFailed(
2390     attr_qname, tmp_value);
2391 goto exit;
2392     }
2393
2394  exit:
2395  
2396 0     if(tmp_value)
2397     {
2398 0         xmlFree(tmp_value);
2399     }
2400
2401 0     GlobusSoapMessageDebugExit();
2402 0     return result;
2403 }    
2404
2405 globus_result_t
2406 globus_soap_message_deserialize_boolean(
2407     globus_soap_message_handle_t        handle,
2408     xsd_boolean *                       val)
2409 15 {
2410 15     const xmlChar *                     tmp_value = NULL;
2411 15     globus_result_t                     result = GLOBUS_SUCCESS;
2412     
2413 15     GlobusFuncName(globus_soap_message_deserialize_boolean);
2414 15     GlobusSoapMessageDebugEnter();
2415
2416 15     result = globus_i_soap_message_deserialize_next_content(handle);
2417 15     if(result != GLOBUS_SUCCESS)
2418     {
2419 0         result = GlobusSoapMessageErrorDeserializeFailed(
2420             result, &xsd_boolean_qname);
2421 0         goto exit;
2422     }
2423     
2424 15     tmp_value = xmlTextReaderConstValue(handle->reader);
2425 15     if(!tmp_value)
2426     {
2427 0         result = GlobusSoapMessageErrorDeserializeFailed(
2428             GLOBUS_SUCCESS, &xsd_boolean_qname);
2429 0         goto exit;
2430     }
2431
2432 15     if(!xmlStrcmp(tmp_value, (xmlChar *) "false"))
2433     {
2434 3         *val = 0;
2435     }
2436     else
2437     {
2438 12         *val = 1;
2439     }
2440
2441  exit:
2442
2443 15     GlobusSoapMessageDebugExit();
2444 15     return result;
2445 }
2446
2447 globus_result_t
2448 globus_soap_message_deserialize_boolean_attribute(
2449     globus_soap_message_handle_t        handle,
2450     const xsd_QName *                   attr_name,
2451     xsd_boolean *                       val)
2452 92 {
2453 92     const xmlChar *                     attr_ns;
2454 92     const xmlChar *                     local_ns;
2455 92     xmlChar *                           tmp_value;
2456 92     globus_result_t                     result = GLOBUS_SUCCESS;
2457     
2458 92     GlobusFuncName(globus_soap_message_deserialize_boolean_attribute);
2459 92     GlobusSoapMessageDebugEnter();
2460
2461 92     attr_ns = xmlTextReaderConstString(
2462         handle->reader, (xmlChar *) attr_name->Namespace);
2463 92     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
2464
2465 92     if(attr_ns != local_ns  && (attr_ns != NULL) && (*attr_ns != '\0'))
2466     {
2467 0         tmp_value = xmlTextReaderGetAttributeNs(
2468             handle->reader, (xmlChar *) attr_name->local, (xmlChar *) attr_name->Namespace);
2469     }
2470     else
2471     {
2472 92         tmp_value = xmlTextReaderGetAttribute(
2473             handle->reader, (xmlChar *) attr_name->local);
2474     }
2475 92     if(!tmp_value)
2476     {
2477 24         result = GlobusSoapMessageErrorAttributeNotFound(
2478                 handle->verbose,
2479                 attr_name);
2480 24         goto exit;
2481     }
2482     
2483 68     if(!xmlStrcmp(tmp_value, (xmlChar *) "false"))
2484     {
2485 40         *val = 0;
2486     }
2487     else
2488     {
2489 28         *val = 1;
2490     }
2491
2492  exit:
2493
2494 92     if(tmp_value)
2495     {
2496 68         xmlFree(tmp_value);
2497     }
2498
2499 92     GlobusSoapMessageDebugExit();
2500 92     return result;
2501 }
2502
2503 globus_result_t
2504 globus_soap_message_deserialize_dateTime(
2505     globus_soap_message_handle_t        handle,
2506     xsd_dateTime *                      val)
2507 740071 {
2508 740071     xmlSchemaValPtr                     schema_val = NULL;
2509 740071     int                                 res = 0;
2510 740071     const xmlChar *                     tmp_value;
2511 740071     globus_result_t                     result = GLOBUS_SUCCESS;
2512
2513 740071     GlobusFuncName(globus_soap_message_deserialize_dateTime);
2514 740071     GlobusSoapMessageDebugEnter();
2515
2516 740071     result = globus_i_soap_message_deserialize_next_content(handle);
2517 740071     if(result != GLOBUS_SUCCESS)
2518     {
2519 0         result = GlobusSoapMessageErrorDeserializeFailed(
2520             result, &xsd_dateTime_qname);
2521 0         goto exit;
2522     }
2523     
2524 740071     tmp_value = xmlTextReaderConstValue(handle->reader);
2525 740071     if(!tmp_value)
2526     {
2527 0         result = GlobusSoapMessageErrorDeserializeFailed(
2528             result, &xsd_dateTime_qname);
2529 0         goto exit;
2530     }
2531
2532 740071     res = xmlSchemaValidatePredefinedType(
2533         xmlSchemaGetBuiltInType(XML_SCHEMAS_DATETIME),
2534         tmp_value,
2535         &schema_val);
2536 740071     if(res != 0)
2537     {
2538 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2539             &xsd_dateTime_qname, tmp_value);
2540 0         goto exit;
2541     }
2542
2543 740071     val->tm_year = schema_val->value.date.year - 1900;
2544 740071     val->tm_mon = schema_val->value.date.mon - 1;
2545 740071     val->tm_mday = schema_val->value.date.day;
2546 740071     val->tm_hour = schema_val->value.date.hour;
2547 740071     val->tm_min = schema_val->value.date.min;
2548 740071     val->tm_sec = schema_val->value.date.sec;
2549 740071     if(schema_val->value.date.tz_flag)
2550     {
2551 740071         val->tm_min += schema_val->value.date.tzo;
2552     }
2553
2554 740071     xmlSchemaFreeValue(schema_val);
2555
2556  exit:
2557
2558 740071     GlobusSoapMessageDebugExit();
2559 740071     return result;
2560 }
2561         
2562 globus_result_t
2563 globus_soap_message_deserialize_date(
2564     globus_soap_message_handle_t        handle,
2565     xsd_date *                          val)
2566 1 {
2567 1     int                                 res = 0;
2568 1     xmlSchemaValPtr                     schema_val = NULL;
2569 1     const xmlChar *                     tmp_value;
2570 1     globus_result_t                     result = GLOBUS_SUCCESS;
2571
2572 1     GlobusFuncName(globus_soap_message_deserialize_date);
2573 1     GlobusSoapMessageDebugEnter();
2574
2575 1     result = globus_i_soap_message_deserialize_next_content(handle);
2576 1     if(result != GLOBUS_SUCCESS)
2577     {
2578 0         result = GlobusSoapMessageErrorDeserializeFailed(
2579             result, &xsd_date_qname);
2580 0         goto exit;
2581     }
2582     
2583 1     tmp_value = xmlTextReaderConstValue(handle->reader);
2584 1     if(!tmp_value)
2585     {
2586 0         result = GlobusSoapMessageErrorDeserializeFailed(
2587             GLOBUS_SUCCESS, &xsd_date_qname);
2588 0         goto exit;
2589     }
2590
2591 1     res = xmlSchemaValidatePredefinedType(
2592         xmlSchemaGetBuiltInType(XML_SCHEMAS_DATE),
2593         tmp_value,
2594         &schema_val);
2595 1     if(res != 0)
2596     {
2597 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2598             &xsd_date_qname, tmp_value);
2599 0         goto exit;
2600     }
2601
2602 1     val->tm_year = schema_val->value.date.year - 1900;
2603 1     val->tm_mon = schema_val->value.date.mon - 1;
2604 1     val->tm_mday = schema_val->value.date.day;
2605
2606 1     xmlSchemaFreeValue(schema_val);
2607
2608  exit:
2609
2610 1     GlobusSoapMessageDebugExit();
2611 1     return result;
2612 }
2613
2614 globus_result_t
2615 globus_soap_message_deserialize_time(
2616     globus_soap_message_handle_t        handle,
2617     xsd_time *                          val)
2618 1 {
2619 1     xmlSchemaValPtr                     schema_val = NULL;
2620 1     int                                 res;
2621 1     const xmlChar *                     tmp_value;
2622 1     globus_result_t                     result = GLOBUS_SUCCESS;
2623
2624 1     GlobusFuncName(globus_soap_message_deserialize_time);
2625 1     GlobusSoapMessageDebugEnter();
2626
2627 1     result = globus_i_soap_message_deserialize_next_content(handle);
2628 1     if(result != GLOBUS_SUCCESS)
2629     {
2630 0         result = GlobusSoapMessageErrorDeserializeFailed(
2631             result, &xsd_time_qname);
2632 0         goto exit;
2633     }
2634     
2635 1     tmp_value = xmlTextReaderConstValue(handle->reader);
2636 1     if(!tmp_value)
2637     {
2638 0         result = GlobusSoapMessageErrorDeserializeFailed(
2639             result, &xsd_time_qname);
2640 0         goto exit;
2641     }
2642
2643 1     res = xmlSchemaValidatePredefinedType(
2644         xmlSchemaGetBuiltInType(XML_SCHEMAS_TIME),
2645         tmp_value,
2646         &schema_val);
2647 1     if(res != 0)
2648     {
2649 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2650             &xsd_time_qname, tmp_value);
2651 0         goto exit;
2652     }
2653
2654 1     val->tm_hour = schema_val->value.date.hour;
2655 1     val->tm_min = schema_val->value.date.min;
2656 1     val->tm_sec = schema_val->value.date.sec;
2657
2658 1     if(schema_val->value.date.tz_flag)
2659     {
2660 1         val->tm_min += (schema_val->value.date.tzo * 60);
2661     }
2662
2663 1     xmlSchemaFreeValue(schema_val);
2664
2665  exit:
2666
2667 1     GlobusSoapMessageDebugExit();
2668 1     return result;
2669 }
2670     
2671
2672 globus_result_t
2673 globus_soap_message_deserialize_duration(
2674     globus_soap_message_handle_t        handle,
2675     xsd_duration *                      val)
2676 107 {
2677 107     xmlSchemaValPtr                     schema_val = NULL;
2678 107     int                                 res;
2679 107     const xmlChar *                     tmp_value;
2680 107     long                                secs;
2681 107     globus_result_t                     result = GLOBUS_SUCCESS;
2682
2683 107     GlobusFuncName(globus_soap_message_deserialize_duration);
2684 107     GlobusSoapMessageDebugEnter();
2685
2686 107     result = globus_i_soap_message_deserialize_next_content(handle);
2687 107     if(result != GLOBUS_SUCCESS)
2688     {
2689 0         result = GlobusSoapMessageErrorDeserializeFailed(
2690             result, &xsd_duration_qname);
2691 0         goto exit;
2692     }
2693     
2694 107     tmp_value = xmlTextReaderConstValue(handle->reader);
2695 107     if(!tmp_value)
2696     {
2697 0         result = GlobusSoapMessageErrorDeserializeFailed(
2698             result, &xsd_duration_qname);
2699 0         goto exit;
2700     }
2701
2702 107     res = xmlSchemaValidatePredefinedType(
2703         xmlSchemaGetBuiltInType(XML_SCHEMAS_DURATION),
2704         tmp_value,
2705         &schema_val);
2706 107     if(res != 0)
2707     {
2708 1         result = GlobusSoapMessageErrorDeserializeContentFailed(
2709             &xsd_duration_qname, tmp_value);
2710 1         goto exit;
2711     }
2712
2713 106     val->year = schema_val->value.dur.mon / 12;
2714 106     val->month = schema_val->value.dur.mon % 12;
2715 106     val->day = schema_val->value.dur.day;
2716
2717 106     secs = schema_val->value.dur.sec;
2718
2719 106     val->hour = secs / (60 * 60);
2720 106     secs = secs % (60 * 60);
2721
2722 106     val->min = secs / 60;
2723 106     secs = secs % 60;
2724
2725 106     if (schema_val->value.dur.sec > 0)
2726     {
2727 103         val->sec = secs + schema_val->value.dur.sec -
2728                             floor(schema_val->value.dur.sec);
2729     }
2730     else
2731     {
2732 3         val->sec = secs + schema_val->value.dur.sec -
2733                             ceil(schema_val->value.dur.sec);
2734     }
2735
2736 106     val->day += val->hour / 24;
2737 106     val->hour = val->hour % 24;
2738
2739 106     xmlSchemaFreeValue(schema_val);
2740
2741  exit:
2742     
2743 107     GlobusSoapMessageDebugExit();
2744 107     return result;
2745 }
2746     
2747
2748 globus_result_t
2749 globus_soap_message_deserialize_float(
2750     globus_soap_message_handle_t        handle,
2751     xsd_float *                         val)
2752 0 {
2753 0     const xmlChar *                     tmp_value;
2754 0     globus_result_t                     result = GLOBUS_SUCCESS;
2755
2756 0     GlobusFuncName(globus_soap_message_deserialize_float);
2757 0     GlobusSoapMessageDebugEnter();
2758
2759 0     result = globus_i_soap_message_deserialize_next_content(handle);
2760 0     if(result != GLOBUS_SUCCESS)
2761     {
2762 0         result = GlobusSoapMessageErrorDeserializeFailed(
2763             result, &xsd_float_qname);
2764 0         goto exit;
2765     }
2766     
2767 0     tmp_value = xmlTextReaderConstValue(handle->reader);
2768 0     if(!tmp_value)
2769     {
2770 0         result = GlobusSoapMessageErrorDeserializeFailed(
2771             result, &xsd_float_qname);
2772 0         goto exit;
2773     }
2774
2775 0     *val = (float) strtod((char *) tmp_value, NULL);
2776
2777  exit:
2778
2779 0     GlobusSoapMessageDebugExit();
2780 0     return result;
2781 }
2782
2783 globus_result_t
2784 globus_soap_message_deserialize_gDay(
2785     globus_soap_message_handle_t        handle,
2786     xsd_gDay *                          val)
2787 1 {
2788 1     xmlSchemaValPtr                     schema_val = NULL;
2789 1     int                                 res = 0;
2790 1     const xmlChar *                     tmp_value;
2791 1     globus_result_t                     result = GLOBUS_SUCCESS;
2792
2793 1     GlobusFuncName(globus_soap_message_deserialize_gDay);
2794 1     GlobusSoapMessageDebugEnter();
2795
2796 1     result = globus_i_soap_message_deserialize_next_content(handle);
2797 1     if(result != GLOBUS_SUCCESS)
2798     {
2799 0         result = GlobusSoapMessageErrorDeserializeFailed(
2800             result, &xsd_dateTime_qname);
2801 0         goto exit;
2802     }
2803     
2804 1     tmp_value = xmlTextReaderConstValue(handle->reader);
2805 1     if(!tmp_value)
2806     {
2807 0         result = GlobusSoapMessageErrorDeserializeFailed(
2808             result, &xsd_dateTime_qname);
2809 0         goto exit;
2810     }
2811
2812 1     res = xmlSchemaValidatePredefinedType(
2813         xmlSchemaGetBuiltInType(XML_SCHEMAS_GDAY),
2814         tmp_value,
2815         &schema_val);
2816 1     if(res != 0)
2817     {
2818 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2819             &xsd_gDay_qname, tmp_value);
2820 0         goto exit;
2821     }
2822
2823 1     memset(val, 0, sizeof(xsd_gDay));
2824
2825 1     val->tm_mday = schema_val->value.date.day;
2826 1     if(schema_val->value.date.tz_flag)
2827     {
2828 0         val->tm_min += schema_val->value.date.tzo;
2829     }
2830
2831 1     xmlSchemaFreeValue(schema_val);
2832
2833  exit:
2834
2835 1     GlobusSoapMessageDebugExit();
2836 1     return result;
2837 }
2838
2839 globus_result_t
2840 globus_soap_message_deserialize_gMonth(
2841     globus_soap_message_handle_t        handle,
2842     xsd_gMonth *                        val)
2843 20 {
2844 20     xmlSchemaValPtr                     schema_val = NULL;
2845 20     int                                 res = 0;
2846 20     const xmlChar *                     tmp_value;
2847 20     globus_result_t                     result = GLOBUS_SUCCESS;
2848
2849 20     GlobusFuncName(globus_soap_message_deserialize_gMonth);
2850 20     GlobusSoapMessageDebugEnter();
2851
2852 20     result = globus_i_soap_message_deserialize_next_content(handle);
2853 20     if(result != GLOBUS_SUCCESS)
2854     {
2855 0         result = GlobusSoapMessageErrorDeserializeFailed(
2856             result, &xsd_dateTime_qname);
2857 0         goto exit;
2858     }
2859     
2860 20     tmp_value = xmlTextReaderConstValue(handle->reader);
2861 20     if(!tmp_value)
2862     {
2863 0         result = GlobusSoapMessageErrorDeserializeFailed(
2864             result, &xsd_dateTime_qname);
2865 0         goto exit;
2866     }
2867
2868 20     res = xmlSchemaValidatePredefinedType(
2869         xmlSchemaGetBuiltInType(XML_SCHEMAS_GMONTH),
2870         tmp_value,
2871         &schema_val);
2872 20     if(res != 0)
2873     {
2874 4         result = GlobusSoapMessageErrorDeserializeContentFailed(
2875             &xsd_gMonth_qname, tmp_value);
2876 4         goto exit;
2877     }
2878
2879 16     memset(val, 0, sizeof(xsd_gMonth));
2880
2881 16     val->tm_mon = schema_val->value.date.mon - 1;
2882 16     if(schema_val->value.date.tz_flag)
2883     {
2884 0         val->tm_min += schema_val->value.date.tzo;
2885     }
2886
2887 16     xmlSchemaFreeValue(schema_val);
2888
2889  exit:
2890
2891 20     GlobusSoapMessageDebugExit();
2892 20     return result;
2893 }
2894
2895 globus_result_t
2896 globus_soap_message_deserialize_gMonthDay(
2897     globus_soap_message_handle_t        handle,
2898     xsd_gMonthDay *                    val)
2899 1 {
2900 1     xmlSchemaValPtr                     schema_val = NULL;
2901 1     int                                 res = 0;
2902 1     const xmlChar *                     tmp_value;
2903 1     globus_result_t                     result = GLOBUS_SUCCESS;
2904
2905 1     GlobusFuncName(globus_soap_message_deserialize_gMonthDay);
2906 1     GlobusSoapMessageDebugEnter();
2907
2908 1     result = globus_i_soap_message_deserialize_next_content(handle);
2909 1     if(result != GLOBUS_SUCCESS)
2910     {
2911 0         result = GlobusSoapMessageErrorDeserializeFailed(
2912             result, &xsd_dateTime_qname);
2913 0         goto exit;
2914     }
2915     
2916 1     tmp_value = xmlTextReaderConstValue(handle->reader);
2917 1     if(!tmp_value)
2918     {
2919 0         result = GlobusSoapMessageErrorDeserializeFailed(
2920             result, &xsd_dateTime_qname);
2921 0         goto exit;
2922     }
2923
2924 1     res = xmlSchemaValidatePredefinedType(
2925         xmlSchemaGetBuiltInType(XML_SCHEMAS_GMONTHDAY),
2926         tmp_value,
2927         &schema_val);
2928 1     if(res != 0)
2929     {
2930 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2931             &xsd_gMonthDay_qname, tmp_value);
2932 0         goto exit;
2933     }
2934
2935 1     memset(val, 0, sizeof(xsd_gMonthDay));
2936
2937 1     val->tm_mon = schema_val->value.date.mon - 1;
2938 1     val->tm_mday = schema_val->value.date.day;
2939 1     if(schema_val->value.date.tz_flag)
2940     {
2941 0         val->tm_min += schema_val->value.date.tzo;
2942     }
2943
2944 1     xmlSchemaFreeValue(schema_val);
2945
2946  exit:
2947
2948 1     GlobusSoapMessageDebugExit();
2949 1     return result;
2950 }
2951
2952 globus_result_t
2953 globus_soap_message_deserialize_gYearMonth(
2954     globus_soap_message_handle_t        handle,
2955     xsd_gYearMonth *                    val)
2956 1 {
2957 1     xmlSchemaValPtr                     schema_val = NULL;
2958 1     int                                 res = 0;
2959 1     const xmlChar *                     tmp_value;
2960 1     globus_result_t                     result = GLOBUS_SUCCESS;
2961
2962 1     GlobusFuncName(globus_soap_message_deserialize_gYearMonth);
2963 1     GlobusSoapMessageDebugEnter();
2964
2965 1     result = globus_i_soap_message_deserialize_next_content(handle);
2966 1     if(result != GLOBUS_SUCCESS)
2967     {
2968 0         result = GlobusSoapMessageErrorDeserializeFailed(
2969             result, &xsd_dateTime_qname);
2970 0         goto exit;
2971     }
2972     
2973 1     tmp_value = xmlTextReaderConstValue(handle->reader);
2974 1     if(!tmp_value)
2975     {
2976 0         result = GlobusSoapMessageErrorDeserializeFailed(
2977             result, &xsd_dateTime_qname);
2978 0         goto exit;
2979     }
2980
2981 1     res = xmlSchemaValidatePredefinedType(
2982         xmlSchemaGetBuiltInType(XML_SCHEMAS_GYEARMONTH),
2983         tmp_value,
2984         &schema_val);
2985 1     if(res != 0)
2986     {
2987 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
2988             &xsd_gYearMonth_qname, tmp_value);
2989 0         goto exit;
2990     }
2991
2992 1     memset(val, 0, sizeof(xsd_gYearMonth));
2993
2994 1     val->tm_year = schema_val->value.date.year - 1900;
2995 1     val->tm_mon = schema_val->value.date.mon - 1;
2996 1     if(schema_val->value.date.tz_flag)
2997     {
2998 0         val->tm_min += schema_val->value.date.tzo;
2999     }
3000
3001 1     xmlSchemaFreeValue(schema_val);
3002
3003  exit:
3004
3005 1     GlobusSoapMessageDebugExit();
3006 1     return result;
3007 }
3008
3009 globus_result_t
3010 globus_soap_message_deserialize_gYear(
3011     globus_soap_message_handle_t        handle,
3012     xsd_gYear *                         val)
3013 8 {
3014 8     xmlSchemaValPtr                     schema_val = NULL;
3015 8     int                                 res = 0;
3016 8     const xmlChar *                     tmp_value;
3017 8     globus_result_t                     result = GLOBUS_SUCCESS;
3018
3019 8     GlobusFuncName(globus_soap_message_deserialize_gYear);
3020 8     GlobusSoapMessageDebugEnter();
3021
3022 8     result = globus_i_soap_message_deserialize_next_content(handle);
3023 8     if(result != GLOBUS_SUCCESS)
3024     {
3025 0         result = GlobusSoapMessageErrorDeserializeFailed(
3026             result, &xsd_dateTime_qname);
3027 0         goto exit;
3028     }
3029     
3030 8     tmp_value = xmlTextReaderConstValue(handle->reader);
3031 8     if(!tmp_value)
3032     {
3033 0         result = GlobusSoapMessageErrorDeserializeFailed(
3034             result, &xsd_dateTime_qname);
3035 0         goto exit;
3036     }
3037
3038 8     res = xmlSchemaValidatePredefinedType(
3039         xmlSchemaGetBuiltInType(XML_SCHEMAS_GYEAR),
3040         tmp_value,
3041         &schema_val);
3042 8     if(res != 0)
3043     {
3044 4         result = GlobusSoapMessageErrorDeserializeContentFailed(
3045             &xsd_gYear_qname, tmp_value);
3046 4         goto exit;
3047     }
3048
3049 4     memset(val, 0, sizeof(xsd_gYear));
3050
3051 4     val->tm_year = schema_val->value.date.year - 1900;
3052 4     if(schema_val->value.date.tz_flag)
3053     {
3054 0         val->tm_min += schema_val->value.date.tzo;
3055     }
3056
3057 4     xmlSchemaFreeValue(schema_val);
3058
3059  exit:
3060
3061 8     GlobusSoapMessageDebugExit();
3062 8     return result;
3063 }
3064
3065 globus_result_t
3066 globus_soap_message_deserialize_double(
3067     globus_soap_message_handle_t        handle,
3068     xsd_double *                        val)
3069 0 {
3070 0     const xmlChar *                     tmp_value;
3071 0     globus_result_t                     result = GLOBUS_SUCCESS;
3072
3073 0     GlobusFuncName(globus_soap_message_deserialize_double);
3074 0     GlobusSoapMessageDebugEnter();
3075
3076 0     result = globus_i_soap_message_deserialize_next_content(handle);
3077 0     if(result != GLOBUS_SUCCESS)
3078     {
3079 0         result = GlobusSoapMessageErrorDeserializeFailed(
3080             result, &xsd_double_qname);
3081 0         goto exit;
3082     }
3083     
3084 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3085 0     if(!tmp_value)
3086     {
3087 0         result = GlobusSoapMessageErrorDeserializeFailed(
3088             result, &xsd_double_qname);
3089 0         goto exit;
3090     }
3091
3092 0     *val = strtod((char *) tmp_value, NULL);
3093
3094  exit:
3095
3096 0     GlobusSoapMessageDebugExit();
3097 0     return result;
3098 }
3099
3100 globus_result_t
3101 globus_soap_message_deserialize_int(
3102     globus_soap_message_handle_t        handle,
3103     xsd_int *                           val)
3104 163 {
3105 163     const xmlChar *                     tmp_value;
3106 163     xmlChar *                           tmp_start;
3107 163     globus_result_t                     result = GLOBUS_SUCCESS;
3108
3109 163     GlobusFuncName(globus_soap_message_deserialize_int);
3110 163     GlobusSoapMessageDebugEnter();
3111
3112 163     *val = 0;
3113
3114 163     result = globus_i_soap_message_deserialize_next_content(handle);
3115 163     if(result != GLOBUS_SUCCESS)
3116     {
3117 0         result = GlobusSoapMessageErrorDeserializeFailed(
3118             result, &xsd_int_qname);
3119 0         goto exit;
3120     }
3121     
3122 163     tmp_value = xmlTextReaderConstValue(handle->reader);
3123 163     if(!tmp_value)
3124     {
3125 0         result = GlobusSoapMessageErrorDeserializeFailed(
3126             result, &xsd_int_qname);
3127 0         goto exit;
3128     }
3129
3130 163     tmp_start = globus_l_soap_message_numeric_content(
3131             tmp_value,
3132             GLOBUS_TRUE);
3133 163     if(tmp_start == NULL)
3134     {
3135 4         result = GlobusSoapMessageErrorDeserializeFailed(
3136             result, &xsd_int_qname);
3137 4         goto exit;
3138     }
3139
3140 159     errno = 0;
3141 159     *val = strtol((const char *)tmp_start, NULL, 0);
3142 159     if(*val == INT32_MAX || *val == INT32_MIN || errno != 0)
3143     {
3144 3         result = GlobusSoapMessageErrorDeserializeContentFailed(
3145             &xsd_int_qname, tmp_value);
3146 3         goto exit;
3147     }
3148 156     free(tmp_start);
3149         
3150  exit:
3151
3152 163     GlobusSoapMessageDebugExit();
3153 163     return result;
3154 }
3155 /* globus_soap_message_deserialize_int() */
3156
3157 globus_result_t
3158 globus_soap_message_deserialize_short(
3159     globus_soap_message_handle_t        handle,
3160     xsd_short *                         val)
3161 11 {
3162 11     const xmlChar *                     tmp_value = NULL;
3163 11     xmlChar *                           tmp_start;
3164 11     globus_result_t                     result = GLOBUS_SUCCESS;
3165 11     long                                tmp_long = 0;
3166
3167 11     GlobusFuncName(globus_soap_message_deserialize_unsignedShort);
3168 11     GlobusSoapMessageDebugEnter();
3169
3170 11     result = globus_i_soap_message_deserialize_next_content(handle);
3171 11     if(result != GLOBUS_SUCCESS)
3172     {
3173 0         result = GlobusSoapMessageErrorDeserializeFailed(
3174             result, &xsd_unsignedShort_qname);
3175 0         goto exit;
3176     }
3177     
3178 11     tmp_value = xmlTextReaderValue(handle->reader);
3179 11     if(!tmp_value)
3180     {
3181 0         result = GlobusSoapMessageErrorDeserializeFailed(
3182             GLOBUS_SUCCESS, &xsd_unsignedShort_qname);
3183 0         goto exit;
3184     }
3185 11     tmp_start = globus_l_soap_message_numeric_content(
3186             tmp_value,
3187             GLOBUS_TRUE);
3188 11     if(tmp_start == NULL)
3189     {
3190 4         result = GlobusSoapMessageErrorDeserializeFailed(
3191             result, &xsd_int_qname);
3192 4         goto exit;
3193     }
3194
3195 7     errno = 0;
3196 7     tmp_long = strtol((const char *)tmp_start, NULL, 0);
3197
3198 7     if (tmp_long > INT16_MAX || tmp_long < INT16_MIN || errno != 0)
3199     {
3200 3         result = GlobusSoapMessageErrorDeserializeContentFailed(
3201             &xsd_int_qname, tmp_value);
3202 3         goto exit;
3203     }
3204
3205 4     *val = (xsd_short) tmp_long;
3206 4     free(tmp_start);
3207
3208  exit:
3209 11     GlobusSoapMessageDebugExit();
3210 11     return result;
3211 }
3212 /* globus_soap_message_deserialize_short() */
3213
3214
3215 globus_result_t
3216 globus_soap_message_deserialize_long(
3217     globus_soap_message_handle_t        handle,
3218     xsd_long *                          val)
3219 0 {
3220 0     const xmlChar *                     tmp_value;
3221 0     xmlChar *                           tmp_start;
3222 0     globus_result_t                     result = GLOBUS_SUCCESS;
3223
3224 0     GlobusFuncName(globus_soap_message_deserialize_long);
3225 0     GlobusSoapMessageDebugEnter();
3226
3227 0     result = globus_i_soap_message_deserialize_next_content(handle);
3228 0     if(result != GLOBUS_SUCCESS)
3229     {
3230 0         result = GlobusSoapMessageErrorDeserializeFailed(
3231             result, &xsd_long_qname);
3232 0         goto exit;
3233     }
3234     
3235 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3236 0     if(!tmp_value)
3237     {
3238 0         result = GlobusSoapMessageErrorDeserializeFailed(
3239             GLOBUS_SUCCESS, &xsd_long_qname);
3240 0         goto exit;
3241     }
3242 0     tmp_start = globus_l_soap_message_numeric_content(
3243             tmp_value,
3244             GLOBUS_TRUE);
3245 0     if(tmp_start == NULL)
3246     {
3247 0         result = GlobusSoapMessageErrorDeserializeFailed(
3248             result, &xsd_int_qname);
3249 0         goto exit;
3250     }
3251
3252 0     *val = strtoll((char *) tmp_value, NULL, 0);
3253 0     if(*val == INT64_MAX || *val == INT64_MIN)
3254     {
3255 0         if(errno == ERANGE)
3256         {
3257 0             result = GlobusSoapMessageErrorDeserializeContentFailed(
3258                 &xsd_long_qname, tmp_value);
3259 0             goto exit;
3260         }
3261     }
3262 0     free(tmp_start);
3263
3264  exit:
3265
3266 0     GlobusSoapMessageDebugExit();
3267 0     return result;
3268 }
3269 /* globus_soap_message_deserialize_long() */
3270
3271
3272 globus_result_t
3273 globus_soap_message_deserialize_decimal(
3274     globus_soap_message_handle_t        handle,
3275     xsd_decimal *                       val)
3276 0 {
3277 0     GlobusFuncName(globus_soap_message_deserialize_decimal);
3278 0     GlobusSoapMessageDebugEnter();
3279
3280     /* not implemented */
3281 0     globus_panic(GLOBUS_SOAP_MESSAGE_MODULE, GLOBUS_SUCCESS,
3282                  "%s NOT IMPLEMENTED", _globus_func_name);
3283
3284 0     GlobusSoapMessageDebugExit();
3285 0     return GLOBUS_FAILURE;
3286 }
3287
3288 globus_result_t
3289 globus_soap_message_deserialize_integer(
3290     globus_soap_message_handle_t        handle,
3291     xsd_integer *                       val)
3292 10 {
3293 10     const xmlChar *                     tmp_value = NULL;
3294 10     char *                              tmp_start;
3295 10     int                                 rc;
3296 10     globus_result_t                     result = GLOBUS_SUCCESS;
3297     
3298 10     GlobusFuncName(globus_soap_message_deserialize_integer);
3299 10     GlobusSoapMessageDebugEnter();
3300
3301 10     result = globus_i_soap_message_deserialize_next_content(handle);
3302 10     if(result != GLOBUS_SUCCESS)
3303     {
3304 0         result = GlobusSoapMessageErrorDeserializeFailed(
3305             result, &xsd_integer_qname);
3306 0         goto exit;
3307     }
3308     
3309 10     tmp_value = xmlTextReaderConstValue(handle->reader);
3310 10     if(!tmp_value)
3311     {
3312 0         result = GlobusSoapMessageErrorDeserializeFailed(
3313             GLOBUS_SUCCESS, &xsd_integer_qname);
3314 0         goto exit;
3315     }
3316 10     tmp_start = (char *) globus_l_soap_message_numeric_content(
3317             tmp_value,
3318             GLOBUS_TRUE);
3319 10     if(tmp_start == NULL)
3320     {
3321 4         result = GlobusSoapMessageErrorDeserializeFailed(
3322             result, &xsd_int_qname);
3323 4         goto exit;
3324     }
3325
3326 6     rc = BN_dec2bn(val, tmp_start);
3327 6     if (rc == 0)
3328     {
3329 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
3330             &xsd_integer_qname, tmp_value);
3331 0         goto exit;
3332     }
3333 6     free(tmp_start);
3334
3335  exit:
3336
3337 10     GlobusSoapMessageDebugExit();
3338 10     return result;
3339 }
3340     
3341 globus_result_t
3342 globus_soap_message_deserialize_byte(
3343     globus_soap_message_handle_t        handle,
3344     xsd_byte *                          val)
3345 0 {
3346 0     const xmlChar *                     tmp_value;
3347 0     short                               sval;
3348 0     globus_result_t                     result = GLOBUS_SUCCESS;
3349
3350 0     GlobusFuncName(globus_soap_message_deserialize_byte);
3351 0     GlobusSoapMessageDebugEnter();
3352
3353 0     result = globus_i_soap_message_deserialize_next_content(handle);
3354 0     if(result != GLOBUS_SUCCESS)
3355     {
3356 0         result = GlobusSoapMessageErrorDeserializeFailed(
3357             result, &xsd_byte_qname);
3358 0         goto exit;
3359     }
3360     
3361 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3362 0     if(!tmp_value)
3363     {
3364 0         result = GlobusSoapMessageErrorDeserializeFailed(
3365             result, &xsd_byte_qname);
3366 0         goto exit;
3367     }
3368
3369 0     sscanf((char *) tmp_value, "%hd", &sval);
3370 0     *val = (char) sval;
3371
3372  exit:
3373
3374 0     GlobusSoapMessageDebugExit();
3375 0     return result;
3376 }
3377
3378 globus_result_t
3379 globus_soap_message_deserialize_unsignedByte(
3380     globus_soap_message_handle_t        handle,
3381     xsd_unsignedByte *                  val)
3382 0 {
3383 0     const xmlChar *                     tmp_value;
3384 0     unsigned short                      sval;
3385 0     globus_result_t                     result = GLOBUS_SUCCESS;
3386
3387 0     GlobusFuncName(globus_soap_message_deserialize_unsignedByte);
3388 0     GlobusSoapMessageDebugEnter();
3389
3390 0     result = globus_i_soap_message_deserialize_next_content(handle);
3391 0     if(result != GLOBUS_SUCCESS)
3392     {
3393 0         result = GlobusSoapMessageErrorDeserializeFailed(
3394             result, &xsd_unsignedByte_qname);
3395 0         goto exit;
3396     }
3397     
3398 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3399 0     if(!tmp_value)
3400     {
3401 0         result = GlobusSoapMessageErrorDeserializeFailed(
3402             GLOBUS_SUCCESS, &xsd_unsignedByte_qname);
3403 0         goto exit;
3404     }
3405
3406 0     if(sscanf((char *) tmp_value, "%hu", &sval) == 0)
3407     {
3408 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
3409             &xsd_unsignedByte_qname, tmp_value);
3410 0         goto exit;
3411     }
3412
3413 0     *val = (unsigned char) sval;
3414
3415  exit:
3416
3417 0     GlobusSoapMessageDebugExit();
3418 0     return result;
3419 }  
3420
3421 globus_result_t
3422 globus_soap_message_deserialize_unsignedLong(
3423     globus_soap_message_handle_t        handle,
3424     xsd_unsignedLong *                  val)
3425 0 {
3426 0     const xmlChar *                     tmp_value;
3427 0     globus_result_t                     result = GLOBUS_SUCCESS;
3428
3429 0     GlobusFuncName(globus_soap_message_deserialize_unsignedLong);
3430 0     GlobusSoapMessageDebugEnter();
3431
3432 0     result = globus_i_soap_message_deserialize_next_content(handle);
3433 0     if(result != GLOBUS_SUCCESS)
3434     {
3435 0         result = GlobusSoapMessageErrorDeserializeFailed(
3436             result, &xsd_unsignedLong_qname);
3437 0         goto exit;
3438     }
3439     
3440 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3441 0     if(!tmp_value)
3442     {
3443 0         result = GlobusSoapMessageErrorDeserializeFailed(
3444             GLOBUS_SUCCESS, &xsd_unsignedLong_qname);
3445 0         goto exit;
3446     }
3447
3448 0     *val = strtoull((char *) tmp_value, NULL, 0);
3449 0     if(*val == UINT64_MAX)
3450     {
3451 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
3452             &xsd_unsignedLong_qname, tmp_value);
3453         goto exit;
3454     }
3455
3456  exit:
3457     
3458 0     GlobusSoapMessageDebugExit();
3459 0     return result;
3460 }  
3461
3462 globus_result_t
3463 globus_soap_message_deserialize_unsignedInt(
3464     globus_soap_message_handle_t        handle,
3465     xsd_unsignedInt *                   val)
3466 13 {
3467 13     const xmlChar *                     tmp_value;
3468 13     xmlChar *                           tmp_start;
3469 13     globus_result_t                     result = GLOBUS_SUCCESS;
3470
3471 13     GlobusFuncName(globus_soap_message_deserialize_unsignedInt);
3472 13     GlobusSoapMessageDebugEnter();
3473
3474 13     result = globus_i_soap_message_deserialize_next_content(handle);
3475 13     if(result != GLOBUS_SUCCESS)
3476     {
3477 0         result = GlobusSoapMessageErrorDeserializeFailed(
3478             result, &xsd_unsignedInt_qname);
3479 0         goto exit;
3480     }
3481     
3482 13     tmp_value = xmlTextReaderConstValue(handle->reader);
3483 13     if(!tmp_value)
3484     {
3485 0         result = GlobusSoapMessageErrorDeserializeFailed(
3486             GLOBUS_SUCCESS, &xsd_unsignedInt_qname);
3487 0         goto exit;
3488     }
3489 13     tmp_start = globus_l_soap_message_numeric_content(
3490             tmp_value,
3491             GLOBUS_FALSE);
3492 13     if(tmp_start == NULL)
3493     {
3494 6         result = GlobusSoapMessageErrorDeserializeFailed(
3495             result, &xsd_int_qname);
3496 6         goto exit;
3497     }
3498
3499 7     *val = strtoul((char *) tmp_value, NULL, 0);
3500 7     if(*val == UINT32_MAX)
3501     {
3502 2         result = GlobusSoapMessageErrorDeserializeContentFailed(
3503             &xsd_unsignedInt_qname, tmp_value);
3504 2         goto exit;
3505     }
3506 5     free(tmp_start);
3507
3508  exit:
3509
3510 13     GlobusSoapMessageDebugExit();
3511 13     return result;
3512 }
3513 /* globus_soap_message_deserialize_unsignedInt() */
3514
3515 globus_result_t
3516 globus_soap_message_deserialize_unsignedShort(
3517     globus_soap_message_handle_t        handle,
3518     xsd_unsignedShort *                 val)
3519 11 {
3520 11     const xmlChar *                     tmp_value = NULL;
3521 11     xmlChar *                           tmp_start;
3522 11     globus_result_t                     result = GLOBUS_SUCCESS;
3523 11     long                                tmp_long;
3524
3525 11     GlobusFuncName(globus_soap_message_deserialize_unsignedShort);
3526 11     GlobusSoapMessageDebugEnter();
3527
3528 11     result = globus_i_soap_message_deserialize_next_content(handle);
3529 11     if(result != GLOBUS_SUCCESS)
3530     {
3531 0         result = GlobusSoapMessageErrorDeserializeFailed(
3532             result, &xsd_unsignedShort_qname);
3533 0         goto exit;
3534     }
3535     
3536 11     tmp_value = xmlTextReaderConstValue(handle->reader);
3537 11     if(!tmp_value)
3538     {
3539 0         result = GlobusSoapMessageErrorDeserializeFailed(
3540             GLOBUS_SUCCESS, &xsd_unsignedShort_qname);
3541 0         goto exit;
3542     }
3543 11     tmp_start = globus_l_soap_message_numeric_content(
3544             tmp_value,
3545             GLOBUS_FALSE);
3546 11     if(tmp_start == NULL)
3547     {
3548 6         result = GlobusSoapMessageErrorDeserializeFailed(
3549             result, &xsd_int_qname);
3550 6         goto exit;
3551     }
3552
3553 5     errno = 0;
3554 5     tmp_long = strtol((const char *)tmp_start, NULL, 0);
3555
3556 5     if (tmp_long > UINT16_MAX || errno != 0)
3557     {
3558 2         result = GlobusSoapMessageErrorDeserializeContentFailed(
3559             &xsd_int_qname, tmp_value);
3560 2         goto exit;
3561     }
3562
3563 3     *val = (xsd_unsignedShort) tmp_long;
3564 3     free(tmp_start);
3565
3566  exit:
3567
3568 11     GlobusSoapMessageDebugExit();
3569 11     return result;
3570 }
3571 /* globus_soap_message_deserialize_unsignedShort() */
3572     
3573 globus_result_t
3574 globus_soap_message_deserialize_base64Binary(
3575     globus_soap_message_handle_t        handle,
3576     xsd_base64Binary *                  val)
3577 0 {
3578 0     const xmlChar *                     tmp_value;
3579 0     int                                 length = 0;
3580 0     globus_result_t                     result = GLOBUS_SUCCESS;
3581
3582 0     GlobusFuncName(globus_soap_message_deserialize_base64Binary);
3583 0     GlobusSoapMessageDebugEnter();
3584
3585 0     result = globus_i_soap_message_deserialize_next_content(handle);
3586 0     if(result != GLOBUS_SUCCESS)
3587     {
3588 0         result = GlobusSoapMessageErrorDeserializeFailed(
3589             result, &xsd_base64Binary_qname);
3590 0         goto exit;
3591     }
3592     
3593 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3594 0     if(!tmp_value)
3595     {
3596 0         result = GlobusSoapMessageErrorDeserializeFailed(
3597             GLOBUS_SUCCESS, &xsd_base64Binary_qname);
3598 0         goto exit;
3599     }
3600     
3601 0     length = strlen((char *) tmp_value);
3602
3603 0     val->length = (int)ceil((length * 3) / 4) + 1;
3604 0     val->value = globus_malloc(val->length);
3605 0     if(!val->value)
3606     {
3607 0 result = GlobusSoapMessageErrorOutOfMemory;
3608 0 goto exit;
3609     }
3610     
3611 0     if(xmlBase64Decode(
3612 tmp_value, 
3613 (unsigned long *)&length, 
3614 (xmlChar *) val->value, 
3615 (unsigned long *)&val->length) < 0)
3616     {
3617 0 result = GlobusSoapMessageErrorDeserializeContentFailed(
3618     &xsd_base64Binary_qname, tmp_value);
3619 goto exit;
3620     }
3621
3622  exit:
3623
3624 0     GlobusSoapMessageDebugExit();
3625 0     return result;
3626 }
3627
3628 globus_result_t
3629 globus_soap_message_deserialize_hexBinary(
3630     globus_soap_message_handle_t        handle,
3631     xsd_hexBinary *                     val)
3632 0 {
3633 0     int                                 res = 0;
3634 0     xmlSchemaValPtr                     schema_val = NULL;
3635 0     const xmlChar *                     tmp_value;
3636 0     globus_result_t                     result = GLOBUS_SUCCESS;
3637
3638 0     GlobusFuncName(globus_soap_message_deserialize_hexBinary);
3639 0     GlobusSoapMessageDebugEnter();
3640
3641 0     result = globus_i_soap_message_deserialize_next_content(handle);
3642 0     if(result != GLOBUS_SUCCESS)
3643     {
3644 0         result = GlobusSoapMessageErrorDeserializeFailed(
3645             result, &xsd_hexBinary_qname);
3646 0         goto exit;
3647     }
3648     
3649 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3650 0     if(!tmp_value)
3651     {
3652 0         result = GlobusSoapMessageErrorDeserializeFailed(
3653             result, &xsd_hexBinary_qname);
3654 0         goto exit;
3655     }
3656
3657 0     res = xmlSchemaValidatePredefinedType(
3658         xmlSchemaGetBuiltInType(XML_SCHEMAS_HEXBINARY),
3659         tmp_value,
3660         &schema_val);
3661 0     if(res != 0)
3662     {
3663 0         result = GlobusSoapMessageErrorDeserializeContentFailed(
3664             &xsd_hexBinary_qname, tmp_value);
3665 0         goto exit;
3666     }
3667
3668 0     val->value = globus_libc_strdup((char *) schema_val->value.hex.str);
3669 0     val->length = schema_val->value.hex.total;
3670
3671 0     xmlSchemaFreeValue(schema_val);
3672
3673  exit:
3674
3675 0     GlobusSoapMessageDebugExit();
3676 0     return result;
3677 }
3678
3679 globus_result_t
3680 globus_soap_message_deserialize_QName(
3681     globus_soap_message_handle_t        handle,
3682     xsd_QName *                         val)
3683 493978 {
3684 493978     xmlChar *                           prefix;
3685 493978     const xmlChar *                     tmp_value;
3686 493978     xmlChar *                           token;
3687 493978     globus_result_t                     result = GLOBUS_SUCCESS;
3688 493978     int                                 start_token;
3689 493978     int                                 end_token;
3690
3691 493978     GlobusFuncName(globus_soap_message_deserialize_QName);
3692 493978     GlobusSoapMessageDebugEnter();
3693
3694 493978     result = globus_i_soap_message_deserialize_next_content(handle);
3695 493978     if(result != GLOBUS_SUCCESS)
3696     {
3697 0         result = GlobusSoapMessageErrorDeserializeFailed(
3698             result, &xsd_QName_qname);
3699 0         goto exit;
3700     }
3701     
3702 493978     tmp_value = xmlTextReaderConstValue(handle->reader);
3703 493978     if(!tmp_value)
3704     {
3705 0         result = GlobusSoapMessageErrorDeserializeFailed(
3706             result, &xsd_QName_qname);
3707 0         goto exit;
3708     }
3709 493978     token = (xmlChar *) globus_l_soap_message_my_strtok(
3710         (char *) tmp_value, strlen((char *) tmp_value), &start_token, &end_token, "\n\t ");
3711 493978     if (token == NULL)
3712     {
3713 0         result = GlobusSoapMessageErrorDeserializeFailed(
3714             result, &xsd_QName_qname);
3715 0         goto exit;
3716     }
3717
3718 493978     val->local = (char *) xmlSplitQName2(token, &prefix);
3719 493978     if(val->local && prefix)
3720     {
3721 493978         val->Namespace = (char *) xmlTextReaderLookupNamespace(handle->reader, prefix);
3722 493978         xmlFree(prefix);
3723     }
3724 0     else if (val->local)
3725     {
3726 0         val->Namespace = NULL;
3727     }
3728     else
3729     {
3730 0         val->local = globus_libc_strdup((char *) tmp_value);
3731     }
3732
3733 493978     free(token);
3734
3735  exit:
3736
3737 493978     GlobusSoapMessageDebugExit();
3738 493978     return result;
3739 }
3740
3741 globus_result_t
3742 globus_soap_message_deserialize_QName_attribute(
3743     globus_soap_message_handle_t        handle,
3744     const xsd_QName *                   attr_name,
3745     xsd_QName *                         val)
3746 3367 {
3747 3367     xmlChar *                           str = NULL;
3748 3367     xmlChar *                           prefix;
3749 3367     const xmlChar *                     attr_ns;
3750 3367     const xmlChar *                     local_ns;
3751 3367     globus_result_t                     result = GLOBUS_SUCCESS;
3752
3753 3367     GlobusFuncName(globus_soap_message_deserialize_QName_attribute);
3754 3367     GlobusSoapMessageDebugEnter();
3755
3756 3367     attr_ns = xmlTextReaderConstString(
3757         handle->reader, (xmlChar *) attr_name->Namespace);
3758 3367     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
3759
3760     /* is it the default or a null namespace? */
3761 3367     if((attr_ns != local_ns) && (attr_ns != NULL) && (*attr_ns != '\0'))
3762     {
3763 0         str = xmlTextReaderGetAttributeNs(
3764             handle->reader, (xmlChar *) attr_name->local, (xmlChar *) attr_name->Namespace);
3765     }
3766     else
3767     {
3768 3367         str = xmlTextReaderGetAttribute(
3769             handle->reader, (xmlChar *) attr_name->local);
3770     }
3771
3772 3367     if((str == NULL || (*str == '\0')))
3773     {
3774 2313         result = GlobusSoapMessageErrorAttributeNotFound(
3775                 handle->verbose,
3776                 attr_name);
3777 2313         goto exit;
3778     }
3779     else
3780     {
3781 1054         val->local = (char *) xmlSplitQName2(str, &prefix);
3782 1054         if(prefix)
3783         {
3784 1042             val->Namespace = (char *) xmlTextReaderLookupNamespace(
3785                 handle->reader, prefix);
3786 1042             xmlFree(prefix);
3787         }
3788         else
3789         {
3790 12             val->Namespace = NULL;
3791 12             if (val->local == NULL)
3792             {
3793 12                 val->local = globus_libc_strdup((char *) str);
3794             }
3795         }
3796     }
3797
3798  exit:
3799
3800 3367     if (str != NULL)
3801     {
3802 1054         xmlFree(str);
3803     }
3804
3805 3367     GlobusSoapMessageDebugExit();
3806 3367     return result;
3807 }
3808
3809 globus_result_t
3810 globus_soap_message_deserialize_QName_list(
3811     globus_soap_message_handle_t        handle,
3812     xsd_QName_array *                   inst)
3813 0 {
3814 0     const xmlChar *                     tmp_value;
3815 0     globus_list_t *                     qnames = NULL;
3816 0     globus_list_t *                     qnlist = NULL;
3817 0     globus_result_t                     result = GLOBUS_SUCCESS;
3818 0     GlobusFuncName(globus_soap_message_deserialize_QName_list);
3819 0     GlobusSoapMessageDebugEnter();
3820
3821 0     result = globus_i_soap_message_deserialize_next_content(handle);
3822 0     if(result != GLOBUS_SUCCESS)
3823     {
3824 0         result = GlobusSoapMessageErrorDeserializeFailed(
3825             result, &xsd_QName_qname);
3826 0         goto exit;
3827     }
3828     
3829 0     tmp_value = xmlTextReaderConstValue(handle->reader);
3830 0     if(!tmp_value)
3831     {
3832 0         result = GlobusSoapMessageErrorDeserializeFailed(
3833             result, &xsd_QName_qname);
3834 0         goto exit;
3835     }
3836
3837 0     globus_i_soap_message_split_qnames(tmp_value, &qnames);
3838 0     qnlist = qnames;
3839 0     while(!globus_list_empty(qnlist))
3840     {
3841 0         char *                          str = globus_list_first(qnlist);
3842 0         xmlChar *                       prefix = NULL;
3843 0         xsd_QName *                     val;
3844
3845 0         val = xsd_QName_array_push(inst);
3846         
3847 0         val->local = (char *) xmlSplitQName2((xmlChar *) str, &prefix);
3848 0         val->Namespace = (char *) xmlTextReaderLookupNamespace(
3849             handle->reader, prefix);
3850
3851 0         globus_free(str);
3852 0         qnlist = globus_list_rest(qnlist);
3853     }
3854     
3855 0     globus_list_destroy_all(qnames, globus_libc_free);
3856     
3857  exit:
3858
3859 0     GlobusSoapMessageDebugExit();
3860 0     return result;
3861 }
3862
3863 globus_result_t
3864 globus_soap_message_deserialize_QName_attribute_list(
3865     globus_soap_message_handle_t        handle,
3866     const xsd_QName *                   attr_qname,
3867     xsd_QName_array *                   inst)
3868 10 {
3869 10     const xmlChar *                     attr_ns = NULL;
3870 10     const xmlChar *                     local_ns = NULL;
3871 10     xmlChar *                           tmp_value;
3872 10     globus_list_t *                     qnames = NULL;
3873 10     globus_list_t *                     qnlist = NULL;
3874 10     globus_result_t                     result = GLOBUS_SUCCESS;
3875 10     GlobusFuncName(globus_soap_message_deserialize_QName_attribute_list);
3876 10     GlobusSoapMessageDebugEnter();
3877
3878 10     attr_ns = xmlTextReaderConstString(
3879         handle->reader, (xmlChar *) attr_qname->Namespace);
3880 10     local_ns = xmlTextReaderConstNamespaceUri(handle->reader);
3881
3882 10     if(attr_ns != local_ns  && (attr_ns != NULL) && (*attr_ns != '\0'))
3883     {
3884 0         tmp_value = xmlTextReaderGetAttributeNs(
3885             handle->reader, (xmlChar *) attr_qname->local, (xmlChar *) attr_qname->Namespace);
3886     }
3887     else
3888     {
3889 10         tmp_value = xmlTextReaderGetAttribute(
3890             handle->reader, (xmlChar *) attr_qname->local);
3891     }
3892
3893 10     if((!tmp_value) || !(*tmp_value))
3894     {
3895 0         result = GlobusSoapMessageErrorDeserializeFailed(
3896             result, &xsd_QName_qname);
3897 0         goto exit;
3898     }
3899
3900 10     globus_i_soap_message_split_qnames(tmp_value, &qnames);
3901 10     qnlist = qnames;
3902 24     while(!globus_list_empty(qnlist))
3903     {
3904 14         xmlChar *                       str = globus_list_first(qnlist);
3905 14         xmlChar *                       prefix = NULL;
3906 14         xsd_QName *                     val;
3907
3908 14         val = xsd_QName_array_push(inst);
3909         
3910 14         val->local = (char *) xmlSplitQName2(str, &prefix);
3911 14         val->Namespace = (char *) xmlTextReaderLookupNamespace(
3912             handle->reader, prefix);
3913
3914 14         qnlist = globus_list_rest(qnlist);
3915     }
3916     
3917 10     globus_list_destroy_all(qnames, globus_libc_free);
3918     
3919  exit:
3920
3921 10     GlobusSoapMessageDebugExit();
3922 10     return result;
3923 }
3924
3925 globus_result_t
3926 globus_soap_message_deserialize_mark(
3927     globus_soap_message_handle_t        handle,
3928     const char *                        idval)
3929 0 {
3930 0     globus_result_t                     result = GLOBUS_SUCCESS;
3931 0     GlobusFuncName(globus_soap_message_deserialize_mark);
3932 0     GlobusSoapMessageDebugEnter();
3933
3934 0     GlobusSoapMessageDebugPrintf(
3935 GLOBUS_SOAP_MESSAGE_DEBUG_DEBUG,
3936 ("SETTING MARK: %s\n", idval));
3937
3938 0     if(handle->xio_handle)
3939     {
3940 0 result = globus_xio_handle_cntl(
3941     handle->xio_handle, globus_i_soap_message_buffer_driver,
3942     GLOBUS_XIO_BUFFER_SET_READ_MARKER_AT_INDEX,
3943     idval,
3944     xmlTextReaderReadPosition(handle->reader));
3945 0 if(result != GLOBUS_SUCCESS)
3946 {
3947 0     result = GlobusSoapMessageErrorWithMarker(
3948 result, "Failed to set read marker: %s", idval);
3949     goto exit;
3950 }
3951     }
3952
3953  exit:
3954     
3955 0     GlobusSoapMessageDebugExit();
3956 0     return result;
3957 }
3958
3959 globus_result_t
3960 globus_soap_message_deserialize_concrete_path(
3961     globus_soap_message_handle_t        handle,
3962     xsd_anyURI *                        namespace,
3963     xsd_NCName_array *                  path)
3964 39 {
3965 39     xmlChar *                           prefix;
3966 39     const char *                        tmp_value;
3967 39     xmlChar *                           token;
3968 39     globus_result_t                     result = GLOBUS_SUCCESS;
3969 39     int                                 start_token;
3970 39     int                                 end_token;
3971 39     xmlChar *                           val;
3972 39     xsd_NCName *                        el;
3973
3974 39     GlobusFuncName(globus_soap_message_deserialize_concrete_path);
3975 39     GlobusSoapMessageDebugEnter();
3976
3977 39     result = globus_i_soap_message_deserialize_next_content(handle);
3978 39     if(result != GLOBUS_SUCCESS)
3979     {
3980 0         result = GlobusSoapMessageErrorDeserializeFailed(
3981             result, &xsd_QName_qname);
3982 0         goto exit;
3983     }
3984     
3985 39     tmp_value = (const char *) xmlTextReaderConstValue(handle->reader);
3986 39     if(!tmp_value)
3987     {
3988 0         result = GlobusSoapMessageErrorDeserializeFailed(
3989             result, &xsd_QName_qname);
3990 0         goto exit;
3991     }
3992 39     token = (xmlChar *) globus_l_soap_message_my_strtok(
3993         tmp_value,
3994         strlen(tmp_value), &start_token, &end_token, "\n\t /");
3995 39     if (token == NULL)
3996     {
3997 0         result = GlobusSoapMessageErrorDeserializeFailed(
3998             result, &xsd_QName_qname);
3999 0         goto exit;
4000     }
4001
4002 39     val = xmlSplitQName2(token, &prefix);
4003 39     el = xsd_NCName_array_push(path);
4004 39     *el = (xsd_NCName) val;
4005 39     if(prefix)
4006     {
4007 39         *namespace = (xsd_anyURI) xmlTextReaderLookupNamespace(handle->reader, prefix);
4008 39         xmlFree(prefix);
4009     }
4010 39     free(token);
4011 39     tmp_value += end_token;
4012
4013 62     do
4014     {
4015 62         token = (xmlChar *) globus_l_soap_message_my_strtok(
4016             tmp_value, strlen(tmp_value), &start_token, &end_token, "\n\t /");
4017 62         tmp_value += end_token;
4018
4019 62         if (token != NULL && strlen((char *) token) != 0)
4020         {
4021 43             el = xsd_NCName_array_push(path);
4022 43             *el = (xsd_NCName) token;
4023         }
4024 62     }
4025     while (token != NULL && end_token != -1);
4026
4027  exit:
4028
4029 39     GlobusSoapMessageDebugExit();
4030 39     return result;
4031 }
4032 /* globus_soap_message_deserialize_concrete_path() */
4033
4034 static
4035 xmlChar *
4036 globus_l_soap_message_numeric_content(
4037     const xmlChar *                     content,
4038     globus_bool_t                       negative_ok)
4039 208 {
4040 208     xmlChar *                           tmp;
4041 208     xmlChar *                           tmp_start;
4042 208     xmlChar *                           tmp_end;
4043
4044 208     tmp = (xmlChar *) globus_libc_strdup((char *) content);
4045 208     tmp_start = tmp;
4046
4047 1054     while(*tmp_start && isspace(*tmp_start))
4048     {
4049 846         tmp_start++;
4050     }
4051 208     if (*tmp_start == '+')
4052     {
4053 5         negative_ok = GLOBUS_FALSE;
4054 5         tmp_start++;
4055     }
4056 208     if ((negative_ok ? (*tmp_start != '-') : 1)
4057             && !isdigit(*tmp_start))
4058     {
4059 18         free(tmp);
4060 18         return NULL;
4061     }
4062 190     tmp_end = tmp_start;
4063
4064 190     if (negative_ok && *tmp_end == '-')
4065     {
4066 12         tmp_end++;
4067     }
4068 919     while (*tmp_end && isdigit(*tmp_end))
4069     {
4070 729         tmp_end++;
4071     }
4072
4073 190     if (*tmp_end && isspace(*tmp_end))
4074     {
4075 49         *tmp_end = '\0';
4076 49         tmp_end++;
4077     }
4078 826     while (*tmp_end && isspace(*tmp_end))
4079     {
4080 636         tmp_end++;
4081     }
4082 190     if (*tmp_end)
4083     {
4084 6         free(tmp);
4085         /* garbage at end */
4086 6         return NULL;
4087     }
4088 184     memmove(tmp, tmp_start, tmp_end-tmp_start);
4089 184     return tmp;
4090 }
4091 /* globus_l_soap_message_numeric_content() */
4092
4093 globus_result_t
4094 globus_soap_message_deserialize_get_prefixes(
4095     globus_soap_message_handle_t        handle,
4096     xsd_string_array *                  namespace_prefixes)
4097 744444 {
4098 744444     xsd_string *                        new_string;
4099 744444     xmlNsPtr *                          ns_list;
4100 744444     globus_result_t                     result = GLOBUS_SUCCESS;
4101 744444     int                                 i;
4102 744444     GlobusFuncName(globus_soap_message_get_prefixes);
4103 744444     GlobusSoapMessageDebugEnter();
4104
4105 744444     result = xsd_string_array_init_contents(namespace_prefixes);
4106
4107 744444     if (result != GLOBUS_SUCCESS)
4108     {
4109 0         goto out;
4110     }
4111 744444     handle->doc_to_free = xmlTextReaderCurrentDoc(handle->reader);
4112 744444     ns_list = xmlGetNsList(
4113             handle->doc_to_free,
4114             xmlTextReaderCurrentNode(handle->reader));
4115
4116 744444     if (ns_list != NULL)
4117     {
4118 4708078         for (i = 0; ns_list[i] != NULL; i++)
4119         {
4120 3963634             if (ns_list[i]->prefix != NULL)
4121             {
4122 3222759                 new_string = xsd_string_array_push(namespace_prefixes);
4123
4124 3222759                 if (new_string == NULL)
4125                 {
4126 0                     result = GlobusSoapMessageErrorOutOfMemory;
4127
4128 0                     goto free_nslist;
4129                 }
4130 3222759                 *new_string = globus_common_create_string(
4131                         "%s=%s",
4132                         ns_list[i]->prefix,
4133                         ns_list[i]->href);
4134 3222759                 if (*new_string == NULL)
4135                 {
4136 0                     goto free_nslist;
4137                 }
4138             }
4139         }
4140     }
4141
4142 free_nslist:
4143 744444     if (ns_list != NULL)
4144     {
4145 744444         xmlFree(ns_list);
4146     }
4147 744444     if (result != GLOBUS_SUCCESS)
4148     {
4149 0         xsd_string_array_destroy_contents(namespace_prefixes);
4150     }
4151 out:
4152 744444     return result;
4153 }