jbuehler-add-missing-extern-c-patch-20031207
[openafs.git] / src / WINNT / client_creds / main.cpp
index 2627d85..f2b9618 100644 (file)
@@ -1,12 +1,25 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ * 
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
 
 extern "C" {
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <osilog.h>
+#include <afs/fs_utils.h>
 }
 
 #include "afscreds.h"
 #include "..\afsreg\afsreg.h" // So we can see if the server's installed
-
+#include "drivemap.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include "rxkad.h"
 
 /*
  * DEFINITIONS ________________________________________________________________
@@ -31,7 +44,6 @@ GLOBALS g;
 
 BOOL InitApp (LPSTR pszCmdLineA);
 void ExitApp (void);
-void Quit (void);
 void PumpMessage (MSG *pmsg);
 BOOL IsServerInstalled (void);
 
@@ -41,11 +53,15 @@ BOOL IsServerInstalled (void);
  *
  */
 
-int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
+extern "C" int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
 {
    Shortcut_Init();
    TaLocale_LoadCorrespondingModule (hInst);
 
+   osi_InitTraceOption();
+   osi_LogEvent0("AFSCreds Main command line",pCmdLine);
+   fs_utils_InitMountRoot();
+
    if (InitApp (pCmdLine))
       {
       MSG msg;
@@ -61,6 +77,8 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdSh
    return 0;
 }
 
+#define ISHIGHSECURITY(v) ( ((v) & LOGON_OPTION_HIGHSECURITY)==LOGON_OPTION_HIGHSECURITY)
+#define REG_CLIENT_PROVIDER_KEY "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\NetworkProvider"
 
 BOOL InitApp (LPSTR pszCmdLineA)
 {
@@ -103,10 +121,19 @@ BOOL InitApp (LPSTR pszCmdLineA)
          case 'U':
             fUninstall = TRUE;
             break;
+                case ':':
+                        MapShareName(pszCmdLineA);
+                        break;
+         case 'x':
+         case 'X':
+             TestAndDoMapShare(SERVICE_START_PENDING);
+             TestAndDoMapShare(SERVICE_RUNNING);
+            return 0;
          }
 
       while (*pszCmdLineA && (*pszCmdLineA != ' '))
          ++pszCmdLineA;
+         if (*pszCmdLineA==' ') ++pszCmdLineA;
       }
 
    if (fInstall)
@@ -187,6 +214,23 @@ BOOL InitApp (LPSTR pszCmdLineA)
 
    InitCommonControls();
    RegisterCheckListClass();
+   osi_Init();
+   lock_InitializeMutex(&g.expirationCheckLock, "expiration check lock");
+   lock_InitializeMutex(&g.credsLock, "global creds lock");
+
+   if ( IsDebuggerPresent() ) {
+       if ( !g.fIsWinNT )
+           OutputDebugString("No Service Present on non-NT systems\n");
+       else {
+           if ( IsServiceRunning() )
+               OutputDebugString("AFSD Service started\n");
+           else {
+               OutputDebugString("AFSD Service stopped\n");
+               if ( !IsServiceConfigured() )
+                   OutputDebugString("AFSD Service not configured\n");
+           }   
+       }
+   }
 
    // Create a main window. All further initialization will be done during
    // processing of WM_INITDIALOG.
@@ -215,12 +259,16 @@ BOOL InitApp (LPSTR pszCmdLineA)
       else if (!IsServerInstalled())
          Message (MB_ICONHAND, IDS_UNCONFIG_TITLE, IDS_UNCONFIG_DESC);
       }
-   if (IsServiceRunning() && fShow)
+   if (IsServiceRunning()) { 
+      if (fShow)
       {
+      if ( IsDebuggerPresent() )
+          OutputDebugString("Displaying Main window\n");
       Main_Show (TRUE);
       }
-
-   return TRUE;
+   } else if ( IsDebuggerPresent() )
+      OutputDebugString("Displaying Main window\n");
+    return TRUE;
 }