summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/Makefile.am14
-rw-r--r--server/src/admin_connection.cc2
-rw-r--r--server/src/admin_export.cc2
-rw-r--r--server/src/artefact.cc2
-rw-r--r--server/src/courselist.cc2
-rw-r--r--server/src/courseparser.cc8
-rw-r--r--server/src/database.cc2
-rw-r--r--server/src/database.h2
-rw-r--r--server/src/debug.cc287
-rw-r--r--server/src/debug.h134
-rw-r--r--server/src/entitylist.cc2
-rw-r--r--server/src/exception.cc2
-rw-r--r--server/src/fieldnamescanner.cc2
-rw-r--r--server/src/httpd.cc2
-rw-r--r--server/src/inotify.cc2
-rw-r--r--server/src/journal.cc2
-rw-r--r--server/src/journal_commit.cc12
-rw-r--r--server/src/log.cc2
-rw-r--r--server/src/luaoncommit.cc2
-rw-r--r--server/src/luapraxisd.cc2
-rw-r--r--server/src/luaresume.cc2
-rw-r--r--server/src/luascript.cc2
-rw-r--r--server/src/luautil.cc2
-rw-r--r--server/src/macroheaderparser.cc24
-rw-r--r--server/src/macrolist.cc2
-rw-r--r--server/src/macroparser.cc24
-rw-r--r--server/src/macrotool/dump.cc2
-rw-r--r--server/src/macrotool/export.cc2
-rw-r--r--server/src/macrotool/fieldnames.cc2
-rw-r--r--server/src/macrotool/filehandler.cc2
-rw-r--r--server/src/macrotool/macrotool.cc2
-rw-r--r--server/src/pgwork.cc2
-rw-r--r--server/src/pracrod.cc48
-rw-r--r--server/src/pracrodaopgsql.cc34
-rw-r--r--server/src/pracrodaotest.cc4
-rw-r--r--server/src/queryhandlerpentominos.cc2
-rw-r--r--server/src/queryhandlerpracro.cc2
-rw-r--r--server/src/queryresult.h2
-rw-r--r--server/src/saxparser.cc2
-rw-r--r--server/src/server.cc6
-rw-r--r--server/src/sessionheaderparser.cc24
-rw-r--r--server/src/sessionparser.cc2
-rw-r--r--server/src/tcpsocket.cc4
-rw-r--r--server/src/templateheaderparser.cc24
-rw-r--r--server/src/templatelist.cc2
-rw-r--r--server/src/templateparser.cc8
-rw-r--r--server/src/transactionparser.cc2
-rw-r--r--server/src/utf8.cc2
-rw-r--r--server/src/util.cc2
-rw-r--r--server/src/widgetvalue.cc2
50 files changed, 136 insertions, 589 deletions
diff --git a/server/src/Makefile.am b/server/src/Makefile.am
index 855bec2..5edec4e 100644
--- a/server/src/Makefile.am
+++ b/server/src/Makefile.am
@@ -8,7 +8,10 @@ pracrod_LDADD = $(LD_EFENCE) $(PQ_LIBS) $(CONFIG_LIBS) \
pracrod_CXXFLAGS = $(PQ_CFLAGS) $(CONFIG_CXXFLAGS) \
$(LUA_CFLAGS) $(HTTPD_CFLAGS) $(EXPAT_CFLAGS) \
- $(PTHREAD_CFLAGS) $(ATF_CFLAGS) $(CURL_CFLAGS)
+ $(PTHREAD_CFLAGS) $(ATF_CFLAGS) $(CURL_CFLAGS) \
+ -I$(top_srcdir)/../hugin -DWITH_HUG_FILTER
+
+pracrod_CFLAGS = -DWITH_HUG_FILTER
pracrod_SOURCES = \
pracrod.cc \
@@ -25,7 +28,6 @@ pracrod_SOURCES = \
courselist.cc \
daemon.cc \
database.cc \
- debug.cc \
entitylist.cc \
environment.cc \
exception.cc \
@@ -72,7 +74,9 @@ pracrod_SOURCES = \
versionstr.cc \
widgetvalue.cc \
widgetgenerator.cc \
- xml_encode_decode.cc
+ xml_encode_decode.cc \
+ $(top_srcdir)/../hugin/hugin.c \
+ $(top_srcdir)/../hugin/hugin_filter.c
EXTRA_DIST = \
artefact.h \
@@ -89,7 +93,6 @@ EXTRA_DIST = \
daemon.h \
database.h \
dbtypes.h \
- debug.h \
environment.h \
entitylist.h \
exception.h \
@@ -140,7 +143,8 @@ EXTRA_DIST = \
versionstr.h \
widgetvalue.h \
widgetgenerator.h \
- xml_encode_decode.h
+ xml_encode_decode.h \
+ $(top_srcdir)/../hugin/hugin.h
################
# Test Section #
diff --git a/server/src/admin_connection.cc b/server/src/admin_connection.cc
index 76c88ea..75b41e7 100644
--- a/server/src/admin_connection.cc
+++ b/server/src/admin_connection.cc
@@ -32,7 +32,7 @@
#include "admin_rc.h"
#include "admin_export.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
#include "sessionserialiser.h"
diff --git a/server/src/admin_export.cc b/server/src/admin_export.cc
index 6f5ecba..2212a6a 100644
--- a/server/src/admin_export.cc
+++ b/server/src/admin_export.cc
@@ -29,7 +29,7 @@
#include <config.h>
#include <stdio.h>
-#include "debug.h"
+#include <hugin.hpp>
#ifndef WITHOUT_DB
diff --git a/server/src/artefact.cc b/server/src/artefact.cc
index 48b8174..84d190b 100644
--- a/server/src/artefact.cc
+++ b/server/src/artefact.cc
@@ -27,7 +27,7 @@
*/
#include "artefact.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
#include "queryparser.h"
diff --git a/server/src/courselist.cc b/server/src/courselist.cc
index b2a33c5..84760ca 100644
--- a/server/src/courselist.cc
+++ b/server/src/courselist.cc
@@ -29,7 +29,7 @@
#include "courseparser.h"
-#include "debug.h"
+#include <hugin.hpp>
CourseList::CourseList(std::string path)
: EntityList(path, "course")
diff --git a/server/src/courseparser.cc b/server/src/courseparser.cc
index 79501f3..1a94e8b 100644
--- a/server/src/courseparser.cc
+++ b/server/src/courseparser.cc
@@ -45,7 +45,7 @@
#include <stdio.h>
#include "configuration.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "exception.h"
void CourseParser::error(const char* fmt, ...)
@@ -55,7 +55,7 @@ void CourseParser::error(const char* fmt, ...)
va_start(argp, fmt);
vasprintf(&p, fmt, argp);
va_end(argp);
- ERR_LOG(course, "Error in CourseParser: %s\n", p);
+ ERR(course, "Error in CourseParser: %s\n", p);
throw Exception(std::string("Error in CourseParser: ") + p);
free(p);
}
@@ -126,12 +126,12 @@ void CourseParser::endTag(std::string name)
int CourseParser::readData(char *data, size_t size)
{
if(fd == -1) {
- ERR_LOG(course, "Invalid file descriptor.\n");
+ ERR(course, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(course, "Could not read...%s\n", strerror(errno));
+ ERR(course, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
diff --git a/server/src/database.cc b/server/src/database.cc
index 27e903f..761f82a 100644
--- a/server/src/database.cc
+++ b/server/src/database.cc
@@ -30,7 +30,7 @@
#include <config.h>
#include <stdlib.h>
-#include "debug.h"
+#include <hugin.hpp>
#include "pracrodaopgsql.h"
#include "pracrodaotest.h"
diff --git a/server/src/database.h b/server/src/database.h
index 7249233..41362cd 100644
--- a/server/src/database.h
+++ b/server/src/database.h
@@ -33,7 +33,7 @@
#include "transaction.h"
#include "template.h"
#include "mutex.h"
-#include "debug.h"
+#include <hugin.hpp>
class Database {
public:
diff --git a/server/src/debug.cc b/server/src/debug.cc
deleted file mode 100644
index e42baae..0000000
--- a/server/src/debug.cc
+++ /dev/null
@@ -1,287 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * debug.cc
- *
- * Wed Feb 11 11:22:12 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.
- */
-#include "debug.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include "log.h"
-
-#include <pthread.h>
-
-#include "mutex.h"
-
-static Mutex mutex;
-
-static unsigned int gettid()
-{
- return (unsigned int)pthread_self();
-}
-
-static FILE *logfp = stderr;
-
-#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
-struct __debug_channel
-{
- char name[32];
- unsigned flags;
-};
-
-static const char * const debug_class_str[] =
- { "fixme", "err", "warn", "info", "debug" };
-
-#define __DEBUG_CHANNEL_MAX 256
-
-static struct __debug_channel debug_channel[__DEBUG_CHANNEL_MAX];
-static unsigned n_debug_channel = 0;
-static unsigned debug_flags = (1 << __class_err) | (1 << __class_fixme);
-
-static int __debug_enabled(const enum __debug_class cl, const char *ch)
-{
- unsigned i;
- for(i = 0; i < n_debug_channel; i++) {
- if(!strcmp(ch, debug_channel[i].name)) {
- return (debug_channel[i].flags & (1 << cl)) != 0;
- }
- }
- return debug_flags & (1 << cl);
-}
-
-
-#ifdef WITH_DEBUG
-int __debug(const char *func, const int line,
- const enum __debug_class cl,
- const char *ch, const char *fmt, ...)
-{
- MutexAutolock m(mutex);
- int ret = 0;
- if(__debug_enabled(cl, ch)) {
- if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(logfp, "%u %s:%s:%s:%d ",
- gettid(), debug_class_str[(unsigned)cl], ch, func, line);
- if(fmt) {
- va_list va;
- va_start(va, fmt);
- ret += vfprintf(logfp, fmt, va);
- va_end(va);
- }
- }
- if(ret){
- fflush(logfp);
- }
- return ret;
-}
-
-int __debug_va(const char *func, const int line,
- const enum __debug_class cl,
- const char *ch, const char *fmt, va_list va)
-{
- MutexAutolock m(mutex);
- int ret = 0;
- if(__debug_enabled(cl, ch)) {
- if((unsigned)cl < NELEM(debug_class_str))
- ret += fprintf(logfp, "%u %s:%s:%s:%d ",
- gettid(), debug_class_str[(unsigned)cl], ch, func, line);
- if(fmt)
- ret += vfprintf(logfp, fmt, va);
- }
- if(ret) {
- fflush(logfp);
- }
- return ret;
-}
-
-#endif
-
-int __log(const char *func, const int line, const enum __debug_class cl,
- const char *ch, const char *fmt, ...)
-{
- MutexAutolock m(mutex);
-
- std::string logmsg;
- char str[8];
-
-#ifdef WITH_DEBUG
- int ret = 0;
-#endif
- if(__debug_enabled(cl, ch)) {
- if((unsigned)cl < NELEM(debug_class_str))
- if((unsigned)cl < NELEM(debug_class_str))
-#ifdef WITH_DEBUG
- ret = fprintf(logfp, "%u %s:%s:%s:%d ",
- gettid(), debug_class_str[(unsigned)cl], ch, func, line);
-#endif
- sprintf(str, "%d", line);
- logmsg = std::string(debug_class_str[(unsigned)cl]) + ":" + ch + ":" + func + ":" + str;
- if(fmt) {
- va_list va;
- va_start(va, fmt);
-#ifdef WITH_DEBUG
- ret += vfprintf(logfp, fmt, va);
-#endif
- char* ptr;
- if(vasprintf(&ptr, fmt, va) == -1) {}
- logmsg += ptr;
- va_end(va);
- }
- }
-#ifdef WITH_DEBUG
- if(ret) {
- fprintf(logfp, "\n");
- fflush(logfp);
- }
-#endif
- log(logmsg);
- return logmsg.size();
-}
-
-int __log_va(const char *func, const int line, const enum __debug_class cl,
- const char *ch, const char *fmt, va_list va)
-{
- MutexAutolock m(mutex);
-
- std::string logmsg;
- char str[8];
-#ifdef WITH_DEBUG
- int ret = 0;
-#endif
- if(__debug_enabled(cl, ch)) {
- if((unsigned)cl < NELEM(debug_class_str))
-#ifdef WITH_DEBUG
- ret = fprintf(logfp, "%u %s:%s:%s:%d ",
- gettid(), debug_class_str[(unsigned)cl], ch, func, line);
-#endif
- sprintf(str, "%d", line);
- logmsg = std::string(debug_class_str[(unsigned)cl]) + ":" + ch + ":" + func + ":" + str;
- if(fmt) {
-#ifdef WITH_DEBUG
- ret += vfprintf(logfp, fmt, va);
-#endif
- char* ptr;
- if(vasprintf(&ptr, fmt, va) == -1) {}
- logmsg += ptr;
- }
- }
-#ifdef WITH_DEBUG
- if(ret) {
- fprintf(logfp, "\n");
- fflush(logfp);
- }
-#endif
- return logmsg.size();
-}
-
-void debug_init(FILE *fp)
-{
- mutex.name = "debug";
- MutexAutolock m(mutex);
- logfp = fp;
-}
-
-void debug_reinit(const char *logfile)
-{
- MutexAutolock m(mutex);
-
- if(logfp != stderr) {
- fclose(logfp);
- logfp = fopen(logfile, "a");
- if(!logfp) {
- fprintf(stderr, "Could not write to logfile: '%s'\n", logfile);
- logfp = stderr;
- }
- }
-}
-
-
-/*
- * fmt := [set[,set]*]*
- * set := [+-]channel
- * | class[+-]channel
- * | [+-]all
- */
-void debug_parse(const char *fmt)
-{
- MutexAutolock m(mutex);
- char *s;
- char *next;
- char *opt;
-
- if(!(s = strdup(fmt))) return;
-
- for(opt = s; opt; opt = next) {
- int set = 0;
- int clr = 0;
- unsigned i;
- if((next = strchr(opt, ','))) *next++ = '\0';
- char *p = opt + strcspn(opt, "+-");
- if(!*p) p = opt; // All chars -> a channel name
- if(p > opt) {
- // we have a class
- for(i = 0; i < NELEM(debug_class_str); i++) {
- int n = strlen(debug_class_str[i]);
- if(n != (p - opt)) continue;
- if(!memcmp(opt, debug_class_str[i], n)) {
- // Found the class
- if(*p == '+')
- set = 1 << i;
- else
- clr = 1 << i;
- break;
- }
- }
- if(i == NELEM(debug_class_str)) continue;
- } else {
- if(*p == '-')
- clr = ~0;
- else
- set = ~0;
- }
- if(*p == '+' || *p == '-') p++;
- if(!*p) continue;
- if(!strcmp("all", p)) {
- debug_flags = (debug_flags & ~clr) | set;
- } else {
- if(strlen(p) >= sizeof(debug_channel[0].name)) continue;
- for(i = 0; i < n_debug_channel; i++) {
- if(!strcmp(p, debug_channel[i].name)) {
- debug_channel[i].flags = (debug_channel[i].flags & ~clr) | set;
- break;
- }
- }
- if(i == n_debug_channel && n_debug_channel < __DEBUG_CHANNEL_MAX) {
- strcpy(debug_channel[i].name, p);
- debug_channel[i].flags = (debug_flags & ~clr) | set;
- n_debug_channel++;
- }
- }
- }
- free(s);
-}
-
diff --git a/server/src/debug.h b/server/src/debug.h
deleted file mode 100644
index 838d83f..0000000
--- a/server/src/debug.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
-/***************************************************************************
- * debug.h
- *
- * Wed Feb 11 11:22:12 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.
- *
- * Pentominos 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 Pentominos; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#ifndef __PENTOMINOS_DEBUG_H__
-#define __PENTOMINOS_DEBUG_H__
-
-#include <stdarg.h>
-#include <stdio.h>
-
-#ifdef HAVE_CONFIG_H
-// For USE_EFENCE
-#include <config.h>
-#ifdef USE_EFENCE
-#include <new>
-#include <stdlib.h>
-#include <efencepp.h>
-#include <efence.h>
-
-// Lazy static alocations makes efence freak out.
-// Use this to use hardcoded values instead.
-// Currently it disables:
-// - gethostbyname
-// - getsockname
-// - getpeername
-// - iconv
-//#define BYPASS_STATICALLOCATIONS
-
-#endif/*USE_EFENCE*/
-#endif/*HAVE_CONFIG*/
-
-void debug_init(FILE *fp);
-void debug_reinit(const char *file);
-void debug_parse(const char *fmt);
-
-enum __debug_class
-{
- __class_fixme = 0,
- __class_err = 1,
- __class_warn = 2,
- __class_info = 3,
- __class_debug = 4
-};
-
-#ifdef WITH_DEBUG
-int __debug(const char *func, const int line, enum __debug_class cl,
- const char *ch, const char *fmt, ...)
- __attribute__((format (printf,5,6)));
-
-int __debug_va(const char *func, const int line, enum __debug_class cl,
- const char *ch, const char *fmt, va_list va);
-
-#define __DEBUG_PRINT(cl, ch, fmt...) \
- do { __debug(__func__, __LINE__, cl, ch, fmt); } while(0)
-#define __DEBUG_PRINT_VA(cl, ch, fmt, a) \
- do { __debug_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
-#define __DEBUG(cl, ch, fmt...) \
- __DEBUG_PRINT(__class##cl, #ch, fmt)
-#define __DEBUG_VA(cl, ch, fmt, a) \
- __DEBUG_PRINT_VA(__class##cl, #ch, fmt, a)
-
-#define FIXME(ch, fmt...) __DEBUG(_fixme, ch, fmt)
-#define ERR(ch, fmt...) __DEBUG(_err, ch, fmt)
-#define WARN(ch, fmt...) __DEBUG(_warn, ch, fmt)
-#define INFO(ch, fmt...) __DEBUG(_info, ch, fmt)
-#define DEBUG(ch, fmt...) __DEBUG(_debug, ch, fmt)
-
-#define FIXME_VA(ch, fmt, a) __DEBUG_VA(_fixme, ch, fmt, a)
-#define ERR_VA(ch, fmt, a) __DEBUG_VA(_err, ch, fmt, a)
-#define WARN_VA(ch, fmt, a) __DEBUG_VA(_warn, ch, fmt, a)
-#define INFO_VA(ch, fmt, a) __DEBUG_VA(_info, ch, fmt, a)
-#define DEBUG_VA(ch, fmt, a) __DEBUG_VA(_debug, ch, fmt, a)
-
-#else
-
-// If we compile without debug support, we want them all to go away
-#define FIXME(ch, fmt...)
-#define INFO(ch, fmt...)
-#define WARN(ch, fmt...)
-#define ERR(ch, fmt...)
-#define DEBUG(ch, fmt...)
-#define FIXME_VA(ch, fmt...)
-#define INFO_VA(ch, fmt...)
-#define WARN_VA(ch, fmt...)
-#define ERR_VA(ch, fmt...)
-#define DEBUG_VA(ch, fmt...)
-
-#endif/*WITH_DEBUG*/
-
-int __log(const char *func, const int line,
- enum __debug_class cl, const char *ch, const char *fmt, ...)
- __attribute__((format (printf,5,6)));
-
-int __log_va(const char *func, const int line, enum __debug_class cl,
- const char *ch, const char *fmt, va_list va);
-
-#define __LOG_PRINT(cl, ch, fmt...) \
- do { __log(__func__, __LINE__, cl, ch, fmt); } while(0)
-#define __LOG_PRINT_VA(cl, ch, fmt, a) \
- do { __log_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
-#define __LOG(cl, ch, fmt...) __LOG_PRINT(__class##cl, #ch, fmt)
-#define __LOG_VA(cl, ch, fmt, a) __LOG_PRINT_VA(__class##cl, #ch, fmt, a)
-
-#define INFO_LOG(ch, fmt...) __LOG(_info, ch, fmt)
-#define WARN_LOG(ch, fmt...) __LOG(_warn, ch, fmt)
-#define ERR_LOG(ch, fmt...) __LOG(_err, ch, fmt)
-#define INFO_LOG_VA(ch, fmt, a) __LOG_VA(_info, ch, fmt, a)
-#define WARN_LOG_VA(ch, fmt, a) __LOG_VA(_warn, ch, fmt, a)
-#define ERR_LOG_VA(ch, fmt, a) __LOG_VA(_err, ch, fmt, a)
-
-#endif/*__PENTOMINOS_DEBUG_H__*/
diff --git a/server/src/entitylist.cc b/server/src/entitylist.cc
index 2f8d82d..bb216cc 100644
--- a/server/src/entitylist.cc
+++ b/server/src/entitylist.cc
@@ -34,7 +34,7 @@
#include <vector>
-#include "debug.h"
+#include <hugin.hpp>
static inline bool isdir(std::string name)
{
diff --git a/server/src/exception.cc b/server/src/exception.cc
index a2bbf95..8dab4ec 100644
--- a/server/src/exception.cc
+++ b/server/src/exception.cc
@@ -26,7 +26,7 @@
*/
#include "exception.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "log.h"
diff --git a/server/src/fieldnamescanner.cc b/server/src/fieldnamescanner.cc
index d8b10f1..419b8fb 100644
--- a/server/src/fieldnamescanner.cc
+++ b/server/src/fieldnamescanner.cc
@@ -37,7 +37,7 @@
#include "exception.h"
#include "macrolist.h"
-#include "debug.h"
+#include <hugin.hpp>
fieldnames_t getFields(Widget &widget)
{
diff --git a/server/src/httpd.cc b/server/src/httpd.cc
index 7bb2828..a412cf9 100644
--- a/server/src/httpd.cc
+++ b/server/src/httpd.cc
@@ -40,7 +40,7 @@
#include <microhttpd.h>
#include <time.h>
-#include "debug.h"
+#include <hugin.hpp>
// for inet_ntop
#include <sys/types.h>
diff --git a/server/src/inotify.cc b/server/src/inotify.cc
index 14a47bc..aed5981 100644
--- a/server/src/inotify.cc
+++ b/server/src/inotify.cc
@@ -27,7 +27,7 @@
*/
#include "inotify.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <sys/stat.h>
#include <errno.h>
diff --git a/server/src/journal.cc b/server/src/journal.cc
index 971e747..ff10fd1 100644
--- a/server/src/journal.cc
+++ b/server/src/journal.cc
@@ -27,7 +27,7 @@
*/
#include "journal.h"
-#include "debug.h"
+#include <hugin.hpp>
Journal::Journal() {}
diff --git a/server/src/journal_commit.cc b/server/src/journal_commit.cc
index 1bfd9e8..9460ce2 100644
--- a/server/src/journal_commit.cc
+++ b/server/src/journal_commit.cc
@@ -28,7 +28,7 @@
#include <config.h>
-#include "debug.h"
+#include <hugin.hpp>
#include <string>
@@ -65,7 +65,7 @@ static int mwrite(int sock, const char *fmt, ...)
va_end(args);
if(sock != -1 && write(sock, buffer, l) != l) {
- ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
+ ERR(journal, "write did not write all the bytes in the buffer.\n");
}
DEBUG(journal, "%s", buffer);
@@ -89,7 +89,7 @@ int journal_commit(const char *cpr, const char *user,
struct hostent *he;
he = gethostbyname(addr);
if(!he || !he->h_length) {
- ERR_LOG(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno);
+ ERR(journal, "gethostbyname(%s) failed (errno=%d)!\n", addr, errno);
return -1;
}
@@ -104,12 +104,12 @@ int journal_commit(const char *cpr, const char *user,
sin.sin_port = htons(port);
if( (sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- ERR_LOG(journal, "Socket() failed!\n");
+ ERR(journal, "Socket() failed!\n");
return -1;
}
if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
- ERR_LOG(journal, "Connect() failed: %s!\n", strerror(errno));
+ ERR(journal, "Connect() failed: %s!\n", strerror(errno));
return -1;
}
#else
@@ -131,7 +131,7 @@ int journal_commit(const char *cpr, const char *user,
// send body
if(sock != -1 && write(sock, resume.c_str(), resume.size()) != (ssize_t)resume.size()) {
- ERR_LOG(journal, "write did not write all the bytes in the buffer.\n");
+ ERR(journal, "write did not write all the bytes in the buffer.\n");
return -1;
}
DEBUG(journal, "%s\n", buf);
diff --git a/server/src/log.cc b/server/src/log.cc
index fe72422..6519031 100644
--- a/server/src/log.cc
+++ b/server/src/log.cc
@@ -26,7 +26,7 @@
*/
#include "log.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <syslog.h>
diff --git a/server/src/luaoncommit.cc b/server/src/luaoncommit.cc
index aa15cdb..de7962a 100644
--- a/server/src/luaoncommit.cc
+++ b/server/src/luaoncommit.cc
@@ -33,7 +33,7 @@
#include "luautil.h"
#include "luapraxisd.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <stdio.h>
diff --git a/server/src/luapraxisd.cc b/server/src/luapraxisd.cc
index b12eace..39cb0eb 100644
--- a/server/src/luapraxisd.cc
+++ b/server/src/luapraxisd.cc
@@ -32,7 +32,7 @@
#include <lauxlib.h>
#include <strings.h>
-#include "debug.h"
+#include <hugin.hpp>
#define luaL_checkbool(L, i) \
(lua_isboolean(L,i) ? lua_toboolean(L,i) : luaL_checkint(L,i))
diff --git a/server/src/luaresume.cc b/server/src/luaresume.cc
index a0a3ade..f7918f3 100644
--- a/server/src/luaresume.cc
+++ b/server/src/luaresume.cc
@@ -31,7 +31,7 @@
#include "luautil.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <stdio.h>
diff --git a/server/src/luascript.cc b/server/src/luascript.cc
index e46aa8d..22b0e94 100644
--- a/server/src/luascript.cc
+++ b/server/src/luascript.cc
@@ -28,7 +28,7 @@
#include "luascript.h"
#include "configuration.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "luautil.h"
#include "luapraxisd.h"
diff --git a/server/src/luautil.cc b/server/src/luautil.cc
index 1042d8f..f5e32a5 100644
--- a/server/src/luautil.cc
+++ b/server/src/luautil.cc
@@ -26,7 +26,7 @@
*/
#include "luautil.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <string>
diff --git a/server/src/macroheaderparser.cc b/server/src/macroheaderparser.cc
index 84efaee..a09686c 100644
--- a/server/src/macroheaderparser.cc
+++ b/server/src/macroheaderparser.cc
@@ -44,28 +44,20 @@
#include <errno.h>
#include <string.h>
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
#include "exception.h"
void MacroHeaderParser::error(const char* fmt, ...)
{
- ERR_LOG(macro, "Error in MacroHeaderParser: ");
-
- {
- va_list argp;
- va_start(argp, fmt);
- ERR_LOG_VA(macro, fmt, argp);
- va_end(argp);
-
- fprintf(stderr, "\n");
- }
+ ERR(macro, "Error in MacroHeaderParser: ");
{
char *p;
va_list argp;
va_start(argp, fmt);
if(vasprintf(&p, fmt, argp) != -1) {
+ ERR(macro, "%s", p);
throw Exception("Error in MacroHeaderParser: " + std::string(p));
free(p);
}
@@ -112,12 +104,12 @@ int MacroHeaderParser::readData(char *data, size_t size)
// tag, and can dismiss the rest of the document.
if(fd == -1) {
- ERR_LOG(macro, "Invalid file descriptor.\n");
+ ERR(macro, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
+ ERR(macro, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -127,11 +119,11 @@ void MacroHeaderParser::parseError(const char *buf, size_t len, std::string erro
{
if(m) return; // Ignore "unclosed token" errors when the macro tag has been parsed.
- ERR_LOG(macro, "MacroHeaderParser[%s] error at line %d: %s\n",
+ ERR(macro, "MacroHeaderParser[%s] error at line %d: %s\n",
file.c_str(), lineno, error.c_str());
- ERR_LOG(macro, "\tBuffer %u bytes: [", (int)len);
+ ERR(macro, "\tBuffer %u bytes: [", (int)len);
if(fwrite(buf, len, 1, stderr) != len) {}
- ERR_LOG(macro, "]\n");
+ ERR(macro, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc
index 935c403..a8ada46 100644
--- a/server/src/macrolist.cc
+++ b/server/src/macrolist.cc
@@ -31,7 +31,7 @@
#include "macroheaderparser.h"
-#include "debug.h"
+#include <hugin.hpp>
MacroList::MacroList(std::string path)
: EntityList(path, "macro")
diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc
index 683c1d5..263d2c3 100644
--- a/server/src/macroparser.cc
+++ b/server/src/macroparser.cc
@@ -24,7 +24,7 @@
* along with Pracro; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "debug.h"
+#include <hugin.hpp>
#include "macroparser.h"
#include "configuration.h"
@@ -54,22 +54,14 @@
void MacroParser::error(const char* fmt, ...)
{
- ERR_LOG(macro, "Error in MacroParser: ");
-
- {
- va_list argp;
- va_start(argp, fmt);
- ERR_LOG_VA(macro, fmt, argp);
- va_end(argp);
-
- fprintf(stderr, "\n");
- }
+ ERR(macro, "Error in MacroParser: ");
{
char *p;
va_list argp;
va_start(argp, fmt);
if(vasprintf(&p, fmt, argp) != -1) {
+ ERR(macro, "%p", p);
throw Exception("Error in MacroParser: " + std::string(p));
free(p);
}
@@ -360,12 +352,12 @@ void MacroParser::endTag(std::string name)
int MacroParser::readData(char *data, size_t size)
{
if(fd == -1) {
- ERR_LOG(macro, "Invalid file descriptor.\n");
+ ERR(macro, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(macro, "Could not read...%s\n", strerror(errno));
+ ERR(macro, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -373,11 +365,11 @@ int MacroParser::readData(char *data, size_t size)
void MacroParser::parseError(const char *buf, size_t len, std::string error, int lineno)
{
- ERR_LOG(macro, "MacroParser[%s] error at line %d: %s\n",
+ ERR(macro, "MacroParser[%s] error at line %d: %s\n",
file.c_str(), lineno, error.c_str());
- ERR_LOG(macro, "\tBuffer %u bytes: [", (int)len);
+ ERR(macro, "\tBuffer %u bytes: [", (int)len);
if(fwrite(buf, len, 1, stderr) != len) {}
- ERR_LOG(macro, "]\n");
+ ERR(macro, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/macrotool/dump.cc b/server/src/macrotool/dump.cc
index 3d28181..29d7c4a 100644
--- a/server/src/macrotool/dump.cc
+++ b/server/src/macrotool/dump.cc
@@ -37,7 +37,7 @@
#include "util.h"
-#include "debug.h"
+#include <hugin.h>
#include "macroparser.h"
#include "templateparser.h"
diff --git a/server/src/macrotool/export.cc b/server/src/macrotool/export.cc
index f42cd34..165cda4 100644
--- a/server/src/macrotool/export.cc
+++ b/server/src/macrotool/export.cc
@@ -29,7 +29,7 @@
#include <config.h>
#include <stdio.h>
-#include "debug.h"
+#include <hugin.h>
#ifndef WITHOUT_DB
diff --git a/server/src/macrotool/fieldnames.cc b/server/src/macrotool/fieldnames.cc
index f348ef4..898b50c 100644
--- a/server/src/macrotool/fieldnames.cc
+++ b/server/src/macrotool/fieldnames.cc
@@ -33,7 +33,7 @@
#include "util.h"
#include "macroparser.h"
-#include "debug.h"
+#include <hugin.h>
#include "database.h"
#include "configuration.h"
diff --git a/server/src/macrotool/filehandler.cc b/server/src/macrotool/filehandler.cc
index 738b687..a45a66e 100644
--- a/server/src/macrotool/filehandler.cc
+++ b/server/src/macrotool/filehandler.cc
@@ -36,7 +36,7 @@
#include "macroparser.h"
#include "template.h"
-#include "debug.h"
+#include <hugin.h>
#include "util.h"
diff --git a/server/src/macrotool/macrotool.cc b/server/src/macrotool/macrotool.cc
index 0445927..60f8302 100644
--- a/server/src/macrotool/macrotool.cc
+++ b/server/src/macrotool/macrotool.cc
@@ -40,7 +40,7 @@
#include "configurationparser.h"
#include "configuration.h"
-#include "debug.h"
+#include <hugin.h>
#include "dump.h"
#include "fieldnames.h"
diff --git a/server/src/pgwork.cc b/server/src/pgwork.cc
index 948bb5f..663795a 100644
--- a/server/src/pgwork.cc
+++ b/server/src/pgwork.cc
@@ -29,7 +29,7 @@
#include <stdlib.h>
-#include "debug.h"
+#include <hugin.hpp>
/**
* Convert list of tuples to list of string arrays.
diff --git a/server/src/pracrod.cc b/server/src/pracrod.cc
index b68cf07..a67ce7d 100644
--- a/server/src/pracrod.cc
+++ b/server/src/pracrod.cc
@@ -62,7 +62,7 @@
#include "tcpsocket.h"
-#include "debug.h"
+#include <hugin.hpp>
static const char version_str[] =
"Pracro server v" VERSION "\n"
@@ -115,13 +115,14 @@ void childwait(int)
}
}
-static FILE *logfp = stderr;
-std::string logfile;
-bool logfile_reload = false;
-
void reload(int)
{
- logfile_reload = true;
+ printf("Reopening logfile...\n");
+ if(hugin_reopen_log() != HUG_STATUS_OK) {
+ fprintf(stderr, "Could not reopen logfile!\n");
+ return;
+ }
+ DEBUG(pracro, "Reopened log\n");
}
class PracroDaemon : public Daemon {
@@ -172,13 +173,16 @@ E0OPPYamkDI/+6Hx2KECQHF9xV1XatyXuFmfRAInK2BtfGY5UIvJaLxVD3Z1+i6q\n\
int main(int argc, char *argv[])
{
+ const char *hugin_filter = "+all";
+ const char *logfile = NULL;
+ unsigned int hugin_flags = 0;
+
int c;
char *configfile = NULL;
char *user = NULL;
char *group = NULL;
bool foreground = false;
char *xml_basedir = NULL;
- char *debugstr = NULL;
std::string database;
std::string pidfile;
std::string sessionpath;
@@ -239,7 +243,8 @@ int main(int argc, char *argv[])
break;
case 'L':
- logfile = optarg;
+ hugin_flags |= HUG_FLAG_OUTPUT_TO_FILE;
+ logfile = strdup(optarg);
break;
case 'S':
@@ -247,7 +252,8 @@ int main(int argc, char *argv[])
break;
case 'D':
- debugstr = strdup(optarg);
+ hugin_flags |= HUG_FLAG_USE_FILTER;
+ hugin_filter = optarg;
break;
case 's':
@@ -277,17 +283,15 @@ int main(int argc, char *argv[])
}
}
- if(logfile != "") {
- logfp = fopen(logfile.c_str(), "a");
- if(!logfp) {
- fprintf(stderr, "Could not write to logfile: '%s'\n", optarg);
- logfp = stderr;
- }
- debug_init(logfp);
- }
+ if(logfile == NULL) hugin_flags |= HUG_FLAG_OUTPUT_TO_STDOUT;
- if(debugstr) {
- debug_parse(debugstr);
+ hug_status_t status = hug_init(hugin_flags,
+ HUG_OPTION_FILTER, hugin_filter,
+ HUG_OPTION_FILENAME, logfile,
+ HUG_OPTION_END);
+ if(status != HUG_STATUS_OK) {
+ printf("Error: %d\n", status);
+ return 1;
}
// Load config
@@ -295,10 +299,10 @@ int main(int argc, char *argv[])
if(configfile) configparser = new ConfigurationParser(configfile);
else configparser = new ConfigurationParser(ETC"/pracrod.conf");
} catch(ConfigurationParser::ParseException &e) {
- ERR_LOG(pracrod, "Config file parse error: %s.\n", e.what());
+ ERR(pracrod, "Config file parse error: %s.\n", e.what());
return 1;
} catch(ConfigurationParser::ReadException &e) {
- ERR_LOG(pracrod, "Config file read error: %s.\n", e.what());
+ ERR(pracrod, "Config file read error: %s.\n", e.what());
return 1;
}
@@ -340,7 +344,5 @@ int main(int argc, char *argv[])
if(user) free(user);
if(group) free(group);
- if(logfp != stderr) fclose(logfp);
-
return 0;
}
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc
index aa1c8bd..6f4d659 100644
--- a/server/src/pracrodaopgsql.cc
+++ b/server/src/pracrodaopgsql.cc
@@ -46,7 +46,7 @@
#include <list>
#include <sstream>
-#include "debug.h"
+#include <hugin.hpp>
#include "pgwork.h"
@@ -66,7 +66,7 @@ PracroDAOPgsql::PracroDAOPgsql(std::string _host, std::string _port,
conn = PQconnectdb(cs.c_str());
if(conn == NULL || PQstatus(conn) == CONNECTION_BAD) {
- ERR_LOG(db, "Postgresql init failed: %s\n", PQerrorMessage(conn));
+ ERR(db, "Postgresql init failed: %s\n", PQerrorMessage(conn));
conn = NULL;
return;
}
@@ -100,7 +100,7 @@ std::string PracroDAOPgsql::newSessionId()
ERR(db, "Something wrong with the session counter.\n");
} catch(std::exception &e) {
- ERR_LOG(db, "Session counter failed: %s\n", e.what());
+ ERR(db, "Session counter failed: %s\n", e.what());
}
return "";
@@ -154,7 +154,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid,
if(ri != R.end()) {
std::string status = (*ri)[0].c_str();
if(status == "committed") {
- ERR_LOG(db, "Attempt to add to committed session %s blocked!\n",
+ ERR(db, "Attempt to add to committed session %s blocked!\n",
sessionid.c_str());
return;
}
@@ -165,7 +165,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid,
/*result_t R = */W.exec(ts);
}
} catch(std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
return;
}
@@ -229,7 +229,7 @@ void PracroDAOPgsql::commitTransaction(std::string sessionid,
W.commit();
} catch(std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -391,7 +391,7 @@ Values PracroDAOPgsql::getLatestValues(std::string sessionid,
}
#endif/*NEW*/
} catch (std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return values;
@@ -424,7 +424,7 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string sessionid,
DEBUG(sql, "Query: %s\n", query.c_str());
result_t R = W.exec(query);
if(R.size() != 1) {
- ERR_LOG(db, "No result set; expected one row with one column\n");
+ ERR(db, "No result set; expected one row with one column\n");
return 0;
}
unsigned n = (unsigned)atol((*R.begin())[0].c_str());
@@ -432,7 +432,7 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string sessionid,
n, patientid.c_str(), macroname.c_str(), oldest);
return n;
} catch (std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return 0;
@@ -470,7 +470,7 @@ void PracroDAOPgsql::addFieldname(std::string name, std::string description)
result_t R = W.exec(ts);
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -490,7 +490,7 @@ void PracroDAOPgsql::delFieldname(std::string name)
result_t R = W.exec(ts);
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -519,7 +519,7 @@ std::vector<Fieldname> PracroDAOPgsql::getFieldnames()
ri++;
}
} catch (std::exception &e) {
- ERR_LOG(db, "Query failed: %s: %s\n", e.what(), query.c_str());
+ ERR(db, "Query failed: %s: %s\n", e.what(), query.c_str());
}
return fieldnames;
@@ -540,7 +540,7 @@ void PracroDAOPgsql::commit(std::string sessionid)
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "Commit failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Commit failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -559,7 +559,7 @@ void PracroDAOPgsql::nocommit(std::string sessionid)
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "NoCommit failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "NoCommit failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -577,7 +577,7 @@ void PracroDAOPgsql::discard(std::string sessionid)
/*result_t R = */W.exec(ts);
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "Abort (rollback) failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "Abort (rollback) failed: %s: %s\n", e.what(), ts.c_str());
}
}
@@ -598,7 +598,7 @@ bool PracroDAOPgsql::idle(std::string sessionid)
return status == "idle";
}
} catch (std::exception &e) {
- ERR_LOG(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str());
}
return false;
@@ -625,7 +625,7 @@ void PracroDAOPgsql::setIdle(std::string sessionid, bool idle)
W.commit();
} catch (std::exception &e) {
- ERR_LOG(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str());
+ ERR(db, "setIdle failed: %s: %s\n", e.what(), ts.c_str());
}
}
diff --git a/server/src/pracrodaotest.cc b/server/src/pracrodaotest.cc
index a98a9fe..27e0158 100644
--- a/server/src/pracrodaotest.cc
+++ b/server/src/pracrodaotest.cc
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <sstream>
-#include "debug.h"
+#include <hugin.hpp>
static dbtable_t::iterator select(dbtable_t &table,
std::string key, std::string value)
@@ -97,7 +97,7 @@ void PracroDAOTest::commitTransaction(std::string sessionid,
} else {
dbrow_t &c = *ci;
if(c["status"] == "committed") {
- ERR_LOG(db, "Attempt to resume committed session %s blocked!\n",
+ ERR(db, "Attempt to resume committed session %s blocked!\n",
sessionid.c_str());
return;
}
diff --git a/server/src/queryhandlerpentominos.cc b/server/src/queryhandlerpentominos.cc
index 698fc2e..6d461e3 100644
--- a/server/src/queryhandlerpentominos.cc
+++ b/server/src/queryhandlerpentominos.cc
@@ -26,7 +26,7 @@
*/
#include "queryhandlerpentominos.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <config.h>
diff --git a/server/src/queryhandlerpracro.cc b/server/src/queryhandlerpracro.cc
index 1187c06..931353d 100644
--- a/server/src/queryhandlerpracro.cc
+++ b/server/src/queryhandlerpracro.cc
@@ -26,7 +26,7 @@
*/
#include "queryhandlerpracro.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <stdlib.h>
diff --git a/server/src/queryresult.h b/server/src/queryresult.h
index f734303..7a0ad1a 100644
--- a/server/src/queryresult.h
+++ b/server/src/queryresult.h
@@ -31,7 +31,7 @@
#include <string>
#include <map>
-#include "debug.h"
+#include <hugin.hpp>
class QueryResult {
public:
diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc
index 22907a0..2453a20 100644
--- a/server/src/saxparser.cc
+++ b/server/src/saxparser.cc
@@ -25,7 +25,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "saxparser.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <string.h>
#include <stdio.h>
diff --git a/server/src/server.cc b/server/src/server.cc
index 8592ad9..ae050d0 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -60,12 +60,6 @@ public:
headers_t &getargs,
headers_t &headers)
{
- if(logfile_reload) {
- DEBUG(pracrod, "Reopen log file %s\n", logfile.c_str());
- debug_reinit(logfile.c_str());
- logfile_reload = false;
- }
-
Connection *connection = NULL;
if(headers.find("User-Agent") != headers.end() &&
diff --git a/server/src/sessionheaderparser.cc b/server/src/sessionheaderparser.cc
index afdaa65..b62e122 100644
--- a/server/src/sessionheaderparser.cc
+++ b/server/src/sessionheaderparser.cc
@@ -54,28 +54,20 @@
#include <errno.h>
#include <string.h>
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
#include "exception.h"
void SessionHeaderParser::error(const char* fmt, ...)
{
- ERR_LOG(session, "Error in SessionHeaderParser: ");
-
- {
- va_list argp;
- va_start(argp, fmt);
- ERR_LOG_VA(session, fmt, argp);
- va_end(argp);
-
- fprintf(stderr, "\n");
- }
+ ERR(session, "Error in SessionHeaderParser: ");
{
char *p;
va_list argp;
va_start(argp, fmt);
if(vasprintf(&p, fmt, argp) != -1) {
+ ERR(session, "%s", p);
throw Exception("Error in SessionHeaderParser: " + std::string(p));
free(p);
}
@@ -129,12 +121,12 @@ int SessionHeaderParser::readData(char *data, size_t size)
// for and can dismiss the rest of the document.
if(fd == -1) {
- ERR_LOG(session, "Invalid file descriptor.\n");
+ ERR(session, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(session, "Could not read...%s\n", strerror(errno));
+ ERR(session, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -145,11 +137,11 @@ void SessionHeaderParser::parseError(const char *buf, size_t len, std::string er
if(done) return; // If done is true we already found what we were looking
// for and can dismiss the rest of the document.
- ERR_LOG(session, "SessionHeaderParser[%s] error at line %d: %s\n",
+ ERR(session, "SessionHeaderParser[%s] error at line %d: %s\n",
file.c_str(), lineno, error.c_str());
- ERR_LOG(session, "\tBuffer %u bytes: [", (int)len);
+ ERR(session, "\tBuffer %u bytes: [", (int)len);
if(fwrite(buf, len, 1, stderr) != len) {}
- ERR_LOG(session, "]\n");
+ ERR(session, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/sessionparser.cc b/server/src/sessionparser.cc
index 349b17b..7674ea1 100644
--- a/server/src/sessionparser.cc
+++ b/server/src/sessionparser.cc
@@ -29,7 +29,7 @@
#include <stdio.h>
-#include "debug.h"
+#include <hugin.hpp>
SessionParser::SessionParser()
{
diff --git a/server/src/tcpsocket.cc b/server/src/tcpsocket.cc
index fc4dab2..ddbedd2 100644
--- a/server/src/tcpsocket.cc
+++ b/server/src/tcpsocket.cc
@@ -28,7 +28,7 @@
#include "tcpsocket.h"
-#include "debug.h"
+#include <hugin.hpp>
//#define WITH_DEBUG
@@ -169,7 +169,7 @@ TCPSocket *TCPSocket::accept()
child->isconnected = true;
return child;
} else {
- ERR_LOG(socket,
+ ERR(socket,
"Accept returned with no socket - This should not happen!\n");
return NULL;
}
diff --git a/server/src/templateheaderparser.cc b/server/src/templateheaderparser.cc
index 3c327fd..7274af8 100644
--- a/server/src/templateheaderparser.cc
+++ b/server/src/templateheaderparser.cc
@@ -44,28 +44,20 @@
#include <errno.h>
#include <string.h>
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
#include "exception.h"
void TemplateHeaderParser::error(const char* fmt, ...)
{
- ERR_LOG(templateparser, "Error in TemplateHeaderParser: ");
-
- {
- va_list argp;
- va_start(argp, fmt);
- ERR_LOG_VA(templateparser, fmt, argp);
- va_end(argp);
-
- fprintf(stderr, "\n");
- }
+ ERR(templateparser, "Error in TemplateHeaderParser: ");
{
char *p;
va_list argp;
va_start(argp, fmt);
if(vasprintf(&p, fmt, argp) != -1) {
+ ERR(templateparser, "%s", p);
throw Exception("Error in TemplateHeaderParser: " + std::string(p));
free(p);
}
@@ -115,12 +107,12 @@ int TemplateHeaderParser::readData(char *data, size_t size)
if(t) return 0;
if(fd == -1) {
- ERR_LOG(templateparser, "Invalid file descriptor.\n");
+ ERR(templateparser, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(templateparser, "Could not read...%s\n", strerror(errno));
+ ERR(templateparser, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
@@ -132,11 +124,11 @@ void TemplateHeaderParser::parseError(const char *buf, size_t len,
// Ignore "unclosed token" errors when the template tag has been parsed.
if(t) return;
- ERR_LOG(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n",
+ ERR(templateparser, "TemplateHeaderParser[%s] error at line %d: %s\n",
file.c_str(), lineno, error.c_str());
- ERR_LOG(templateparser, "\tBuffer %u bytes: [", (int)len);
+ ERR(templateparser, "\tBuffer %u bytes: [", (int)len);
if(fwrite(buf, len, 1, stderr) != len) {}
- ERR_LOG(templateparser, "]\n");
+ ERR(templateparser, "]\n");
char *slineno;
if(asprintf(&slineno, " at line %d\n", lineno) != -1) {
diff --git a/server/src/templatelist.cc b/server/src/templatelist.cc
index 48dbab5..cf44dda 100644
--- a/server/src/templatelist.cc
+++ b/server/src/templatelist.cc
@@ -29,7 +29,7 @@
#include "templateheaderparser.h"
-#include "debug.h"
+#include <hugin.hpp>
TemplateList::TemplateList(std::string path)
: EntityList(path, "template")
diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc
index 770d8d7..7c35518 100644
--- a/server/src/templateparser.cc
+++ b/server/src/templateparser.cc
@@ -44,7 +44,7 @@
#include <stdio.h>
#include "configuration.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "exception.h"
void TemplateParser::error(const char* fmt, ...)
@@ -54,7 +54,7 @@ void TemplateParser::error(const char* fmt, ...)
va_start(argp, fmt);
vasprintf(&p, fmt, argp);
va_end(argp);
- ERR_LOG(template, "Error in TemplateParser: %s\n", p);
+ ERR(template, "Error in TemplateParser: %s\n", p);
throw Exception(std::string("Error in TemplateParser: ") + p);
free(p);
}
@@ -191,12 +191,12 @@ void TemplateParser::endTag(std::string name)
int TemplateParser::readData(char *data, size_t size)
{
if(fd == -1) {
- ERR_LOG(template, "Invalid file descriptor.\n");
+ ERR(template, "Invalid file descriptor.\n");
return 0;
}
ssize_t r = read(fd, data, size);
if(r == -1) {
- ERR_LOG(template, "Could not read...%s\n", strerror(errno));
+ ERR(template, "Could not read...%s\n", strerror(errno));
return 0;
}
return r;
diff --git a/server/src/transactionparser.cc b/server/src/transactionparser.cc
index 0340d74..f1e1aee 100644
--- a/server/src/transactionparser.cc
+++ b/server/src/transactionparser.cc
@@ -33,7 +33,7 @@
#include <string>
#include <map>
-#include "debug.h"
+#include <hugin.hpp>
#include "exception.h"
TransactionParser::TransactionParser(Transaction *transaction)
diff --git a/server/src/utf8.cc b/server/src/utf8.cc
index f43d858..51eba94 100644
--- a/server/src/utf8.cc
+++ b/server/src/utf8.cc
@@ -26,7 +26,7 @@
*/
#include "utf8.h"
-#include "debug.h"
+#include <hugin.hpp>
#include <errno.h>
diff --git a/server/src/util.cc b/server/src/util.cc
index d1085a4..1c431dc 100644
--- a/server/src/util.cc
+++ b/server/src/util.cc
@@ -31,7 +31,7 @@
#include <sys/types.h>
#include <dirent.h>
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
static std::vector<std::string> listdir(std::string path)
diff --git a/server/src/widgetvalue.cc b/server/src/widgetvalue.cc
index 7e176bb..f1310f5 100644
--- a/server/src/widgetvalue.cc
+++ b/server/src/widgetvalue.cc
@@ -27,7 +27,7 @@
*/
#include "widgetvalue.h"
-#include "debug.h"
+#include <hugin.hpp>
#include "configuration.h"
static bool getMapValue(Value &value,