rendered paste bodyvoid ProcessMsg::composeMsg() {
connectToCASA();
// outputs the STOC and STOC data block
composeStoc();
openlog("mid", LOG_PID, LOG_AUTH);
vector<DataField *>dataField = _appMID->dataFieldGet();
vector<DataField *>::const_iterator fIter;
cout << "\n\nThis is the primary data block. ProcessMsg \n\n";
// outputs the primary data block
for (fIter = dataField.begin(); fIter != dataField.end(); fIter++) {
vector<string>fileInfo = (*fIter)->fileNamesGet();
vector<string>::iterator infoIter;
for (infoIter = fileInfo.begin(); infoIter != fileInfo.end(); infoIter++) {
_ptocTb.clear();
composePtoc((*fIter), (*infoIter));
int counter = 0;
int bufferSize = (_lastPage + 1) * 256;
unsigned char buffer[bufferSize];
memset(buffer, '\0', bufferSize);
map<int, pair< pair<unsigned char, unsigned char>, string > >:: const_iterator cIter;
for (cIter = _ptocTb.begin(); cIter != _ptocTb.end(); cIter++) {
buffer[counter] = cIter->second.first.first;
counter++;
buffer[counter] = cIter->second.first.second;
counter++;
}
for (cIter = _stocTb.begin(); cIter != _stocTb.end(); cIter++) {
buffer[counter] = cIter->second.first.first;
counter++;
buffer[counter] = cIter->second.first.second;
counter++;
}
for (cIter = _stocTb.begin(); cIter != _stocTb.end(); cIter++) {
const string data = cIter->second.second;
for (int index = 0; index < data.size(); index++) {
buffer[counter] = data[index];
counter++;
}
}
for (cIter = _ptocTb.begin(); cIter != _ptocTb.end(); cIter++) {
const string data = cIter->second.second;
if (cIter->first < SOURCE) {
continue;
} else if (cIter->first == SOURCE) {
unsigned int connectId = _inOutFile->connectIdGet();
buffer[counter] = connectId / 256;
counter++;
buffer[counter] = connectId % 256;
counter++;
} else {
for (int index = 0; index < data.size(); index++) {
buffer[counter] = data[index];
counter++;
}
}
}
int returnSize;
if ((returnSize = send(_sock, &buffer, bufferSize, 0)) != bufferSize) {
cout<<"Error sending message to CASA. "<<__FILE__<<" "<<__LINE__<<endl;
}
int total = 0;
int size = 0;
unsigned char echoBuffer[bufferSize];
memset(echoBuffer, '\0', bufferSize);
string testStr;
cout<<"\n\nPlease identify this string of zeroes\n\n";
for (int index = 0; index < returnSize; index++) {
if ((index < 40) || (index == 88) || (index == 89)) {
cout<<static_cast<int>(echoBuffer[index])<<":";
} else {
testStr = testStr + static_cast<char>(echoBuffer[index]);
cout<<static_cast<unsigned char>(echoBuffer[index]);
}
}
cout<<"\n\nPlease identify this string of zeroes\n\n";
cout<<endl;
}
cout << "\n\nDoes this line repeat?\n\n";
cout<<endl;
}
close(_sock);
closelog();
}