- Start the logging thread from ServiceMain.
- Move UNICODE definition to the configuration file.
- Code cleanup.
Modified: trunk/reactos/services/eventlog/eventlog.c
Modified: trunk/reactos/services/eventlog/logport.c

Modified: trunk/reactos/services/eventlog/eventlog.c
--- trunk/reactos/services/eventlog/eventlog.c	2005-06-01 21:55:36 UTC (rev 15720)
+++ trunk/reactos/services/eventlog/eventlog.c	2005-06-01 21:57:52 UTC (rev 15721)
@@ -1,6 +1,6 @@
 /*
  *  ReactOS kernel
- *  Copyright (C) 2002 ReactOS Team
+ *  Copyright (C) 2002, 2005 ReactOS Team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -16,8 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id$
- *
+/*
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             services/eventlog/eventlog.c
@@ -27,8 +26,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#define UNICODE
-
 #define NTOS_MODE_USER
 #include <ntos.h>
 #include <windows.h>
@@ -40,9 +37,17 @@
 #include <debug.h>
 
 
+VOID CALLBACK
+ServiceMain(DWORD argc, LPTSTR *argv);
 
+
 /* GLOBALS ******************************************************************/
 
+SERVICE_TABLE_ENTRY ServiceTable[2] =
+{
+  {L"EventLog", (LPSERVICE_MAIN_FUNCTION)ServiceMain},
+  {NULL, NULL}
+};
 
 
 /* FUNCTIONS *****************************************************************/
@@ -53,6 +58,10 @@
 {
   DPRINT("ServiceMain() called\n");
 
+  if (StartPortThread() == FALSE)
+    {
+      DPRINT("StartPortThread() failed\n");
+    }
 
   DPRINT("ServiceMain() done\n");
 }
@@ -61,37 +70,15 @@
 int
 main(int argc, char *argv[])
 {
-  SERVICE_TABLE_ENTRY ServiceTable[2] = {{L"EventLog", (LPSERVICE_MAIN_FUNCTION)ServiceMain},
-					 {NULL, NULL}};
+  DPRINT("main() called\n");
 
-  HANDLE hEvent;
-//  NTSTATUS Status;
-
-  DPRINT("EventLog started\n");
-
-
-
-
-
   StartServiceCtrlDispatcher(ServiceTable);
 
-  DPRINT("StartServiceCtrlDispatcher() done\n");
+  DPRINT("main() done\n");
 
-  if (StartPortThread() == FALSE)
-    {
-      DPRINT1("StartPortThread() failed\n");
-    }
-
-  DPRINT("EventLog waiting\n");
-
-  hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-  WaitForSingleObject(hEvent, INFINITE);
-
-  DPRINT("EventLog done\n");
-
   ExitThread(0);
 
-  return(0);
+  return 0;
 }
 
 /* EOF */

Modified: trunk/reactos/services/eventlog/logport.c
--- trunk/reactos/services/eventlog/logport.c	2005-06-01 21:55:36 UTC (rev 15720)
+++ trunk/reactos/services/eventlog/logport.c	2005-06-01 21:57:52 UTC (rev 15721)
@@ -16,8 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id$
- *
+/*
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
  * FILE:             services/eventlog/logport.c
@@ -27,8 +26,6 @@
 
 /* INCLUDES *****************************************************************/
 
-#define UNICODE
-
 #define NTOS_MODE_USER
 #include <ntos.h>
 #include <windows.h>
@@ -50,7 +47,7 @@
 /* FUNCTIONS ****************************************************************/
 
 static NTSTATUS
-InitLogPort (VOID)
+InitLogPort(VOID)
 {
   OBJECT_ATTRIBUTES ObjectAttributes;
   UNICODE_STRING PortName;
@@ -93,27 +90,27 @@
 			       TRUE,
 			       NULL,
 			       NULL);
-  if (!NT_SUCCESS (Status))
+  if (!NT_SUCCESS(Status))
     {
       DPRINT1("NtAcceptConnectPort() failed (Status %lx)\n", Status);
       goto ByeBye;
     }
 
-  Status = NtCompleteConnectPort (MessagePortHandle);
-  if (!NT_SUCCESS (Status))
+  Status = NtCompleteConnectPort(MessagePortHandle);
+  if (!NT_SUCCESS(Status))
     {
       DPRINT1("NtCompleteConnectPort() failed (Status %lx)\n", Status);
       goto ByeBye;
     }
 
 ByeBye:
