Samba3: Include util.h header file rather than having custom prototypes.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 02:14:43 +0000 (03:14 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 02:14:43 +0000 (03:14 +0100)
lib/util/util.h
lib/util/util_ldb.h
source3/include/includes.h
source3/include/smb_macros.h
source3/param/loadparm.c
source4/include/includes.h

index 6a341b218d9f8eeb19446736c12164b8c5151287..bfd09ba20be21fe5d67f22e20977af7375093ecf 100644 (file)
@@ -49,13 +49,22 @@ extern const char *panic_action;
 /**
  * assert macros 
  */
+#ifdef DEVELOPER
 #define SMB_ASSERT(b) do { if (!(b)) { \
-       DEBUG(0,("PANIC: assert failed at %s(%d)\n", __FILE__, __LINE__)); \
-       smb_panic("assert failed"); }} while (0)
+        DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
+                __FILE__, __LINE__, #b)), smb_panic("assert failed: " #b); }} while(0)
+#else
+/* redefine the assert macro for non-developer builds */
+#define SMB_ASSERT(b) do { if (!(b)) { \
+        DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
+           __FILE__, __LINE__, #b)); }} while (0)
+#endif
 
+#if _SAMBA_BUILD_ == 4
 #if defined(VALGRIND)
 #define strlen(x) valgrind_strlen(x)
 #endif
+#endif
 
 #include "../lib/util/memory.h"
 
@@ -69,10 +78,12 @@ _PUBLIC_ void call_backtrace(void);
 **/
 _PUBLIC_ _NORETURN_ void smb_panic(const char *why);
 
+#if _SAMBA_BUILD_ == 4
 /**
 setup our fault handlers
 **/
 _PUBLIC_ void fault_setup(const char *pname);
+#endif
 
 /**
   register a fault handler. 
@@ -168,12 +179,14 @@ _PUBLIC_ char *generate_random_str_list(TALLOC_CTX *mem_ctx, size_t len, const c
 _PUBLIC_ char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
 
 /* The following definitions come from lib/util/dprintf.c  */
+#if _SAMBA_BUILD_ == 4
 
 _PUBLIC_ void d_set_iconv(smb_iconv_t);
 _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) PRINTF_ATTRIBUTE(2,0);
 _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
 _PUBLIC_ int d_printf(const char *format, ...) PRINTF_ATTRIBUTE(1,2);
 _PUBLIC_ void display_set_stderr(void);
+#endif
 
 /* The following definitions come from lib/util/util_str.c  */
 
@@ -285,11 +298,6 @@ limited by 'n' bytes
 **/
 _PUBLIC_ size_t ascii_len_n(const char *src, size_t n);
 
-/**
- Return a string representing a CIFS attribute for a file.
-**/
-_PUBLIC_ char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
-
 /**
  Set a boolean variable from the text value stored in the passed string.
  Returns true in success, false if the passed string does not correctly 
@@ -306,10 +314,12 @@ _PUBLIC_ bool set_boolean(const char *boolean_string, bool *boolean);
  */
 _PUBLIC_ bool conv_str_bool(const char * str, bool * val);
 
+#if _SAMBA_BUILD_ == 4
 /**
  * Convert a size specification like 16K into an integral number of bytes. 
  **/
 _PUBLIC_ bool conv_str_size(const char * str, uint64_t * val);
+#endif
 
 /**
  * Parse a uint64_t value from a string
@@ -354,7 +364,9 @@ _PUBLIC_ bool strequal(const char *s1, const char *s2);
 /* The following definitions come from lib/util/util_strlist.c  */
 
 /* separators for lists */
+#ifndef LIST_SEP
 #define LIST_SEP " \t,\n\r"
+#endif
 
 /**
   build a null terminated list of strings from a input string and a
@@ -642,6 +654,7 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize);
  * @brief MS-style Filename matching
  */
 
