Add information letting us know creation deletion of services has worked.
[reactos.git] / reactos / subsys / csrss / csrss.c
index e99abd3..b5d7303 100644 (file)
@@ -1,9 +1,9 @@
-/* $Id: csrss.c,v 1.7 2000/04/23 17:44:53 phreak Exp $
+/* $Id$
  *
  * csrss.c - Client/Server Runtime subsystem
- * 
+ *
  * ReactOS Operating System
- * 
+ *
  * --------------------------------------------------------------------
  *
  * This software is free software; you can redistribute it and/or
  * You should have received a copy of the GNU General Public License
  * along with this software; see the file COPYING.LIB. If not, write
  * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
- * MA 02139, USA.  
+ * MA 02139, USA.
  *
  * --------------------------------------------------------------------
- * 
- *     19990417 (Emanuele Aliberti)
- *             Do nothing native application skeleton
- *     19990528 (Emanuele Aliberti)
- *             Compiled successfully with egcs 1.1.2
- *     19990605 (Emanuele Aliberti)
- *             First standalone run under ReactOS (it
- *             actually does nothing but running).
  */
-#include <ddk/ntddk.h>
-#include <ntdll/rtl.h>
-#include <csrss/csrss.h>
-
-#include "api.h"
 
-VOID PrintString (char* fmt, ...);
+#include <csrss.h>
 
-/* Native process' entry point */
+#define NDEBUG
+#include <debug.h>
 
-VOID NtProcessStartup(PPEB Peb)
+int _cdecl _main(int argc,
+                char *argv[],
+                char *envp[],
+                int DebugFlag)
 {
-   PRTL_USER_PROCESS_PARAMETERS ProcParams;
-   PWSTR ArgBuffer;
-   PWSTR *argv;
-   ULONG argc = 0;
-   int i = 0;
-   int afterlastspace = 0;
-   OBJECT_ATTRIBUTES ObjectAttributes;
-   HANDLE CsrssInitEvent;
-   UNICODE_STRING UnicodeString;
-   NTSTATUS Status;
+   NTSTATUS Status = STATUS_SUCCESS;
    
-   DisplayString(L"Client/Server Runtime Subsystem\n");
-
-   ProcParams = RtlNormalizeProcessParams (Peb->ProcessParameters);
-
-   argv = (PWSTR *)RtlAllocateHeap (Peb->ProcessHeap,
-                                    0, 512 * sizeof(PWSTR));
-   ArgBuffer = (PWSTR)RtlAllocateHeap (Peb->ProcessHeap,
-                                       0,
-                                       ProcParams->CommandLine.Length + sizeof(WCHAR));
-   memcpy (ArgBuffer,
-           ProcParams->CommandLine.Buffer,
-           ProcParams->CommandLine.Length + sizeof(WCHAR));
+   PrintString("ReactOS Client/Server Run-Time (Build %s)\n",
+            KERNEL_VERSION_BUILD_STR);
 
-   while (ArgBuffer[i])
+   /*==================================================================
+    *  Initialize the Win32 environment subsystem server.
+    *================================================================*/
+   if (CsrServerInitialization (argc, argv, envp) == TRUE)
      {
-       if (ArgBuffer[i] == L' ')
-         {
-            argc++;
-            ArgBuffer[i] = L'\0';
-            argv[argc-1] = &(ArgBuffer[afterlastspace]);
-            i++;
-            while (ArgBuffer[i] == L' ')
-               i++;
-            afterlastspace = i;
-         }
-       else
-         {
-            i++;
-         }
-     }
-
-   if (ArgBuffer[afterlastspace] != L'\0')
-     {
-       argc++;
-       ArgBuffer[i] = L'\0';
-       argv[argc-1] = &(ArgBuffer[afterlastspace]);
-     }
-   
-   RtlInitUnicodeString(&UnicodeString,
-                       L"\\CsrssInitDone");
-   InitializeObjectAttributes(&ObjectAttributes,
-                             &UnicodeString,
-                             EVENT_ALL_ACCESS,
-                             0,
-                             NULL);
-   Status = NtOpenEvent(&CsrssInitEvent,
-                       EVENT_ALL_ACCESS,
-                       &ObjectAttributes);
-   if (!NT_SUCCESS(Status))
-     {
-       DbgPrint("CSR: Failed to open csrss notification event\n");
-     }
-   DbgPrint( "foof\n" );
-   if (CsrServerInitialization (argc, argv) == TRUE)
-     {
-       DisplayString( L"CSR: Subsystem initialized.\n" );
-
-       NtSetEvent(CsrssInitEvent,
-                  NULL);
-       
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0, argv);
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0,
-                    ArgBuffer);
-
-       /* terminate the current thread only */
-       NtTerminateThread( NtCurrentThread(), 0 );
+       /*
+        * Terminate the current thread only.
+        */
+       Status = NtTerminateThread (NtCurrentThread(), 0);
      }
    else
      {
-       DisplayString( L"CSR: Subsystem initialization failed.\n" );
-
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0, argv);
-       RtlFreeHeap (Peb->ProcessHeap,
-                    0,
-                    ArgBuffer);
-
+       DisplayString (L"CSR: CsrServerInitialization failed.\n");
        /*
-        * Tell SM we failed.
+        * Tell the SM we failed.
         */
-       NtTerminateProcess( NtCurrentProcess(), 0 );
+       Status = NtTerminateProcess (NtCurrentProcess(), 0);
      }
+   return (int) Status;
 }
 
 /* EOF */