-  if (!NT_SUCCESS (Status))
+  if (!NT_SUCCESS(Status))
     {
       if (ConnectPortHandle != NULL)
-	NtClose (ConnectPortHandle);
+	NtClose(ConnectPortHandle);
 
       if (MessagePortHandle != NULL)
-	NtClose (MessagePortHandle);
+	NtClose(MessagePortHandle);
     }
 
   return Status;
@@ -148,40 +145,40 @@
 	  break;
 	}
 
-      DPRINT ("Received message\n");
+      DPRINT("Received message\n");
 
       if (Request.Header.MessageType == LPC_PORT_CLOSED)
 	{
-	  DPRINT ("Port closed\n");
+	  DPRINT("Port closed\n");
 
-	  return (STATUS_UNSUCCESSFUL);
+	  return STATUS_SUCCESS;
 	}
       if (Request.Header.MessageType == LPC_REQUEST)
 	{
-	  DPRINT ("Received request\n");
+	  DPRINT("Received request\n");
 
 	}
       else if (Request.Header.MessageType == LPC_DATAGRAM)
 	{
-	  DPRINT ("Received datagram\n");
+	  DPRINT("Received datagram\n");
 
 
 	  Message = (PIO_ERROR_LOG_MESSAGE)&Request.Data;
 
-	  DPRINT ("Message->Type %hx\n", Message->Type);
-	  DPRINT ("Message->Size %hu\n", Message->Size);
+	  DPRINT("Message->Type %hx\n", Message->Type);
+	  DPRINT("Message->Size %hu\n", Message->Size);
 
 //#ifndef NDEBUG
-	  DbgPrint ("\n Error mesage:\n");
-	  DbgPrint ("Error code: %lx\n", Message->EntryData.ErrorCode);
-	  DbgPrint ("Retry count: %u\n", Message->EntryData.RetryCount);
-	  DbgPrint ("Sequence number: %lu\n", Message->EntryData.SequenceNumber);
+	  DbgPrint("\n Error mesage:\n");
+	  DbgPrint("Error code: %lx\n", Message->EntryData.ErrorCode);
+	  DbgPrint("Retry count: %u\n", Message->EntryData.RetryCount);
+	  DbgPrint("Sequence number: %lu\n", Message->EntryData.SequenceNumber);
 
 	  if (Message->DriverNameLength != 0)
 	    {
-	      DbgPrint ("Driver name: %.*S\n",
-		        Message->DriverNameLength / sizeof(WCHAR),
-		        (PWCHAR)((ULONG_PTR)Message + Message->DriverNameOffset));
+	      DbgPrint("Driver name: %.*S\n",
+		       Message->DriverNameLength / sizeof(WCHAR),
+		       (PWCHAR)((ULONG_PTR)Message + Message->DriverNameOffset));
 	    }
 
 	  if (Message->EntryData.NumberOfStrings != 0)
@@ -189,13 +186,16 @@
 	      p = (PWSTR)((ULONG_PTR)&Message->EntryData + Message->EntryData.StringOffset);
 	      for (i = 0; i < Message->EntryData.NumberOfStrings; i++)
 		{
-		  DbgPrint ("String %lu: %S\n", i, p);
+		  DbgPrint("String %lu: %S\n", i, p);
 		  p += wcslen(p) + 1;
 		}
 	      DbgPrint("\n");
 	    }
 
 //#endif
+
+	  /* FIXME: Enqueue message */
+
 	}
     }
 
@@ -210,7 +210,7 @@
 
   Status = InitLogPort();
   if (!NT_SUCCESS(Status))
-    return(Status);
+    return Status;
 
   while (NT_SUCCESS(Status))
     {
@@ -218,12 +218,12 @@
     }
 
   if (ConnectPortHandle != NULL)
-    NtClose (ConnectPortHandle);
+    NtClose(ConnectPortHandle);
 
   if (MessagePortHandle != NULL)
-    NtClose (MessagePortHandle);
+    NtClose(MessagePortHandle);
 
-  return(Status);
+  return Status;
 }
 
 
@@ -239,7 +239,7 @@
 				  0,
 				  &ThreadId);
 
-  return((PortThreadHandle != NULL));
+  return (PortThreadHandle != NULL);
 }
 
 /* EOF */