#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
-#if _SAMBA_BUILD_ == 4
-#include "../lib/util/charset/charset.h"
-#endif
-#include "../lib/util/attr.h"
+#include "lib/util/charset/charset.h"
+#include "lib/util/attr.h"
/* for TALLOC_CTX */
#include <talloc.h>
extern const char *logfile;
extern const char *panic_action;
-#include "../lib/util/time.h"
-#include "../lib/util/data_blob.h"
-#include "../lib/util/xfile.h"
-#include "../lib/util/mutex.h"
-#include "../lib/util/byteorder.h"
-#include "../lib/util/talloc_stack.h"
+#include "lib/util/time.h"
+#include "lib/util/data_blob.h"
+#include "lib/util/xfile.h"
+#include "lib/util/byteorder.h"
+#include "lib/util/talloc_stack.h"
/**
* assert macros
__FILE__, __LINE__, #b)); }} while (0)
#endif
-#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"
+#include "lib/util/memory.h"
/**
* Write backtrace to debug log
**/
_PUBLIC_ _NORETURN_ void smb_panic(const char *why);
-#if _SAMBA_BUILD_ == 4
-/**
-setup our fault handlers
-**/
-_PUBLIC_ void fault_setup(const char *pname);
-#endif
+typedef void (*smb_panic_handler_t)(const char *why);
+
+_PUBLIC_ void fault_configure(smb_panic_handler_t panic_handler);
+_PUBLIC_ void fault_setup(void);
+_PUBLIC_ void fault_setup_disable(void);
+_PUBLIC_ void dump_core_setup(const char *progname, const char *logfile);
+_PUBLIC_ void smb_panic(const char *reason);
+
/**
register a fault handler.
/**
Sleep for a specified number of milliseconds.
**/
-_PUBLIC_ void msleep(unsigned int t);
+_PUBLIC_ void smb_msleep(unsigned int t);
/**
Get my own name, return in talloc'ed storage.
**/
_PUBLIC_ char* get_myname(TALLOC_CTX *mem_ctx);
-/**
- Return true if a string could be a pure IP address.
-**/
-_PUBLIC_ bool is_ipaddress(const char *str);
-
-/**
- Interpret an internet address or name into an IP address in 4 byte form.
-**/
-_PUBLIC_ uint32_t interpret_addr(const char *str);
-
-/**
- A convenient addition to interpret_addr().
-**/
-_PUBLIC_ struct in_addr interpret_addr2(const char *str);
-
-/**
- Check if an IP is the 0.0.0.0.
-**/
-_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip);
-
-/**
- Are two IPs on the same subnet?
-**/
-_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?
**/
**/
_PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
+/**
+ * Write dump of binary data to a callback
+ */
+void dump_data_cb(const uint8_t *buf, int len,
+ bool omit_zero_bytes,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data);
+
/**
* Write dump of binary data to the log file.
*
int gen_fnmatch(const char *pattern, const char *string);
#endif
-/* The following definitions come from lib/util/mutex.c */
-
-
-/**
- register a set of mutex/rwlock handlers.
- Should only be called once in the execution of smbd.
-*/
-_PUBLIC_ bool register_mutex_handlers(const char *name, struct mutex_ops *ops);
-
/* The following definitions come from lib/util/idtree.c */
/**
Become a daemon, discarding the controlling terminal.
**/
-_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group);
+_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group, bool log_stdout);
/**
* Load a ini-style file.
bool unmap_file(void *start, size_t size);
void print_asc(int level, const uint8_t *buf,int len);
+void print_asc_cb(const uint8_t *buf, int len,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data);
/**
* Add an id to an array of ids.
*/
bool add_uid_to_array_unique(TALLOC_CTX *mem_ctx, uid_t uid,
- uid_t **uids, size_t *num_uids);
+ uid_t **uids, uint32_t *num_uids);
bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
- gid_t **gids, size_t *num_gids);
+ gid_t **gids, uint32_t *num_gids);
+
+/**
+ * Allocate anonymous shared memory of the given size
+ */
+void *anonymous_shared_allocate(size_t bufsz);
+void anonymous_shared_free(void *ptr);
/*
run a command as a child process, with a timeout.
const char * const *argv0, ...);
int samba_runcmd_recv(struct tevent_req *req, int *perrno);
+#ifdef DEVELOPER
+void samba_start_debugger(void);
+#endif
+
#endif /* _SAMBA_UTIL_H_ */