diff options
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/debug.c | 1 | ||||
-rw-r--r-- | lib/util/debug.h | 4 | ||||
-rw-r--r-- | lib/util/memory.h | 25 | ||||
-rw-r--r-- | lib/util/time.h | 7 | ||||
-rw-r--r-- | lib/util/unix_privs.c | 1 | ||||
-rw-r--r-- | lib/util/util.c | 1 | ||||
-rw-r--r-- | lib/util/util.h | 38 | ||||
-rw-r--r-- | lib/util/xfile.h | 2 |
8 files changed, 50 insertions, 29 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c index faec52aec8..98aabc554b 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -37,6 +37,7 @@ static int debug_all_class_hack = 1; int *DEBUGLEVEL_CLASS = &debug_all_class_hack; /* For samba 3 */ static bool debug_all_class_isset_hack = true; bool *DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack; /* For samba 3 */ +XFILE *dbf = NULL; /* For Samba 3*/ /* the registered mutex handlers */ static struct { diff --git a/lib/util/debug.h b/lib/util/debug.h index 8f4fa2a8fc..8c634f910a 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -80,6 +80,8 @@ enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2}; */ _PUBLIC_ void dbghdr(int level, const char *location, const char *func); +_PUBLIC_ void dbghdrclass(int level, int class, const char *location, const char *func); + /** reopen the log file (usually called because the log file name might have changed) */ @@ -127,3 +129,5 @@ _PUBLIC_ void register_debug_handlers(const char *name, struct debug_ops *ops); macro instead. */ _PUBLIC_ void dbgtext(const char *format, ...) PRINTF_ATTRIBUTE(1,2); + +extern XFILE *dbf; diff --git a/lib/util/memory.h b/lib/util/memory.h index de01492aa2..cfc13ab836 100644 --- a/lib/util/memory.h +++ b/lib/util/memory.h @@ -88,6 +88,31 @@ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) #endif +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#ifndef discard_const +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) +#endif + +/** Type-safe version of discard_const */ +#ifndef discard_const_p +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#endif #endif /* _SAMBA_MEMORY_H_ */ diff --git a/lib/util/time.h b/lib/util/time.h index 1a1fcc999c..42644a3954 100644 --- a/lib/util/time.h +++ b/lib/util/time.h @@ -231,7 +231,12 @@ bool nt_time_equal(NTTIME *t1, NTTIME *t2); void interpret_dos_date(uint32_t date,int *year,int *month,int *day,int *hour,int *minute,int *second); - struct timespec nt_time_to_unix_timespec(NTTIME *nt); +time_t convert_timespec_to_time_t(struct timespec ts); + +struct timespec convert_time_t_to_timespec(time_t t); + +bool null_timespec(struct timespec ts); + #endif /* _SAMBA_TIME_H_ */ diff --git a/lib/util/unix_privs.c b/lib/util/unix_privs.c index 47c172dcfa..f55e739a9b 100644 --- a/lib/util/unix_privs.c +++ b/lib/util/unix_privs.c @@ -21,6 +21,7 @@ #include "includes.h" #include "system/filesys.h" +#include "../lib/util/unix_privs.h" /** * @file diff --git a/lib/util/util.c b/lib/util/util.c index 1e7991dbf1..4e2a5aab09 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -283,7 +283,6 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type) return true; } - void print_asc(int level, const uint8_t *buf,int len) { int i; diff --git a/lib/util/util.h b/lib/util/util.h index 4c9a223093..fc651d58af 100644 --- a/lib/util/util.h +++ b/lib/util/util.h @@ -46,33 +46,6 @@ extern const char *panic_action; #include "../lib/util/byteorder.h" /** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#ifndef discard_const -#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) -#endif - -/** Type-safe version of discard_const */ -#ifndef discard_const_p -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -#endif - -/** * assert macros */ #define SMB_ASSERT(b) do { if (!(b)) { \ @@ -458,6 +431,9 @@ load a file into memory from a fd. **/ _PUBLIC_ char *fd_load(int fd, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx); + +char **file_lines_parse(char *p, size_t size, int *numlines, TALLOC_CTX *mem_ctx); + /** load a file into memory **/ @@ -612,6 +588,8 @@ _PUBLIC_ void *smb_xmemdup(const void *p, size_t size); **/ _PUBLIC_ char *smb_xstrdup(const char *s); +char *smb_xstrndup(const char *s, size_t n); + /** Like strdup but for memory. **/ @@ -636,6 +614,8 @@ _PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size); */ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count, bool free_on_fail); +void *malloc_array(size_t el_size, unsigned int count); + /* The following definitions come from lib/util/fsusage.c */ @@ -742,4 +722,8 @@ _PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name); #define talloc_get_type_abort(ptr, type) \ (type *)talloc_check_name_abort(ptr, #type) +bool unmap_file(void *start, size_t size); + +void print_asc(int level, const uint8_t *buf,int len); + #endif /* _SAMBA_UTIL_H_ */ diff --git a/lib/util/xfile.h b/lib/util/xfile.h index aa14b7c30a..af90f3f55c 100644 --- a/lib/util/xfile.h +++ b/lib/util/xfile.h @@ -96,4 +96,6 @@ char *x_fgets(char *s, int size, XFILE *stream) ; * set then an error is returned */ off_t x_tseek(XFILE *f, off_t offset, int whence); +XFILE *x_fdup(const XFILE *f); + #endif /* _XFILE_H_ */ |