[SRVSVC] Set and retrieve service bits and rename unknown functions
[reactos.git] / base / services / srvsvc / rpcserver.c
index e47eafb..214bf0b 100644 (file)
@@ -348,10 +348,91 @@ __stdcall
 NetrServerGetInfo(
     SRVSVC_HANDLE ServerName,
     DWORD Level,
-    LPSERVER_INFO InfoStruct)
+    LPSERVER_INFO *InfoStruct)
 {
-    UNIMPLEMENTED;
-    return ERROR_CALL_NOT_IMPLEMENTED;
+    WCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+    DWORD dwComputerNameLength, dwSize;
+    PSERVER_INFO pServerInfo = NULL;
+    OSVERSIONINFOW VersionInfo;
+
+    TRACE("NetrServerGetInfo(%p %lu %p)\n",
+          ServerName, Level, InfoStruct);
+
+    dwComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;
+    GetComputerNameW(szComputerName, &dwComputerNameLength);
+    dwComputerNameLength++; /* include NULL terminator */
+
+    VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
+    GetVersionExW(&VersionInfo);
+
+    switch (Level)
+    {
+        case 100:
+            dwSize = sizeof(SERVER_INFO_100) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo100.sv100_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo100.sv100_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_100));
+            wcscpy(pServerInfo->ServerInfo100.sv100_name, szComputerName);
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        case 101:
+            dwSize = sizeof(SERVER_INFO_101) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo101.sv101_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo101.sv101_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_101));
+            wcscpy(pServerInfo->ServerInfo101.sv101_name, szComputerName);
+
+            pServerInfo->ServerInfo101.sv101_version_major = VersionInfo.dwMajorVersion;
+            pServerInfo->ServerInfo101.sv101_version_minor = VersionInfo.dwMinorVersion;
+            pServerInfo->ServerInfo101.sv101_type = dwServiceBits | SV_TYPE_NT;
+            pServerInfo->ServerInfo101.sv101_comment = NULL; /* FIXME */
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        case 102:
+            dwSize = sizeof(SERVER_INFO_102) +
+                     dwComputerNameLength * sizeof(WCHAR);
+            pServerInfo = midl_user_allocate(dwSize);
+            if (pServerInfo == NULL)
+                return ERROR_NOT_ENOUGH_MEMORY;
+
+            pServerInfo->ServerInfo102.sv102_platform_id = PLATFORM_ID_NT;
+            pServerInfo->ServerInfo102.sv102_name = (LPWSTR)((ULONG_PTR)pServerInfo + sizeof(SERVER_INFO_102));
+            wcscpy(pServerInfo->ServerInfo102.sv102_name, szComputerName);
+
+            pServerInfo->ServerInfo102.sv102_version_major = VersionInfo.dwMajorVersion;
+            pServerInfo->ServerInfo102.sv102_version_minor = VersionInfo.dwMinorVersion;
+            pServerInfo->ServerInfo102.sv102_type = dwServiceBits | SV_TYPE_NT;
+            pServerInfo->ServerInfo102.sv102_comment = NULL; /* FIXME */
+
+            pServerInfo->ServerInfo102.sv102_users = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_disc = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_hidden = SV_VISIBLE; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_announce = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_anndelta = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_licenses = 0; /* FIXME */
+            pServerInfo->ServerInfo102.sv102_userpath = NULL; /* FIXME */
+
+            *InfoStruct = pServerInfo;
+            break;
+
+        default:
+            FIXME("level %d unimplemented\n", Level);
+            return ERROR_INVALID_LEVEL;
+    }
+
+    return NERR_Success;
 }
 
 
@@ -538,8 +619,15 @@ NetrServerSetServiceBits(
     DWORD ServiceBits,
     DWORD UpdateImmediately)
 {
-    UNIMPLEMENTED;
-    return ERROR_CALL_NOT_IMPLEMENTED;
+    FIXME("NetrServerSetServiceBits(%p %s %lx %lu)\n",
+          ServerName, debugstr_w(Transport), ServiceBits, UpdateImmediately);
+
+    /* FIXME: Support Transport */
+    /* FIXME: Support UpdateImmdiately */
+
+    dwServiceBits = ServiceBits;
+
+    return NERR_Success;
 }
 
 
@@ -717,12 +805,19 @@ NetrServerTransportAddEx(
 }
 
 
-/* Function 42 */
-void
+/* Function 42 - Not used on wire */
+NET_API_STATUS
 __stdcall
-Opnum42NotUsedOnWire(void)
+NetrServerSetServiceBitsEx(
+    SRVSVC_HANDLE ServerName,
+    WCHAR *EmulatedServer,
+    WCHAR *Transport,
+    DWORD ServiceBitsOfInterest,
+    DWORD ServiceBits,
+    DWORD UpdateImmediately)
 {
     UNIMPLEMENTED;
+    return ERROR_CALL_NOT_IMPLEMENTED;
 }
 
 
@@ -782,12 +877,13 @@ NetrDfsSetLocalVolumeState(
 }
 
 
-/* Function 47 */
-void
+/* Function 47 - Not used on wire */
+NET_API_STATUS
 __stdcall
-Opnum47NotUsedOnWire(void)
+NetrDfsSetServerInfo(void)
 {
     UNIMPLEMENTED;
+    return ERROR_CALL_NOT_IMPLEMENTED;
 }