commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r770588 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
Date Fri, 01 May 2009 08:57:10 GMT
Author: mturk
Date: Fri May  1 08:57:10 2009
New Revision: 770588

URL: http://svn.apache.org/viewvc?rev=770588&view=rev
Log:
Add internal token info function

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=770588&r1=770587&r2=770588&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Fri May  1 08:57:10 2009
@@ -145,6 +145,36 @@
     return sidtype;
 }
 
+LPVOID ACR_GetTokenInformation(JNIEnv *_E, HANDLE h,
+                               TOKEN_INFORMATION_CLASS ic)
+{
+    LPVOID rv;    
+    DWORD  sz = 0;
+    DWORD  rc;
+    
+    GetTokenInformation(h, ic, NULL, sz, &sz);
+    if ((rc = GetLastError()) != ERROR_INSUFFICIENT_BUFFER) {
+        if(_E) {
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
+                               ACR_FROM_OS_ERROR(rc));
+        }
+        return NULL;    
+    }
+    if (!(rv = ACR_Malloc(_E, THROW_FMARK, sz))) {
+        return NULL;
+    }
+    if (!GetTokenInformation(h, ic, rv, sz, &sz)) {
+        rc = GetLastError();    
+        if(_E) {
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
+                               ACR_FROM_OS_ERROR(rc));
+        }
+        free(rv);
+        rv = NULL;        
+    }
+    return rv;    
+}
+
 static void GetUserHomePath(LPWSTR buf, DWORD blen, PSID sid)
 {
     LPWSTR ssid = NULL;



Mime
View raw message