| 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_soap_message.h" | |
| 19 | ||
| 20 | int | |
| 21 | xsd_QName_strcmp( | |
| 22 | char * s1, | |
| 23 | char * s2) | |
| 24 | 15766940 | { |
| 25 | GlobusFuncName(globus_l_xsd_safe_strcmp); | |
| 26 | 15766940 | return (s1 == s2 || |
| 27 | (s1 && s2 && strcmp(s1, s2) == 0)); | |
| 28 | } | |
| 29 | ||
| 30 | int | |
| 31 | xsd_QName_keyeq( | |
| 32 | void * qname1, | |
| 33 | void * qname2) | |
| 34 | 8071003 | { |
| 35 | 8071003 | xsd_QName * q1 = qname1; |
| 36 | 8071003 | xsd_QName * q2 = qname2; |
| 37 | GlobusFuncName(xsd_QName_keyeq); | |
| 38 | ||
| 39 | 8071003 | return (q1 == q2) || (q1 && q2 && |
| 40 | xsd_QName_strcmp(q1->Namespace, q2->Namespace) && | |
| 41 | xsd_QName_strcmp(q1->local, q2->local)); | |
| 42 | } | |
| 43 | ||
| 44 | int | |
| 45 | xsd_QName_hash( | |
| 46 | void * qname, | |
| 47 | int limit) | |
| 48 | 19309186 | { |
| 49 | 19309186 | unsigned long h = 0; |
| 50 | unsigned long g; | |
| 51 | char * key; | |
| 52 | 19309186 | xsd_QName * q = qname; |
| 53 | GlobusFuncName(xsd_QName_hash); | |
| 54 | ||
| 55 | 19309186 | key = q->Namespace; |
| 56 | ||
| 57 | 19309186 | if (key) |
| 58 | { | |
| 59 | 733372188 | while (*key) |
| 60 | { | |
| 61 | 694763242 | h = (h << 4) + *key++; |
| 62 | ||
| 63 | 694763242 | if ((g = (h & 0xF0000000UL))) |
| 64 | { | |
| 65 | 558483305 | h ^= g >> 24; |
| 66 | 558483305 | h ^= g; |
| 67 | } | |
| 68 | } | |
| 69 | } | |
| 70 | 19309186 | key = q->local; |
| 71 | 19309186 | if (key) |
| 72 | { | |
| 73 | 337894587 | while (*key) |
| 74 | { | |
| 75 | 299281853 | h = (h << 4) + *key++; |
| 76 | ||
| 77 | 299281853 | if ((g = (h & 0xF0000000UL))) |
| 78 | { | |
| 79 | 225830242 | h ^= g >> 24; |
| 80 | 225830242 | h ^= g; |
| 81 | } | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | 19309186 | return h % limit; |