From 0f52550e090db50ab068ed8369f9158497d217e0 Mon Sep 17 00:00:00 2001 From: psychon Date: Wed, 25 Mar 2009 17:56:29 +0000 Subject: [PATCH] Add defines.h for Csocket and make Csocket use ZNC's DEBUG() This adds a new file defines.h and moves all the Csocket specific stuff from main.h into this new file. Then this makes Csocket use ZNC's DEBUG() macro for its debug output which means this can now also be enabled by running znc --debug. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1445 726aef4b-f618-498e-8847-2d620e286838 --- Csocket.h | 4 +++- defines.h | 29 +++++++++++++++++++++++++++++ main.h | 15 --------------- 3 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 defines.h diff --git a/Csocket.h b/Csocket.h index 8c8e4c94..4a5ce147 100644 --- a/Csocket.h +++ b/Csocket.h @@ -85,7 +85,7 @@ #include #include -#include "main.h" // require this as a general rule, most projects have a defines.h or the like +#include "defines.h" // require this as a general rule, most projects have a defines.h or the like #ifndef CS_STRING # ifdef _HAS_CSTRING_ @@ -103,11 +103,13 @@ #endif /* __DEBUG__ */ #endif /* CS_DEBUG */ +#ifndef PERROR #ifdef __DEBUG__ # define PERROR( f ) __Perror( f, __FILE__, __LINE__ ) #else # define PERROR( f ) (void)0 #endif /* __DEBUG__ */ +#endif #ifndef _NO_CSOCKET_NS // some people may not want to use a namespace namespace Csocket diff --git a/defines.h b/defines.h new file mode 100644 index 00000000..5f072e02 --- /dev/null +++ b/defines.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2004-2009 See the AUTHORS file for details. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#ifndef _DEFINES_H +#define _DEFINES_H + +// This header file is just for Csocket + +#include "main.h" +#include "Utils.h" + +#define CS_STRING CString +#define _NO_CSOCKET_NS + +#ifdef _DEBUG +#define __DEBUG__ +#endif + +// Redefine some Csocket debugging mechanisms to use znc's +#define CS_DEBUG(f) DEBUG(__FILE__ << ":" << __LINE__ << " " << f) +#define PERROR(f) DEBUG(__FILE__ << ":" << __LINE__ << " " << f << ": " << strerror(GetSockError())) + + +#endif // !_DEFINES_H diff --git a/main.h b/main.h index 6e1f4df7..4f1ea157 100644 --- a/main.h +++ b/main.h @@ -53,24 +53,9 @@ #define MODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) #endif - -#ifndef CS_STRING -#define CS_STRING CString -#endif - -#ifndef _NO_CSOCKET_NS -#define _NO_CSOCKET_NS -#endif - -#ifdef _DEBUG -#define __DEBUG__ -#endif - #include using std::cout; using std::cerr; using std::endl; -#include "ZNCString.h" - #endif // !_MAIN_H