// load a field from string buffer int MimeField::Load(const char* pszData, int nDataSize, bool unfold) { Clear(); ASSERT(pszData != NULL); const char *pszEnd, *pszStart = pszData; // find the next field (e.g. "\r\nContent...") while (CMimeChar::IsSpace((unsigned char)*pszStart)) { if (*pszStart == '\r') // end of header ? return 0; pszStart = FindString(pszStart, "\r\n", pszData+nDataSize); if (!pszStart) return 0; pszStart += 2; } // get the field name pszEnd = LineFind(pszStart, ':'); if (pszEnd != NULL) // if colon not found, Name would be empty { m_strName.assign(pszStart, (pszEnd-pszStart)); pszStart = pszEnd + 1; } // find the end of the field while (*pszStart == ' ' || *pszStart == '\t') pszStart++; pszEnd = pszStart; do { pszEnd = FindString(pszEnd, "\r\n", pszData+nDataSize); if (!pszEnd) return 0; pszEnd += 2; } while (*pszEnd == '\t' || *pszEnd == ' '); // linear-white-space // BEGIN change for hMailServer int lLength = (int)(pszEnd-pszStart)-2; char *pValue = new char[lLength + 1]; memset(pValue, 0, lLength+1); strncpy(pValue, pszStart, lLength); m_strValue = pValue; delete [] pValue; // We need to unfold the field value if (unfold) UnfoldField(m_strValue); // END change for hMailServer return (int) (pszEnd - pszData); }
// Note: we could pass in history by reference if we delete added entries at // the end of each iteration void Node::walk(vector<Area*>& areas, Area history, Connection* connection, Node* initial) { history.push_back(connection); // We have a circuit/loop if we're back to the start node if (connection->dest == initial) { //rotate the area to allow for uniqueness comparison Area::iterator iter; int oSize=history.size(); Area rotatedHist(oSize); iter = min_element(history.begin(),history.end(),LineCmp); if (iter==history.end()) //this should never happen throw "Node::walk() didn't find minimum"; for (int i=0;i<oSize;i++) rotatedHist[i]=history[(iter-history.begin()+i)%oSize]; // Add a copy of the rotated history to areas vector if it isn't // already there if (find_if(areas.begin(), areas.end(), AreaFind(rotatedHist)) == areas.end()) { Area* keep = new Area(rotatedHist); areas.push_back(keep); } return; } // Walk each connection for (int i = 0; i < 3; i++) { // If a connection is filled and we have not already been to it, recurse // Note we use the connection's node for the current node, not *this, which // is where we started. if (connections[i].exists() && find_if(history.begin(), history.end(), LineFind(connections[i].line)) == history.end()) connections[i].dest->walk(areas, history, &connections[i], initial); } }