r21090: Add some helper routines
authorVolker Lendecke <vlendec@samba.org>
Wed, 31 Jan 2007 14:28:08 +0000 (14:28 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:35 +0000 (12:17 -0500)
(This used to be commit 985dde8ed0a7e6da5adf9c55654a4fd362b22acb)

source3/smbd/notify.c
source3/smbd/server.c
source3/torture/vfstest.c

index 9cb121a0394a2f03cc2482ece0a374e8c046ae63..2907bd7e0f47ff438eae32a179676877be608399 100644 (file)
@@ -521,6 +521,44 @@ static void notify_message_callback(int msgtype, struct process_id pid,
        }
 }
 
+char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32 filter)
+{
+       char *result = NULL;
+
+       result = talloc_strdup(mem_ctx, "");
+
+       if (filter & FILE_NOTIFY_CHANGE_FILE_NAME)
+               result = talloc_asprintf_append(result, "FILE_NAME|");
+       if (filter & FILE_NOTIFY_CHANGE_DIR_NAME)
+               result = talloc_asprintf_append(result, "DIR_NAME|");
+       if (filter & FILE_NOTIFY_CHANGE_ATTRIBUTES)
+               result = talloc_asprintf_append(result, "ATTRIBUTES|");
+       if (filter & FILE_NOTIFY_CHANGE_SIZE)
+               result = talloc_asprintf_append(result, "SIZE|");
+       if (filter & FILE_NOTIFY_CHANGE_LAST_WRITE)
+               result = talloc_asprintf_append(result, "LAST_WRITE|");
+       if (filter & FILE_NOTIFY_CHANGE_LAST_ACCESS)
+               result = talloc_asprintf_append(result, "LAST_ACCESS|");
+       if (filter & FILE_NOTIFY_CHANGE_CREATION)
+               result = talloc_asprintf_append(result, "CREATION|");
+       if (filter & FILE_NOTIFY_CHANGE_EA)
+               result = talloc_asprintf_append(result, "EA|");
+       if (filter & FILE_NOTIFY_CHANGE_SECURITY)
+               result = talloc_asprintf_append(result, "SECURITY|");
+       if (filter & FILE_NOTIFY_CHANGE_STREAM_NAME)
+               result = talloc_asprintf_append(result, "STREAM_NAME|");
+       if (filter & FILE_NOTIFY_CHANGE_STREAM_SIZE)
+               result = talloc_asprintf_append(result, "STREAM_SIZE|");
+       if (filter & FILE_NOTIFY_CHANGE_STREAM_WRITE)
+               result = talloc_asprintf_append(result, "STREAM_WRITE|");
+
+       if (result == NULL) return NULL;
+       if (*result == '\0') return result;
+
+       result[strlen(result)-1] = '\0';
+       return result;
+}
+
 /****************************************************************************
  Initialise the change notify subsystem.
 ****************************************************************************/
index dcb685511bf72898fc32c85fdb3bc3757cbcd6cf..ab43bcb66f0bcb558ddfda83bdc6db58456e5ce7 100644 (file)
@@ -71,6 +71,17 @@ struct event_context *smbd_event_context(void)
        return ctx;
 }
 
+struct messaging_context *smbd_messaging_context(void)
+{
+       static struct messaging_context *ctx;
+
+       if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
+                                          smbd_event_context()))) {
+               smb_panic("Could not init smbd messaging context\n");
+       }
+       return ctx;
+}
+
 /*******************************************************************
  What to do when smb.conf is updated.
  ********************************************************************/
index f9a01a3e91c9f37155f775031078b0d469b105a7..872c7a74c32e920e147df93d8702a1bba6f1890a 100644 (file)
@@ -489,6 +489,17 @@ struct event_context *smbd_event_context(void)
        return ctx;
 }
 
+struct messaging_context *smbd_messaging_context(void)
+{
+       static struct messaging_context *ctx;
+
+       if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
+                                          smbd_event_context()))) {
+               smb_panic("Could not init smbd messaging context\n");
+       }
+       return ctx;
+}
+
 /* Main function */
 
 int main(int argc, char *argv[])