(file) Return to util.c CVS log (file) (dir) Up to [OMI] / omi / indication / common

 1 krisbash 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 krisbash 1.1 **==============================================================================
23              */
24              
25              #include "indicommon.h"
26              #include <pal/atomic.h>
27              #include <pal/strings.h>
28              
29              typedef struct _LifecycleIndicationClass
30              {
31                  MI_ConstString name;
32                  SubscriptionTargetType targetType;
33              }LifecycleIndicationClass;
34              
35              /* list of lifecycle classes */
36              LifecycleIndicationClass g_cLifecycleClasses[] = {
37                  { MI_T("CIM_InstIndication"), SUBSCRIP_TARGET_LIFECYCLE_ALL },
38                  { MI_T("CIM_InstCreation"), SUBSCRIP_TARGET_LIFECYCLE_CREATE },
39                  { MI_T("CIM_InstModification"), SUBSCRIP_TARGET_LIFECYCLE_MODIFY },
40                  { MI_T("CIM_InstDeletion"), SUBSCRIP_TARGET_LIFECYCLE_DELETE },
41                  { MI_T("CIM_InstRead"), SUBSCRIP_TARGET_LIFECYCLE_READ },
42                  { MI_T("CIM_InstMethodCall"), SUBSCRIP_TARGET_LIFECYCLE_METHODCALL },
43 krisbash 1.1     { NULL, SUBSCRIP_TARGET_UNSUPPORTED},
44              };
45              
46              /* 
47              * Get SubscriptionTargetType if given class is lifecycle class,
48              * otherwise return SUBSCRIP_TARGET_DEFAULT;
49              */
50              _Use_decl_annotations_
51              SubscriptionTargetType GetSubscriptionTargetType(MI_ConstString name)
52              {
53                  LifecycleIndicationClass *cls;
54                  DEBUG_ASSERT(name);
55                  cls = &g_cLifecycleClasses[0];
56                  while (cls->name)
57                  {
58                      if (Tcscasecmp(cls->name, name) == 0)
59                          return cls->targetType;
60                      cls++;
61                  }
62                  return SUBSCRIP_TARGET_DEFAULT;
63              }
64 krisbash 1.1 
65              /* global subscription ID variable */
66              ptrdiff_t g_SubscriptionID = 1;
67              
68              /* Generate an unique subscription ID */
69              MI_Uint64 GenerateSubscriptionID()
70              {
71                  return (MI_Uint64)Atomic_Inc(&g_SubscriptionID);
72              }
73              

ViewCVS 0.9.2