(file) Return to classdecl.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 <assert.h>
26           #include "classdecl.h"
27           #include "naming.h"
28           #include "strings.h"
29           
30           static MI_Uint32 _Find(
31               MI_FeatureDecl** data,
32               MI_Uint32 size,
33               const MI_Char* name)
34           {
35               MI_Uint32 code;
36               MI_Uint32 i;
37           
38               /* Zero-length CIM names are illegal */
39               if (*name == '\0')
40                   return (MI_Uint32)-1;
41           
42               /* Calculate hash code */
43 mike  1.1     code = Hash(name);
44           
45               /* Find the object */
46               for (i = 0; i < size; i++)
47               {
48                   const MI_FeatureDecl* p = data[i];
49                   if (p->code == code && Zcasecmp(p->name, name) == 0)
50                       return i;
51               }
52           
53               /* Not found */
54               return (MI_Uint32)-1;
55           }
56           
57           MI_MethodDecl* ClassDecl_FindMethodDecl(
58               const MI_ClassDecl* self,
59               const MI_Char* name)
60           {
61               MI_Uint32 i;
62           
63               if (!self || !name)
64 mike  1.1         return NULL;
65           
66               i = _Find((MI_FeatureDecl**)self->methods, self->numMethods, name);
67           
68               return i == (MI_Uint32)-1 ? NULL : self->methods[i];
69           }
70           
71           MI_PropertyDecl* ClassDecl_FindPropertyDecl(
72               const MI_ClassDecl* self,
73               const MI_Char* name)
74           {
75               MI_Uint32 i;
76           
77               if (!self || !name)
78                   return NULL;
79           
80               i = _Find((MI_FeatureDecl**)self->properties, self->numProperties, name);
81           
82               return i == (MI_Uint32)-1 ? NULL : self->properties[i];
83           }

ViewCVS 0.9.2