From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- src/hdb/comp.cc | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/hdb/comp.cc (limited to 'src/hdb/comp.cc') diff --git a/src/hdb/comp.cc b/src/hdb/comp.cc new file mode 100644 index 0000000..3cb304a --- /dev/null +++ b/src/hdb/comp.cc @@ -0,0 +1,78 @@ +/************************************************************************* + * + * 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 +using namespace std; + +const mstring compat="(compatibility)"; +const int zkey=0; + +OP2_IMPL(lti) {out<<(atoi(L)=atoi(R));} +OP2_IMPL(gti) {out<<(atoi(L)>atoi(R));} + +void dbmap::setup() +{ + MLOCK(mutex); + if(M.empty()) { + opAddComp(M); + OP_ADDN(20,lti,lt.int,compat); + OP_ADDN(20,lei,le.int,compat); + OP_ADDN(20,gei,ge.int,compat); + OP_ADDN(20,gti,gt.int,compat); + + M.add(new op_t("lt.case",20,M.get(sref("lt"))->f2,compat)); + M.add(new op_t("gt.case",20,M.get(sref("gt"))->f2,compat)); + M.add(new op_t("lt.nocase",20,M.get(sref("ltn"))->f2,compat)); + M.add(new op_t("gt.nocase",20,M.get(sref("gtn"))->f2,compat)); + } +} + +const op_t* dbmap::CompOperator(const sref& s) +{ + if(M.empty()) setup(); + const op_t* p=M.get(s); + if(!p) THROW("dbmap: could not find operator "<head()->setcomp(index,compname); + remap_tabs(); + } +} + -- cgit v1.2.3