[SCM] Samba Shared Repository - branch master updated - 621cf3c9bf161e686935f57393ab184d298d72de

Jelmer Vernooij jelmer at samba.org
Sat Oct 11 19:03:09 GMT 2008


The branch, master has been updated
       via  621cf3c9bf161e686935f57393ab184d298d72de (commit)
       via  2c4391e95002404fb2e1d09f97541c1ece1da46f (commit)
      from  a85f6634853a4cf825d70e07a789e96e1882f376 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 621cf3c9bf161e686935f57393ab184d298d72de
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Oct 11 21:02:13 2008 +0200

    Use data_blob() for now, since it seems to be the only function available in both Samba 3 and Samba 4.

commit 2c4391e95002404fb2e1d09f97541c1ece1da46f
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sat Oct 11 20:44:19 2008 +0200

    Provide the same set of helper functions for DEBUG in Samba 3 and Samba
    4, even though the macros are still different.
    
    This makes it possible to use object code compiled with one DEBUG()
    macro from the other sourceX directory.

-----------------------------------------------------------------------

Summary of changes:
 lib/crypto/arcfour.c                  |    2 +-
 source3/include/debug.h               |   12 +++++++-----
 source3/include/proto.h               |    3 ++-
 source3/lib/debug.c                   |   12 +++++++++---
 source4/auth/gensec/cyrus_sasl.c      |   22 +++++++++++-----------
 source4/lib/smbreadline/smbreadline.c |    2 +-
 source4/lib/tdb_wrap.c                |   14 +++++++-------
 source4/lib/util/debug.c              |   15 ++++++++++++---
 source4/lib/util/debug.h              |    9 +++++----
 9 files changed, 55 insertions(+), 36 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/crypto/arcfour.c b/lib/crypto/arcfour.c
index e70713b..c57e05d 100644
--- a/lib/crypto/arcfour.c
+++ b/lib/crypto/arcfour.c
@@ -81,7 +81,7 @@ _PUBLIC_ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key)
 */
 _PUBLIC_ void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len)
 {
-	DATA_BLOB key = data_blob_named(keystr, 16, "DATA_BLOB: "__location__);
+	DATA_BLOB key = data_blob(keystr, 16);
 	
 	arcfour_crypt_blob(data, len, &key);
 
diff --git a/source3/include/debug.h b/source3/include/debug.h
index d171632..56d0237 100644
--- a/source3/include/debug.h
+++ b/source3/include/debug.h
@@ -40,11 +40,13 @@
 int  Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
 /* PRINTFLIKE1 */
 bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2);
-bool dbghdr( int level, int cls, const char *file, const char *func, int line );
+bool dbghdrclass( int level, int cls, const char *location, const char *func);
+bool dbghdr( int level, const char *location, const char *func);
 
 #if defined(sgi) && (_COMPILER_VERSION >= 730)
 #pragma mips_frequency_hint NEVER Debug1
 #pragma mips_frequency_hint NEVER dbgtext
+#pragma mips_frequency_hint NEVER dbghdrclass
 #pragma mips_frequency_hint NEVER dbghdr
 #endif
 
@@ -192,7 +194,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
 
 #define DEBUGLVL( level ) \
   ( CHECK_DEBUGLVL(level) \
-   && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
+   && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO ) )
 
 
 #define DEBUGLVLC( dbgc_class, level ) \
@@ -200,7 +202,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
      unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
      (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
       DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-   && dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )
+   && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO) )
 
 
 #define DEBUG( level, body ) \
@@ -208,7 +210,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
            unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
             DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-       && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
+       && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO )) \
        && (dbgtext body) )
 
 #define DEBUGC( dbgc_class, level, body ) \
@@ -216,7 +218,7 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
            unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
            (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
 	    DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
-       && (dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) )) \
+       && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO)) \
        && (dbgtext body) )
 
 #define DEBUGADD( level, body ) \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 3df87a6..bf66908 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -486,7 +486,8 @@ void force_check_log_size( void );
 bool need_to_check_log_size( void );
 void check_log_size( void );
 void dbgflush( void );
