(file) Return to schemadecl.c CVS log (file) (dir) Up to [OMI] / omi / base

 1 mike  1.1 /*
 2           **==============================================================================
 3           **
 4           ** Open Management Infrastructure (OMI)
 5           **
 6           ** Copyright (c) Microsoft Corporation
 7           ** 
 8           ** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 9           ** use this file except in compliance with the License. You may obtain a copy 
10           ** of the License at 
11           **
12           **     http://www.apache.org/licenses/LICENSE-2.0 
13           **
14           ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15           ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
16           ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
17           ** MERCHANTABLITY OR NON-INFRINGEMENT. 
18           **
19           ** See the Apache 2 License for the specific language governing permissions 
20           ** and limitations under the License.
21           **
22 mike  1.1 **==============================================================================
23           */
24           
25           #include "schemadecl.h"
26           #include "naming.h"
27           
28           static MI_Uint32 _Find(
29               MI_FeatureDecl** data,
30               MI_Uint32 size,
31               const MI_Char* name)
32           {
33               MI_Uint32 code;
34               MI_Uint32 i;
35           
36               /* Zero-length CIM names are illegal */
37               if (*name == '\0')
38                   return (MI_Uint32)-1;
39           
40               /* Calculate hash code */
41               code = Hash(name);
42           
43 mike  1.1     /* Find the object */
44               for (i = 0; i < size; i++)
45               {
46                   const MI_FeatureDecl* p = data[i];
47                   if (p->code == code && Zcasecmp(p->name, name) == 0)
48                       return i;
49               }
50           
51               /* Not found */
52               return (MI_Uint32)-1;
53           }
54           
55           MI_ClassDecl* SchemaDecl_FindClassDecl(
56               const MI_SchemaDecl* self,
57               const MI_Char* name)
58           {
59               MI_Uint32 i;
60           
61               if (!self || !name)
62                   return NULL;
63               
64 mike  1.1     i = _Find((MI_FeatureDecl**)self->classDecls, self->numClassDecls, name);
65               return i == (MI_Uint32)-1 ? NULL : self->classDecls[i];
66           }
67           
68           MI_MethodDecl* SchemaDecl_FindMethodDecl(
69               const MI_ClassDecl* cd,
70               const MI_Char* name)
71           {
72               MI_Uint32 i;
73           
74               if (!cd || !name)
75                   return NULL;
76               
77               i = _Find((MI_FeatureDecl**)cd->methods, cd->numMethods, name);
78               return i == (MI_Uint32)-1 ? NULL : cd->methods[i];
79           }

ViewCVS 0.9.2