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

 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 "wql.h"
26 krisbash 1.3 #include <pal/strings.h>
27              #include <pal/format.h>
28 mike     1.1 
29              int WQL_Identical(const WQL* x, const WQL* y)
30              {
31                  size_t i;
32              
33                  if (!x || !y)
34                      return 0;
35                  /* Check properties */
36                  {
37                      if (x->nproperties != y->nproperties)
38                          return 0;
39              
40                      for (i = 0; i < x->nproperties; i++)
41                      {
42 krisbash 1.3             if (Tcscmp(x->properties[i], y->properties[i]) != 0)
43 mike     1.1                 return 0;
44                      }
45                  }
46              
47                  /* Check classname */
48 krisbash 1.3     if (Tcscmp(x->className, y->className) != 0)
49 mike     1.1         return 0;
50              
51                  /* Check symbols */
52                  {
53                      if (x->nsymbols != y->nsymbols)
54                          return 0;
55              
56                      for (i = 0; i < x->nsymbols; i++)
57                      {
58                          const WQL_Symbol* sx = &x->symbols[i];
59                          const WQL_Symbol* sy = &y->symbols[i];
60              
61                          if (sx->type != sy->type)
62                              return 0;
63              
64                          switch (sx->type)
65                          {
66                              case WQL_TYPE_IDENTIFIER:
67                              case WQL_TYPE_STRING:
68                              {
69 krisbash 1.3                     if (Tcscmp(sx->value.string, sy->value.string) != 0)
70 mike     1.1                         return 0;
71                                  break;
72                              }
73                              case WQL_TYPE_BOOLEAN:
74                                  if (sx->value.boolean != sy->value.boolean)
75                                      return 0;
76                                  break;
77                              case WQL_TYPE_INTEGER:
78                                  if (sx->value.integer != sy->value.integer)
79                                      return 0;
80                                  break;
81                              case WQL_TYPE_REAL:
82                                  if (sx->value.boolean != sy->value.boolean)
83                                      return 0;
84                                  break;
85                              default:
86                                  break;
87                          }
88                      }
89                  }
90              
91 mike     1.1     /* Identical! */
92                  return 1;
93              }

ViewCVS 0.9.2