summaryrefslogtreecommitdiff
path: root/source3/include/smb.h
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>1998-07-31 20:16:35 +0000
committerChristopher R. Hertel <crh@samba.org>1998-07-31 20:16:35 +0000
commitebd415c03f7e76a024182748d2cafebbfd5238b1 (patch)
treedb956df7486412e92cafa9c3a18eb852ebc6c8f4 /source3/include/smb.h
parent3a1fdf05dde2fdd71976b77b85635e300bd436f7 (diff)
downloadsamba-ebd415c03f7e76a024182748d2cafebbfd5238b1.tar.gz
samba-ebd415c03f7e76a024182748d2cafebbfd5238b1.tar.bz2
samba-ebd415c03f7e76a024182748d2cafebbfd5238b1.zip
This is the checkin of the debug changes.
Makefile.in: I've added debug.o. proto.h : Rebuilt, as is standard for these sorts of things. smb.h : New macros, etc. util.c : Debug code removed. I'll check in debug.c in the next step. Chris -)----- (This used to be commit 653c17c1b8e34bfbd05ea35ada9436a50d5a7ba4)
Diffstat (limited to 'source3/include/smb.h')
-rw-r--r--source3/include/smb.h68
1 files changed, 59 insertions, 9 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 115d8ce31b..60e214d73e 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -90,17 +90,69 @@ typedef unsigned short uint16;
/* how long to wait for secondary SMB packets (milli-seconds) */
#define SMB_SECONDARY_WAIT (60*1000)
-/* debugging code */
-#if !defined(WITH_SYSLOG) || defined(NO_SYSLOG)
-#define DEBUG(level,body) ((DEBUGLEVEL>=(level))?(Debug1 body):0)
-#define DEBUGLVL(level) (DEBUGLEVEL>=(level))
+/* -------------------------------------------------------------------------- **
+ * Debugging code. See also debug.c
+ */
+
+/* mkproto.awk has trouble with ifdef'd function definitions (it ignores
+ * the #ifdef directive and will read both definitions, thus creating two
+ * diffferent prototype declarations), so we must do these by hand.
+ */
+#ifdef HAVE_STDARG_H
+int Debug1( char *, ... );
+BOOL dbgtext( char *, ... );
#else
-extern int syslog_level;
+int Debug1();
+BOOL dbgtext();
+#endif
-#define DEBUG(level,body) ((DEBUGLEVEL>=(level))? (syslog_level = (level), Debug1 body):0)
-#define DEBUGLVL(level) ( DEBUGLEVEL >= (syslog_level=(level)) )
+/* If we have these macros, we can add additional info to the header. */
+#ifdef HAVE_FILE_MACRO
+#define FILE_MACRO (__FILE__)
+#else
+#define FILE_MACRO ("")
#endif
+#ifdef HAVE_FUNCTION_MACRO
+#define FUNCTION_MACRO (__FUNCTION__)
+#else
+#define FUNCTION_MACRO ("")
+#endif
+
+/* Debugging macros.
+ * DEBUGLVL() - If level is <= the system-wide DEBUGLEVEL then generate a
+ * header using the default macros for file, line, and
+ * function name.
+ * Returns True if the debug level was <= DEBUGLEVEL.
+ * Example usage:
+ * if( DEBUGLVL( 2 ) )
+ * dbgtext( "Some text.\n" );
+ * DEGUG() - Good old DEBUG(). Each call to DEBUG() will generate a new
+ * header *unless* the previous debug output was unterminated
+ * (i.e., no '\n'). See debug.c:dbghdr() for more info.
+ * Example usage:
+ * DEBUG( 2, ("Some text.\n") );
+ * DEBUGADD() - If level <= DEBUGLEVEL, then the text is appended to the
+ * current message (i.e., no header).
+ * Usage:
+ * DEBUGADD( 2, ("Some additional text.\n") );
+ */
+#define DEBUGLVL( level ) \
+ ( (DEBUGLEVEL>=(level)) \
+ && dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) )
+
+#define DEBUG( level, body ) \
+ if( (DEBUGLEVEL>=(level)) \
+ && dbghdr( level, FILE_MACRO, FUNCTION_MACRO, (__LINE__) ) ) \
+ (void)dbgtext body
+
+#define DEBUGADD( level, body ) \
+ if( DEBUGLEVEL>=(level) ) (void)dbgtext body
+
+/* End Debugging code section.
+ * -------------------------------------------------------------------------- **
+ */
+
/* this defines the error codes that receive_smb can put in smb_read_error */
#define READ_TIMEOUT 1
#define READ_EOF 2
@@ -1154,10 +1206,8 @@ struct parm_struct
#define ERRCMD 0xFF /* Command was not in the "SMB" format. */
#ifdef HAVE_STDARG_H
-int Debug1(char *, ...);
int slprintf(char *str, int n, char *format, ...);
#else
-int Debug1();
int slprintf();
#endif