void DocCHMPlugin::createTOC(DocumentationCatalogItem* item) { QStringList lines = QStringList::split("\n", getSpecialData("catalog", item->url()) ); if(lines.count() % 4 != 0) { kdDebug(9002) << "DocCHMPlugin::createTOC: wrong count of strings"; return;} QValueVector<DocumentationItem*> items; items.push_back(item); for(QStringList::Iterator it = lines.begin(); it != lines.end();) { bool ok1 = true, ok2 = true; int parent = (*it).toInt(&ok1); ++it; int current = (*it).toInt(&ok2); ++it; if(int(items.size()) != current || !ok1 || !ok2 || parent < 0 || parent >= int(items.size()) || current < 0 || current != int(items.size())) { kdDebug(9002) << "DocCHMPlugin::createTOC error while parsing output of ioslave" << endl; break; } QString& name(*it); ++it; KURL url(*it); ++it; items.push_back(new DocumentationItem( DocumentationItem::Document, items[parent], chainEnd(items[parent]), decodeHTML(name))); items[current]->setURL(url); if(parent != 0) items[parent]->setType(DocumentationItem::Book); } return; }
bool KHtRewriteModule::getXml(std::stringstream &s) { chainEnd(); if(chain.str().size()==0){ return false; } s << "<request action='allow'>\n"; s << "<table name='" << BEGIN_TABLE << "'>\n"; s << chain.str(); s << "</table>\n</request>\n"; return true; }
bool KHtRewriteModule::process(KApacheConfig *htaccess, const char *cmd, std::vector<char *> &item) { if (strcasecmp(cmd, "RewriteEngine") == 0) { if (item.size() <= 0) { return true; } if (strcasecmp(item[0], "OFF") == 0) { enable = false; } if (strcasecmp(item[0], "ON") == 0) { enable = true; } return true; } if (!enable) { return false; } if (strcasecmp(cmd,"RewriteBase") == 0) { if (item.size() <= 0) { return true; } rewriteBase = item[0]; return true; } if (strcasecmp(cmd, "RewriteCond") == 0) { if (item.size() < 2) { return true; } rewrite_flag_t rf; memset(&rf, 0, sizeof(rf)); if (item.size() > 2) { parseRewriteFlag(item[2], rf); } chainStart(htaccess); rule << "<cond str='" << item[0] << "'"; if(lastCondOr){ rule << " or='1'"; } if (TEST(rf.flag,REWRITE_OR)) { lastCondOr = true; }else{ lastCondOr = false; } rule << " nc='"; if (TEST(rf.flag,REWRITE_NOCASE)) { rule << "1"; } else { rule << "0"; } rule << "'"; //if (TEST(rf.flag,REWRITE_QSA)) { // rule << " qsa='1'"; //} rule << ">" << CDATA_START << item[1] << CDATA_END << "</cond>\n"; return true; } if (strcasecmp(cmd, "RewriteRule") == 0) { if (item.size() < 2) { return true; } rewrite_flag_t rf; memset(&rf, 0, sizeof(rf)); if (item.size() > 2) { parseRewriteFlag(item[2], rf); } if (action.str().size() == 0) { //chain << "<chain action='"; if (TEST(rf.flag,REWRITE_LAST)) { action << "default"; } else if (TEST(rf.flag,REWRITE_NEXT)) { action << "table:BEGIN"; } else if (TEST(rf.flag,REWRITE_SKIP)) { action << "tablechain:BEGIN:" << cur_chainid + rf.skip; } else if (TEST(rf.flag,REWRITE_FOBIDDEN|REWRITE_GONE)) { action << "deny"; } else if (TEST(rf.flag,REWRITE_REDIRECT)) { action << "default"; } } // chain << "'>\n"; chainStart(htaccess); rule << "<rule path='" << item[0] << "' dst='" << item[1] << "' internal='";///>\n"; //internal='"; if (TEST(rf.flag,REWRITE_REDIRECT)) { rule << "0"; if (rf.code>0) { rule << "' code='" << rf.code; } } else { rule << "1"; } rule << "' nc='"; if (TEST(rf.flag,REWRITE_NOCASE)) { rule << "1"; } else { rule << "0"; } rule << "'"; if (TEST(rf.flag,REWRITE_PROXY)) { rule << " proxy='1'"; } if (TEST(rf.flag,REWRITE_QSA)) { rule << " qsa='1'"; } rule << "/>\n"; if (!TEST(rf.flag,REWRITE_CHAIN_AND)) { //last_chainand = true; chainEnd(); //last_chainand = false; } return true; } if (strcasecmp(cmd,"Redirect")==0) { return true; } return false; }