/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include const mstring RCURI="/sys/htcd.rc"; const mstring TREEURI="/sys/sitemap.hdb"; const mstring TEMPURI="/sys/temp.hdb"; const mstring LOGURI="/sys/htcd.log"; const mstring ERRURI="/sys/htcd.err"; /////////////////////////////////////////////////// static void OpenTREE(dbmap& db,const sref& path) { mstring TREEMAP=path+TREEURI; db.Open(TREEMAP,1); if(db.Tables()==0) for(int i=0;idb,path); OpenTEMP(DBRef(toks,TEMP_tag,ms_empty,tok_t::SYSONLY)->db,path); } /////////////////////////////////////////////////// void SetCookies(tokmap& map,const httpReq& req); void envAddForm(tokmap& map,const httpReq& req); int htcd_req::RootAllowed() { if(htcd()->bindroot.empty()) return 1; sref first,rest=htcd()->bindroot; while(Split(first,rest)) if(first==tcp->node.name) return 1; return 0; } htcd_req::htcd_req(HTCd& g,tokmap& p,mstream& out, tcpReq& trec,httpReq& hrec) : htc_req(g,p) { output=&out; tcp=&trec; req=&hrec; SetCookies(toks,hrec); } void htcd_req::AddBody(const sref& body) { req->body=body; envAddForm(toks,*req); } /////////////////////////////////////////////////// void envAddDirect(tokmap& map); void envAddReq(tokmap& map); void envAddConst(tokmap& map); void envAddAuth(tokmap& map); void envAddTemp(tokmap& map); HTCd::HTCd(const mstring& path): logger(fopen((path+LOGURI).c_str(),"a+")), errlog(fopen((path+ERRURI).c_str(),"a+")), HTC(path) { envAddDirect(toks); envAddReq(toks); envAddConst(toks); envAddAuth(toks); envAddTemp(toks); memset(&mutex,0,sizeof(mutex)); errlog<<"["<