+#if _SAMBA_BUILD_ == 4
 /* protocol types. It assumes that higher protocols include lower protocols
    as subsets. FIXME: Move to one of the smb-specific headers */
 enum protocol_types {
@@ -658,6 +671,7 @@ int ms_fnmatch(const char *pattern, const char *string, enum protocol_types prot
 
 /** a generic fnmatch function - uses for non-CIFS pattern matching */
 int gen_fnmatch(const char *pattern, const char *string);
+#endif
 
 /* The following definitions come from lib/util/mutex.c  */
 
@@ -707,10 +721,12 @@ _PUBLIC_ int idr_remove(struct idr_context *idp, int id);
 
 /* The following definitions come from lib/util/become_daemon.c  */
 
+#if _SAMBA_BUILD_ == 4
 /**
  Become a daemon, discarding the controlling terminal.
 **/
 _PUBLIC_ void become_daemon(bool fork);
+#endif
 
 /**
  * Load a ini-style file.
index 43f98ae1a9f2f6f6abaace007b6345b875f191de..f9eb0289160ca8183d68bdaef002fd8dd8430339 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __LIB_UTIL_UTIL_LDB_H__
 #define __LIB_UTIL_UTIL_LDB_H__
 
+struct ldb_dn;
+
 /* The following definitions come from lib/util/util_ldb.c  */
 
 int gendb_search_v(struct ldb_context *ldb,
index 24e33c172009a565d859624fe4f5353cc923c8c7..73600e379b47df2bfe67a979fb67c09eb611886d 100644 (file)
@@ -572,6 +572,7 @@ extern void *cmdline_lp_ctx;
 struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
 
 /* Lists, trees, caching, database... */
+#include "../lib/util/util.h"
 #include "../lib/util/xfile.h"
 #include "../lib/util/memory.h"
 #include "../lib/util/attr.h"
@@ -619,6 +620,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
 #include "msdfs.h"
 #include "rap.h"
 #include "../lib/crypto/md5.h"
+#include "../lib/crypto/md4.h"
 #include "../lib/crypto/arcfour.h"
 #include "../lib/crypto/crc32.h"
 #include "../lib/crypto/hmacmd5.h"
index d2e0aa95acefa239b2c4fe135614815d1c998c56..668dc186d3ac77be7222c8c4d6d5482b10ce3b70 100644 (file)
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
 #endif
 
-/* assert macros */
-#ifdef DEVELOPER
-#define SMB_ASSERT(b) ( (b) ? (void)0 : \
-        (DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
-                __FILE__, __LINE__, #b)), smb_panic("assert failed: " #b)))
-#else
-/* redefine the assert macro for non-developer builds */
-#define SMB_ASSERT(b) ( (b) ? (void)0 : \
-        (DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
-           __FILE__, __LINE__, #b))))
-#endif
+
 
 #define SMB_WARN(condition, message) \
     ((condition) ? (void)0 : \
index d91d34d29bfab55e42e7bbd488346cee699e7ea1..800a47c3438e7ba9770bc2ab137f74f33ed9b603 100644 (file)
@@ -5418,7 +5418,6 @@ FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrappi
 
 static int map_parameter(const char *pszParmName);
 static int map_parameter_canonical(const char *pszParmName, bool *inverse);
-static bool set_boolean(bool *pb, const char *pszParmValue);
 static const char *get_boolean(bool bool_value);
 static int getservicebyname(const char *pszServiceName,
                            struct service *pserviceDest);
@@ -5532,7 +5531,7 @@ static bool lp_bool(const char *s)
                return False;
        }
        
-       if (!set_boolean(&ret,s)) {
+       if (!set_boolean(s, &ret)) {
                DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
                return False;
        }
@@ -6314,49 +6313,13 @@ void show_parameter_list(void)
        }
 }
 
-/***************************************************************************
- Set a boolean variable from the text value stored in the passed string.
- Returns True in success, False if the passed string does not correctly 
- represent a boolean.
-***************************************************************************/
-
-static bool set_boolean(bool *pb, const char *pszParmValue)
-{
-       bool bRetval;
-       bool value;
-
-       bRetval = True;
-       value = False;
-       if (strwicmp(pszParmValue, "yes") == 0 ||
-           strwicmp(pszParmValue, "true") == 0 ||
-           strwicmp(pszParmValue, "1") == 0)
-               value = True;
-       else if (strwicmp(pszParmValue, "no") == 0 ||
-                   strwicmp(pszParmValue, "False") == 0 ||
-                   strwicmp(pszParmValue, "0") == 0)
-               value = False;
-       else {
-               DEBUG(2,
-                     ("ERROR: Badly formed boolean in configuration file: \"%s\".\n",
-                      pszParmValue));
-               bRetval = False;
-       }
-
-       if ((pb != NULL) && (bRetval != False)) {
-               *pb = value;
-       }
-
-       return (bRetval);
-}
-
-
 /***************************************************************************
  Check if a given string correctly represents a boolean value.
 ***************************************************************************/
 
 bool lp_string_is_valid_boolean(const char *parm_value)
 {
-       return set_boolean(NULL, parm_value);
+       return set_boolean(parm_value, NULL);
 }
 
 /***************************************************************************
@@ -6381,7 +6344,7 @@ bool lp_invert_boolean(const char *str, const char **inverse_str)
 {
        bool val;
 
-       if (!set_boolean(&val, str)) {
+       if (!set_boolean(str, &val)) {
                return False;
        }
 
@@ -6399,7 +6362,7 @@ bool lp_canonicalize_boolean(const char *str, const char**canon_str)
 {
        bool val;
 
-       if (!set_boolean(&val, str)) {
+       if (!set_boolean(str, &val)) {
                return False;
        }
 
index 08d6cdb5f690b49cec790378eb103642b316073f..f925e836c56bcb8a78a351e265ba8fa01ea976d2 100644 (file)
 #ifndef _PRINTF_ATTRIBUTE
 #define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
 #endif
-#include "../lib/util/util.h"
+#include "../lib/util/xfile.h"
+#include "../lib/util/attr.h"
 #include "../lib/util/debug.h"
+#include "../lib/util/util.h"
 
 #include "libcli/util/error.h"