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 #ifndef _base_naming_h
26 #define _base_naming_h
27
28 #include "config.h"
29 #include <common.h>
|
30 krisbash 1.3 #include <pal/strings.h>
|
31 mike 1.1
32 BEGIN_EXTERNC
33
34 extern const MI_Uint8 __omi_ToLowerTable[256];
35
36 /* Return MI_TRUE if name is a legal CIM name */
|
37 krisbash 1.3 MI_Boolean LegalName(const ZChar* name);
|
38 mike 1.1
39 /* Return lowercase of this character */
40 MI_INLINE MI_Uint8 ToLower(MI_Uint8 x)
41 {
42 return __omi_ToLowerTable[x];
43 }
44
45 /* Return hash code os this name */
|
46 krisbash 1.3 MI_INLINE MI_Uint32 Hash(const ZChar* name)
|
47 mike 1.1 {
|
48 krisbash 1.3 MI_Uint32 n = (MI_Uint32)Tcslen(name);
|
49 mike 1.1
50 if (n == 0)
51 return 0;
52
53 return ToLower((MI_Uint8)name[0]) << 16 |
54 ToLower((MI_Uint8)name[n-1]) << 8 | n;
55 }
56
|
57 krisbash 1.3 /* Determine the length of a name by its code */
58 MI_INLINE MI_Uint32 NameLen(const ZChar* name, MI_Uint32 code)
59 {
60 /* The 8 least signifiant bits of the length (possibly full length) */
61 MI_Uint32 n = code & 0xFF;
62 return name[n] ? (n + (MI_Uint32)Tcslen(name + n)) : n;
63 }
64
|
65 mike 1.1 END_EXTERNC
66
67 #endif /* _base_naming_h */
|