| 1 | 
 + | 
 /*  | 
 
 
 
 
 
 
 
 
 | 2 | 
 + | 
  * i-scream central monitoring system | 
 
 
 
 
 
 
 
 
 | 3 | 
 + | 
  * Copyright (C) 2000-2002 i-scream | 
 
 
 
 
 
 
 
 
 | 4 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 5 | 
 + | 
  * This program is free software; you can redistribute it and/or | 
 
 
 
 
 
 
 
 
 | 6 | 
 + | 
  * modify it under the terms of the GNU General Public License | 
 
 
 
 
 
 
 
 
 | 7 | 
 + | 
  * as published by the Free Software Foundation; either version 2 | 
 
 
 
 
 
 
 
 
 | 8 | 
 + | 
  * of the License, or (at your option) any later version. | 
 
 
 
 
 
 
 
 
 | 9 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 10 | 
 + | 
  * This program is distributed in the hope that it will be useful, | 
 
 
 
 
 
 
 
 
 | 11 | 
 + | 
  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 
 
 
 
 
 
 
 
 | 12 | 
 + | 
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 
 
 
 
 
 
 
 
 | 13 | 
 + | 
  * GNU General Public License for more details. | 
 
 
 
 
 
 
 
 
 | 14 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 15 | 
 + | 
  * You should have received a copy of the GNU General Public License | 
 
 
 
 
 
 
 
 
 | 16 | 
 + | 
  * along with this program; if not, write to the Free Software | 
 
 
 
 
 
 
 
 
 | 17 | 
 + | 
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
 
 
 
 
 
 
 
 
 | 18 | 
 + | 
  */ | 
 
 
 
 
 
 
 
 
 | 19 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | 
   | 
 #include "SysMon.h" | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
   | 
 SysMon::SysMon( Config config, int printDebug){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | 
   | 
         // setup some standard variables | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
         sequence = 0; // no packets sent yet | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 | 14 | 
 – | 
         // get our values from config | 
 
 
 
 
 
 
 
 
 
 | 15 | 
 – | 
          | 
 
 
 
 
 
 
 
 
 
 | 16 | 
 – | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | 
   | 
         // setup our arrays | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | 
   | 
         titlepointer = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | 
 < | 
         for ( int i=0; i < maxTitles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 | 35 | 
 > | 
         for ( int i=0; i < max_titles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | 
   | 
                 titles[i] = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 | 
   | 
                 values[i] = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 | 
   | 
 int SysMon::collect(){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | 
   | 
         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 | 
   | 
                 std::cout << "SysMon::collect()\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 47 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | 
   | 
         // say we have checked again | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | 
   | 
         checks++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | 
   | 
         // collect the system data and place it in an array of strings. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | 
   | 
         // presume that the data is all formtted correctly. | 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | 
 < | 
         // char input[2048]; | 
 
 
 
 
 
 
 
 
 
 | 54 | 
 > | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 | 55 | 
   | 
         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | 
   | 
                 std::cout << "SysMon::collect::ipipestream\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | 
 < | 
         // ipipestream p("statgrab.pl"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | 
 < | 
         p = new SubPipe("statgrab.pl"); | 
 
 
 
 
 
 
 
 
 
 | 58 | 
 > | 
  | 
 
 
 
 
 
 | 59 | 
 > | 
         p = new SubPipe("./statgrab.pl"); | 
 
 
 
 
 
 
 
 
 
 
 
 | 60 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | 
   | 
         // get the output into input from statgrab | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | 
   | 
         string sinput; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | 
   | 
         while ( p->getLine(&sinput) == 0 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 | 65 | 
 + | 
                 if ( titlepointer == max_titles ){ | 
 
 
 
 
 
 
 
 
 | 66 | 
 + | 
                     std::cout << "WARNING: Max Titles reached, skipping remaining" << endl; | 
 
 
 
 
 
 
 
 
 | 67 | 
 + | 
                     std::cout << "Try recompiling with a value greater than the current (" << max_titles << ")" << endl; | 
 
 
 
 
 
 
 
 
 | 68 | 
 + | 
                     titlepointer--; | 
 
 
 
 
 
 
 
 
 | 69 | 
 + | 
                     break; | 
 
 
 
 
 
 
 
 
 | 70 | 
 + | 
                 } // if | 
 
 
 
 
 
 
 
 
 | 71 | 
 + | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 72 | 
   | 
                 // locate the first white space | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 | 
   | 
                 int found = sinput.find(" ",0); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 | 
   | 
                 if ( found == string::npos ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 | 
   | 
                         // error | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 76 | 
   | 
                         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 | 
   | 
                                 std::cout << "SysMon::collect::Parse error from statgrab.pl\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 78 | 
 < | 
                         } | 
 
 
 
 
 
 
 
 
 
 | 78 | 
 > | 
                         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | 
   | 
                 } else { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
                         int gotTitle = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
   | 
                         // now use the array of titles and values  | 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
 < | 
                         for ( int i = 0; i < maxTitles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 | 82 | 
 > | 
                         for ( int i = 0; i < max_titles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | 
   | 
                                 // check against the array value | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 | 
   | 
                                 if ( titles[i] == sinput.substr(0,found) ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 | 
   | 
                                         // is the one we are looking for. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | 
   | 
                         if ( gotTitle == 0 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | 
   | 
                                 // didnt | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 | 
   | 
                                 if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 99 | 
 < | 
                                                 std::cout << "SysMon::collect::Adding New Value\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 | 
 < | 
                                                 std::cout << "'" << sinput.substr(0,found) << "' : "; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 101 | 
 < | 
                                                 std::cout << "'" <<  sinput.substr(found+1, sinput.length()) << "'\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 102 | 
 < | 
                                 } | 
 
 
 
 
 
 
 
 
 
 | 99 | 
 > | 
                                         std::cout << "SysMon::collect::Adding New Value\n"; | 
 
 
 
 
 
 | 100 | 
 > | 
                                         std::cout << "'" << sinput.substr(0,found) << "' : "; | 
 
 
 
 
 
 | 101 | 
 > | 
                                         std::cout << "'" <<  sinput.substr(found+1, sinput.length()) << "'\n"; | 
 
 
 
 
 
 | 102 | 
 > | 
                                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 103 | 
   | 
                                 titles[titlepointer] = sinput.substr(0,found); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 104 | 
   | 
                                 values[titlepointer] = sinput.substr(found+1, sinput.length()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 105 | 
   | 
                                 titlepointer++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 | 
   | 
         } // while | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 | 
   | 
          | 
 
 
 
 
 
 
 
 
 | 112 | 
 + | 
         // delete the pointer to free up memory | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 | 
   | 
         delete p; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 114 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 115 | 
   | 
         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 116 | 
   | 
                 std::cout << "SysMon::collect::Parse from StatGrab finished\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 117 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 117 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 118 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 119 | 
   | 
         // return sucessful | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 120 | 
   | 
         return 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 124 | 
   | 
 void SysMon::clearData(){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 125 | 
   | 
      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 126 | 
   | 
     titlepointer = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 | 127 | 
 < | 
         for ( int i=0; i < maxTitles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 | 127 | 
 > | 
         for ( int i=0; i < max_titles; i++ ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 128 | 
   | 
                 titles[i] = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 129 | 
   | 
                 values[i] = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 | 130 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 130 | 
 > | 
         } // for | 
 
 
 
 
 
 
 
 
 
 
 
 | 131 | 
   | 
      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 132 | 
   | 
     return; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 133 | 
   | 
      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 138 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 139 | 
   | 
         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 140 | 
   | 
                 std::cout << "SysMon::getData()\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 141 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 141 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 142 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 143 | 
   | 
         // create an xml object | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 144 | 
   | 
         XMLFormatter xml = XMLFormatter(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 145 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 146 | 
   | 
     if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 147 | 
   | 
                 std::cout << "SysMon::getData::Sorting " << titlepointer << " elements\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 148 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 148 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 149 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
     // firstly sort the data. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 | 
   | 
     // simple bubble sort | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 169 | 
   | 
         } // for | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 170 | 
   | 
     } // while | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
 < | 
     /* | 
 
 
 
 
 
 
 
 
 
 | 172 | 
 > | 
     /* used to check the array has sorted correctly | 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | 
   | 
     for ( int i=0; i < titlepointer; i++ ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 174 | 
   | 
         std::cout << titles[i] << endl;     | 
 
 
 
 
 
 
 
 
 
 | 151 | 
 – | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 175 | 
   | 
     } | 
 
 
 
 
 
 
 
 
 
 
 
 | 176 | 
 < | 
      */ | 
 
 
 
 
 
 
 
 
 
 | 176 | 
 > | 
     */ | 
 
 
 
 
 
 
 
 
 
 
 
 | 177 | 
   | 
         | 
 
 
 
 
 
 
 
 
 
 | 155 | 
 – | 
       | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 178 | 
   | 
         // work through each one of the titles in turn and  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 179 | 
   | 
         // work out their levels. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 180 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 194 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 195 | 
   | 
         if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 196 | 
   | 
                 std::cout << "SysMon::getData::Starting while\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 197 | 
 < | 
         } | 
 
 
 
 
 
 
 
 
 
 | 197 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 198 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 199 | 
   | 
         while ( count <= titlepointer ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 200 | 
 < | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 179 | 
 < | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 180 | 
 < | 
              | 
 
 
 
 
 
 
 
 
 
 | 200 | 
 > | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 201 | 
   | 
             if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 202 | 
   | 
                     std::cout << "Processing: " << titles[count] << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 | 203 | 
 < | 
             } | 
 
 
 
 
 
 
 
 
 
 | 203 | 
 > | 
             } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 204 | 
   | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 205 | 
   | 
             retryCount++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 206 | 
   | 
                      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 244 | 
   | 
                 // first one mind!        | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 245 | 
   | 
                 if ( levels[0] == "packet" ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 246 | 
   | 
                     level--; | 
 
 
 
 
 
 
 
 
 
 
 
 | 247 | 
 < | 
                 }                | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 247 | 
 > | 
                 } // if | 
 
 
 
 
 
 | 248 | 
 > | 
                          | 
 
 
 
 
 
 
 
 
 
 
 
 | 249 | 
   | 
             } // while dotPosition | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 250 | 
   | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 251 | 
   | 
             // now grab the value title | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 267 | 
   | 
                          xml.addElement(attributeLevel,attributes,""); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 268 | 
   | 
                          if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 269 | 
   | 
                                std::cout << "Adding Element + attributes" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 | 270 | 
 < | 
                          } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 271 | 
 < | 
                          count++; | 
 
 
 
 
 
 
 
 
 
 | 270 | 
 > | 
                          } // if | 
 
 
 
 
 
 | 271 | 
 > | 
                           | 
 
 
 
 
 
 
 
 
 
 
 
 | 272 | 
   | 
                     } // if | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 273 | 
   | 
                 isAttrib = 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 274 | 
   | 
                 attributeLevel = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 278 | 
   | 
                     newLevelString += levels[i];                 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 279 | 
   | 
                     if ( i != level-1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 280 | 
   | 
                         newLevelString += "."; | 
 
 
 
 
 
 
 
 
 
 
 
 | 281 | 
 < | 
                     } | 
 
 
 
 
 
 
 
 
 
 | 281 | 
 > | 
                     } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 282 | 
   | 
                 } // for | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 283 | 
   | 
             } // if levels[level] | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 284 | 
   | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 291 | 
   | 
                     newLevelString += levels[i];                 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 292 | 
   | 
                     if ( i != level-1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 293 | 
   | 
                         newLevelString += "."; | 
 
 
 
 
 
 
 
 
 
 
 
 | 294 | 
 < | 
                     } | 
 
 
 
 
 
 
 
 
 
 | 294 | 
 > | 
                     } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 295 | 
   | 
                 } // for | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 296 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 297 | 
   | 
                 isAttrib = 1; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 304 | 
   | 
                         if ( attributeLevel != levels[level] ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 305 | 
   | 
                            xml.addElement(attributeLevel,attributes,""); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 306 | 
   | 
                            if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 307 | 
 < | 
                                         std::cout << "Adding Element + attributes" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 308 | 
 < | 
                                 } | 
 
 
 
 
 
 
 
 
 
 | 307 | 
 > | 
                                         std::cout << "Adding Element + attributes1" << endl; | 
 
 
 
 
 
 | 308 | 
 > | 
                                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 309 | 
   | 
                            attributeLevel = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 310 | 
   | 
                            attributes = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 311 | 
   | 
                            count++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 313 | 
   | 
                         if ( count == titlepointer ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 314 | 
   | 
                                 xml.addElement(attributeLevel,attributes,""); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 315 | 
   | 
                             if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 316 | 
 < | 
                                         std::cout << "Adding Element + attributes" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 317 | 
 < | 
                                 } | 
 
 
 
 
 
 
 
 
 
 | 316 | 
 > | 
                                         std::cout << "Adding Element + attributes2" << endl; | 
 
 
 
 
 
 | 317 | 
 > | 
                                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 318 | 
   | 
                             attributeLevel = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 319 | 
   | 
                             attributes = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 320 | 
   | 
                             count++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 329 | 
   | 
                 if ( attributeLevel != "" ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 330 | 
   | 
                     xml.addElement(attributeLevel,attributes,""); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 331 | 
   | 
                     if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 | 332 | 
 < | 
                                 std::cout << "Adding Element + attributes" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 333 | 
 < | 
                         } | 
 
 
 
 
 
 
 
 
 
 | 332 | 
 > | 
                                 std::cout << "Adding Element + attributes3" << endl; | 
 
 
 
 
 
 | 333 | 
 > | 
                         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 334 | 
   | 
                     attributeLevel = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 335 | 
   | 
                     attributes = ""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 336 | 
   | 
                     count++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 342 | 
   | 
                     newLevelString += levels[i];                 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 343 | 
   | 
                     if ( i != level-1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 344 | 
   | 
                         newLevelString += "."; | 
 
 
 
 
 
 
 
 
 
 
 
 | 345 | 
 < | 
                     } | 
 
 
 
 
 
 
 
 
 
 | 345 | 
 > | 
                     } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 346 | 
   | 
                 } // for | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 347 | 
   | 
             } // if level == 1 | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 348 | 
   | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 354 | 
   | 
                     attributes += "=\""; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 355 | 
   | 
                     attributes += values[count];         | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 356 | 
   | 
                     attributes += "\" "; | 
 
 
 
 
 
 
 
 
 
 
 
 | 357 | 
 < | 
                     // now check if this is the last element | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 337 | 
 < | 
                      | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 338 | 
 < | 
          | 
 
 
 
 
 
 
 
 
 
 | 357 | 
 > | 
                              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 358 | 
   | 
                 } else { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 359 | 
   | 
                 xml.addElement(levels[level],  values[count]); | 
 
 
 
 
 
 
 
 
 | 360 | 
 + | 
                 count++;             | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 361 | 
   | 
                 if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 362 | 
   | 
                     std::cout << "Adding Element" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 | 363 | 
 < | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 364 | 
 < | 
             } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 365 | 
 < | 
                 count++;                 | 
 
 
 
 
 
 
 
 
 
 | 363 | 
 > | 
                 } // if | 
 
 
 
 
 
 | 364 | 
 > | 
             } // if | 
 
 
 
 
 
 | 365 | 
 > | 
                      | 
 
 
 
 
 
 
 
 
 
 
 
 | 366 | 
   | 
             } else { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 367 | 
   | 
                 // gotta change it     | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 368 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 370 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 371 | 
   | 
                 if ( currentLevelint <= 0 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 372 | 
   | 
                     break; | 
 
 
 
 
 
 
 
 
 
 
 
 | 373 | 
 < | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 373 | 
 > | 
                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 374 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 375 | 
   | 
                 // back up atleast one level... | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 376 | 
   | 
                 xml.closeNest(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 377 | 
   | 
                 if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 378 | 
   | 
                     std::cout << "Closing Nest" << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 | 379 | 
 < | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 379 | 
 > | 
                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 380 | 
   | 
                 // remove the last item | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 381 | 
   | 
                 currentLevelint--; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 382 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 400 | 
   | 
                 xml.addNest(levels[currentLevelint]); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 401 | 
   | 
                 if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 402 | 
   | 
                     std::cout << "Adding nest " << levels[currentLevelint] << endl; | 
 
 
 
 
 
 
 
 
 
 
 
 | 403 | 
 < | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 403 | 
 > | 
                 } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 404 | 
   | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 405 | 
   | 
                 // set this to be the top level of the new level | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 406 | 
   | 
                 currentLevelint++; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 434 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 435 | 
   | 
     if ( debug == 1 ){ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 436 | 
   | 
                 std::cout << "\n"; | 
 
 
 
 
 
 
 
 
 
 
 
 | 437 | 
 < | 
         }                | 
 
 
 
 
 
 
 
 
 
 | 437 | 
 > | 
         } // if | 
 
 
 
 
 
 
 
 
 
 
 
 | 438 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 439 | 
   | 
         // return the string | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 440 | 
   | 
         return xml.returnXML(); |