#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
+#include <netinet/in.h>
+
#if _SAMBA_BUILD_ == 4
#include "../lib/util/charset/charset.h"
#endif
#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)
+ __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)) { \
#endif
#if _SAMBA_BUILD_ == 4
-#if defined(VALGRIND)
+#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"
/* 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_ struct hostent *sys_gethostbyname(const char *name);
_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host);
+/**
+ * Wrapper for fork used to invalid pid cache.
+ **/
+_PUBLIC_ pid_t sys_fork(void);
+
+/**
+ * Wrapper for getpid. Ensures we only do a system call *once*.
+ **/
+_PUBLIC_ pid_t sys_getpid(void);
+
/* The following definitions come from lib/util/genrand.c */
/**
/* The following definitions come from lib/util/util_str.c */
+bool next_token_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep);
+
+/**
+ * Get the next token from a string, return false if none found. Handles
+ * double-quotes. This version does not trim leading separator characters
+ * before looking for a token.
+ */
+bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep);
+
/**
Trim the specified elements off the front and back of a string.
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_ void msleep(unsigned int t);
/**
- Get my own name, return in malloc'ed storage.
+ Get my own name, return in talloc'ed storage.
**/
-_PUBLIC_ char* get_myname(void);
+_PUBLIC_ char* get_myname(TALLOC_CTX *mem_ctx);
/**
Return true if a string could be a pure IP address.
/* The following definitions come from lib/util/become_daemon.c */
-#if _SAMBA_BUILD_ == 4
+/**
+ Close the low 3 fd's and open dev/null in their place
+**/
+_PUBLIC_ void close_low_fds(bool stderr_too);
+
/**
Become a daemon, discarding the controlling terminal.
**/
-_PUBLIC_ void become_daemon(bool fork);
-#endif
+_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group);
/**
* Load a ini-style file.