115{
116
117
118
119
120
121
122
123
124 if(filenames.size()==0) return false;
125
127 if(filename_vec.size() == 0) return false;
128
129 vector<string>::const_iterator filename_iter;
130 for(filename_iter = filename_vec.begin();
131 filename_iter != filename_vec.end(); ++filename_iter)
132 {
133
135
137 << "Reading msg stream priorities from XML file: " << filename;
138
139 xmlDocPtr xml_doc = xmlParseFile(filename.c_str());
140 if(xml_doc==NULL) {
142 << "XML file could not be parsed! [file: " << filename << "]";
143 return false;
144 }
145
146 xmlNodePtr xml_root = xmlDocGetRootElement(xml_doc);
147 if(xml_root==NULL) {
149 << "XML doc. has null root element! [file: " << filename << "]";
150 xmlFreeDoc(xml_doc);
151 return false;
152 }
153
154 if( xmlStrcmp(xml_root->name, (const xmlChar *) "messenger_config") ) {
156 << "XML doc. has invalid root element! [file: " << filename << "]";
157 xmlFreeNode(xml_root);
158 xmlFreeDoc(xml_doc);
159 return false;
160 }
161
162 xmlNodePtr xml_msgp = xml_root->xmlChildrenNode;
163
164
165 while (xml_msgp != NULL) {
166
167
168 if( (!xmlStrcmp(xml_msgp->name, (const xmlChar *) "priority")) ) {
169
172 string priority =
174 xml_doc, xml_msgp->xmlChildrenNode, 1));
178 << "Set priority level: " << setfill('.')
179 << setw(24) << msgstream << " --> " << priority;
180 }
181 xml_msgp = xml_msgp->next;
182 }
183
184
185 xmlFreeNode(xml_msgp);
186 xmlFreeDoc(xml_doc);
187 }
188
189 return true;
190}
log4cpp::Priority::Value PriorityFromString(string priority)
void SetPriorityLevel(const char *stream, log4cpp::Priority::Value p)
string TrimSpaces(string input)
vector< string > Split(string input, string delim)
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
string TrimSpacesClean(xmlChar *xmls)