[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Mon Feb 28 18:59:14 MST 2011
The branch, master has been updated
via ec1009f s3-debug Always use C99 true/false rather than True and False
via 243abcb s3-build __FUNCTION__ is always available, always use it
via 608c8e7 lib/util/time: Merge time functions from source3/lib/time.c
from db11e65 spoolss.idl: align spoolss_DriverFileInfo relative pointer to 4 byte
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ec1009f7a066d9beba675c833a9a202c2726e618
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 1 08:52:25 2011 +1100
s3-debug Always use C99 true/false rather than True and False
This will help with the merge into the common code.
Autobuild-User: Andrew Bartlett <abartlet at samba.org>
Autobuild-Date: Tue Mar 1 02:58:55 CET 2011 on sn-devel-104
commit 243abcb0af981d17dd7dd6c4d9908b855b15e90c
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Mar 1 00:46:30 2011 +1100
s3-build __FUNCTION__ is always available, always use it
This avoids duplication between FUNCTION_NAME and __FUNCTION__
commit 608c8e787253f01b24f95c1523187a0a37737691
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Feb 22 17:59:51 2011 +1100
lib/util/time: Merge time functions from source3/lib/time.c
-----------------------------------------------------------------------
Summary of changes:
lib/util/time.c | 59 ++++++++++++++++++++++++++++++++++++++
lib/util/time.h | 17 +++++++++++
source3/include/safe_string.h | 2 +-
source3/include/vfs.h | 4 +-
source3/lib/debug.c | 58 +++++++++++++++++++-------------------
source3/lib/time.c | 63 -----------------------------------------
source3/libsmb/clientgen.c | 4 +-
7 files changed, 110 insertions(+), 97 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/util/time.c b/lib/util/time.c
index 770ebc4..4843fc9 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -4,6 +4,8 @@
Copyright (C) Andrew Tridgell 1992-2004
Copyright (C) Stefan (metze) Metzmacher 2002
+ Copyright (C) Jeremy Allison 2007
+ Copyright (C) Andrew Bartlett 2011
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
@@ -337,6 +339,63 @@ _PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset)
}
+/****************************************************************************
+ Return the date and time as a string
+****************************************************************************/
+
+char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires)
+{
+ time_t t;
+ struct tm *tm;
+
+ t = (time_t)tp->tv_sec;
+ tm = localtime(&t);
+ if (!tm) {
+ if (hires) {
+ return talloc_asprintf(ctx,
+ "%ld.%06ld seconds since the Epoch",
+ (long)tp->tv_sec,
+ (long)tp->tv_usec);
+ } else {
+ return talloc_asprintf(ctx,
+ "%ld seconds since the Epoch",
+ (long)t);
+ }
+ } else {
+#ifdef HAVE_STRFTIME
+ char TimeBuf[60];
+ if (hires) {
+ strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
+ return talloc_asprintf(ctx,
+ "%s.%06ld", TimeBuf,
+ (long)tp->tv_usec);
+ } else {
+ strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
+ return talloc_strdup(ctx, TimeBuf);
+ }
+#else
+ if (hires) {
+ const char *asct = asctime(tm);
+ return talloc_asprintf(ctx, "%s.%06ld",
+ asct ? asct : "unknown",
+ (long)tp->tv_usec);
+ } else {
+ const char *asct = asctime(tm);
+ return talloc_asprintf(ctx, asct ? asct : "unknown");
+ }
+#endif
+ }
+}
+
+char *current_timestring(TALLOC_CTX *ctx, bool hires)
+{
+ struct timeval tv;
+
+ GetTimeOfDay(&tv);
+ return timeval_string(ctx, &tv, hires);
+}
+
+
/**
return a HTTP/1.0 time string
**/
diff --git a/lib/util/time.h b/lib/util/time.h
index 345382b..3a40634 100644
--- a/lib/util/time.h
+++ b/lib/util/time.h
@@ -119,12 +119,29 @@ _PUBLIC_ time_t pull_dos_date2(const uint8_t *date_ptr, int zone_offset);
_PUBLIC_ time_t pull_dos_date3(const uint8_t *date_ptr, int zone_offset);
/**
+ Return a date and time as a string (optionally with microseconds)
+
+ format is %Y/%m/%d %H:%M:%S if strftime is available
+**/
+
+char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires);
+
+/**
+ Return the current date and time as a string (optionally with microseconds)
+
+ format is %Y/%m/%d %H:%M:%S if strftime is available
+**/
+char *current_timestring(TALLOC_CTX *ctx, bool hires);
+
+/**
return a HTTP/1.0 time string
**/
_PUBLIC_ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t);
/**
Return the date and time as a string
+
+ format is %a %b %e %X %Y %Z
**/
_PUBLIC_ char *timestring(TALLOC_CTX *mem_ctx, time_t t);
diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h
index 4ed7ff2..56e3b67 100644
--- a/source3/include/safe_string.h
+++ b/source3/include/safe_string.h
@@ -63,7 +63,7 @@
#endif /* !_SPLINT_ */
#ifdef DEVELOPER
-#define SAFE_STRING_FUNCTION_NAME FUNCTION_MACRO
+#define SAFE_STRING_FUNCTION_NAME __FUNCTION__
#define SAFE_STRING_LINE __LINE__
#else
#define SAFE_STRING_FUNCTION_NAME ("")
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 45193d2..7e5b87a 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -471,14 +471,14 @@ typedef struct vfs_statvfs_struct {
#define SMB_VFS_HANDLE_GET_DATA(handle, datap, type, ret) { \
if (!(handle)||((datap=(type *)(handle)->data)==NULL)) { \
- DEBUG(0,("%s() failed to get vfs_handle->data!\n",FUNCTION_MACRO)); \
+ DEBUG(0,("%s() failed to get vfs_handle->data!\n",__FUNCTION__)); \
ret; \
} \
}
#define SMB_VFS_HANDLE_SET_DATA(handle, datap, free_fn, type, ret) { \
if (!(handle)) { \
- DEBUG(0,("%s() failed to set handle->data!\n",FUNCTION_MACRO)); \
+ DEBUG(0,("%s() failed to set handle->data!\n",__FUNCTION__)); \
ret; \
} else { \
if ((handle)->free_data) { \
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index a97c0bf..1ec79cd 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -87,8 +87,8 @@ static struct {
*/
static char *debugf = NULL;
-bool debug_warn_unknown_class = True;
-bool debug_auto_add_unknown_class = True;
+bool debug_warn_unknown_class = true;
+bool debug_auto_add_unknown_class = true;
/*
used to check if the user specified a
@@ -101,7 +101,7 @@ bool override_logfile;
* system has been initialized.
*/
static int debug_all_class_hack = 1;
-static bool debug_all_class_isset_hack = True;
+static bool debug_all_class_isset_hack = true;
static int debug_num_classes = 0;
int *DEBUGLEVEL_CLASS = &debug_all_class_hack;
@@ -128,7 +128,7 @@ int DEBUGLEVEL = &debug_all_class_hack;
* format_pos - Marks the first free byte of the format_bufr.
*
*
- * log_overflow - When this variable is True, never attempt to check the
+ * log_overflow - When this variable is true, never attempt to check the
* size of the log. This is a hack, so that we can write
* a message using DEBUG, from open_logs() when we
* are unable to open a new log file for some reason.
@@ -140,7 +140,7 @@ static int syslog_level = 0;
#endif
static char *format_bufr = NULL;
static size_t format_pos = 0;
-static bool log_overflow = False;
+static bool log_overflow = false;
/*
* Define all the debug class selection names here. Names *MUST NOT* contain
@@ -226,7 +226,7 @@ static char *debug_list_class_names_and_levels(void)
char **list;
char *buf = NULL;
char *b;
- bool err = False;
+ bool err = false;
if (DEBUGLEVEL_CLASS == &debug_all_class_hack) {
return NULL;
@@ -244,7 +244,7 @@ static char *debug_list_class_names_and_levels(void)
classname_table[i],
DEBUGLEVEL_CLASS_ISSET[i]?DEBUGLEVEL_CLASS[i]:DEBUGLEVEL);
if (l < 0 || l > MAX_CLASS_NAME_SIZE) {
- err = True;
+ err = true;
goto done;
}
dim += l;
@@ -253,7 +253,7 @@ static char *debug_list_class_names_and_levels(void)
/* create single string list - add space for newline */
b = buf = (char *)SMB_MALLOC(dim+1);
if (!buf) {
- err = True;
+ err = true;
goto done;
}
for (i = 0; i < debug_num_classes; i++) {
@@ -353,7 +353,7 @@ int debug_add_class(const char *classname)
if (!new_ptr)
return -1;
DEBUGLEVEL_CLASS_ISSET = (bool *)new_ptr;
- DEBUGLEVEL_CLASS_ISSET[ndx] = False;
+ DEBUGLEVEL_CLASS_ISSET[ndx] = false;
new_ptr = SMB_REALLOC_ARRAY(classname_table, char *, debug_num_classes + 1);
if (!new_ptr)
@@ -425,14 +425,14 @@ static bool debug_parse_params(char **params)
char *class_level;
if (!params)
- return False;
+ return false;
/* Allow DBGC_ALL to be specified w/o requiring its class name e.g."10"
* v.s. "all:10", this is the traditional way to set DEBUGLEVEL
*/
if (isdigit((int)params[0][0])) {
DEBUGLEVEL_CLASS[DBGC_ALL] = atoi(params[0]);
- DEBUGLEVEL_CLASS_ISSET[DBGC_ALL] = True;
+ DEBUGLEVEL_CLASS_ISSET[DBGC_ALL] = true;
i = 1; /* start processing at the next params */
} else {
i = 0; /* DBGC_ALL not specified OR class name was included */
@@ -445,14 +445,14 @@ static bool debug_parse_params(char **params)
(class_level = strtok_r(NULL, "\0", &saveptr)) &&
((ndx = debug_lookup_classname(class_name)) != -1)) {
DEBUGLEVEL_CLASS[ndx] = atoi(class_level);
- DEBUGLEVEL_CLASS_ISSET[ndx] = True;
+ DEBUGLEVEL_CLASS_ISSET[ndx] = true;
} else {
DEBUG(0,("debug_parse_params: unrecognized debug class name or format [%s]\n", params[i]));
- return False;
+ return false;
}
}
- return True;
+ return true;
}
/****************************************************************************
@@ -473,10 +473,10 @@ bool debug_parse_levels(const char *params_str)
if (debug_parse_params(params)) {
debug_dump_status(5);
TALLOC_FREE(params);
- return True;
+ return true;
} else {
TALLOC_FREE(params);
- return False;
+ return false;
}
}
@@ -635,7 +635,7 @@ bool reopen_logs(void)
mode_t oldumask;
int new_fd = 0;
int old_fd = 0;
- bool ret = True;
+ bool ret = true;
char *fname = NULL;
if (state.reopening_logs) {
@@ -683,10 +683,10 @@ bool reopen_logs(void)
new_fd = open( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644);
if (new_fd == -1) {
- log_overflow = True;
+ log_overflow = true;
DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno)));
- log_overflow = False;
- ret = False;
+ log_overflow = false;
+ ret = false;
} else {
old_fd = state.fd;
state.fd = new_fd;
@@ -702,7 +702,7 @@ bool reopen_logs(void)
/* Take over stderr to catch output into logs */
if (state.fd > 0 && dup2(state.fd, 2) == -1) {
- close_low_fds(True); /* Close stderr too, if dup2 can't point it
+ close_low_fds(true); /* Close stderr too, if dup2 can't point it
at the logfile */
}
@@ -727,14 +727,14 @@ bool need_to_check_log_size( void )
int maxlog;
if( debug_count < 100 )
- return( False );
+ return( false );
maxlog = lp_max_log_size() * 1024;
if ( state.fd > 0 || maxlog <= 0 ) {
debug_count = 0;
- return(False);
+ return(false);
}
- return( True );
+ return( true );
}
/**************************************************************************
@@ -996,7 +996,7 @@ void dbgflush( void )
line - line number of the call to dbghdr, assuming __LINE__
works.
- Output: Always True. This makes it easy to fudge a call to dbghdr()
+ Output: Always true. This makes it easy to fudge a call to dbghdr()
in a macro, since the function can be called as part of a test.
Eg: ( (level <= DEBUGLEVEL) && (dbghdr(level,"",line)) )
@@ -1019,7 +1019,7 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
* we'll work under the assumption that an incomplete line indicates
* that a new header is *not* desired.
*/
- return( True );
+ return( true );
}
#ifdef WITH_SYSLOG
@@ -1029,7 +1029,7 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
/* Don't print a header if we're logging to stdout. */
if ( state.logtype != DEBUG_FILE ) {
- return( True );
+ return( true );
}
/* Print the header if timestamps are turned on. If parameters are
@@ -1075,7 +1075,7 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
}
errno = old_errno;
- return( True );
+ return( true );
}
bool dbghdr(int level, const char *location, const char *func)
@@ -1092,7 +1092,7 @@ bool dbghdr(int level, const char *location, const char *func)
..or.. va_alist - Old style variable parameter list starting point.
- Output: Always True. See dbghdr() for more info, though this is not
+ Output: Always true. See dbghdr() for more info, though this is not
likely to be used in the same way.
***************************************************************************/
diff --git a/source3/lib/time.c b/source3/lib/time.c
index eba358f..db9ec0a 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -129,69 +129,6 @@ int set_server_zone_offset(time_t t)
return server_zone_offset;
}
-/****************************************************************************
- Return the date and time as a string
-****************************************************************************/
-
-char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires)
-{
- fstring TimeBuf;
- time_t t;
- struct tm *tm;
-
- t = (time_t)tp->tv_sec;
- tm = localtime(&t);
- if (!tm) {
- if (hires) {
- slprintf(TimeBuf,
- sizeof(TimeBuf)-1,
- "%ld.%06ld seconds since the Epoch",
- (long)tp->tv_sec,
- (long)tp->tv_usec);
- } else {
- slprintf(TimeBuf,
- sizeof(TimeBuf)-1,
- "%ld seconds since the Epoch",
- (long)t);
- }
- } else {
-#ifdef HAVE_STRFTIME
- if (hires) {
- strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
- slprintf(TimeBuf+strlen(TimeBuf),
- sizeof(TimeBuf)-1 - strlen(TimeBuf),
- ".%06ld",
- (long)tp->tv_usec);
- } else {
- strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %H:%M:%S",tm);
- }
-#else
- if (hires) {
- const char *asct = asctime(tm);
- slprintf(TimeBuf,
- sizeof(TimeBuf)-1,
- "%s.%06ld",
- asct ? asct : "unknown",
- (long)tp->tv_usec);
- } else {
- const char *asct = asctime(tm);
- fstrcpy(TimeBuf, asct ? asct : "unknown");
- }
-#endif
- }
- return talloc_strdup(ctx, TimeBuf);
-}
-
-char *current_timestring(TALLOC_CTX *ctx, bool hires)
-{
- struct timeval tv;
-
- GetTimeOfDay(&tv);
- return timeval_string(ctx, &tv, hires);
-}
-
-
-
/***************************************************************************
Server versions of the above functions.
***************************************************************************/
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index e26c171..096dd2f 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -618,8 +618,8 @@ struct cli_state *cli_initialise_ex(int signing_state)
#if defined(DEVELOPER)
/* just because we over-allocate, doesn't mean it's right to use it */
- clobber_region(FUNCTION_MACRO, __LINE__, cli->outbuf+cli->bufsize, SAFETY_MARGIN);
- clobber_region(FUNCTION_MACRO, __LINE__, cli->inbuf+cli->bufsize, SAFETY_MARGIN);
+ clobber_region(__FUNCTION__, __LINE__, cli->outbuf+cli->bufsize, SAFETY_MARGIN);
+ clobber_region(__FUNCTION__, __LINE__, cli->inbuf+cli->bufsize, SAFETY_MARGIN);
#endif
/* initialise signing */
--
Samba Shared Repository
More information about the samba-cvs
mailing list