1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* http://www.i-scream.org.uk |
4 |
+ |
* Copyright (C) 2000-2002 i-scream |
5 |
+ |
* |
6 |
+ |
* This program is free software; you can redistribute it and/or |
7 |
+ |
* modify it under the terms of the GNU General Public License |
8 |
+ |
* as published by the Free Software Foundation; either version 2 |
9 |
+ |
* of the License, or (at your option) any later version. |
10 |
+ |
* |
11 |
+ |
* This program is distributed in the hope that it will be useful, |
12 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
+ |
* GNU General Public License for more details. |
15 |
+ |
* |
16 |
+ |
* You should have received a copy of the GNU General Public License |
17 |
+ |
* along with this program; if not, write to the Free Software |
18 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
+ |
*/ |
20 |
+ |
|
21 |
|
#include "SysMon.h" |
22 |
|
|
23 |
|
SysMon::SysMon( Config config, int printDebug){ |
31 |
|
// setup some standard variables |
32 |
|
sequence = 0; // no packets sent yet |
33 |
|
|
14 |
– |
// get our values from config |
15 |
– |
|
16 |
– |
|
34 |
|
// setup our arrays |
35 |
|
titlepointer = 0; |
36 |
< |
for ( int i=0; i < 40; i++ ){ |
36 |
> |
for ( int i=0; i < max_titles; i++ ){ |
37 |
|
titles[i] = ""; |
38 |
|
values[i] = ""; |
39 |
|
} |
45 |
|
int SysMon::collect(){ |
46 |
|
if ( debug == 1 ){ |
47 |
|
std::cout << "SysMon::collect()\n"; |
48 |
< |
} |
48 |
> |
} // if |
49 |
|
|
50 |
|
// say we have checked again |
51 |
|
checks++; |
52 |
|
|
53 |
|
// collect the system data and place it in an array of strings. |
54 |
|
// presume that the data is all formtted correctly. |
55 |
< |
char input[2048]; |
55 |
> |
|
56 |
|
if ( debug == 1 ){ |
57 |
|
std::cout << "SysMon::collect::ipipestream\n"; |
58 |
|
} |
59 |
< |
// ipipestream p("statgrab.pl"); |
60 |
< |
p = new SubPipe("statgrab.pl"); |
59 |
> |
|
60 |
> |
p = new SubPipe("./statgrab.pl"); |
61 |
|
|
62 |
|
// get the output into input from statgrab |
63 |
|
string sinput; |
64 |
< |
while ( p->getLine(&sinput) ){ |
48 |
< |
// find the first non-whitespace char in input |
64 |
> |
while ( p->getLine(&sinput) == 0 ){ |
65 |
|
|
66 |
+ |
if ( titlepointer == max_titles ){ |
67 |
+ |
std::cout << "WARNING: Max Titles reached, skipping remaining" << endl; |
68 |
+ |
std::cout << "Try recompiling with a value greater than the current (" << max_titles << ")" << endl; |
69 |
+ |
titlepointer--; |
70 |
+ |
break; |
71 |
+ |
} // if |
72 |
+ |
|
73 |
|
// locate the first white space |
74 |
|
int found = sinput.find(" ",0); |
75 |
|
if ( found == string::npos ){ |
76 |
|
// error |
77 |
|
if ( debug == 1 ){ |
78 |
|
std::cout << "SysMon::collect::Parse error from statgrab.pl\n"; |
79 |
< |
} |
79 |
> |
} // if |
80 |
|
} else { |
81 |
|
int gotTitle = 0; |
82 |
|
// now use the array of titles and values |
83 |
< |
for ( int i = 0; i < 60; i++ ){ |
83 |
> |
for ( int i = 0; i < max_titles; i++ ){ |
84 |
|
// check against the array value |
85 |
|
if ( titles[i] == sinput.substr(0,found) ){ |
86 |
|
// is the one we are looking for. |
87 |
|
if ( debug == 2 ){ |
88 |
|
std::cout << "SysMon::collect::Found Value\n"; |
89 |
< |
|
90 |
< |
} |
89 |
> |
} // if debug |
90 |
> |
|
91 |
|
gotTitle = 1; |
92 |
|
// now modify the data in the arrays if they are numbers |
93 |
< |
char * end; |
71 |
< |
char *buffer; |
72 |
< |
// buffer = sinput.substr(found+1, sinput.length()); |
73 |
< |
double dbl = strtod( ((string) sinput.substr(found+1, sinput.length())).c_str(), &end); |
74 |
< |
if ( dbl == 0 ){ |
75 |
< |
// error? we aren't so sure. check the position |
76 |
< |
// of end. |
77 |
< |
if ( *end == sinput.length()-1 ){ |
78 |
< |
// was the end.. ok |
79 |
< |
// must have worked! |
80 |
< |
double dbl2 = 0; //strtod(values[i], &end); |
81 |
< |
dbl2 += dbl; |
82 |
< |
char * buffer; |
83 |
< |
int precision = 5; |
84 |
< |
int decimal, sign; |
85 |
< |
buffer = ecvt (dbl2, precision, &decimal, &sign); |
86 |
< |
} // if *end |
87 |
< |
} else { |
88 |
< |
// must have worked! |
89 |
< |
double dbl2 = 0; //strtod(values[i], &end); |
90 |
< |
dbl2 += dbl; |
91 |
< |
char * buffer; |
92 |
< |
int precision = 5; |
93 |
< |
int decimal, sign; |
94 |
< |
buffer = ecvt (dbl2, precision, &decimal, &sign); |
95 |
< |
} // if |
96 |
< |
} // if |
93 |
> |
} // if (titles[i]) |
94 |
|
} // for |
95 |
+ |
|
96 |
|
// did we find this title? if not add it |
97 |
|
if ( gotTitle == 0 ){ |
98 |
|
// didnt |
99 |
|
if ( debug == 1 ){ |
100 |
< |
std::cout << "SysMon::collect::Adding New Value\n"; |
101 |
< |
std::cout << "'" << sinput.substr(0,found) << "'\n"; |
102 |
< |
std::cout << "'" << sinput.substr(found+1, sinput.length()) << "'\n"; |
103 |
< |
} |
100 |
> |
std::cout << "SysMon::collect::Adding New Value\n"; |
101 |
> |
std::cout << "'" << sinput.substr(0,found) << "' : "; |
102 |
> |
std::cout << "'" << sinput.substr(found+1, sinput.length()) << "'\n"; |
103 |
> |
} // if |
104 |
|
titles[titlepointer] = sinput.substr(0,found); |
105 |
|
values[titlepointer] = sinput.substr(found+1, sinput.length()); |
106 |
|
titlepointer++; |
110 |
|
|
111 |
|
} // while |
112 |
|
|
113 |
+ |
// delete the pointer to free up memory |
114 |
|
delete p; |
115 |
|
|
116 |
|
if ( debug == 1 ){ |
117 |
|
std::cout << "SysMon::collect::Parse from StatGrab finished\n"; |
118 |
< |
} |
118 |
> |
} // if |
119 |
|
|
121 |
– |
// alert? |
122 |
– |
// return 1; |
123 |
– |
|
120 |
|
// return sucessful |
121 |
|
return 0; |
122 |
|
|
123 |
|
} // collect |
124 |
|
|
125 |
+ |
void SysMon::clearData(){ |
126 |
+ |
|
127 |
+ |
titlepointer = 0; |
128 |
+ |
for ( int i=0; i < max_titles; i++ ){ |
129 |
+ |
titles[i] = ""; |
130 |
+ |
values[i] = ""; |
131 |
+ |
} // for |
132 |
+ |
|
133 |
+ |
return; |
134 |
+ |
|
135 |
+ |
} // clearData |
136 |
+ |
|
137 |
+ |
|
138 |
|
string SysMon::getData(){ |
139 |
|
|
140 |
|
if ( debug == 1 ){ |
141 |
|
std::cout << "SysMon::getData()\n"; |
142 |
< |
} |
142 |
> |
} // if |
143 |
|
|
144 |
|
// create an xml object |
145 |
|
XMLFormatter xml = XMLFormatter(); |
146 |
|
|
147 |
< |
int i=0; |
147 |
> |
if ( debug == 1 ){ |
148 |
> |
std::cout << "SysMon::getData::Sorting " << titlepointer << " elements\n"; |
149 |
> |
} // if |
150 |
> |
|
151 |
> |
// firstly sort the data. |
152 |
> |
// simple bubble sort |
153 |
> |
int flag = 1; |
154 |
> |
while ( flag == 1 ){ |
155 |
> |
flag = 0; |
156 |
> |
for ( int i=1; i<=titlepointer; i++ ){ |
157 |
> |
if (titles[i-1].compare(titles[i]) > 0 ){ |
158 |
> |
// swap them |
159 |
> |
string temp; |
160 |
> |
temp = titles[i-1]; |
161 |
> |
titles[i-1] = titles[i]; |
162 |
> |
titles[i] = temp; |
163 |
> |
// now do the values |
164 |
> |
temp = values[i-1]; |
165 |
> |
values[i-1] = values[i]; |
166 |
> |
values[i] = temp; |
167 |
> |
// say we have changed something |
168 |
> |
flag = 1; |
169 |
> |
} // if |
170 |
> |
} // for |
171 |
> |
} // while |
172 |
> |
|
173 |
> |
/* used to check the array has sorted correctly |
174 |
> |
for ( int i=0; i < titlepointer; i++ ){ |
175 |
> |
std::cout << titles[i] << endl; |
176 |
> |
} |
177 |
> |
*/ |
178 |
> |
|
179 |
> |
// work through each one of the titles in turn and |
180 |
> |
// work out their levels. |
181 |
> |
|
182 |
|
int count = 0; |
183 |
< |
int finished = 0; |
184 |
< |
string root = "packet."; |
185 |
< |
string level = root; |
183 |
> |
string currentLevel = "packet"; |
184 |
> |
string currentLevels[10]; |
185 |
> |
int currentLevelint = 0; |
186 |
> |
int retryCount = 0; |
187 |
|
string attributes = ""; |
188 |
< |
string attr = ""; |
189 |
< |
while ( i < titlepointer ){ |
146 |
< |
finished = 0; |
147 |
< |
count = 0; |
148 |
< |
attr = ""; |
149 |
< |
while ( finished != 1 ){ |
150 |
< |
count++; |
151 |
< |
if ( count > 10 ){ |
152 |
< |
// don't do more than 10 times.. its probably not gonna work! |
153 |
< |
finished = 1; |
154 |
< |
} |
155 |
< |
|
156 |
< |
// do for each item |
157 |
< |
int where = titles[i].find(level,0); |
158 |
< |
|
159 |
< |
// where now contains the position of 'level' |
160 |
< |
if ( where != string::npos ){ |
161 |
< |
// we found it, now check the size to see if this is the final level |
162 |
< |
// grab the end bit a look for .'s |
163 |
< |
string end = titles[i].substr(level.length(), titles[i].length()-level.length() ); |
164 |
< |
|
165 |
< |
// now end should contain "something.something" etc |
166 |
< |
// look to find a . in there that means more to traverse |
167 |
< |
// but check for 'attributes' tags... |
168 |
< |
|
169 |
< |
where = end.find("attributes.",0); |
170 |
< |
if ( where != string::npos ){ |
171 |
< |
// is an attribute |
172 |
< |
// need to check that there are no more levels above this one |
173 |
< |
|
174 |
< |
|
175 |
< |
|
176 |
< |
/* |
177 |
< |
|
178 |
< |
// where points to the start of attributes |
179 |
< |
int start = 0; |
180 |
< |
if ( level.find(".",start) < where-1 ){ |
181 |
< |
start = level.find(".", start); |
182 |
< |
} // if |
183 |
< |
|
184 |
< |
// start points to the thing to apply the attributes to. |
185 |
< |
// need to take the level upto before this point |
186 |
< |
string needLevel = end.substr(0,start-2); |
187 |
< |
std::cout << "needlevel " << needLevel << endl; |
188 |
< |
|
189 |
< |
// now we need to find the level we are at |
190 |
< |
while (( needLevel.length() > 0 ) && (needLevel.find(".",0) != string::npos ) ){ |
191 |
< |
int got = needLevel.find(".",0); |
192 |
< |
if ( got != string::npos ){ |
193 |
< |
// we need to grab up until the . |
194 |
< |
xml.addNest(needLevel.substr(0,got)); |
195 |
< |
level += needLevel.substr(0,got); |
196 |
< |
level += "."; |
197 |
< |
std::cout << "Adding Nest " << needLevel.substr(0,got) << endl; |
198 |
< |
needLevel = needLevel.substr(got+1, needLevel.length()-(got+1)); |
199 |
< |
} // if |
200 |
< |
std::cout << "needlevel " << needLevel << endl; |
201 |
< |
} // while |
202 |
< |
|
203 |
< |
// add the final nest |
204 |
< |
xml.addNest(needLevel); |
205 |
< |
level += needLevel; |
206 |
< |
level += "."; |
207 |
< |
std::cout << "Adding Nest " << needLevel << endl; |
208 |
< |
|
209 |
< |
*/ |
210 |
< |
|
211 |
< |
// now write out the variable |
212 |
< |
xml.addElement(end, values[i]); |
213 |
< |
finished = 1; |
214 |
< |
|
215 |
< |
} else { |
216 |
< |
if ( where == 0 ){ |
217 |
< |
// this is something we care about. |
218 |
< |
// it has an attribute tab, and thus we want to add it |
219 |
< |
// to the tag one lower than this (hopefully level!) |
220 |
< |
|
221 |
< |
// attributes = attributes + mount |
222 |
< |
attributes += end.substr(where+11, end.length()-(where+11)); |
223 |
< |
// attributes = attributes + mount=" |
224 |
< |
attributes += "=\""; |
225 |
< |
// attributes = attributes + mount="/dev |
226 |
< |
attributes += values[i]; |
227 |
< |
// attributes = attributes + mount="/dev" |
228 |
< |
attributes += "\" "; |
229 |
< |
} else { |
230 |
< |
// need to check if we are the last element before |
231 |
< |
// an attribute tag, so we want to get up to this tag first |
232 |
< |
while ( end.find(".",0) != string::npos ){ |
233 |
< |
|
234 |
< |
where = end.find(".",0); |
235 |
< |
string newNest = end.substr(0,where); |
236 |
< |
xml.addNest(newNest); |
237 |
< |
level += newNest; |
238 |
< |
level += "."; |
239 |
< |
// redefine end |
240 |
< |
end = end.substr(where+1, end.length()-(where+1)); |
241 |
< |
} // while |
242 |
< |
|
243 |
< |
|
244 |
< |
xml.addElement(end, values[i]); |
245 |
< |
finished = 1; |
246 |
< |
} // if where == 0 |
247 |
< |
} // if attribute tags |
188 |
> |
int isAttrib = 0; |
189 |
> |
string attributeLevel = ""; |
190 |
|
|
191 |
< |
|
191 |
> |
// init that array quickly ;) |
192 |
> |
for ( int i=0; i< 10; i++ ){ |
193 |
> |
currentLevels[i] = ""; |
194 |
> |
} // for |
195 |
|
|
196 |
< |
|
197 |
< |
} else { // if doesn't contains level |
198 |
< |
|
254 |
< |
// we need to move one back and try again, until we are all the way |
255 |
< |
// back to "packet." |
256 |
< |
// go about it by closing nests |
257 |
< |
|
258 |
< |
while ( level.length() > root.length() ){ |
259 |
< |
// need to close one nest and locate the next . from the end (hassle) |
260 |
< |
int start = 0; |
261 |
< |
if ( level.find(".",start) != string::npos ){ |
262 |
< |
start = level.find(".", start); |
263 |
< |
} // if |
264 |
< |
// should now have the last . |
265 |
< |
xml.closeNest(); |
266 |
< |
level = level.substr(0, start+1); |
267 |
< |
} |
268 |
< |
|
269 |
< |
} // if contains level |
270 |
< |
|
271 |
< |
} // while |
272 |
< |
i++; |
273 |
< |
} // while |
196 |
> |
if ( debug == 1 ){ |
197 |
> |
std::cout << "SysMon::getData::Starting while\n"; |
198 |
> |
} // if |
199 |
|
|
200 |
< |
|
201 |
< |
|
202 |
< |
|
203 |
< |
|
204 |
< |
|
205 |
< |
|
200 |
> |
while ( count <= titlepointer ){ |
201 |
> |
|
202 |
> |
if ( debug == 1 ){ |
203 |
> |
std::cout << "Processing: " << titles[count] << endl; |
204 |
> |
} // if |
205 |
> |
|
206 |
> |
retryCount++; |
207 |
> |
|
208 |
> |
currentLevel = ""; |
209 |
> |
for ( int i=0; i<currentLevelint; i++ ){ |
210 |
> |
if (( currentLevel != "" ) && ( i != currentLevelint )){ |
211 |
> |
currentLevel += "."; |
212 |
> |
} // if |
213 |
> |
currentLevel += currentLevels[i]; |
214 |
> |
} // for |
215 |
> |
|
216 |
> |
// set the title into a variable |
217 |
> |
string currentTitle = titles[count]; |
218 |
> |
|
219 |
> |
// make an array of strings to hold the levels |
220 |
> |
string levels[10]; |
221 |
> |
for ( int i=0; i< 10; i++ ){ |
222 |
> |
levels[i] = ""; |
223 |
> |
} // for |
224 |
> |
int level = 0; |
225 |
> |
|
226 |
> |
|
227 |
> |
// firstly find the first . |
228 |
> |
int dotPosition = currentTitle.find("."); |
229 |
> |
|
230 |
> |
while ( dotPosition != string::npos ){ |
231 |
> |
|
232 |
> |
levels[level] = currentTitle.substr(0,dotPosition); |
233 |
> |
|
234 |
> |
// now remove this bit |
235 |
> |
currentTitle = currentTitle.substr(dotPosition+1); |
236 |
> |
|
237 |
> |
// now find the position of the next dot |
238 |
> |
dotPosition = currentTitle.find("."); |
239 |
> |
|
240 |
> |
// increment level etc |
241 |
> |
level++; |
242 |
> |
|
243 |
> |
// we already are at 'packet' level because of |
244 |
> |
// the outer packet tags, get rif of it , only |
245 |
> |
// first one mind! |
246 |
> |
if ( levels[0] == "packet" ){ |
247 |
> |
level--; |
248 |
> |
} // if |
249 |
> |
|
250 |
> |
} // while dotPosition |
251 |
> |
|
252 |
> |
// now grab the value title |
253 |
> |
levels[level] = currentTitle; |
254 |
> |
|
255 |
> |
// now have the levels and the level depth. |
256 |
> |
// check it against the last one, reconstruct a |
257 |
> |
// level string |
258 |
> |
|
259 |
> |
// only do this if the 2nd to last string is not |
260 |
> |
// atrribute |
261 |
> |
string newLevelString = ""; |
262 |
> |
|
263 |
> |
if ( level > 0 ){ |
264 |
> |
if ( levels[level-1] != "attributes" ){ |
265 |
> |
// say it isn't an attribute, but write out |
266 |
> |
// the attribute first if the last one was |
267 |
> |
if ( attributeLevel != "" ){ |
268 |
> |
xml.addElement(attributeLevel,attributes,""); |
269 |
> |
if ( debug == 1 ){ |
270 |
> |
std::cout << "Adding Element + attributes" << endl; |
271 |
> |
} // if |
272 |
> |
|
273 |
> |
} // if |
274 |
> |
isAttrib = 0; |
275 |
> |
attributeLevel = ""; |
276 |
> |
attributes = ""; |
277 |
> |
|
278 |
> |
for ( int i=0; i < level; i++ ){ |
279 |
> |
newLevelString += levels[i]; |
280 |
> |
if ( i != level-1 ){ |
281 |
> |
newLevelString += "."; |
282 |
> |
} // if |
283 |
> |
} // for |
284 |
> |
} // if levels[level] |
285 |
> |
|
286 |
> |
else |
287 |
> |
|
288 |
> |
{ |
289 |
> |
// we need to add to the attributes |
290 |
> |
level -= 2; |
291 |
> |
for ( int i=0; i < level; i++ ){ |
292 |
> |
newLevelString += levels[i]; |
293 |
> |
if ( i != level-1 ){ |
294 |
> |
newLevelString += "."; |
295 |
> |
} // if |
296 |
> |
} // for |
297 |
> |
|
298 |
> |
isAttrib = 1; |
299 |
> |
if ( attributeLevel == "" ){ |
300 |
> |
// set this attribute to be the level |
301 |
> |
attributeLevel = levels[level]; |
302 |
> |
} else { |
303 |
> |
if ( levels[level] != attributeLevel ){ |
304 |
> |
// arrg! its a different level! |
305 |
> |
if ( attributeLevel != levels[level] ){ |
306 |
> |
xml.addElement(attributeLevel,attributes,""); |
307 |
> |
if ( debug == 1 ){ |
308 |
> |
std::cout << "Adding Element + attributes1" << endl; |
309 |
> |
} // if |
310 |
> |
attributeLevel = ""; |
311 |
> |
attributes = ""; |
312 |
> |
count++; |
313 |
> |
} // if |
314 |
> |
if ( count == titlepointer ){ |
315 |
> |
xml.addElement(attributeLevel,attributes,""); |
316 |
> |
if ( debug == 1 ){ |
317 |
> |
std::cout << "Adding Element + attributes2" << endl; |
318 |
> |
} // if |
319 |
> |
attributeLevel = ""; |
320 |
> |
attributes = ""; |
321 |
> |
count++; |
322 |
> |
} // if |
323 |
> |
} // if |
324 |
> |
} // if else |
325 |
> |
|
326 |
> |
} // else attributes |
327 |
> |
} // if level > 1 |
328 |
> |
else { |
329 |
> |
if ( count == titlepointer ){ |
330 |
> |
if ( attributeLevel != "" ){ |
331 |
> |
xml.addElement(attributeLevel,attributes,""); |
332 |
> |
if ( debug == 1 ){ |
333 |
> |
std::cout << "Adding Element + attributes3" << endl; |
334 |
> |
} // if |
335 |
> |
attributeLevel = ""; |
336 |
> |
attributes = ""; |
337 |
> |
count++; |
338 |
> |
} // if |
339 |
> |
} // if |
340 |
> |
|
341 |
> |
|
342 |
> |
for ( int i=0; i < level; i++ ){ |
343 |
> |
newLevelString += levels[i]; |
344 |
> |
if ( i != level-1 ){ |
345 |
> |
newLevelString += "."; |
346 |
> |
} // if |
347 |
> |
} // for |
348 |
> |
} // if level == 1 |
349 |
> |
|
350 |
> |
// check if it is the same |
351 |
> |
if ( newLevelString == currentLevel ){ |
352 |
> |
// it is the same level, just add this as another element |
353 |
> |
if ( isAttrib ){ |
354 |
> |
attributes += levels[level+2]; |
355 |
> |
attributes += "=\""; |
356 |
> |
attributes += values[count]; |
357 |
> |
attributes += "\" "; |
358 |
> |
|
359 |
> |
} else { |
360 |
> |
xml.addElement(levels[level], values[count]); |
361 |
> |
count++; |
362 |
> |
if ( debug == 1 ){ |
363 |
> |
std::cout << "Adding Element" << endl; |
364 |
> |
} // if |
365 |
> |
} // if |
366 |
> |
|
367 |
> |
} else { |
368 |
> |
// gotta change it |
369 |
> |
|
370 |
> |
while( newLevelString.find(currentLevel) == string::npos ){ |
371 |
> |
|
372 |
> |
if ( currentLevelint <= 0 ){ |
373 |
> |
break; |
374 |
> |
} // if |
375 |
> |
|
376 |
> |
// back up atleast one level... |
377 |
> |
xml.closeNest(); |
378 |
> |
if ( debug == 1 ){ |
379 |
> |
std::cout << "Closing Nest" << endl; |
380 |
> |
} // if |
381 |
> |
// remove the last item |
382 |
> |
currentLevelint--; |
383 |
> |
|
384 |
> |
currentLevel = ""; |
385 |
> |
for ( int i=0; i<currentLevelint; i++ ){ |
386 |
> |
currentLevel += currentLevels[i]; |
387 |
> |
if ( i != currentLevelint-1 ){ |
388 |
> |
currentLevel += "."; |
389 |
> |
} // if |
390 |
> |
} // for |
391 |
> |
|
392 |
> |
} // while |
393 |
> |
|
394 |
> |
|
395 |
> |
while ( newLevelString != currentLevel ){ |
396 |
> |
|
397 |
> |
// now got to a level which we like. |
398 |
> |
currentLevels[currentLevelint] = levels[currentLevelint]; |
399 |
> |
|
400 |
> |
// add in one more level and restart the loop |
401 |
> |
xml.addNest(levels[currentLevelint]); |
402 |
> |
if ( debug == 1 ){ |
403 |
> |
std::cout << "Adding nest " << levels[currentLevelint] << endl; |
404 |
> |
} // if |
405 |
> |
|
406 |
> |
// set this to be the top level of the new level |
407 |
> |
currentLevelint++; |
408 |
> |
|
409 |
> |
currentLevel = ""; |
410 |
> |
for ( int i=0; i<currentLevelint; i++ ){ |
411 |
> |
currentLevel += currentLevels[i]; |
412 |
> |
if ( i != currentLevelint-1 ){ |
413 |
> |
currentLevel += "."; |
414 |
> |
} // if |
415 |
> |
} // for |
416 |
> |
|
417 |
> |
} // while |
418 |
> |
|
419 |
> |
|
420 |
> |
} // if |
421 |
> |
|
422 |
> |
if ( debug == 1 ){ |
423 |
> |
std::cout << "Retrying Main While" << endl; |
424 |
> |
} // if |
425 |
> |
|
426 |
> |
if ( retryCount > 10 ){ |
427 |
> |
count++; |
428 |
> |
if ( debug == 1 ){ |
429 |
> |
std::cout << "Tried too many times" << endl; |
430 |
> |
} // if |
431 |
> |
retryCount = 0; |
432 |
> |
} // if |
433 |
> |
|
434 |
> |
} // while |
435 |
> |
|
436 |
> |
if ( debug == 1 ){ |
437 |
> |
std::cout << "\n"; |
438 |
> |
} // if |
439 |
> |
|
440 |
|
// return the string |
441 |
|
return xml.returnXML(); |
442 |
|
|