| 1329 | |
| 1330 | |
| 1331 | int |
| 1332 | XmlFileStream::mergeXML() |
| 1333 | { |
| 1334 | int fileNameLength = int(strlen(fileName)); |
| 1335 | |
| 1336 | theFile.close(); |
| 1337 | fileOpen = 0; |
| 1338 | |
| 1339 | if (sendSelfCount < 0) { |
| 1340 | |
| 1341 | int numColumns = numXMLTags; |
| 1342 | |
| 1343 | if (numColumns < 0) |
| 1344 | return 0; |
| 1345 | |
| 1346 | ifstream theFile0; |
| 1347 | theFile0.open(fileName, ios::in); |
| 1348 | |
| 1349 | string s; |
| 1350 | string s2; |
| 1351 | |
| 1352 | for (int j=0; j<numColumns; j++) { |
| 1353 | char *data = 0; |
| 1354 | int sizeData = 0; // for terminating character |
| 1355 | |
| 1356 | int numLines = (*xmlColumns)(j); |
| 1357 | for (int k=0; k<=numLines; k++) { |
| 1358 | getline(theFile0, s); |
| 1359 | const char *s1 = s.c_str(); |
| 1360 | int sizeNewData = int(strlen(s1)) + 1; // for newline |
| 1361 | char *nextData = new char[sizeData + sizeNewData +1]; // for end char |
| 1362 | if (data != 0) { |
| 1363 | strncpy(nextData, data, sizeData); |
| 1364 | delete [] data; |
| 1365 | } |
| 1366 | strncpy(&nextData[sizeData], s1, sizeNewData); |
| 1367 | sizeData = sizeData + sizeNewData; |
| 1368 | data = nextData; |
| 1369 | data[sizeData-1] = '\n'; |
| 1370 | data[sizeData] = '\0'; |
| 1371 | } |
| 1372 | static ID dataSize(1); |
| 1373 | dataSize(0) = sizeData; |
| 1374 | theChannels[0]->sendID(0, 0, dataSize); |
| 1375 | |
| 1376 | Message dataMsg(data, sizeData); |
| 1377 | theChannels[0]->sendMsg(0, 0, dataMsg); |
| 1378 | if (data != 0) |
| 1379 | delete [] data; |
| 1380 | } |
| 1381 | } else if (sendSelfCount > 0) { |
| 1382 | |
| 1383 | ifstream theFile0; |
| 1384 | |
| 1385 | theFile0.open(fileName, ios::in); |
| 1386 | |
| 1387 | int fileNameLength = int(strlen(fileName)); |
| 1388 | sprintf(&fileName[fileNameLength-2],""); |