1 karl 1.17 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.10 //
|
3 karl 1.17 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.10 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.13 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.10 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.10 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.13 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.10 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Bob Blair (bblair@bmc.com)
27 //
|
28 gerarda 1.15 // Modified By: Gerarda Marquez (gmarquez@us.ibm.com)
29 // -- PEP 43 changes
|
30 mike 1.10 //
31 //%/////////////////////////////////////////////////////////////////////////////
32
33
34 //
35 // implementation of cimmofMessages class
36
37 #include "cimmofMessages.h"
38 #include <cstdio>
39 #include <iostream> // for debug only
|
40 humberto 1.16 #include <Pegasus/Common/MessageLoader.h> //l10n
41 #include <Pegasus/Common/Formatter.h> //l10n
|
42 mike 1.10
43 PEGASUS_NAMESPACE_BEGIN
44 PEGASUS_USING_STD;
45
46 const cimmofMessages::arglist cimmofMessages::EMPTYLIST;
47
|
48 humberto 1.16 //l10n replaced % sprintf style substitution with $ Formatter style substitution
|
49 mike 1.10 static String _cimmofMessages[] = {
50 "OK", //CIM_ERR_SUCCESS
|
51 humberto 1.16 "$0:$1: $2 before '$3'", //PARSER_SYNTAX_ERROR
52 "Error applying parameter $0 to method $1: $2", //APPLY_PARAMETER_ERROR
53 "Error creating new CIMParameter object $0: $1", //NEW_PARAMETER_ERROR
|
54 mike 1.10 //UNINTIALIZED_PARAMETER_ERROR
|
55 humberto 1.16 "Internal Error: Uninitialized parameter handle $0 in class $1",
|
56 mike 1.10 //METHOD_ALREADY_EXISTS_WARNING
|
57 humberto 1.16 "Warning: CIMMethod $0 already exists for CIMClass $1",
58 "Error applying method $0 to CIMClass $1: $2:", //APPLY_METHOD_ERROR
59 "Error creating new CIMMethod $0: $1", //NEW_METHOD_ERROR
|
60 mike 1.10 "ADD QUALIFIER: ", //ADD_QUALIFIER
61 "[Trace]", //TRACE
|
62 humberto 1.16 "Error adding qualifier declaration $0: $1", //ADD_QUALIFIER_DECL_ERROR
|
63 mike 1.10 "\tOK", //TAB_OK
|
64 humberto 1.16 "Error creating new Qualifier $0: $1", //NEW_QUALIFIER_ERROR
65 "Error adding new Qualifier $0: $1", //ADD_QUALIFIER_ERROR
|
66 mike 1.10 //NEW_QUALIFIER_DECLARATION_ERROR
|
67 humberto 1.16 "Error creating new Qualifier Declaration $0: $1",
|
68 bob 1.11 // GET_QUALIFIER_DECL_ERROR
|
69 humberto 1.16 "Could not find declaration for Qualifier named $0",
|
70 mike 1.10 "ADD INSTANCE: ", //ADD_INSTANCE
71 //UNINITIALIZED_PROPERTY_ERROR
|
72 humberto 1.16 "Internal Error: Uninitialized parameter $1 in class $0",
|
73 mike 1.10 //PROPERTY_ALREADY_EXISTS_WARNING
|
74 humberto 1.16 "Warning: Property $1 already exists in class $0",
75 "Error applying property $1 to class $0: $2", //APPLYING_PROPERTY_ERROR
76 "Error creating new Property $0: $1", //NEW_PROPERTY_ERROR
77 "Error creating new Class Declaration $0: $1", //NEW_CLASS_ERROR
|
78 mike 1.10 "ADD CLASS: ", //ADD_CLASS
|
79 humberto 1.16 "Warning: Class $0 already exists in the repository", //CLASS_EXISTS_WARNING
80 "Error adding class $0 to the repository: $1", //ADD_CLASS_ERROR
|
81 mike 1.10 //SETREPOSITORY_NO_COMPILER_OPTIONS
82 "Internal Error: Compiler options not set before setting repository",
83 //SETREPOSITORY_BLANK_NAME
84 "Internal Error: No repository name was specified to setRepository",
85 //NAMESPACE_CREATE_ERROR
|
86 humberto 1.16 "Error trying to create repository name space $0: $1",
87 "Error trying to create Repository in path $0: $1", //REPOSITORY_CREATE_ERROR
88 "Error trying to create a reference to object $0: $1", //NEW_REFERENCE_ERROR
|
89 mike 1.10 //FIND_CLASS_OF_INSTANCE_ERROR
|
90 humberto 1.16 "Error looking for class of current instance while looking up property $0: $1",
|
91 mike 1.10 // FIND_PROPERTY_VALUE_ERROR
|
92 humberto 1.16 "Error looking up value of property $2 in class $1 (namespace $0): $3",
93 "Error cloning property $0: $1", // CLONING_PROPERTY_ERROR
|
94 mike 1.10 // APPLY_INSTANCE_PROPERTY_ERROR
|
95 humberto 1.16 "Error applying property $0 to an instance of class $1: $2",
|
96 mike 1.10 // GET_INSTANCE_PROPERTY_ERROR
|
97 humberto 1.16 "Error getting property $0 from an instance: $1",
|
98 chuck 1.18 "Error getting class $0 from name space $1: $2", //GET_CLASS_ERROR
|
99 humberto 1.16 "Error getting value of property $0: $1", //GET_PROPERTY_VALUE_ERROR
100 "Error creating new instance of class $0: $1", // NEW_INSTANCE_ERROR
|
101 mike 1.10 // INSTANCE_PROPERTY_EXISTS_WARNING
|
102 humberto 1.16 "Warning: property $1 already exists for this instance of class $0",
|
103 mike 1.10 // INSTANCE_EXISTS_WARNING
|
104 kumpf 1.12 "Warning: the instance already exists.\nIn this"
|
105 mike 1.10 " implementation, that means it cannot be changed.",
|
106 humberto 1.16 "Error adding an instance: $0", // ADD_INSTANCE_ERROR
107 "Error: $0", // GENERAL_ERROR
108 "Warning: Class $0 was not added or updated: $1", //CLASS_NOT_UPDATED
|
109 gerarda 1.15 "Class has the same version", //SAME_VERSION
110 "Experimental update not allowed (set appropriate compiler option)", //NO_EXPERIMENTAL_UPDATE
111 "Version update not allowed (set appropriate compiler option)", //NO_VERSION_UPDATE
112 "Class update not allowed (set appropriate compiler option)", //NO_CLASS_UPDATE
113 "Invalid version format in mof class or repository class (valid format is m.n.u)", //INVALID_VERSION_FORMAT
|
114 mike 1.10 ""
115 };
|
116 humberto 1.16 //l10n
117 static String _cimmofMessagesKeys [] = {
118
119 "Compiler.cimmofMessages.CIM_ERR_SUCCESS",
120 "Compiler.cimmofMessages.PARSER_SYNTAX_ERROR",
121 "Compiler.cimmofMessages.APPLY_PARAMETER_ERROR",
122 "Compiler.cimmofMessages.NEW_PARAMETER_ERROR",
123 "Compiler.cimmofMessages.UNINITIALIZED_PARAMETER_ERROR",
124 "Compiler.cimmofMessages.METHOD_ALREADY_EXISTS_WARNING",
125 "Compiler.cimmofMessages.APPLY_METHOD_ERROR",
126 "Compiler.cimmofMessages.NEW_METHOD_ERROR",
127 "Compiler.cimmofMessages.ADD_QUALIFIER",
128 "Compiler.cimmofMessages.TRACE",
129 "Compiler.cimmofMessages.ADD_QUALIFIER_DECL_ERROR",
130 "Compiler.cimmofMessages.TAB_OK",
131 "Compiler.cimmofMessages.NEW_QUALIFIER_ERROR",
132 "Compiler.cimmofMessages.ADD_QUALIFIER_ERROR",
133 "Compiler.cimmofMessages.NEW_QUALIFIER_DECLARATION_ERROR",
134 "Compiler.cimmofMessages.GET_QUALIFIER_DECL_ERROR",
135 "Compiler.cimmofMessages.ADD_INSTANCE",
136 "Compiler.cimmofMessages.UNINITIALIZED_PROPERTY_ERROR",
137 humberto 1.16 "Compiler.cimmofMessages.PROPERTY_ALREADY_EXISTS_WARNING",
138 "Compiler.cimmofMessages.APPLYING_PROPERTY_ERROR",
139 "Compiler.cimmofMessages.NEW_PROPERTY_ERROR",
140 "Compiler.cimmofMessages.NEW_CLASS_ERROR",
141 "Compiler.cimmofMessages.ADD_CLASS",
142 "Compiler.cimmofMessages.CLASS_EXISTS_WARNING",
143 "Compiler.cimmofMessages.ADD_CLASS_ERROR",
144 "Compiler.cimmofMessages.SETREPOSITORY_NO_COMPILER_OPTIONS",
145 "Compiler.cimmofMessages.SETREPOSITORY_BLANK_NAME",
146 "Compiler.cimmofMessages.NAMESPACE_CREATE_ERROR",
147 "Compiler.cimmofMessages.REPOSITORY_CREATE_ERROR",
148 "Compiler.cimmofMessages.NEW_REFERENCE_ERROR",
149 "Compiler.cimmofMessages.FIND_CLASS_OF_INSTANCE_ERROR",
150 "Compiler.cimmofMessages.FIND_PROPERTY_VALUE_ERROR",
151 "Compiler.cimmofMessages.CLONING_PROPERTY_ERROR",
152 "Compiler.cimmofMessages.APPLY_INSTANCE_PROPERTY_ERROR",
153 "Compiler.cimmofMessages.GET_INSTANCE_PROPERTY_ERROR",
|
154 chuck 1.18 "Compiler.cimmofMessages.GET_CLASS_ERROR",
|
155 humberto 1.16 "Compiler.cimmofMessages.GET_PROPERTY_VALUE_ERROR",
156 "Compiler.cimmofMessages.NEW_INSTANCE_ERROR",
157 "Compiler.cimmofMessages.INSTANCE_PROPERTY_EXISTS_WARNING",
158 "Compiler.cimmofMessages.INSTANCE_EXISTS_WARNING",
159 "Compiler.cimmofMessages.ADD_INSTANCE_ERROR",
160 "Compiler.cimmofMessages.GENERAL_ERROR",
161 "Compiler.cimmofMessages.CLASS_NOT_UPDATED",
162 "Compiler.cimmofMessages.SAME_VERSION",
163 "Compiler.cimmofMessages.NO_EXPERIMENTAL_UPDATE",
164 "Compiler.cimmofMessages.NO_VERSION_UPDATE",
165 "Compiler.cimmofMessages.NO_CLASS_UPDATE",
166 "Compiler.cimmofMessages.INVALID_VERSION_FORMAT",
167 "Compiler.cimmofMessages.END"
168
169 };
170
|
171 mike 1.10
172 const String &
173 cimmofMessages::msgCodeToString(MsgCode code)
|
174 humberto 1.16 {
175 return _cimmofMessages[(unsigned int)code];
|
176 mike 1.10 }
177
178 static int
179 find(const String &haystack, const String &needle)
180 {
181 unsigned int size = haystack.size();
182 unsigned int npos = 0;
183 unsigned int nsize = needle.size();
184 for (unsigned int i = 0; i < size; i++) {
185 if (haystack[i] == '\\')
186 i++;
187 if (haystack[i] == needle[npos]) {
188 npos++;
189 if (npos >= nsize)
190 return ( (int)(i - nsize + 1) );
191 } else {
192 npos = 0;
193 }
194 }
195 return -1;
196 }
197 mike 1.10
198 static void
199 replace(String &s, unsigned int pos, unsigned int len, const String &r)
200 {
201 String s1 = s.subString(0, pos) + r + s.subString(pos + len);
202 s = s1;
203 }
204
205 void
206 cimmofMessages::getMessage(String &out, MsgCode code, const arglist &args)
207 {
|
208 humberto 1.16 //l10n
209 Array<String> _args;
210 for (unsigned int i = 0; i < 10; i++) {
211 if(i < args.size())
212 _args.append(args[i]);
213 else
214 _args.append("");
|
215 mike 1.10 }
|
216 humberto 1.16
217 MessageLoaderParms parms(_cimmofMessagesKeys[(unsigned int)code],
218 _cimmofMessages[(unsigned int)code],
219 _args[0],_args[1],_args[2],_args[3],_args[4],
220 _args[5],_args[6],_args[7],_args[8],_args[9]);
221
222 out = MessageLoader::getMessage(parms);
223
224 //String s = msgCodeToString(code);
225 //out = s;
226 //int pos;
227 //for (unsigned int i = 0; i < args.size(); i++) {
228 //int state = 0;
229 //char buf[40];
230 //sprintf(buf, "%d", i + 1);
231 //String srchstr = "%";
232 //srchstr.append(buf);
233 //if ( (pos = find(out, srchstr)) != -1 ) {
234 //replace(out, pos, srchstr.size(), args[i]);
235 //}
236 //}
|
237 mike 1.10 }
238
239 PEGASUS_NAMESPACE_END
|