char UTF8UTF16::processText(SWBuf &text, const SWKey *key, const SWModule *module) { const unsigned char *from; SWBuf orig = text; from = (const unsigned char *)orig.c_str(); // ------------------------------- text = ""; while (*from) { __u32 ch = getUniCharFromUTF8(&from); if (!ch) continue; // invalid char if (ch < 0x10000) { text.setSize(text.size()+2); *((__u16 *)(text.getRawData()+(text.size()-2))) = (__u16)ch; } else { __u16 utf16; utf16 = (__s16)((ch - 0x10000) / 0x400 + 0xD800); text.setSize(text.size()+4); *((__u16 *)(text.getRawData()+(text.size()-4))) = utf16; utf16 = (__s16)((ch - 0x10000) % 0x400 + 0xDC00); *((__u16 *)(text.getRawData()+(text.size()-2))) = utf16; } } text.setSize(text.size()+2); *((__u16 *)(text.getRawData()+(text.size()-2))) = (__u16)0; text.setSize(text.size()-2); return 0; }
void zStr::getCompressedText(long block, long entry, char **buf) const { __u32 size = 0; if (cacheBlockIndex != block) { __u32 start = 0; zdxfd->seek(block * ZDXENTRYSIZE, SEEK_SET); zdxfd->read(&start, 4); zdxfd->read(&size, 4); start = swordtoarch32(start); size = swordtoarch32(size); SWBuf buf; buf.setSize(size + 5); zdtfd->seek(start, SEEK_SET); zdtfd->read(buf.getRawData(), size); flushCache(); unsigned long len = size; buf.setSize(size); rawZFilter(buf, 0); // 0 = decipher compressor->zBuf(&len, buf.getRawData()); char *rawBuf = compressor->Buf(0, &len); cacheBlock = new EntriesBlock(rawBuf, len); cacheBlockIndex = block; } size = cacheBlock->getEntrySize(entry); *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1); strcpy(*buf, cacheBlock->getEntry(entry)); }
char CipherFilter::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if (text.length() > 2) { //check if it's large enough to substract 2 in the next step. unsigned long len = text.length(); if (!key) { // hack, using key to determine encipher, or decipher cipher->cipherBuf(&len, text.getRawData()); //set buffer to enciphered text memcpy(text.getRawData(), cipher->Buf(), len); // text = cipher->Buf(); //get the deciphered buffer } else if ((unsigned long)key == 1) { cipher->Buf(text.getRawData(), len); memcpy(text.getRawData(), cipher->cipherBuf(&len), len); // text = cipher->cipherBuf(&len); } } return 0; }
vector<struct DirEntry> RemoteTransport::getDirList(const char *dirURL) { SWLog::getSystemLog()->logDebug("RemoteTransport::getDirList(%s)", dirURL); vector<struct DirEntry> dirList; SWBuf dirBuf; if (!getURL("", dirURL, &dirBuf)) { char *start = dirBuf.getRawData(); char *end = start; while (start < (dirBuf.getRawData()+dirBuf.size())) { struct ftpparse item; bool looking = true; for (end = start; *end; end++) { if (looking) { if ((*end == 10) || (*end == 13)) { *end = 0; looking = false; } } else if ((*end != 10) && (*end != 13)) break; } SWLog::getSystemLog()->logDebug("getDirList: parsing item %s(%d)\n", start, end-start); int status = ftpparse(&item, start, end - start); // in ftpparse.h, there is a warning that name is not necessarily null terminated SWBuf name; name.append(item.name, item.namelen); SWLog::getSystemLog()->logDebug("getDirList: got item %s\n", name.c_str()); if (status && name != "." && name != "..") { struct DirEntry i; i.name = name; i.size = item.size; i.isDirectory = (item.flagtrycwd == 1); dirList.push_back(i); } start = end; } } else { SWLog::getSystemLog()->logWarning("getDirList: failed to get dir %s\n", dirURL); } return dirList; }
char UTF8NFC::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering return -1; err = U_ZERO_ERROR; UnicodeString source(text.getRawData(), text.length(), conv, err); UnicodeString target; err = U_ZERO_ERROR; Normalizer::normalize(source, UNORM_NFC, 0, target, err); err = U_ZERO_ERROR; text.setSize(text.size()*2); // potentially, it can grow to 2x the original size int32_t len = target.extract(text.getRawData(), text.size(), conv, err); text.setSize(len); return 0; }
vector<struct DirEntry> FTPTransport::getDirList(const char *dirURL) { vector<struct DirEntry> dirList; SWBuf dirBuf; if (!getURL("", dirURL, &dirBuf)) { char *start = dirBuf.getRawData(); char *end = start; while (start < (dirBuf.getRawData()+dirBuf.size())) { struct ftpparse item; bool looking = true; for (end = start; *end; end++) { if (looking) { if ((*end == 10) || (*end == 13)) { *end = 0; looking = false; } } else if ((*end != 10) && (*end != 13)) break; } SWLog::getSystemLog()->logWarning("FTPURLGetDir: parsing item %s(%d)\n", start, end-start); int status = ftpparse(&item, start, end - start); SWLog::getSystemLog()->logWarning("FTPURLGetDir: got item %s\n", item.name); if (status) { struct DirEntry i; i.name = item.name; i.size = item.size; i.isDirectory = (item.flagtrycwd == 1); dirList.push_back(i); } start = end; } } else { SWLog::getSystemLog()->logWarning("FTPURLGetDir: failed to get dir %s\n", dirURL); } return dirList; }
void RawVerse::readText(char testmt, long start, unsigned short size, SWBuf &buf) const { buf = ""; buf.setFillByte(0); buf.setSize(size + 1); if (!testmt) testmt = ((idxfp[1]) ? 1:2); if (size) { if (textfp[testmt-1]->getFd() >= 0) { textfp[testmt-1]->seek(start, SEEK_SET); textfp[testmt-1]->read(buf.getRawData(), (int)size); } } }
void RawStr::readText(__u32 istart, __u16 *isize, char **idxbuf, SWBuf &buf) const { unsigned int ch; char *idxbuflocal = 0; getIDXBufDat(istart, &idxbuflocal); __u32 start = istart; do { if (*idxbuf) delete [] *idxbuf; buf = ""; buf.setFillByte(0); buf.setSize(++(*isize)); *idxbuf = new char [ (*isize) ]; datfd->seek(start, SEEK_SET); datfd->read(buf.getRawData(), (int)((*isize) - 1)); for (ch = 0; buf[ch]; ch++) { // skip over index string if (buf[ch] == 10) { ch++; break; } } buf = SWBuf(buf.c_str()+ch); // resolve link if (!strncmp(buf.c_str(), "@LINK", 5)) { for (ch = 0; buf[ch]; ch++) { // null before nl if (buf[ch] == 10) { buf[ch] = 0; break; } } findOffset(buf.c_str() + 6, &start, isize); } else break; } while (true); // while we're resolving links if (idxbuflocal) { int localsize = strlen(idxbuflocal); localsize = (localsize < (*isize - 1)) ? localsize : (*isize - 1); strncpy(*idxbuf, idxbuflocal, localsize); (*idxbuf)[localsize] = 0; free(idxbuflocal); } }
void zVerse::flushCache() const { if (dirtyCache) { __u32 idxoff; __u32 start, outstart; __u32 size, outsize; __u32 zsize, outzsize; idxoff = cacheBufIdx * 12; if (cacheBuf) { size = outsize = zsize = outzsize = strlen(cacheBuf); if (size) { // if (compressor) { // delete compressor; // compressor = new LZSSCompress(); // } compressor->Buf(cacheBuf); unsigned long tmpSize; compressor->zBuf(&tmpSize); outzsize = zsize = tmpSize; SWBuf buf; buf.setSize(zsize + 5); memcpy(buf.getRawData(), compressor->zBuf(&tmpSize), tmpSize); outzsize = zsize = tmpSize; buf.setSize(zsize); rawZFilter(buf, 1); // 1 = encipher start = outstart = textfp[cacheTestament-1]->seek(0, SEEK_END); outstart = archtosword32(start); outsize = archtosword32(size); outzsize = archtosword32(zsize); textfp[cacheTestament-1]->write(buf, zsize); idxfp[cacheTestament-1]->seek(idxoff, SEEK_SET); idxfp[cacheTestament-1]->write(&outstart, 4); idxfp[cacheTestament-1]->write(&outzsize, 4); idxfp[cacheTestament-1]->write(&outsize, 4); } free(cacheBuf); cacheBuf = 0; } dirtyCache = false; } }
char UTF8arShaping::processText(SWBuf &text, const SWKey *key, const SWModule *module) { UChar *ustr, *ustr2; if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering return -1; int32_t len = text.length(); ustr = new UChar[len]; ustr2 = new UChar[len]; // Convert UTF-8 string to UTF-16 (UChars) len = ucnv_toUChars(conv, ustr, len, text.c_str(), -1, &err); len = u_shapeArabic(ustr, len, ustr2, len, U_SHAPE_LETTERS_SHAPE | U_SHAPE_DIGITS_EN2AN, &err); text.setSize(text.size()*2); len = ucnv_fromUChars(conv, text.getRawData(), text.size(), ustr2, len, &err); text.setSize(len); delete [] ustr2; delete [] ustr; return 0; }
char UTF8NFKD::processText(SWBuf &text, const SWKey *key, const SWModule *module) { if ((unsigned long)key < 2) // hack, we're en(1)/de(0)ciphering return -1; int32_t len = 5 + text.length() * 5; source = new UChar[len + 1]; //each char could become a surrogate pair // Convert UTF-8 string to UTF-16 (UChars) int32_t ulen = ucnv_toUChars(conv, source, len, text.c_str(), -1, &err); target = new UChar[len + 1]; //compatability decomposition ulen = unorm_normalize(source, ulen, UNORM_NFKD, 0, target, len, &err); text.setSize(len); len = ucnv_fromUChars(conv, text.getRawData(), len, target, ulen, &err); text.setSize(len); delete [] source; delete [] target; return 0; }
static int myhttp_trace(CURL *handle, curl_infotype type, unsigned char *data, size_t size, void *userp) { SWBuf header; (void)userp; /* prevent compiler warning */ (void)handle; /* prevent compiler warning */ switch (type) { case CURLINFO_TEXT: header = "TEXT"; break; case CURLINFO_HEADER_OUT: header = "=> Send header"; break; case CURLINFO_HEADER_IN: header = "<= Recv header"; break; // these we don't want to log (HUGE) case CURLINFO_DATA_OUT: header = "=> Send data"; case CURLINFO_SSL_DATA_OUT: header = "=> Send SSL data"; case CURLINFO_DATA_IN: header = "<= Recv data"; case CURLINFO_SSL_DATA_IN: header = "<= Recv SSL data"; default: /* in case a new one is introduced to shock us */ return 0; } if (size > 120) size = 120; SWBuf text; text.size(size); memcpy(text.getRawData(), data, size); SWLog::getSystemLog()->logDebug("CURLHTTPTransport: %s: %s", header.c_str(), text.c_str()); return 0; }
bool TEIHTMLHREF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { // manually process if it wasn't a simple substitution if (!substituteToken(buf, token)) { MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if (!strcmp(tag.getName(), "p")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag buf += "<!P><br />"; } else if (tag.isEndTag()) { // end tag buf += "<!/P><br />"; //userData->supressAdjacentWhitespace = true; } else { // empty paragraph break marker buf += "<!P><br />"; //userData->supressAdjacentWhitespace = true; } } // <hi> else if (!strcmp(tag.getName(), "hi")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { SWBuf rend = tag.getAttribute("rend"); u->lastHi = rend; if (rend == "ital") buf += "<i>"; else if (rend == "bold") buf += "<b>"; else if (rend == "sup") buf += "<small><sup>"; } else if (tag.isEndTag()) { SWBuf rend = u->lastHi; if (rend == "ital") buf += "</i>"; else if (rend == "bold") buf += "</b>"; else if (rend == "sup") buf += "</sup></small>"; } } // <entryFree> else if (!strcmp(tag.getName(), "entryFree")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { SWBuf n = tag.getAttribute("n"); if (n != "") { buf += "<b>"; buf += n; buf += "</b>"; } } } // <sense> else if (!strcmp(tag.getName(), "sense")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { SWBuf n = tag.getAttribute("n"); if (n != "") { buf += "<br /><b>"; buf += n; buf += "</b>"; } } } // <div> else if (!strcmp(tag.getName(), "div")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { buf += "<!P>"; } else if (tag.isEndTag()) { } } // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def> else if (!strcmp(tag.getName(), "pos") || !strcmp(tag.getName(), "gen") || !strcmp(tag.getName(), "case") || !strcmp(tag.getName(), "gram") || !strcmp(tag.getName(), "number") || !strcmp(tag.getName(), "pron") /*|| !strcmp(tag.getName(), "def")*/) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { buf += "<i>"; } else if (tag.isEndTag()) { buf += "</i>"; } } // <tr> else if (!strcmp(tag.getName(), "tr")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { buf += "<i>"; } else if (tag.isEndTag()) { buf += "</i>"; } } // orth else if (!strcmp(tag.getName(), "orth")) { if ((!tag.isEndTag()) && (!tag.isEmpty())) { buf += "<b>"; } else if (tag.isEndTag()) { buf += "</b>"; } } // <etym>, <usg> else if (!strcmp(tag.getName(), "etym") || !strcmp(tag.getName(), "usg")) { // do nothing here } else if (!strcmp(tag.getName(), "ref")) { if (!tag.isEndTag()) { u->suspendTextPassThru = true; SWBuf target; SWBuf work; SWBuf ref; int was_osisref = false; if(tag.getAttribute("osisRef")) { target += tag.getAttribute("osisRef"); was_osisref=true; } else if(tag.getAttribute("target")) target += tag.getAttribute("target"); if(target.size()) { const char* the_ref = strchr(target, ':'); if(!the_ref) { // No work ref = target; } else { // Compensate for starting : ref = the_ref + 1; int size = target.size() - ref.size() - 1; work.setSize(size); strncpy(work.getRawData(), target, size); } if(was_osisref) { buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">", (ref) ? URL::encode(ref.c_str()).c_str() : "", (work.size()) ? URL::encode(work.c_str()).c_str() : ""); } else { // Dictionary link, or something buf.appendFormatted("<a href=\"sword://%s/%s\">", (work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(), (ref) ? URL::encode(ref.c_str()).c_str() : "" ); } } else { //std::cout << "TARGET WASN'T\n"; } } else { buf += u->lastTextNode.c_str(); buf += "</a>"; u->suspendTextPassThru = false; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup>*n</sup></small></a>", URL::encode(footnoteNumber.c_str()).c_str(), URL::encode(u->version.c_str()).c_str(), URL::encode(u->key->getText()).c_str()); u->suspendTextPassThru = false; } } else { return false; // we still didn't handle token } } return true; }
void writeEntry(SWModule *book, SWBuf keyBuffer, SWBuf entBuffer) { if (greekFilter) { greekAccentsFilter.processText(keyBuffer); } if (toUpper) { unsigned size = (keyBuffer.size()+5)*3; keyBuffer.setFillByte(0); keyBuffer.resize(size); StringMgr::getSystemStringMgr()->upperUTF8(keyBuffer.getRawData(), size-2); } // Added for Hesychius, but this stuff should be pushed back into new StringMgr // functionality #ifdef _ICU_ // if (lexLevels) { if (lexLevels && !keyBuffer.startsWith("/Intro")) { unsigned size = (keyBuffer.size()+(lexLevels*2)); keyBuffer.setFillByte(0); keyBuffer.resize(size); UErrorCode err = U_ZERO_ERROR; int max = (size+5)*3; UChar *ubuffer = new UChar[max+10]; int32_t len; u_strFromUTF8(ubuffer, max+9, &len, keyBuffer.c_str(), -1, &err); if (err == U_ZERO_ERROR) { UChar *upper = new UChar[(lexLevels+1)*3]; memcpy(upper, ubuffer, lexLevels*sizeof(UChar)); upper[lexLevels] = 0; len = u_strToUpper(upper, (lexLevels+1)*3, upper, -1, 0, &err); memmove(ubuffer+len+1, ubuffer, (max-len)*sizeof(UChar)); memcpy(ubuffer, upper, len*sizeof(UChar)); ubuffer[len] = '/'; delete [] upper; int totalShift = 0; for (int i = lexLevels-1; i; i--) { int shift = (i < len)? i : len; memmove(ubuffer+(shift+1), ubuffer, (max-shift)*sizeof(UChar)); ubuffer[shift] = '/'; totalShift += (shift+1); } u_strToUTF8(keyBuffer.getRawData(), max, 0, ubuffer, -1, &err); } /* u_strFromUTF8(ubuffer, max+9, &len, keyBuffer.c_str(), -1, &err); if (err == U_ZERO_ERROR) { int totalShift = 0; for (int i = lexLevels; i; i--) { int shift = (i < len)? i : len; memmove(ubuffer+(shift+1), ubuffer, (max-shift)*sizeof(UChar)); ubuffer[shift] = '/'; totalShift += (shift+1); } UChar *upper = new UChar[(totalShift+1)*3]; memcpy(upper, ubuffer, totalShift*sizeof(UChar)); upper[totalShift] = 0; len = u_strToUpper(upper, (totalShift+1)*3, upper, -1, 0, &err); memmove(ubuffer+len, ubuffer+totalShift, (max-totalShift)*sizeof(UChar)); memcpy(ubuffer, upper, len*sizeof(UChar)); delete [] upper; u_strToUTF8(keyBuffer.getRawData(), max, 0, ubuffer, -1, &err); } */ delete [] ubuffer; } #endif std::cout << keyBuffer << std::endl; book->setKey(keyBuffer.c_str()); // check to see if we already have an entry for (int i = 2; book->getKey()->popError() != KEYERR_OUTOFBOUNDS; i++) { SWBuf key; key.setFormatted("%s {%d}", keyBuffer.c_str(), i); std::cout << "dup key, trying: " << key << std::endl; book->setKey(key.c_str()); } book->setEntry(entBuffer); }
void zVerse::zReadText(char testmt, long start, unsigned short size, unsigned long ulBuffNum, SWBuf &inBuf) const { __u32 ulCompOffset = 0; // compressed buffer start __u32 ulCompSize = 0; // buffer size compressed __u32 ulUnCompSize = 0; // buffer size uncompressed if (!testmt) { testmt = ((idxfp[0]) ? 1:2); } // assert we have and valid file descriptor if (compfp[testmt-1]->getFd() < 1) return; if (size && !(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) { //fprintf(stderr, "Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize); if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12) { fprintf(stderr, "Error seeking compressed file index\n"); return; } if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4) { fprintf(stderr, "Error reading ulCompOffset\n"); return; } if (idxfp[testmt-1]->read(&ulCompSize, 4)<4) { fprintf(stderr, "Error reading ulCompSize\n"); return; } if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4) { fprintf(stderr, "Error reading ulUnCompSize\n"); return; } ulCompOffset = swordtoarch32(ulCompOffset); ulCompSize = swordtoarch32(ulCompSize); ulUnCompSize = swordtoarch32(ulUnCompSize); if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset) { fprintf(stderr, "Error: could not seek to right place in compressed text\n"); return; } SWBuf pcCompText; pcCompText.setSize(ulCompSize+5); if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) { fprintf(stderr, "Error reading compressed text\n"); return; } pcCompText.setSize(ulCompSize); rawZFilter(pcCompText, 0); // 0 = decipher unsigned long bufSize = ulCompSize; compressor->zBuf(&bufSize, pcCompText.getRawData()); if (cacheBuf) { flushCache(); free(cacheBuf); } unsigned long len = 0; compressor->Buf(0, &len); cacheBuf = (char *)calloc(len + 1, 1); memcpy(cacheBuf, compressor->Buf(), len); cacheBufSize = strlen(cacheBuf); // TODO: can we just use len? cacheTestament = testmt; cacheBufIdx = ulBuffNum; } inBuf = ""; if ((size > 0) && cacheBuf && ((unsigned)start < cacheBufSize)) { inBuf.setFillByte(0); inBuf.setSize(size+1); strncpy(inBuf.getRawData(), &(cacheBuf[start]), size); inBuf.setSize(strlen(inBuf.c_str())); } }
void zStr::flushCache() const { static const char nl[] = {13, 10}; if (cacheBlock) { if (cacheDirty) { __u32 start = 0; unsigned long size = 0; __u32 outstart = 0, outsize = 0; const char *rawBuf = cacheBlock->getRawData(&size); compressor->Buf(rawBuf, &size); compressor->zBuf(&size); SWBuf buf; buf.setSize(size + 5); memcpy(buf.getRawData(), compressor->zBuf(&size), size); // 1 = encipher buf.setSize(size); rawZFilter(buf, 1); // 1 = encipher long zdxSize = zdxfd->seek(0, SEEK_END); unsigned long zdtSize = zdtfd->seek(0, SEEK_END); if ((cacheBlockIndex * ZDXENTRYSIZE) > (zdxSize - ZDXENTRYSIZE)) { // New Block start = zdtSize; } else { zdxfd->seek(cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET); zdxfd->read(&start, 4); zdxfd->read(&outsize, 4); start = swordtoarch32(start); outsize = swordtoarch32(outsize); if (start + outsize >= zdtSize) { // last entry, just overwrite // start is already set } else if (size < outsize) { // middle entry, but smaller, that's fine and let's preserve bigger size size = outsize; } else { // middle and bigger-- we have serious problems, for now let's put it at the end = lots of wasted space start = zdtSize; } } outstart = archtosword32(start); outsize = archtosword32((__u32)size); zdxfd->seek(cacheBlockIndex * ZDXENTRYSIZE, SEEK_SET); zdtfd->seek(start, SEEK_SET); zdtfd->write(buf, size); // add a new line to make data file easier to read in an editor zdtfd->write(&nl, 2); zdxfd->write(&outstart, 4); zdxfd->write(&outsize, 4); } delete cacheBlock; cacheBlock = 0; } cacheBlockIndex = -1; cacheDirty = false; }
char OSISXHTMLXS::processText(SWBuf &text, const SWKey *key, const SWModule *module) { char *from; char token[4096]; int tokpos = 0; bool intoken = false; bool inEsc = false; SWBuf lastTextNode; MyUserDataXS *userData = (MyUserDataXS *)createUserData(module, key); SWBuf orig = text; from = orig.getRawData(); text = ""; for (;*from; from++) { if (*from == '<') { intoken = true; tokpos = 0; token[0] = 0; token[1] = 0; token[2] = 0; inEsc = false; continue; } if (*from == '&') { intoken = true; tokpos = 0; token[0] = 0; token[1] = 0; token[2] = 0; inEsc = true; continue; } if (inEsc) { if (*from == ';') { intoken = inEsc = false; userData->lastTextNode = lastTextNode; if (!userData->suspendTextPassThru) { //if text through is disabled no tokens should pass, too handleEscapeString(text, token, userData); } lastTextNode = ""; continue; } } if (!inEsc) { if (*from == '>') { intoken = false; userData->lastTextNode = lastTextNode; handleToken(text, token, userData); lastTextNode = ""; continue; } } if (intoken) { if (tokpos < 4090) { token[tokpos++] = *from; token[tokpos+2] = 0; } } else { if ((!userData->supressAdjacentWhitespace) || (*from != ' ')) { if (!userData->suspendTextPassThru) { text.append(*from); userData->lastSuspendSegment.size(0); } else userData->lastSuspendSegment.append(*from); lastTextNode.append(*from); } userData->supressAdjacentWhitespace = false; } } // THE MAIN PURPOSE OF THIS OVERRIDE FUNCTION: is to insure all opened HTML tags are closed while (!userData->htmlTagStack->empty()) { text.append((SWBuf)"</" + userData->htmlTagStack->top().c_str() + ">"); userData->htmlTagStack->pop(); } delete userData; return 0; }