From 382518de257997418e059c7a99f54dc0768d6089 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sat, 5 Jul 2014 22:10:21 +0100 Subject: [PATCH] removed logger and source subdirs --- configure.ac | 5 +-- include/Makefile.am | 2 -- include/tr/interface/logger.h | 43 ------------------------ include/tr/logger.h | 59 --------------------------------- src/Makefile.am | 19 +++++++---- src/{socket => }/accept.c | 0 src/{socket => }/connect.c | 0 src/{stream => }/i_reader.c | 0 src/{stream => }/i_writer.c | 0 src/{socket => }/listen.c | 0 src/logger/Makefile.am | 9 ----- src/logger/i_logger.c | 62 ----------------------------------- src/logger/logger.c | 57 -------------------------------- src/logger/stderr.c | 39 ---------------------- src/logger/syslog.c | 52 ----------------------------- src/{socket => }/nonblock.c | 0 src/{stream => }/read.c | 0 src/{socket => }/socket.c | 0 src/socket/Makefile.am | 9 ----- src/{stream => }/stream.c | 0 src/stream/Makefile.am | 11 ------- src/{stream => }/write.c | 0 22 files changed, 13 insertions(+), 354 deletions(-) delete mode 100644 include/tr/interface/logger.h delete mode 100644 include/tr/logger.h rename src/{socket => }/accept.c (100%) rename src/{socket => }/connect.c (100%) rename src/{stream => }/i_reader.c (100%) rename src/{stream => }/i_writer.c (100%) rename src/{socket => }/listen.c (100%) delete mode 100644 src/logger/Makefile.am delete mode 100644 src/logger/i_logger.c delete mode 100644 src/logger/logger.c delete mode 100644 src/logger/stderr.c delete mode 100644 src/logger/syslog.c rename src/{socket => }/nonblock.c (100%) rename src/{stream => }/read.c (100%) rename src/{socket => }/socket.c (100%) delete mode 100644 src/socket/Makefile.am rename src/{stream => }/stream.c (100%) delete mode 100644 src/stream/Makefile.am rename src/{stream => }/write.c (100%) diff --git a/configure.ac b/configure.ac index 7ca5b54..974a8ef 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AM_INIT_AUTOMAKE AM_SILENT_RULES([yes]) AC_COPYRIGHT([Copyright © 2014 Georg Hopp]) AC_REVISION([0.0.0]) -AC_CONFIG_SRCDIR([src/stream/stream.c]) +AC_CONFIG_SRCDIR([src/stream.c]) AC_CONFIG_HEADERS([trio.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -61,8 +61,5 @@ AC_CONFIG_FILES([Makefile docs/Makefile tests/Makefile src/Makefile - src/logger/Makefile - src/socket/Makefile - src/stream/Makefile include/Makefile]) AC_OUTPUT diff --git a/include/Makefile.am b/include/Makefile.am index bc9b8d6..615ca4a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,7 +1,5 @@ nobase_include_HEADERS = trio.h \ - tr/logger.h \ tr/socket.h \ tr/stream.h \ - tr/interface/logger.h \ tr/interface/reader.h \ tr/interface/writer.h diff --git a/include/tr/interface/logger.h b/include/tr/interface/logger.h deleted file mode 100644 index 950cb28..0000000 --- a/include/tr/interface/logger.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * \file - * The logger interface. - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __TR_INTERFACE_LOGGER_H__ -#define __TR_INTERFACE_LOGGER_H__ - -#include - -#include "trbase.h" -#include "tr/logger.h" - -typedef void (* fptr_TR_log)(void *, TR_logger_level, const char * const); - -TR_INTERFACE(TR_Logger) { - TR_IFID; - fptr_TR_log log; -}; - -extern void TR_loggerLog(void *, TR_logger_level, const char * const, ...); - -#endif // __TR_INTERFACE_LOGGER_H__ - -// vim: set ts=4 sw=4: diff --git a/include/tr/logger.h b/include/tr/logger.h deleted file mode 100644 index a21cf56..0000000 --- a/include/tr/logger.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * \file - * A generic logger class and two extended classes, One that logs to - * stderr and one that logs to the system syslog. - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __TR_LOGGER_H__ -#define __TR_LOGGER_H__ - -#include "trbase.h" - -typedef enum { - TR_LOGGER_DEBUG=0, - TR_LOGGER_INFO, - TR_LOGGER_NOTICE, - TR_LOGGER_WARNING, - TR_LOGGER_ERR, - TR_LOGGER_CRIT, - TR_LOGGER_ALERT, - TR_LOGGER_EMERG -} TR_logger_level; - -#include "tr/interface/logger.h" - -extern const char * const TR_logger_level_str[]; - -TR_CLASS(TR_Logger) { - TR_logger_level min_level; -}; - -TR_CLASS(TR_LoggerStderr) { - TR_EXTENDS(TR_Logger); -}; - -TR_CLASS(TR_LoggerSyslog) { - TR_EXTENDS(TR_Logger); -}; - -#endif // __TR_LOGGER_H__ - -// vim: set ts=4 sw=4: diff --git a/src/Makefile.am b/src/Makefile.am index 6984ee4..0283460 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,14 +3,19 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CFLAGS += -I../include/ -TRIOLIBS = logger/liblogger.la \ - stream/libstream.la \ - socket/libsocket.la +TRIO = stream.c \ + read.c \ + write.c \ + socket.c \ + accept.c \ + connect.c \ + listen.c \ + nonblock.c \ + i_reader.c \ + i_writer.c lib_LTLIBRARIES = libtrio.la -libtrio_la_SOURCES = +libtrio_la_SOURCES = $(TRIO) libtrio_la_CFLAGS = $(AM_CFLAGS) -libtrio_la_LIBADD = $(TRIOLIBS) - -SUBDIRS = logger socket stream +libtrio_la_LIBADD = diff --git a/src/socket/accept.c b/src/accept.c similarity index 100% rename from src/socket/accept.c rename to src/accept.c diff --git a/src/socket/connect.c b/src/connect.c similarity index 100% rename from src/socket/connect.c rename to src/connect.c diff --git a/src/stream/i_reader.c b/src/i_reader.c similarity index 100% rename from src/stream/i_reader.c rename to src/i_reader.c diff --git a/src/stream/i_writer.c b/src/i_writer.c similarity index 100% rename from src/stream/i_writer.c rename to src/i_writer.c diff --git a/src/socket/listen.c b/src/listen.c similarity index 100% rename from src/socket/listen.c rename to src/listen.c diff --git a/src/logger/Makefile.am b/src/logger/Makefile.am deleted file mode 100644 index f6fbfb6..0000000 --- a/src/logger/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -AUTOMAKE_OPTIONS = subdir-objects - -AM_CFLAGS += -I../../include/ - -noinst_LTLIBRARIES = liblogger.la - -liblogger_la_SOURCES = i_logger.c logger.c stderr.c syslog.c -liblogger_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/logger/i_logger.c b/src/logger/i_logger.c deleted file mode 100644 index 31046b0..0000000 --- a/src/logger/i_logger.c +++ /dev/null @@ -1,62 +0,0 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include - -#include "tr/logger.h" -#include "tr/interface/logger.h" -#include "trbase.h" - -TR_CREATE_INTERFACE(TR_Logger, 1); - -void -TR_loggerLog( - void * _object, - TR_logger_level level, - const char * const fmt, - ...) { - TR_Logger object = _object; - - if (level >= object->min_level) { - char * msg = NULL; - size_t msg_size = 0; - va_list params; - - va_start(params, fmt); - msg_size = vsnprintf(NULL, msg_size, fmt, params); - va_end(params); - - msg = TR_malloc(msg_size + 1); - - va_start(params, fmt); - vsnprintf(msg, msg_size + 1, fmt, params); - va_end(params); - - TR_CALL(_object, TR_Logger, log, level, msg); - - TR_MEM_FREE(msg); - } -} - -// vim: set ts=4 sw=4: diff --git a/src/logger/logger.c b/src/logger/logger.c deleted file mode 100644 index eb24930..0000000 --- a/src/logger/logger.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include "trbase.h" -#include "tr/logger.h" -#include "tr/interface/logger.h" - -const -char * const -TR_logger_level_str[] = { - "DEBUG", - "INFO", - "NOTICE", - "WARNING", - "ERR", - "CRIT", - "ALERT", - "EMERG" -}; - -static -int -loggerCtor(void * _this, va_list * params) -{ - TR_Logger this = _this; - this->min_level = va_arg(*params, int); - - return 0; -} - -static void loggerDtor(void * _this) {} - -TR_INIT_IFACE(TR_Class, loggerCtor, loggerDtor, NULL); -TR_CREATE_CLASS(TR_Logger, NULL, TR_IF(TR_Class)); - -// vim: set ts=4 sw=4: diff --git a/src/logger/stderr.c b/src/logger/stderr.c deleted file mode 100644 index a0e7a05..0000000 --- a/src/logger/stderr.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include "trbase.h" -#include "tr/logger.h" -#include "tr/interface/logger.h" - -static -void -logStderr(void * this, TR_logger_level level, const char * const msg) -{ - fprintf(stderr, "[%s] %s\n", TR_logger_level_str[level], msg); -} - -TR_INIT_IFACE(TR_Logger, logStderr); -TR_CREATE_CLASS(TR_LoggerStderr, TR_Logger, TR_IF(TR_Logger)); - -// vim: set ts=4 sw=4: diff --git a/src/logger/syslog.c b/src/logger/syslog.c deleted file mode 100644 index 8e226e7..0000000 --- a/src/logger/syslog.c +++ /dev/null @@ -1,52 +0,0 @@ -/** - * \file - * - * \author Georg Hopp - * - * \copyright - * Copyright © 2012 Georg Hopp - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -#include "trbase.h" -#include "tr/logger.h" -#include "tr/interface/logger.h" - -static -const -int syslog_priority[] = { - LOG_USER | LOG_DEBUG, - LOG_USER | LOG_INFO, - LOG_USER | LOG_NOTICE, - LOG_USER | LOG_WARNING, - LOG_USER | LOG_ERR, - LOG_USER | LOG_CRIT, - LOG_USER | LOG_ALERT, - LOG_USER | LOG_EMERG -}; - -static -void -logSyslog(void * this, TR_logger_level level, const char * const msg) -{ - syslog(syslog_priority[level], "[%s] %s", TR_logger_level_str[level], msg); -} - -TR_INIT_IFACE(TR_Logger, logSyslog); -TR_CREATE_CLASS(TR_LoggerSyslog, TR_Logger, TR_IF(TR_Logger)); - -// vim: set ts=4 sw=4: diff --git a/src/socket/nonblock.c b/src/nonblock.c similarity index 100% rename from src/socket/nonblock.c rename to src/nonblock.c diff --git a/src/stream/read.c b/src/read.c similarity index 100% rename from src/stream/read.c rename to src/read.c diff --git a/src/socket/socket.c b/src/socket.c similarity index 100% rename from src/socket/socket.c rename to src/socket.c diff --git a/src/socket/Makefile.am b/src/socket/Makefile.am deleted file mode 100644 index 21c0849..0000000 --- a/src/socket/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -AUTOMAKE_OPTIONS = subdir-objects - -AM_CFLAGS += -I../../include/ - -noinst_LTLIBRARIES = libsocket.la - -libsocket_la_SOURCES = socket.c accept.c connect.c listen.c nonblock.c -libsocket_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/stream/stream.c b/src/stream.c similarity index 100% rename from src/stream/stream.c rename to src/stream.c diff --git a/src/stream/Makefile.am b/src/stream/Makefile.am deleted file mode 100644 index b64cbcd..0000000 --- a/src/stream/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -AUTOMAKE_OPTIONS = subdir-objects - -AM_CFLAGS += -I../../include/ - -STREAM = stream.c read.c write.c i_reader.c i_writer.c - -noinst_LTLIBRARIES = libstream.la - -libstream_la_SOURCES = $(STREAM) -libstream_la_CFLAGS = $(AM_CFLAGS) diff --git a/src/stream/write.c b/src/write.c similarity index 100% rename from src/stream/write.c rename to src/write.c