/************************************************************************* * * 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 #include #include const mstring PREFSMAP=htchome()+sref("/htc/prefs.hdb"); const mstring SYSLOG=htchome()+sref("/log/htc.log"); static fp_stream mout(stdout),merr(stderr); /////////////////////////////////////////////////// mstring Cwd() { static char buf[1024]; mstring cwd=getcwd(buf,1024); cwd+='/'; return cwd; } /////////////////////////////////////////////////// static void OpenUSERS(dbmap& db) { db.Open(USERMAP,1); if(db.Tables()==0) for(int i=0;idb); OpenPREFS(DBRef(toks,PREFS_tag,ms_empty,tok_t::SYSONLY)->db); } /////////////////////////////////////////////////// htc_req::htc_req(HTC& g,tokmap& p) : req_env(g,p) { user.reset(); } /////////////////////////////////////////////////// void envAddFile(tokmap& map); void envAddConvert(tokmap& map); void envAddDates(tokmap& map); void envAddUser(tokmap& map) throw(merror_t); void envAddTree(tokmap& map); void envAddSys(tokmap& map); void envAddNet(tokmap& map); /////////////////////////////////////////////////// HTC::HTC(const sref& root): syslog(fopen(SYSLOG.c_str(),"a+")) { docroot=root; if(docroot.back()=='/') docroot=docroot.popb(); username=getpwuid(getuid())->pw_name; envAddFile(toks); envAddConvert(toks); envAddDates(toks); envAddUser(toks); envAddTree(toks); envAddSys(toks); envAddNet(toks); } /////////////////////////////////////////////////// HTC::~HTC() { fclose(syslog.fp); } /////////////////////////////////////////////////// void HTC::setHost(const sref& s) { host=s; if(!Lookup(node,host)) THROW("sys: host "<