From 69d26642da5ca087b5f3acb7dd77fbd0344f085a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:29:25 +0100 Subject: Remove common VERSION file and put version numbers directly in configure.in and client.pro files allowing for diverging versions. --- VERSION | 1 - client/client.pro | 3 +-- server/configure.in | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 52b6a1f..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -VERSION=2.2.0 \ No newline at end of file diff --git a/client/client.pro b/client/client.pro index 61a6e06..dce4838 100644 --- a/client/client.pro +++ b/client/client.pro @@ -16,8 +16,7 @@ debug { DEFINES+=USE_DEBUG } -include(../VERSION) -DEFINES+=VERSION=\\\"$$VERSION\\\" +DEFINES+=VERSION=\\\"2.2.0\\\" win32 { LIBPATH += lua/lib diff --git a/server/configure.in b/server/configure.in index fcab921..c647aed 100644 --- a/server/configure.in +++ b/server/configure.in @@ -2,7 +2,7 @@ AC_INIT(src/pracrod.cc) -VERSION="`cat ../VERSION | cut -d'=' -f2`" +VERSION="2.2.0" AM_INIT_AUTOMAKE( pracrod, $VERSION ) dnl ====================== -- cgit v1.2.3 From 39276e77092e8fd9c2b6e6ebd8863e5d2e1f00b2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:32:16 +0100 Subject: Remove obsolete getdata. --- server/getdata/Makefile.am | 28 ------- server/getdata/getdata.cc | 192 --------------------------------------------- 2 files changed, 220 deletions(-) delete mode 100644 server/getdata/Makefile.am delete mode 100644 server/getdata/getdata.cc diff --git a/server/getdata/Makefile.am b/server/getdata/Makefile.am deleted file mode 100644 index c0e6f09..0000000 --- a/server/getdata/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -bin_PROGRAMS = getdata convertdata - -getdata_LDADD = $(LD_EFENCE) $(PQXX_LIBS) $(CONFIG_LIBS) - -getdata_CXXFLAGS = $(PQXX_CXXFLAGS) $(CONFIG_CXXFLAGS) - -getdata_SOURCES = \ - getdata.cc - -convertdata_LDADD = $(LD_EFENCE) $(PQXX_LIBS) $(CONFIG_LIBS) - -convertdata_CXXFLAGS = $(PQXX_CXXFLAGS) $(CONFIG_CXXFLAGS) - -convertdata_SOURCES = \ - convertdata.cc - -EXTRA_DIST = - -################ -# Test Section # -################ - -TEST_SOURCE_DEPS = ${pracrod_SOURCES} ${EXTRA_DIST} -TEST_SCRIPT_DIR = $(top_srcdir)/../tools - -include ${TEST_SCRIPT_DIR}/Makefile.am.test - -include Makefile.am.test \ No newline at end of file diff --git a/server/getdata/getdata.cc b/server/getdata/getdata.cc deleted file mode 100644 index 717d1a9..0000000 --- a/server/getdata/getdata.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * getdata.cc - * - * Tue Jan 18 08:11:53 CET 2011 - * Copyright 2011 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include -#include -#include -/* -Commits: - patientid | template | version | timestamp | uid | status - -Transactions: - macro | version | timestamp | user | uid | cid - -Fields: - transaction | name | value -*/ - -#define SEP "\t" - -std::string escape(std::string str) -{ - std::string out = "\""; - std::string::iterator i = str.begin(); - while(i != str.end()) { - if(*i == '\"') out += "''"; - else out += *i; - i++; - } - out += "\""; - return out; -} - -int main() -{ - std::vector fields; - fields.push_back("visus.egen_korr.mangler.odxt"); - fields.push_back("visus.egen_korr.kontrast.odxt"); - fields.push_back("visus.egen_korr.snellen.odxt"); - fields.push_back("visus.egen_korr.etdrs.odxt"); - fields.push_back("visus.egen_korr.korr.sf.odxt"); - fields.push_back("visus.egen_korr.korr.cyl.odxt"); - fields.push_back("visus.egen_korr.korr.grader.odxt"); - fields.push_back("visus.egen_korr.st_hul.odxt"); - fields.push_back("visus.egen_korr.st_hul.snellen.odxt"); - fields.push_back("visus.egen_korr.st_hul.etdrs.odxt"); - fields.push_back("visus.egen_korr.mangler.osin"); - fields.push_back("visus.egen_korr.kontrast.osin"); - fields.push_back("visus.egen_korr.snellen.osin"); - fields.push_back("visus.egen_korr.etdrs.osin"); - fields.push_back("visus.egen_korr.korr.sf.osin"); - fields.push_back("visus.egen_korr.korr.cyl.osin"); - fields.push_back("visus.egen_korr.korr.grader.osin"); - fields.push_back("visus.egen_korr.st_hul.osin"); - fields.push_back("visus.egen_korr.st_hul.snellen.osin"); - fields.push_back("visus.egen_korr.st_hul.etdrs.osin"); - fields.push_back("visus.egen_korr.ou"); - fields.push_back("visus.egen_korr.kontrast.ou"); - fields.push_back("visus.egen_korr.snellen.ou"); - fields.push_back("visus.egen_korr.etdrs.ou"); - - std::string like = "ref"; - - std::string host = "localhost"; - std::string port = "5432"; - std::string user = "pracro"; - std::string password = "pracro"; - std::string dbname = "pracro"; - - std::string cs = "host="+host+" port="+port+ - " user="+user+" password="+password+" dbname="+dbname; - - pqxx::connection conn(cs); - pqxx::work W(conn); - - - - std::map fieldnames; - int idx = 0; - pqxx::result Rf = W.exec("SELECT DISTINCT name FROM fields ORDER BY name;"); - pqxx::result::const_iterator rfi = Rf.begin(); - for(unsigned int r = 0; r < Rf.size(); r++) { - pqxx::result::tuple tuple = Rf.at(r); - std::string name = tuple.at(0).c_str(); - fieldnames[name] = idx; - idx++; - } - - printf("patientid"SEP); - printf("template"SEP); - printf("macro"SEP); - printf("version"SEP); - printf("timestamp"SEP); - printf("user"SEP); - printf("uid"SEP); - std::map::iterator i = fieldnames.begin(); - while(i != fieldnames.end()) { - printf("%s"SEP, i->first.c_str()); - i++; - } - printf("\n"); - - pqxx::result R = W.exec("SELECT * FROM transactions WHERE template LIKE '"+like+"%';"); - - pqxx::result::const_iterator ri = R.begin(); - for(unsigned int r = 0; r < R.size(); r++) { - - pqxx::result::tuple tuple = R.at(r); - - std::string patientid = tuple.at(PATIENTID).c_str(); - std::string macro = tuple.at(MACRO).c_str(); - std::string version = tuple.at(VERSION).c_str(); - std::string timestamp = tuple.at(TIMESTAMP).c_str(); - std::string user = tuple.at(USER).c_str(); - std::string uid = tuple.at(UID).c_str(); - std::string templ = tuple.at(TEMPLATE).c_str(); - - pqxx::result Rf = W.exec("SELECT * FROM fields WHERE transaction="+uid+";"); - - std::vector values; - values.insert(values.begin(), fieldnames.size(), ""); - pqxx::result::const_iterator rfi = Rf.begin(); - for(unsigned int r = 0; r < Rf.size(); r++) { - pqxx::result::tuple tuple = Rf.at(r); - - std::string name = tuple.at(NAME).c_str(); - std::string value = tuple.at(VALUE).c_str(); - values[fieldnames[name]] = value; - } - - printf("%s"SEP, escape(patientid).c_str()); - printf("%s"SEP, escape(templ).c_str()); - printf("%s"SEP, escape(macro).c_str()); - printf("%s"SEP, escape(version).c_str()); - time_t t = atol(timestamp.c_str()); - printf("%s"SEP, escape(ctime(&t)).c_str()); - printf("%s"SEP, escape(user).c_str()); - printf("%s"SEP, escape(uid).c_str()); - std::vector::iterator vi = values.begin(); - while(vi != values.end()) { - printf("%s"SEP, escape(*vi).c_str()); - vi++; - } - printf("\n"); - - } - - return 0; -} - - - - - - - -#ifdef TEST_GETDATA -//deps: -//cflags: -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_GETDATA*/ -- cgit v1.2.3 From 5a7b924ba441ad0fef77d9c312c23f53cdba5fe8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:34:44 +0100 Subject: Remove getdata from Makefile.am.test creation list. --- server/autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/autogen.sh b/server/autogen.sh index 5be400b..6e23e5b 100755 --- a/server/autogen.sh +++ b/server/autogen.sh @@ -52,7 +52,7 @@ if [ "$DIE" -eq 1 ]; then fi # Create testfiles -TESTDIRS="src getdata" +TESTDIRS="src" for d in $TESTDIRS do if [ ! -f $d/Makefile.am.test ] -- cgit v1.2.3 From 64610c7453fc6bc0be7d3f9cb49058fb849be725 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:38:54 +0100 Subject: Move server-only tools to server tools folder. --- server/tools/Makefile.am.test | 21 ++++ server/tools/hexify.cc | 62 ++++++++++ server/tools/test | 55 +++++++++ server/tools/test.h | 262 ++++++++++++++++++++++++++++++++++++++++++ server/tools/testlist | 31 +++++ tools/Makefile.am.test | 21 ---- tools/hexify.cc | 62 ---------- tools/test | 55 --------- tools/test.h | 262 ------------------------------------------ tools/testlist | 31 ----- 10 files changed, 431 insertions(+), 431 deletions(-) create mode 100644 server/tools/Makefile.am.test create mode 100644 server/tools/hexify.cc create mode 100755 server/tools/test create mode 100644 server/tools/test.h create mode 100755 server/tools/testlist delete mode 100644 tools/Makefile.am.test delete mode 100644 tools/hexify.cc delete mode 100755 tools/test delete mode 100644 tools/test.h delete mode 100755 tools/testlist diff --git a/server/tools/Makefile.am.test b/server/tools/Makefile.am.test new file mode 100644 index 0000000..cad2627 --- /dev/null +++ b/server/tools/Makefile.am.test @@ -0,0 +1,21 @@ +Makefile.am.test: ${TEST_SOURCE_DEPS} + ${TEST_SCRIPT_DIR}/testlist > Makefile.am.test + @touch Makefile.am + +test: Makefile.am.test $(TESTFILES) + @echo "All tests done." + +test_clean: + rm -Rf lgov + rm -f $(TESTFILES) $(TESTLOGS) + +test_report: + lcov --directory . --capture --output-file app.info + genhtml -o lcov app.info + +test_all: test_clean test test_report + +TESTLOGS = `for F in ${TESTFILES}; do echo $$F.log; done` + +CLEANFILES = $(TESTFILES) $(TESTLOGS) Makefile.am.test *~ + diff --git a/server/tools/hexify.cc b/server/tools/hexify.cc new file mode 100644 index 0000000..8f8b308 --- /dev/null +++ b/server/tools/hexify.cc @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * hexify.cc + * + * Mon Feb 7 08:42:59 CET 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of Pracro. + * + * Pracro 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. + * + * Pracro 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 Pracro; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include + +#define WIDTH 12 + +int main(int argc, char *argv[]) +{ + if(argc < 2) { + printf("Usage %s file\n", argv[0]); + return 1; + } + + FILE *fp = fopen(argv[1], "r"); + if(!fp) { + printf("Could not open %s\n", argv[1]); + return 1; + } + + int cnt = 0; + printf("static const char val[] = {"); + while(!feof(fp)) { + unsigned char c; + int sz = fread(&c, 1, 1, fp); + if(cnt) printf(", "); + if(cnt % WIDTH == 0) printf("\n "); + printf("0x%02x", c); + cnt++; + } + printf("\n};\n"); + printf("static int valsize = %d;\n", cnt); + + fclose(fp); + + return 0; +} + diff --git a/server/tools/test b/server/tools/test new file mode 100755 index 0000000..ec54e70 --- /dev/null +++ b/server/tools/test @@ -0,0 +1,55 @@ +#!/bin/bash + +TEST=`echo -n $1 | cut -d'.' -f1` +UPPER=`echo $TEST | tr 'a-z.' 'A-Z_'` +OUTPUT=test_$TEST +DEFINE=TEST_$UPPER + +SCRIPTDIR=`dirname $0` + +INFILE=$1 +shift +OBJFILES="" +for f in $TEST_DEPS +do + of=`echo -n $f | cut -d'.' -f1`.o; + OBJFILES="$OBJFILES $of" +done + +COMMON_FLAGS="-DHAVE_CONFIG_H -I$SCRIPTDIR -O0 -g -D$DEFINE $TEST_LIBS $TEST_CFLAGS" +CLEAN="rm -f $OBJFILES" +PRECOMPILE="g++ -c $TEST_DEPS $COMMON_FLAGS" +COMPILE="g++ -fprofile-arcs -ftest-coverage -fno-elide-constructors -Wall -Werror $COMMON_FLAGS -o $OUTPUT $INFILE $OBJFILES" + +echo -e "\033[0;2mTesting $TEST:" +echo Testing $TEST: > $OUTPUT.log + +echo -n "* Compiling $TEST test" +echo Compiling $TEST test: > $OUTPUT.log + +echo ${CLEAN} >> $OUTPUT.log +${CLEAN} >> ${OUTPUT}.log 2>&1 +echo ${PRECOMPILE} >> $OUTPUT.log +${PRECOMPILE} >> ${OUTPUT}.log 2>&1 +echo ${COMPILE} >> $OUTPUT.log + +if ${COMPILE} >> ${OUTPUT}.log 2>&1; then + echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]" + echo "[Success]" >> $OUTPUT.log + + echo -n "* Running $TEST test" + echo Running $TEST test: >> $OUTPUT.log + if ./$OUTPUT >> $OUTPUT.log 2>&1; then + echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]" + echo "[Success]" >> $OUTPUT.log + else + echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]" + echo "[Failure]" >> $OUTPUT.log + rm -f $OUTPUT + fi +else + echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]" + echo "[Failure]" >> $OUTPUT.log +fi + +echo \ No newline at end of file diff --git a/server/tools/test.h b/server/tools/test.h new file mode 100644 index 0000000..4770a1e --- /dev/null +++ b/server/tools/test.h @@ -0,0 +1,262 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set et sw=2 ts=2: */ +/*************************************************************************** + * test.h + * + * Wed Dec 16 12:33:19 CET 2009 + * Copyright 2009 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of Pracro. + * + * Pracro 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. + * + * Pracro 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 Pracro; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __PRACRO_TEST_H__ +#define __PRACRO_TEST_H__ + +#include + +#define TEST_REPORT { \ + fprintf(stderr, "\nTest report:\n%d tests\n%d test failed.\n", \ + TEST_num_tests, TEST_num_fails); \ + } + +#define TEST_BEGIN \ + int main() { \ + int TEST_num_fails = 0; \ + int TEST_num_tests = 0; \ + {} + +#define TEST_END { \ + TEST_REPORT; \ + return TEST_num_fails != 0; \ + } } + +#define TEST_OK(m) { \ + fprintf(stderr, " OK: "m"\n"); \ + } + +#define TEST_FAIL(m) { \ + fprintf(stderr, " FAIL: "m"\t\t\t<------------\n"); \ + TEST_num_fails++; \ + } + +#define TEST_FATAL(m) { \ + fprintf(stderr, "FATAL: %s\t\t\t<============\n", m); \ + TEST_num_fails++; \ + { TEST_END; } + +#define TEST_MSG(fmt...) { \ + fprintf(stderr, "\n"); \ + fprintf(stderr, fmt); \ + fprintf(stderr, " (line %d)\n", __LINE__); \ + } + +#define TEST_BASE(fmt...) { \ + TEST_num_tests++; \ + TEST_MSG(fmt); \ + } + +#define TEST_TRUE(x, fmt...) { \ + TEST_BASE(fmt); \ + if(x) { TEST_OK(#x" is true.") } \ + else { TEST_FAIL(#x" is not true.") } \ + } + +#define TEST_FALSE(x, fmt...) { \ + TEST_BASE(fmt); \ + if(!x) { TEST_OK(#x" is false.") } \ + else { TEST_FAIL(#x" is not false.") } \ + } + +#define TEST_EQUAL(x, y, fmt...) { \ + TEST_BASE(fmt); \ + if(x == y) { TEST_OK(#x" and "#y" are equal.") } \ + else { TEST_FAIL(#x" and "#y" are not equal.") } \ + } + +#define TEST_NOTEQUAL(x, y, fmt...) { \ + TEST_BASE(fmt); \ + if(x != y) { TEST_OK(#x" and "#y" are not equal.") } \ + else { TEST_FAIL(#x" and "#y" are equal.") } \ + } + +#define TEST_GREATER_THAN(x, y, fmt...) { \ + TEST_BASE(fmt); \ + if(x > y) { TEST_OK(#x" are greater than "#y".") } \ + else { TEST_FAIL(#x" are not greater than "#y".") } \ + } + +#define TEST_LESS_THAN(x, y, fmt...) { \ + TEST_BASE(fmt); \ + if(x < y) { TEST_OK(#x" are less than "#y".") } \ + else { TEST_FAIL(#x" are not less than "#y".") } \ + } + +#define TEST_EQUAL_STR(x, y, fmt...) { \ + TEST_BASE(fmt); \ + std::string __s1 = x; \ + std::string __s2 = y; \ + fprintf(stderr, "Comparing: \"%s\" == \"%s\"\n", \ + __s1.c_str(), __s2.c_str()); \ + if(__s1 == __s2) { \ + TEST_OK(#x" and "#y" are equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are not equal."); \ + } \ + } + +#define TEST_NOTEQUAL_STR(x, y, fmt...) { \ + TEST_BASE(fmt); \ + std::string __s1 = x; \ + std::string __s2 = y; \ + fprintf(stderr, "Comparing: \"%s\" != \"%s\"\n", \ + __s1.c_str(), __s2.c_str()); \ + if(__s1 != __s2) { \ + TEST_OK(#x" and "#y" not are equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are equal."); \ + } \ + } + +#define TEST_EQUAL_INT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + int i1 = x; \ + int i2 = y; \ + fprintf(stderr, "Comparing: \"%d\" == \"%d\"\n", i1, i2); \ + if(i1 == i2) { \ + TEST_OK(#x" and "#y" are equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are not equal."); \ + } \ + } + +#define TEST_NOTEQUAL_INT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + int i1 = x; \ + int i2 = y; \ + fprintf(stderr, "Comparing: \"%d\" != \"%d\"\n", i1, i2); \ + if(i1 != i2) { \ + TEST_OK(#x" and "#y" are not equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are equal."); \ + } \ + } + +#define TEST_EQUAL_FLOAT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + double d1 = x; \ + double d2 = y; \ + fprintf(stderr, "Comparing: \"%f\" == \"%f\"\n", d1, d2); \ + if(d1 == d2) { \ + TEST_OK(#x" and "#y" are equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are not equal."); \ + } \ + } + +#define TEST_NOTEQUAL_FLOAT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + double d1 = x; \ + double d2 = y; \ + fprintf(stderr, "Comparing: \"%f\" != \"%f\"\n", d1, d2); \ + if(d1 != d2) { \ + TEST_OK(#x" and "#y" are not equal."); \ + } else { \ + TEST_FAIL(#x" and "#y" are equal."); \ + } \ + } + +#define TEST_GREATER_THAN_INT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + int i1 = x; \ + int i2 = y; \ + fprintf(stderr, "Comparing: \"%d\" > \"%d\"\n", i1, i2); \ + if(i1 > i2) { \ + TEST_OK(#x" are greater than "#y"."); \ + } else { \ + TEST_FAIL(#x" are not greater than "#y"."); \ + } \ + } + +#define TEST_LESS_THAN_INT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + int i1 = x; \ + int i2 = y; \ + fprintf(stderr, "Comparing: \"%d\" < \"%d\"\n", i1, i2); \ + if(i1 < i2) { \ + TEST_OK(#x" are less than "#y"."); \ + } else { \ + TEST_FAIL(#x" are not less than "#y"."); \ + } \ + } + +#define TEST_GREATER_THAN_FLOAT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + double d1 = x; \ + double d2 = y; \ + fprintf(stderr, "Comparing: \"%f\" > \"%f\"\n", d1, d2); \ + if(d1 > d2) { \ + TEST_OK(#x" are greater than "#y"."); \ + } else { \ + TEST_FAIL(#x" are not greater than "#y"."); \ + } \ + } + +#define TEST_LESS_THAN_FLOAT(x, y, fmt...) { \ + TEST_BASE(fmt); \ + double d1 = x; \ + double d2 = y; \ + fprintf(stderr, "Comparing: \"%f\" < \"%f\"\n", d1, d2); \ + if(d1 < d2) { \ + TEST_OK(#x" are less than "#y"."); \ + } else { \ + TEST_FAIL(#x" are not less than "#y"."); \ + } \ + } + +#define TEST_EXCEPTION(x, y, fmt...) { \ + TEST_BASE(fmt); \ + try { \ + x; \ + TEST_FAIL("Exception "#y" was not trown."); \ + } catch( y &e ) { \ + TEST_OK("Exception "#y" was thrown as expected."); \ + } \ + } + +#define TEST_NOTEXCEPTION(x, y, fmt...) { \ + TEST_BASE(fmt); \ + try { \ + x; \ + TEST_OK("Exception "#y" was not trown as expected"); \ + } catch( y &e ) { \ + TEST_FAIL("Exception "#y" was thrown."); \ + } \ + } + +#define TEST_NOEXCEPTION(x, fmt...) { \ + TEST_BASE(fmt); \ + try { \ + x; \ + TEST_OK("Exception was not trown as expected"); \ + } catch( ... ) { \ + TEST_FAIL("Exception was thrown."); \ + } \ + } + +#endif/*__PRACRO_TEST_H__*/ diff --git a/server/tools/testlist b/server/tools/testlist new file mode 100755 index 0000000..01a48e2 --- /dev/null +++ b/server/tools/testlist @@ -0,0 +1,31 @@ +#!/bin/bash + +SCRIPTDIR=`dirname $0` + +grep -l "TEST_BEGIN" *.cc > tmp + +echo -n "TESTFILES=" +while read LINE +do + FILE=$LINE + NAME=`echo $FILE | cut -d'.' -f1` + TEST=test_$NAME + echo -ne "$TEST " +done < tmp +echo "" +echo "" + +while read LINE +do + FILE=$LINE + NAME=`echo $FILE | cut -d'.' -f1` + DEPS=`cat $FILE | grep "deps:" | cut -d':' -f2` + LIBS=`cat $FILE | grep "libs:" | cut -d':' -f2` + CFLAGS=`cat $FILE | grep "cflags:" | cut -d':' -f2` + TEST=test_$NAME + echo "$TEST: $FILE $DEPS" + echo -e "\t@TEST_DEPS=\"$DEPS\" TEST_CFLAGS=\"$CFLAGS\" TEST_LIBS=\"$LIBS\" ${SCRIPTDIR}/test $FILE" + echo "" +done < tmp + +rm -f tmp \ No newline at end of file diff --git a/tools/Makefile.am.test b/tools/Makefile.am.test deleted file mode 100644 index cad2627..0000000 --- a/tools/Makefile.am.test +++ /dev/null @@ -1,21 +0,0 @@ -Makefile.am.test: ${TEST_SOURCE_DEPS} - ${TEST_SCRIPT_DIR}/testlist > Makefile.am.test - @touch Makefile.am - -test: Makefile.am.test $(TESTFILES) - @echo "All tests done." - -test_clean: - rm -Rf lgov - rm -f $(TESTFILES) $(TESTLOGS) - -test_report: - lcov --directory . --capture --output-file app.info - genhtml -o lcov app.info - -test_all: test_clean test test_report - -TESTLOGS = `for F in ${TESTFILES}; do echo $$F.log; done` - -CLEANFILES = $(TESTFILES) $(TESTLOGS) Makefile.am.test *~ - diff --git a/tools/hexify.cc b/tools/hexify.cc deleted file mode 100644 index 8f8b308..0000000 --- a/tools/hexify.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * hexify.cc - * - * Mon Feb 7 08:42:59 CET 2011 - * Copyright 2011 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include - -#define WIDTH 12 - -int main(int argc, char *argv[]) -{ - if(argc < 2) { - printf("Usage %s file\n", argv[0]); - return 1; - } - - FILE *fp = fopen(argv[1], "r"); - if(!fp) { - printf("Could not open %s\n", argv[1]); - return 1; - } - - int cnt = 0; - printf("static const char val[] = {"); - while(!feof(fp)) { - unsigned char c; - int sz = fread(&c, 1, 1, fp); - if(cnt) printf(", "); - if(cnt % WIDTH == 0) printf("\n "); - printf("0x%02x", c); - cnt++; - } - printf("\n};\n"); - printf("static int valsize = %d;\n", cnt); - - fclose(fp); - - return 0; -} - diff --git a/tools/test b/tools/test deleted file mode 100755 index ec54e70..0000000 --- a/tools/test +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -TEST=`echo -n $1 | cut -d'.' -f1` -UPPER=`echo $TEST | tr 'a-z.' 'A-Z_'` -OUTPUT=test_$TEST -DEFINE=TEST_$UPPER - -SCRIPTDIR=`dirname $0` - -INFILE=$1 -shift -OBJFILES="" -for f in $TEST_DEPS -do - of=`echo -n $f | cut -d'.' -f1`.o; - OBJFILES="$OBJFILES $of" -done - -COMMON_FLAGS="-DHAVE_CONFIG_H -I$SCRIPTDIR -O0 -g -D$DEFINE $TEST_LIBS $TEST_CFLAGS" -CLEAN="rm -f $OBJFILES" -PRECOMPILE="g++ -c $TEST_DEPS $COMMON_FLAGS" -COMPILE="g++ -fprofile-arcs -ftest-coverage -fno-elide-constructors -Wall -Werror $COMMON_FLAGS -o $OUTPUT $INFILE $OBJFILES" - -echo -e "\033[0;2mTesting $TEST:" -echo Testing $TEST: > $OUTPUT.log - -echo -n "* Compiling $TEST test" -echo Compiling $TEST test: > $OUTPUT.log - -echo ${CLEAN} >> $OUTPUT.log -${CLEAN} >> ${OUTPUT}.log 2>&1 -echo ${PRECOMPILE} >> $OUTPUT.log -${PRECOMPILE} >> ${OUTPUT}.log 2>&1 -echo ${COMPILE} >> $OUTPUT.log - -if ${COMPILE} >> ${OUTPUT}.log 2>&1; then - echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]" - echo "[Success]" >> $OUTPUT.log - - echo -n "* Running $TEST test" - echo Running $TEST test: >> $OUTPUT.log - if ./$OUTPUT >> $OUTPUT.log 2>&1; then - echo -e "\r\t\t\t\t\t\t[\033[1;32mSuccess\033[0;2m]" - echo "[Success]" >> $OUTPUT.log - else - echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]" - echo "[Failure]" >> $OUTPUT.log - rm -f $OUTPUT - fi -else - echo -e "\r\t\t\t\t\t\t[\033[1;31mFailure\033[0;2m]" - echo "[Failure]" >> $OUTPUT.log -fi - -echo \ No newline at end of file diff --git a/tools/test.h b/tools/test.h deleted file mode 100644 index 4770a1e..0000000 --- a/tools/test.h +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * test.h - * - * Wed Dec 16 12:33:19 CET 2009 - * Copyright 2009 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#ifndef __PRACRO_TEST_H__ -#define __PRACRO_TEST_H__ - -#include - -#define TEST_REPORT { \ - fprintf(stderr, "\nTest report:\n%d tests\n%d test failed.\n", \ - TEST_num_tests, TEST_num_fails); \ - } - -#define TEST_BEGIN \ - int main() { \ - int TEST_num_fails = 0; \ - int TEST_num_tests = 0; \ - {} - -#define TEST_END { \ - TEST_REPORT; \ - return TEST_num_fails != 0; \ - } } - -#define TEST_OK(m) { \ - fprintf(stderr, " OK: "m"\n"); \ - } - -#define TEST_FAIL(m) { \ - fprintf(stderr, " FAIL: "m"\t\t\t<------------\n"); \ - TEST_num_fails++; \ - } - -#define TEST_FATAL(m) { \ - fprintf(stderr, "FATAL: %s\t\t\t<============\n", m); \ - TEST_num_fails++; \ - { TEST_END; } - -#define TEST_MSG(fmt...) { \ - fprintf(stderr, "\n"); \ - fprintf(stderr, fmt); \ - fprintf(stderr, " (line %d)\n", __LINE__); \ - } - -#define TEST_BASE(fmt...) { \ - TEST_num_tests++; \ - TEST_MSG(fmt); \ - } - -#define TEST_TRUE(x, fmt...) { \ - TEST_BASE(fmt); \ - if(x) { TEST_OK(#x" is true.") } \ - else { TEST_FAIL(#x" is not true.") } \ - } - -#define TEST_FALSE(x, fmt...) { \ - TEST_BASE(fmt); \ - if(!x) { TEST_OK(#x" is false.") } \ - else { TEST_FAIL(#x" is not false.") } \ - } - -#define TEST_EQUAL(x, y, fmt...) { \ - TEST_BASE(fmt); \ - if(x == y) { TEST_OK(#x" and "#y" are equal.") } \ - else { TEST_FAIL(#x" and "#y" are not equal.") } \ - } - -#define TEST_NOTEQUAL(x, y, fmt...) { \ - TEST_BASE(fmt); \ - if(x != y) { TEST_OK(#x" and "#y" are not equal.") } \ - else { TEST_FAIL(#x" and "#y" are equal.") } \ - } - -#define TEST_GREATER_THAN(x, y, fmt...) { \ - TEST_BASE(fmt); \ - if(x > y) { TEST_OK(#x" are greater than "#y".") } \ - else { TEST_FAIL(#x" are not greater than "#y".") } \ - } - -#define TEST_LESS_THAN(x, y, fmt...) { \ - TEST_BASE(fmt); \ - if(x < y) { TEST_OK(#x" are less than "#y".") } \ - else { TEST_FAIL(#x" are not less than "#y".") } \ - } - -#define TEST_EQUAL_STR(x, y, fmt...) { \ - TEST_BASE(fmt); \ - std::string __s1 = x; \ - std::string __s2 = y; \ - fprintf(stderr, "Comparing: \"%s\" == \"%s\"\n", \ - __s1.c_str(), __s2.c_str()); \ - if(__s1 == __s2) { \ - TEST_OK(#x" and "#y" are equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are not equal."); \ - } \ - } - -#define TEST_NOTEQUAL_STR(x, y, fmt...) { \ - TEST_BASE(fmt); \ - std::string __s1 = x; \ - std::string __s2 = y; \ - fprintf(stderr, "Comparing: \"%s\" != \"%s\"\n", \ - __s1.c_str(), __s2.c_str()); \ - if(__s1 != __s2) { \ - TEST_OK(#x" and "#y" not are equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are equal."); \ - } \ - } - -#define TEST_EQUAL_INT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - int i1 = x; \ - int i2 = y; \ - fprintf(stderr, "Comparing: \"%d\" == \"%d\"\n", i1, i2); \ - if(i1 == i2) { \ - TEST_OK(#x" and "#y" are equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are not equal."); \ - } \ - } - -#define TEST_NOTEQUAL_INT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - int i1 = x; \ - int i2 = y; \ - fprintf(stderr, "Comparing: \"%d\" != \"%d\"\n", i1, i2); \ - if(i1 != i2) { \ - TEST_OK(#x" and "#y" are not equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are equal."); \ - } \ - } - -#define TEST_EQUAL_FLOAT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - double d1 = x; \ - double d2 = y; \ - fprintf(stderr, "Comparing: \"%f\" == \"%f\"\n", d1, d2); \ - if(d1 == d2) { \ - TEST_OK(#x" and "#y" are equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are not equal."); \ - } \ - } - -#define TEST_NOTEQUAL_FLOAT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - double d1 = x; \ - double d2 = y; \ - fprintf(stderr, "Comparing: \"%f\" != \"%f\"\n", d1, d2); \ - if(d1 != d2) { \ - TEST_OK(#x" and "#y" are not equal."); \ - } else { \ - TEST_FAIL(#x" and "#y" are equal."); \ - } \ - } - -#define TEST_GREATER_THAN_INT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - int i1 = x; \ - int i2 = y; \ - fprintf(stderr, "Comparing: \"%d\" > \"%d\"\n", i1, i2); \ - if(i1 > i2) { \ - TEST_OK(#x" are greater than "#y"."); \ - } else { \ - TEST_FAIL(#x" are not greater than "#y"."); \ - } \ - } - -#define TEST_LESS_THAN_INT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - int i1 = x; \ - int i2 = y; \ - fprintf(stderr, "Comparing: \"%d\" < \"%d\"\n", i1, i2); \ - if(i1 < i2) { \ - TEST_OK(#x" are less than "#y"."); \ - } else { \ - TEST_FAIL(#x" are not less than "#y"."); \ - } \ - } - -#define TEST_GREATER_THAN_FLOAT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - double d1 = x; \ - double d2 = y; \ - fprintf(stderr, "Comparing: \"%f\" > \"%f\"\n", d1, d2); \ - if(d1 > d2) { \ - TEST_OK(#x" are greater than "#y"."); \ - } else { \ - TEST_FAIL(#x" are not greater than "#y"."); \ - } \ - } - -#define TEST_LESS_THAN_FLOAT(x, y, fmt...) { \ - TEST_BASE(fmt); \ - double d1 = x; \ - double d2 = y; \ - fprintf(stderr, "Comparing: \"%f\" < \"%f\"\n", d1, d2); \ - if(d1 < d2) { \ - TEST_OK(#x" are less than "#y"."); \ - } else { \ - TEST_FAIL(#x" are not less than "#y"."); \ - } \ - } - -#define TEST_EXCEPTION(x, y, fmt...) { \ - TEST_BASE(fmt); \ - try { \ - x; \ - TEST_FAIL("Exception "#y" was not trown."); \ - } catch( y &e ) { \ - TEST_OK("Exception "#y" was thrown as expected."); \ - } \ - } - -#define TEST_NOTEXCEPTION(x, y, fmt...) { \ - TEST_BASE(fmt); \ - try { \ - x; \ - TEST_OK("Exception "#y" was not trown as expected"); \ - } catch( y &e ) { \ - TEST_FAIL("Exception "#y" was thrown."); \ - } \ - } - -#define TEST_NOEXCEPTION(x, fmt...) { \ - TEST_BASE(fmt); \ - try { \ - x; \ - TEST_OK("Exception was not trown as expected"); \ - } catch( ... ) { \ - TEST_FAIL("Exception was thrown."); \ - } \ - } - -#endif/*__PRACRO_TEST_H__*/ diff --git a/tools/testlist b/tools/testlist deleted file mode 100755 index 01a48e2..0000000 --- a/tools/testlist +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -SCRIPTDIR=`dirname $0` - -grep -l "TEST_BEGIN" *.cc > tmp - -echo -n "TESTFILES=" -while read LINE -do - FILE=$LINE - NAME=`echo $FILE | cut -d'.' -f1` - TEST=test_$NAME - echo -ne "$TEST " -done < tmp -echo "" -echo "" - -while read LINE -do - FILE=$LINE - NAME=`echo $FILE | cut -d'.' -f1` - DEPS=`cat $FILE | grep "deps:" | cut -d':' -f2` - LIBS=`cat $FILE | grep "libs:" | cut -d':' -f2` - CFLAGS=`cat $FILE | grep "cflags:" | cut -d':' -f2` - TEST=test_$NAME - echo "$TEST: $FILE $DEPS" - echo -e "\t@TEST_DEPS=\"$DEPS\" TEST_CFLAGS=\"$CFLAGS\" TEST_LIBS=\"$LIBS\" ${SCRIPTDIR}/test $FILE" - echo "" -done < tmp - -rm -f tmp \ No newline at end of file -- cgit v1.2.3 From ff0ebb2f67e51e4ef37088eebef420b0566a45ff Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:41:17 +0100 Subject: Fix compilation with new location of server tools. --- server/configure.in | 2 +- server/src/Makefile.am | 2 +- server/src/praxisd.cc | 2 +- server/tools/Makefile.am | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 server/tools/Makefile.am diff --git a/server/configure.in b/server/configure.in index c647aed..d8cb0c0 100644 --- a/server/configure.in +++ b/server/configure.in @@ -246,12 +246,12 @@ AC_SUBST(PTHREAD_LIBS) AC_OUTPUT( Makefile src/Makefile - getdata/Makefile gentoo/init.d/Makefile gentoo/init.d/pracrod gentoo/logrotate.d/Makefile etc/Makefile man/Makefile + tools/Makefile xml/templates/Makefile xml/macros/Makefile xml/Makefile) diff --git a/server/src/Makefile.am b/server/src/Makefile.am index 9f3f100..dbf20da 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -138,7 +138,7 @@ EXTRA_DIST = \ ################ TEST_SOURCE_DEPS = ${pracrod_SOURCES} ${EXTRA_DIST} -TEST_SCRIPT_DIR = $(top_srcdir)/../tools +TEST_SCRIPT_DIR = $(top_srcdir)/tools include ${TEST_SCRIPT_DIR}/Makefile.am.test diff --git a/server/src/praxisd.cc b/server/src/praxisd.cc index a75ad9f..3ccdf0d 100644 --- a/server/src/praxisd.cc +++ b/server/src/praxisd.cc @@ -139,7 +139,7 @@ void Praxisd::journal_add(std::string cpr, std::string entry) // Unset 'Expect' header, set by CURLOPT_POSTFIELDS slist = curl_slist_append(slist, "Expect:"); slist = curl_slist_append(slist, "Content-Type: text/xml"); - slist = curl_slist_append(slist, "Connection: keep-alive"); + // slist = curl_slist_append(slist, "Connection: keep-alive"); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, slist); std::string uri = host + "/praxisd/1.0/journal/add"; diff --git a/server/tools/Makefile.am b/server/tools/Makefile.am new file mode 100644 index 0000000..8f54004 --- /dev/null +++ b/server/tools/Makefile.am @@ -0,0 +1,6 @@ +EXTRA_DIST = \ + Makefile.am.test \ + hexify.cc \ + test \ + test.h \ + testlist -- cgit v1.2.3 From 3c594986b569a1d6943d3eb0cfe4902f56c10c4d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:45:21 +0100 Subject: Add missing header files to EXTRA_DIST. --- server/src/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/Makefile.am b/server/src/Makefile.am index dbf20da..167f4e4 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -113,6 +113,7 @@ EXTRA_DIST = \ queryhandlerpentominos.h \ queryhandlerpracro.h \ queryparser.h \ + queryresult.h \ resumeparser.h \ saxparser.h \ semaphore.h \ @@ -120,9 +121,11 @@ EXTRA_DIST = \ session.h \ sessionparser.h \ sessionserialiser.h \ + template.h \ templatelist.h \ templateheaderparser.h \ templateparser.h \ + transaction.h \ transactionhandler.h \ transactionparser.h \ tcpsocket.h \ -- cgit v1.2.3 From 6b4be5c411c204d5f3aa55bf742cd4817c665dbe Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 17 Nov 2011 14:47:25 +0100 Subject: Remove currently unused acl files. --- server/src/acl.cc | 45 --------------------------------------------- server/src/acl.h | 33 --------------------------------- 2 files changed, 78 deletions(-) delete mode 100644 server/src/acl.cc delete mode 100644 server/src/acl.h diff --git a/server/src/acl.cc b/server/src/acl.cc deleted file mode 100644 index ec9d7d2..0000000 --- a/server/src/acl.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * acl.cc - * - * Mon Apr 11 15:23:18 CEST 2011 - * Copyright 2011 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "acl.h" - -#ifdef TEST_ACL -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - - - -TEST_END; - -#endif/*TEST_ACL*/ diff --git a/server/src/acl.h b/server/src/acl.h deleted file mode 100644 index 6aaae22..0000000 --- a/server/src/acl.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set et sw=2 ts=2: */ -/*************************************************************************** - * acl.h - * - * Mon Apr 11 15:23:18 CEST 2011 - * Copyright 2011 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro 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. - * - * Pracro 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 Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#ifndef __PRACRO_ACL_H__ -#define __PRACRO_ACL_H__ - - - -#endif/*__PRACRO_ACL_H__*/ -- cgit v1.2.3 From 57b98d1445697727f6b1eee8ef1e1e5a33d10c56 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 21 Nov 2011 10:00:13 +0100 Subject: Add missing dir to dist. --- server/configure.in | 1 + server/xml/courses/Makefile.am | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 server/xml/courses/Makefile.am diff --git a/server/configure.in b/server/configure.in index d8cb0c0..63e2e24 100644 --- a/server/configure.in +++ b/server/configure.in @@ -254,5 +254,6 @@ AC_OUTPUT( tools/Makefile xml/templates/Makefile xml/macros/Makefile + xml/courses/Makefile xml/Makefile) diff --git a/server/xml/courses/Makefile.am b/server/xml/courses/Makefile.am new file mode 100644 index 0000000..5f769c4 --- /dev/null +++ b/server/xml/courses/Makefile.am @@ -0,0 +1,7 @@ +EXTRA_DIST = \ + test.xml + +xmldir = $(datadir)/xml/courses + +xml_DATA = \ + test.xml -- cgit v1.2.3 From 49fbc693518b698f0110616947d9c4c83dc67f7b Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 21 Nov 2011 10:00:27 +0100 Subject: Add missing dir to dist. --- server/Makefile.am | 6 +++--- server/xml/Makefile.am | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/Makefile.am b/server/Makefile.am index 34bd487..cf8151b 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src gentoo/init.d gentoo/logrotate.d \ - etc man xml xml/templates xml/macros $(DOC_DIR) -DISTDIRS = src etc man xml xml/templates xml/macros $(DOC_DIR) +SUBDIRS = src gentoo/init.d gentoo/logrotate.d tools \ + etc man xml $(DOC_DIR) +DISTDIRS = src etc man xml tools $(DOC_DIR) .PHONY: doc doc: diff --git a/server/xml/Makefile.am b/server/xml/Makefile.am index a478a79..350048a 100644 --- a/server/xml/Makefile.am +++ b/server/xml/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = templates macros courses + EXTRA_DIST = xmldir = $(datadir)/xml -- cgit v1.2.3 From 0db0201087d44a567e82708270d9e6ecbb546a2b Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 23 Nov 2011 11:44:53 +0100 Subject: Bugfix: Terminate sessions without template names (discard) so that they are not used by future connections. Some sanity checks with corresponding error responses. --- server/src/client_connection.cc | 60 +++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/server/src/client_connection.cc b/server/src/client_connection.cc index 1ec7e7c..fe55efc 100644 --- a/server/src/client_connection.cc +++ b/server/src/client_connection.cc @@ -141,6 +141,18 @@ void ClientConnection::discard(Session *session) bool ClientConnection::handle(const char *data, size_t size) { + if(patientid == "") { + response = error_box(xml_encode("Missing patientid.")); + parser_complete = true; + return true; + } + + if(request.course == "") { + response = error_box(xml_encode("Missing course.")); + parser_complete = true; + return true; + } + Session *session = NULL; try { if(sessionid == "") { @@ -159,12 +171,14 @@ bool ClientConnection::handle(const char *data, size_t size) ERR(connection, "Session already active.\n"); parser_complete = true; response = error_box(xml_encode("Session "+e.sessionid+" already active.")); + parser_complete = true; return true; } if(session == NULL) { ERR(connection, "New session could not be created.\n"); response = error_box(xml_encode("New session could not be created.")); + parser_complete = true; return true; } @@ -180,6 +194,9 @@ bool ClientConnection::handle(const char *data, size_t size) return true; } + // Force session discard on empty template name. + if(templ == "") dodiscard = true; + if(size == 0 || parser.parse(data, size)) { parser_complete = true; @@ -195,7 +212,7 @@ bool ClientConnection::handle(const char *data, size_t size) return true; } } catch(...) { - ERR(server, "Failed to parse data!\n"); + ERR(connection, "Failed to parse data!\n"); response = error_box(xml_encode("XML Parse error.")); return true; } @@ -221,9 +238,9 @@ void ClientConnection::getReply(Httpd::Reply &reply) } #ifdef TEST_CLIENT_CONNECTION -//deps: debug.cc transactionparser.cc session.cc xml_encode_decode.cc saxparser.cc transactionhandler.cc journal.cc mutex.cc templateparser.cc exception.cc configuration.cc macroparser.cc semaphore.cc entitylist.cc luaquerymapper.cc inotify.cc log.cc queryhandlerpentominos.cc widgetgenerator.cc queryhandlerpracro.cc resumeparser.cc journal_commit.cc versionstr.cc luaresume.cc luautil.cc artefact.cc environment.cc database.cc macrolist.cc templatelist.cc pracrodao.cc templateheaderparser.cc macroheaderparser.cc pracrodaotest.cc pracrodaopgsql.cc journal_uploadserver.cc sessionserialiser.cc sessionparser.cc widgetvalue.cc -//cflags: -DWITHOUT_DATABASE -DWITHOUT_ARTEFACT -I.. $(LUA_CFLAGS) $(EXPAT_CFLAGS) $(PTHREAD_CFLAGS) $(PQXX_CXXFLAGS) -//libs: $(LUA_LIBS) $(EXPAT_LIBS) $(PTHREAD_LIBS) $(PQXX_LIBS) +//deps: debug.cc transactionparser.cc session.cc xml_encode_decode.cc saxparser.cc transactionhandler.cc journal.cc mutex.cc templateparser.cc exception.cc configuration.cc macroparser.cc semaphore.cc entitylist.cc luaquerymapper.cc inotify.cc log.cc queryhandlerpentominos.cc widgetgenerator.cc queryhandlerpracro.cc resumeparser.cc journal_commit.cc versionstr.cc luaresume.cc luautil.cc artefact.cc environment.cc database.cc macrolist.cc templatelist.cc pracrodao.cc templateheaderparser.cc macroheaderparser.cc pracrodaotest.cc pracrodaopgsql.cc journal_uploadserver.cc sessionserialiser.cc sessionparser.cc widgetvalue.cc courseparser.cc praxisd.cc luapraxisd.cc courselist.cc +//cflags: -DWITHOUT_DATABASE -DWITHOUT_ARTEFACT -I.. $(LUA_CFLAGS) $(EXPAT_CFLAGS) $(PTHREAD_CFLAGS) $(PQXX_CXXFLAGS) $(CURL_CFLAGS) +//libs: $(LUA_LIBS) $(EXPAT_LIBS) $(PTHREAD_LIBS) $(PQXX_LIBS) $(CURL_LIBS) #include "test.h" /* static char xml_request[] = @@ -258,8 +275,20 @@ static char xml_commit_p2[] = "\n" ; */ + +static const char empty_reply[] = + "\n" + "\n" + "\n"; + +#include "configuration.h" + TEST_BEGIN; +debug_parse("-all,+connection,+session"); + +Conf::xml_basedir = "../xml"; + Environment env; Httpd::Reply reply; std::string sid; @@ -267,28 +296,30 @@ std::string sid; // Without data { headers_t hdrs; - ClientConnection con(env, hdrs); + ClientConnection con(env, hdrs, hdrs, "/test"); TEST_TRUE(con.handle("", 0), "Test handler return value."); con.getReply(reply); - TEST_EQUAL_STR(reply.data, "", "Test response value."); - TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Test new session id."); + TEST_NOTEQUAL_STR(reply.data, empty_reply, "Did we get nonemtpy reply?"); + TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", + "Did we get a new session id?"); + sid = reply.headers["SessionID"]; TEST_FALSE(did_commit, "No commit."); } { headers_t hdrs; - ClientConnection con(env, hdrs); + ClientConnection con(env, hdrs, hdrs, "/test/test"); TEST_TRUE(con.handle("", 0), "Test handler return value."); con.getReply(reply); - TEST_EQUAL_STR(reply.data, "", "Test response value."); - TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Test existing session id."); - TEST_EQUAL_STR(reply.headers["SessionID"], sid, "Test existing session id."); + TEST_EQUAL_STR(reply.data, empty_reply, "Did we get an empty reponse?"); + TEST_NOTEQUAL_STR(reply.headers["SessionID"], "", "Non empty session id?"); + TEST_NOTEQUAL_STR(reply.headers["SessionID"], sid, "Not the same id!"); TEST_FALSE(did_commit, "No commit."); } - +/* { headers_t hdrs; - ClientConnection con(env, hdrs); + ClientConnection con(env, hdrs, hdrs, ""); TEST_TRUE(con.handle("", 0), "Test handler return value."); con.getReply(reply); TEST_EQUAL_STR(reply.data, "", "Test response value."); @@ -298,7 +329,7 @@ std::string sid; { headers_t hdrs; - ClientConnection con(env, hdrs); + ClientConnection con(env, hdrs, hdrs, ""); TEST_TRUE(con.handle("", 0), "Test handler return value."); con.getReply(reply); TEST_EQUAL_STR(reply.data, "", "Test response value."); @@ -306,6 +337,7 @@ std::string sid; TEST_NOTEQUAL_STR(reply.headers["SessionID"], sid, "Test new session id."); TEST_FALSE(did_commit, "No commit."); } +*/ /* // With commit partial data { -- cgit v1.2.3 From 867a4bee43cad43aa5855c138e53ce27c7ea5847 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 23 Nov 2011 14:56:47 +0100 Subject: Fix horrible bug in PatientParser using only the last sogeord in the list if more than one present. --- client/praxisd.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/praxisd.cc b/client/praxisd.cc index 001eb90..161b471 100644 --- a/client/praxisd.cc +++ b/client/praxisd.cc @@ -104,18 +104,16 @@ static Patient getPatient(QByteArray data) DOPATIENT(frilinie5); if(element.tagName() == "sogeords") { - sogeord_t sogeord; - QDomNodeList nodes = element.childNodes(); for(int j = 0; j < nodes.count(); j++) { + sogeord_t sogeord; QDomNode node = nodes.at(j); QDomElement element = node.toElement(); sogeord.sogenr = element.attribute("sogenr"); sogeord.sogedato = element.attribute("sogedato"); sogeord.sogetxt = element.text(); + patient.sogeord.push_back(sogeord); } - - patient.sogeord.push_back(sogeord); } DOPATIENT(ydernr); -- cgit v1.2.3 From 07244d0376e2e25eaeba913e684bd06122ded893 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 23 Nov 2011 15:03:04 +0100 Subject: Tick version. --- client/client.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client.pro b/client/client.pro index dce4838..e002942 100644 --- a/client/client.pro +++ b/client/client.pro @@ -16,7 +16,7 @@ debug { DEFINES+=USE_DEBUG } -DEFINES+=VERSION=\\\"2.2.0\\\" +DEFINES+=VERSION=\\\"2.2.1\\\" win32 { LIBPATH += lua/lib -- cgit v1.2.3