#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
+#include <netinet/in.h>
+
#if _SAMBA_BUILD_ == 4
-#include "lib/charset/charset.h"
+#include "../lib/util/charset/charset.h"
#endif
#include "../lib/util/attr.h"
/**
* assert macros
*/
+#ifdef DEVELOPER
+#define SMB_ASSERT(b) do { if (!(b)) { \
+ 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)\n", __FILE__, __LINE__)); \
- smb_panic("assert failed"); }} while (0)
+ DEBUG(0,("PANIC: assert failed at %s(%d): %s\n", \
+ __FILE__, __LINE__, #b)); }} while (0)
+#endif
-#if defined(VALGRIND)
+#if _SAMBA_BUILD_ == 4
+#ifdef VALGRIND
#define strlen(x) valgrind_strlen(x)
+size_t valgrind_strlen(const char *s);
+#endif
+#endif
+
+#ifndef ABS
+#define ABS(a) ((a)>0?(a):(-(a)))
#endif
#include "../lib/util/memory.h"
**/
_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.
/* The following definitions come from lib/util/system.c */
-
-struct in_addr;
-
/**************************************************************************
A wrapper for gethostbyname() that tries avoids looking up hostnames
in the root domain, which can cause dial-on-demand links to come up for no
_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 */
Unescape a URL encoded string, in place.
**/
_PUBLIC_ void rfc1738_unescape(char *buf);
-size_t valgrind_strlen(const char *s);
/**
format a string into length-prefixed dotted domain format, as used in NBT
**/
_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
*/
_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
/* 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
/**
Check if an IP is the 0.0.0.0.
**/
-_PUBLIC_ bool is_zero_ip(struct in_addr ip);
+_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip);
/**
Are two IPs on the same subnet?
**/
-_PUBLIC_ bool same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
+_PUBLIC_ bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
+
+_PUBLIC_ bool is_ipaddress_v4(const char *str);
/**
Check if a process exists. Does this work on all unixes?
* @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 {
/** 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 */
/* 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.