struct messaging_context *server_messaging_context(void);
void server_messaging_context_free(void);
+struct tevent_context *client_event_context(void);
+void client_event_context_free(void);
+struct messaging_context *client_messaging_context(const char *config_file);
+void client_messaging_context_free(void);
+
/* The following definitions come from lib/sessionid_tdb.c */
struct sessionid;
NTSTATUS sessionid_traverse_read(int (*fn)(const char *key,
{
TALLOC_FREE(msg_ctx);
}
+
+struct tevent_context *client_event_context(void)
+{
+ if (ev != NULL) {
+ return ev;
+ }
+
+ /*
+ * Note we MUST use the NULL context here, not the
+ * autofree context, to avoid side effects in forked
+ * children exiting.
+ */
+ ev = samba_tevent_context_init(NULL);
+ if (ev == NULL) {
+ smb_panic("Could not init client's event context");
+ }
+ return ev;
+}
+
+void client_event_context_free(void)
+{
+ TALLOC_FREE(ev);
+}
+
+struct messaging_context *client_messaging_context(const char *config_file)
+{
+ if (msg_ctx != NULL) {
+ return msg_ctx;
+ }
+
+ if (!lp_load_initial_only(config_file)) {
+ return NULL;
+ }
+
+ /*
+ * Note we MUST use the NULL context here, not the
+ * autofree context, to avoid side effects in forked
+ * children exiting.
+ */
+ msg_ctx = messaging_init(NULL, client_event_context());
+
+ return msg_ctx;
+}
+
+void client_messaging_context_free(void)
+{
+ TALLOC_FREE(msg_ctx);
+}