-bool dbghdr(int level, int cls, const char *file, const char *func, int line);
+bool dbghdrclass(int level, int cls, const char *location, const char *func);
+bool dbghdr(int level, const char *location, const char *func);
 TALLOC_CTX *debug_ctx(void);
 
 /* The following definitions come from lib/display_sec.c  */
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index d91b55d..be2707b 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -984,7 +984,7 @@ void dbgflush( void )
 
 ****************************************************************************/
 
-bool dbghdr(int level, int cls, const char *file, const char *func, int line)
+bool dbghdrclass(int level, int cls, const char *location, const char *func)
 {
 	/* Ensure we don't lose any real errno value. */
 	int old_errno = errno;
@@ -1046,10 +1046,10 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
 					   lp_debug_hires_timestamp()),
 			level, header_str);
 		} else {
-		    (void)Debug1( "[%s, %2d%s] %s:%s(%d)\n",
+		    (void)Debug1( "[%s, %2d%s] %s(%s)\n",
 			current_timestring(debug_ctx(),
 					   lp_debug_hires_timestamp()),
-			level, header_str, file, func, line );
+			level, header_str, location, func );
 		}
 	}
 
@@ -1057,6 +1057,12 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
 	return( True );
 }
 
+bool dbghdr(int level, const char *location, const char *func)
+{
+	/* For compatibility with Samba 4, which doesn't have debug classes */
+	return dbghdrclass(level, 0, location, func);
+}
+
 /***************************************************************************
  Add text to the body of the "current" debug message via the format buffer.
 
diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c
index 6f82de8..e8918ef 100644
--- a/source4/auth/gensec/cyrus_sasl.c
+++ b/source4/auth/gensec/cyrus_sasl.c
@@ -323,39 +323,39 @@ int gensec_sasl_log(void *context,
 		    int sasl_log_level,
 		    const char *message) 
 {
-	int debug_level;
+	int dl;
 	switch (sasl_log_level) {
 	case SASL_LOG_NONE:
-		debug_level = 0;
+		dl = 0;
 		break;
 	case SASL_LOG_ERR:
-		debug_level = 1;
+		dl = 1;
 		break;
 	case SASL_LOG_FAIL:
-		debug_level = 2;
+		dl = 2;
 		break;
 	case SASL_LOG_WARN:
-		debug_level = 3;
+		dl = 3;
 		break;
 	case SASL_LOG_NOTE:
-		debug_level = 5;
+		dl = 5;
 		break;
 	case SASL_LOG_DEBUG:
-		debug_level = 10;
+		dl = 10;
 		break;
 	case SASL_LOG_TRACE:
-		debug_level = 11;
+		dl = 11;
 		break;
 #if DEBUG_PASSWORD
 	case SASL_LOG_PASS:
-		debug_level = 100;
+		dl = 100;
 		break;
 #endif
 	default:
-		debug_level = 0;
+		dl = 0;
 		break;
 	}
-	DEBUG(debug_level, ("gensec_sasl: %s\n", message));
+	DEBUG(dl, ("gensec_sasl: %s\n", message));
 
 	return SASL_OK;
 }
diff --git a/source4/lib/smbreadline/smbreadline.c b/source4/lib/smbreadline/smbreadline.c
index a85f335..314fe13 100644
--- a/source4/lib/smbreadline/smbreadline.c
+++ b/source4/lib/smbreadline/smbreadline.c
@@ -82,7 +82,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
 	int fd = STDIN_FILENO;
 	char *ret;
 
-	do_debug("%s", prompt);
+	printf("%s", prompt);
 
 	line = (char *)malloc(BUFSIZ);
 	if (!line) {
diff --git a/source4/lib/tdb_wrap.c b/source4/lib/tdb_wrap.c
index fadf173..4dd2e78 100644
--- a/source4/lib/tdb_wrap.c
+++ b/source4/lib/tdb_wrap.c
@@ -46,7 +46,7 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
 {
 	va_list ap;
 	char *ptr = NULL;
-	int debug_level;
+	int dl;
 
 	va_start(ap, format);
 	vasprintf(&ptr, format, ap);
@@ -54,24 +54,24 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
 	
 	switch (level) {
 	case TDB_DEBUG_FATAL:
-		debug_level = 0;
+		dl = 0;
 		break;
 	case TDB_DEBUG_ERROR:
-		debug_level = 1;
+		dl = 1;
 		break;
 	case TDB_DEBUG_WARNING:
-		debug_level = 2;
+		dl = 2;
 		break;
 	case TDB_DEBUG_TRACE:
-		debug_level = 5;
+		dl = 5;
 		break;
 	default:
-		debug_level = 0;
+		dl = 0;
 	}		
 
 	if (ptr != NULL) {
 		const char *name = tdb_name(tdb);
-		DEBUG(debug_level, ("tdb(%s): %s", name ? name : "unnamed", ptr));
+		DEBUG(dl, ("tdb(%s): %s", name ? name : "unnamed", ptr));
 		free(ptr);
 	}
 }
diff --git a/source4/lib/util/debug.c b/source4/lib/util/debug.c
index 00dcbfc..b6edb90 100644
--- a/source4/lib/util/debug.c
+++ b/source4/lib/util/debug.c
@@ -31,7 +31,9 @@
 /** 
  * this global variable determines what messages are printed 
  */
