add units to time, use configuration time api where appropriate, fixing Mantis #1875
[oweals/gnunet.git] / src / util / winproc.c
index 4fa3ab4848f5e3c343c69de7e20f8a9a2e36af56..252cacbfba0cf229c417d48fd9751f4d4a09099a 100644 (file)
@@ -66,15 +66,15 @@ TAddAce GNAddAce;
 TAddAccessAllowedAce GNAddAccessAllowedAce;
 TSetNamedSecurityInfo GNSetNamedSecurityInfo;
 
+#define LOG(kind,...) GNUNET_log_from (kind, "winproc", __VA_ARGS__)
 /**
  * Log (panic) messages from PlibC
  */
 void
 plibc_panic (int err, char *msg)
 {
-  GNUNET_log (((err ==
-                INT_MAX) ? GNUNET_ERROR_TYPE_DEBUG : GNUNET_ERROR_TYPE_ERROR),
-              "%s", msg);
+  LOG (((err == INT_MAX) ? GNUNET_ERROR_TYPE_DEBUG : GNUNET_ERROR_TYPE_ERROR),
+       "%s", msg);
 }
 
 /**
@@ -100,8 +100,9 @@ GNInitWinEnv ()
   /* Function to get CPU usage under Win NT */
   if (hNTDLL)
   {
-    GNNtQuerySystemInformation = (TNtQuerySystemInformation)
-        GetProcAddress (hNTDLL, "NtQuerySystemInformation");
+    GNNtQuerySystemInformation =
+        (TNtQuerySystemInformation) GetProcAddress (hNTDLL,
+                                                    "NtQuerySystemInformation");
   }
   else
   {
@@ -113,13 +114,13 @@ GNInitWinEnv ()
   if (hIphlpapi)
   {
     GNGetIfEntry = (TGetIfEntry) GetProcAddress (hIphlpapi, "GetIfEntry");
-    GNGetIpAddrTable = (TGetIpAddrTable) GetProcAddress (hIphlpapi,
-                                                         "GetIpAddrTable");
+    GNGetIpAddrTable =
+        (TGetIpAddrTable) GetProcAddress (hIphlpapi, "GetIpAddrTable");
     GNGetIfTable = (TGetIfTable) GetProcAddress (hIphlpapi, "GetIfTable");
-    GNGetBestInterface = (TGetBestInterface) GetProcAddress (hIphlpapi,
-                                                             "GetBestInterface");
-    GGetAdaptersInfo = (TGetAdaptersInfo) GetProcAddress (hIphlpapi,
-                                                          "GetAdaptersInfo");
+    GNGetBestInterface =
+        (TGetBestInterface) GetProcAddress (hIphlpapi, "GetBestInterface");
+    GGetAdaptersInfo =
+        (TGetAdaptersInfo) GetProcAddress (hIphlpapi, "GetAdaptersInfo");
   }
   else
   {
@@ -134,51 +135,57 @@ GNInitWinEnv ()
   hAdvapi = LoadLibrary ("advapi32.dll");
   if (hAdvapi)
   {
-    GNOpenSCManager = (TOpenSCManager)
-        GetProcAddress (hAdvapi, "OpenSCManagerA");
-    GNCreateService = (TCreateService)
-        GetProcAddress (hAdvapi, "CreateServiceA");
-    GNCloseServiceHandle = (TCloseServiceHandle)
-        GetProcAddress (hAdvapi, "CloseServiceHandle");
-    GNDeleteService = (TDeleteService)
-        GetProcAddress (hAdvapi, "DeleteService");
-    GNRegisterServiceCtrlHandler = (TRegisterServiceCtrlHandler)
-        GetProcAddress (hAdvapi, "RegisterServiceCtrlHandlerA");
-    GNSetServiceStatus = (TSetServiceStatus)
-        GetProcAddress (hAdvapi, "SetServiceStatus");
-    GNStartServiceCtrlDispatcher = (TStartServiceCtrlDispatcher)
-        GetProcAddress (hAdvapi, "StartServiceCtrlDispatcherA");
-    GNControlService = (TControlService)
-        GetProcAddress (hAdvapi, "ControlService");
+    GNOpenSCManager =
+        (TOpenSCManager) GetProcAddress (hAdvapi, "OpenSCManagerA");
+    GNCreateService =
+        (TCreateService) GetProcAddress (hAdvapi, "CreateServiceA");
+    GNCloseServiceHandle =
+        (TCloseServiceHandle) GetProcAddress (hAdvapi, "CloseServiceHandle");
+    GNDeleteService =
+        (TDeleteService) GetProcAddress (hAdvapi, "DeleteService");
+    GNRegisterServiceCtrlHandler =
+        (TRegisterServiceCtrlHandler) GetProcAddress (hAdvapi,
+                                                      "RegisterServiceCtrlHandlerA");
+    GNSetServiceStatus =
+        (TSetServiceStatus) GetProcAddress (hAdvapi, "SetServiceStatus");
+    GNStartServiceCtrlDispatcher =
+        (TStartServiceCtrlDispatcher) GetProcAddress (hAdvapi,
+                                                      "StartServiceCtrlDispatcherA");
+    GNControlService =
+        (TControlService) GetProcAddress (hAdvapi, "ControlService");
     GNOpenService = (TOpenService) GetProcAddress (hAdvapi, "OpenServiceA");
 
-    GNLsaOpenPolicy = (TLsaOpenPolicy)
-        GetProcAddress (hAdvapi, "LsaOpenPolicy");
-    GNLsaAddAccountRights = (TLsaAddAccountRights)
-        GetProcAddress (hAdvapi, "LsaAddAccountRights");
-    GNLsaRemoveAccountRights = (TLsaRemoveAccountRights)
-        GetProcAddress (hAdvapi, "LsaRemoveAccountRights");
+    GNLsaOpenPolicy =
+        (TLsaOpenPolicy) GetProcAddress (hAdvapi, "LsaOpenPolicy");
+    GNLsaAddAccountRights =
+        (TLsaAddAccountRights) GetProcAddress (hAdvapi, "LsaAddAccountRights");
+    GNLsaRemoveAccountRights =
+        (TLsaRemoveAccountRights) GetProcAddress (hAdvapi,
+                                                  "LsaRemoveAccountRights");
     GNLsaClose = (TLsaClose) GetProcAddress (hAdvapi, "LsaClose");
-    GNLookupAccountName = (TLookupAccountName)
-        GetProcAddress (hAdvapi, "LookupAccountNameA");
-
-    GNGetFileSecurity = (TGetFileSecurity)
-        GetProcAddress (hAdvapi, "GetFileSecurityA");
-    GNInitializeSecurityDescriptor = (TInitializeSecurityDescriptor)
-        GetProcAddress (hAdvapi, "InitializeSecurityDescriptor");
-    GNGetSecurityDescriptorDacl = (TGetSecurityDescriptorDacl)
-        GetProcAddress (hAdvapi, "GetSecurityDescriptorDacl");
-    GNGetAclInformation = (TGetAclInformation)
-        GetProcAddress (hAdvapi, "GetAclInformation");
-    GNInitializeAcl = (TInitializeAcl)
-        GetProcAddress (hAdvapi, "InitializeAcl");
+    GNLookupAccountName =
+        (TLookupAccountName) GetProcAddress (hAdvapi, "LookupAccountNameA");
+
+    GNGetFileSecurity =
+        (TGetFileSecurity) GetProcAddress (hAdvapi, "GetFileSecurityA");
+    GNInitializeSecurityDescriptor =
+        (TInitializeSecurityDescriptor) GetProcAddress (hAdvapi,
+                                                        "InitializeSecurityDescriptor");
+    GNGetSecurityDescriptorDacl =
+        (TGetSecurityDescriptorDacl) GetProcAddress (hAdvapi,
+                                                     "GetSecurityDescriptorDacl");
+    GNGetAclInformation =
+        (TGetAclInformation) GetProcAddress (hAdvapi, "GetAclInformation");
+    GNInitializeAcl =
+        (TInitializeAcl) GetProcAddress (hAdvapi, "InitializeAcl");
     GNGetAce = (TGetAce) GetProcAddress (hAdvapi, "GetAce");
     GNEqualSid = (TEqualSid) GetProcAddress (hAdvapi, "EqualSid");
     GNAddAce = (TAddAce) GetProcAddress (hAdvapi, "AddAce");
-    GNAddAccessAllowedAce = (TAddAccessAllowedAce)
-        GetProcAddress (hAdvapi, "AddAccessAllowedAce");
-    GNSetNamedSecurityInfo = (TSetNamedSecurityInfo)
-        GetProcAddress (hAdvapi, "SetNamedSecurityInfoA");
+    GNAddAccessAllowedAce =
+        (TAddAccessAllowedAce) GetProcAddress (hAdvapi, "AddAccessAllowedAce");
+    GNSetNamedSecurityInfo =
+        (TSetNamedSecurityInfo) GetProcAddress (hAdvapi,
+                                                "SetNamedSecurityInfoA");
   }
   else
   {
@@ -215,8 +222,8 @@ GNInitWinEnv ()
   if (hNetapi)
   {
     GNNetUserAdd = (TNetUserAdd) GetProcAddress (hNetapi, "NetUserAdd");
-    GNNetUserSetInfo = (TNetUserSetInfo)
-        GetProcAddress (hNetapi, "NetUserSetInfo");
+    GNNetUserSetInfo =
+        (TNetUserSetInfo) GetProcAddress (hNetapi, "NetUserSetInfo");
   }
   else
   {