s3-eventlog: add evlog_tdb_entry_to_evt_entry.
authorGünther Deschner <gd@samba.org>
Wed, 4 Feb 2009 17:31:04 +0000 (18:31 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 4 Feb 2009 17:39:20 +0000 (18:39 +0100)
Guenther

source3/include/proto.h
source3/rpc_server/srv_eventlog_lib.c

index bb9d87eb5330b416e290bbb7ab2d37b781a10a48..3ae2448e4be1003f9a9ae53d90942ee1b57c6196 100644 (file)
@@ -6274,6 +6274,9 @@ NTSTATUS evlog_push_record_tdb(TALLOC_CTX *mem_ctx,
 NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx,
                                      const struct EVENTLOGRECORD *e,
                                      struct eventlog_Record_tdb *t);
+NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx,
+                                     const struct eventlog_Record_tdb *t,
+                                     struct EVENTLOGRECORD *e);
 
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
index 247c8ac04b48b56813597cff4e4e4baad476d7f9..fdd3db91913e10a71bce37ec2970164cc95e5c1a 100644 (file)
@@ -967,3 +967,66 @@ NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx,
 
        return NT_STATUS_OK;
 }
+
+/********************************************************************
+ ********************************************************************/
+
+NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx,
+                                     const struct eventlog_Record_tdb *t,
+                                     struct EVENTLOGRECORD *e)
+{
+       uint32_t i;
+
+       ZERO_STRUCTP(e);
+
+       e->Length               = t->size;
+       e->Reserved             = t->reserved;
+       e->RecordNumber         = t->record_number;
+       e->TimeGenerated        = t->time_generated;
+       e->TimeWritten          = t->time_written;
+       e->EventID              = t->event_id;
+       e->EventType            = t->event_type;
+       e->NumStrings           = t->num_of_strings;
+       e->EventCategory        = t->event_category;
+       e->ReservedFlags        = t->reserved_flags;
+       e->ClosingRecordNumber  = t->closing_record_number;
+
+       e->StringOffset         = t->stringoffset;
+       e->UserSidLength        = t->sid_length;
+       e->UserSidOffset        = t->sid_offset;
+       e->DataLength           = t->data_length;
+       e->DataOffset           = t->data_offset;
+
+       e->SourceName           = talloc_strdup(mem_ctx, t->source_name);
+       NT_STATUS_HAVE_NO_MEMORY(e->SourceName);
+
+       e->Computername         = talloc_strdup(mem_ctx, t->computer_name);
+       NT_STATUS_HAVE_NO_MEMORY(e->Computername);
+
+       if (t->sid_length > 0) {
+               const char *sid_str = NULL;
+               size_t len;
+               if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
+                                          t->sid.data, t->sid.length,
+                                          &sid_str, &len, false)) {
+                       return NT_STATUS_INVALID_SID;
+               }
+               if (len > 0) {
+                       e->UserSid = *string_sid_talloc(mem_ctx, sid_str);
+               }
+       }
+
+       e->Strings              = talloc_array(mem_ctx, const char *, t->num_of_strings);
+       for (i=0; i < t->num_of_strings; i++) {
+               e->Strings[i] = talloc_strdup(e->Strings, t->strings[i]);
+               NT_STATUS_HAVE_NO_MEMORY(e->Strings[i]);
+       }
+
+       e->Data                 = (uint8_t *)talloc_memdup(mem_ctx, t->data.data, t->data_length);
+       e->Pad                  = talloc_strdup(mem_ctx, "");
+       NT_STATUS_HAVE_NO_MEMORY(e->Pad);
+
+       e->Length2              = t->size;
+
+       return NT_STATUS_OK;
+}