-_PUBLIC_ int DEBUGLEVEL;
+int _debug_level = 0;
+_PUBLIC_ int *debug_level = &_debug_level;
+int *DEBUGLEVEL_CLASS = NULL; /* For samba 3 */
 
 /* the registered mutex handlers */
 static struct {
@@ -89,12 +91,19 @@ static void log_timestring(int level, const char *location, const char *func)
   the backend for debug messages. Note that the DEBUG() macro has already
   ensured that the log level has been met before this is called
 */
-_PUBLIC_ void do_debug_header(int level, const char *location, const char *func)
+_PUBLIC_ void dbghdr(int level, const char *location, const char *func)
 {
 	log_timestring(level, location, func);
 	log_task_id();
 }
 
+
+_PUBLIC_ void dbghdrclass(int level, int class, const char *location, const char *func)
+{
+	/* Simple wrapper, Samba 4 doesn't do debug classes */
+	dbghdr(level, location, func);
+}
+
 /**
   the backend for debug messages. Note that the DEBUG() macro has already
   ensured that the log level has been met before this is called
@@ -102,7 +111,7 @@ _PUBLIC_ void do_debug_header(int level, const char *location, const char *func)
   @note You should never have to call this function directly. Call the DEBUG()
   macro instead.
 */
-_PUBLIC_ void do_debug(const char *format, ...)
+_PUBLIC_ void dbgtext(const char *format, ...)
 {
 	va_list ap;
 	char *s = NULL;
diff --git a/source4/lib/util/debug.h b/source4/lib/util/debug.h
index 6056281..8f4fa2a 100644
--- a/source4/lib/util/debug.h
+++ b/source4/lib/util/debug.h
@@ -39,6 +39,7 @@ struct debug_ops {
 	void (*log_task_id)(int fd);
 };
 
+#define DEBUGLEVEL *debug_level
 extern int DEBUGLEVEL;
 
 #define debug_ctx() (_debug_ctx?_debug_ctx:(_debug_ctx=talloc_new(NULL)))
@@ -48,9 +49,9 @@ extern int DEBUGLEVEL;
 	if (DEBUGLVL(level)) { \
 		void* _debug_ctx=NULL; \
 		if (header) { \
-			do_debug_header(level, __location__, __FUNCTION__); \
+			dbghdr(level, __location__, __FUNCTION__); \
 		} \
-		do_debug body; \
+		dbgtext body; \
 		talloc_free(_debug_ctx); \
 	} \
 } while (0)
@@ -77,7 +78,7 @@ enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2};
   the backend for debug messages. Note that the DEBUG() macro has already
   ensured that the log level has been met before this is called
 */
-_PUBLIC_ void do_debug_header(int level, const char *location, const char *func);
+_PUBLIC_ void dbghdr(int level, const char *location, const char *func);
 
 /**
   reopen the log file (usually called because the log file name might have changed)
@@ -125,4 +126,4 @@ _PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops);
   @note You should never have to call this function directly. Call the DEBUG()
   macro instead.
 */
-_PUBLIC_ void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
+_PUBLIC_ void dbgtext(const char *format, ...) PRINTF_ATTRIBUTE(1,2);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list