What is wrong with my patch?

I have fixed all errors found by Juan Lang.
I resent this patch several times, but hasn't received any answer.

Why my patch is ignored?

Maybe something is still wrong, but why somebody just tell me about it?

"Juan Lang" <[EMAIL PROTECTED]> wrote:
>Hi Vitaliy, overall your patch looks pretty good.  A few minor points:
>
>+    FIXME("(%s %d %p) partially implemented\n",
>debugstr_w(servername), level, buf);
>Because you add a more specific FIXME for every unimplemented path, it
>seems to me this would be better as a TRACE.
>
>+    result = RegCreateKeyExA(HKEY_LOCAL_MACHINE, regKey, 0, NULL, 0, 
>KEY_WRITE,
>+                NULL, &hKey, &disposition);
>+    if (result != ERROR_SUCCESS)
>+    {
>+        FIXME("Unable to open/create key 'HKLM\\%s'\n", regKey);
>+        return result;
>This shouldn't be a FIXME, as there's nothing to "fix" in the code:
>if the key couldn't be created, there's a setup problem or some other
>unrecoverable error.  A TRACE is fine.

>+    /* FIXME: A duplicate patch checking should be implemented here */
>Do you mean a duplicate path?

-- 
Best wishes,
Vitaly Perov
Russia, Saint-Petersburg. www.etersoft.ru
From 073fc32326d2b48be58487d291b0c304e6aa34f4 Mon Sep 17 00:00:00 2001
From: Vitaly Perov <[EMAIL PROTECTED]>
Date: Tue, 18 Nov 2008 16:10:10 +0300
Subject: [PATCH] netapi32: Add partial implementation of NetShareAdd

---
 dlls/netapi32/share.c |  121 ++++++++++++++++++++++++++++++++++++++++++++++++-
 include/lmshare.h     |   11 +++++
 2 files changed, 130 insertions(+), 2 deletions(-)

diff --git a/dlls/netapi32/share.c b/dlls/netapi32/share.c
index f19f732..8fecf95 100644
--- a/dlls/netapi32/share.c
+++ b/dlls/netapi32/share.c
@@ -18,6 +18,9 @@
 #include "wine/debug.h"
 #include "lm.h"
 #include "winerror.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(share);
 
@@ -106,10 +109,124 @@ NET_API_STATUS WINAPI NetShareGetInfo(LMSTR servername, LMSTR netname,
 
 /************************************************************
  * NetShareAdd  (NETAPI32.@)
+ *
+ * PARAMS
+ *   servername    [I]   Pointer to a string with the name of the server
+ *   level         [I]   Data information level
+ *   bufptr        [I]   Pointer to the buffer that specifies the data
+ *   parm_err      [O]   Index of the first member of the share information
+ *                       structure that causes the ERROR_INVALID_PARAMETER
+ *
+ * RETURNS
+ *   If successful, the function returns NERR_Success
+ *   On failure it returns:
+ *     ERROR_ACCESS_DENIED         User has no access to the requested information
+ *     ERROR_INVALID_LEVEL         Value of 'level' is not correct
+ *     ERROR_INVALID_NAME          TThe character or file system name is not correct
+ *     ERROR_INVALID_PARAMETER     Wrong parameter
+ *     NERR_DuplicateShare         The given name is already in use
+ *     NERR_RedirectedPath         The operation is not valid for a redirected resource
+ *     NERR_UnknownDevDir          The device or directory does not exist
+ *
+ * FIXME
+ *   Sharing of the given resource is unimplemented.
+ *   Now this function just create a registry entry
  */
 NET_API_STATUS WINAPI NetShareAdd(LMSTR servername,
     DWORD level, LPBYTE buf, LPDWORD parm_err)
 {
-    FIXME("Stub (%s %d %p %p)\n", debugstr_w(servername), level, buf, parm_err);
-    return ERROR_NOT_SUPPORTED;
+    static const CHAR regKey[] =
+        "SYSTEM\\CurrentControlSet\\Services\\lanmanserver\\Shares";
+    static const WCHAR formatStr[] = { 'C','S','C','F','l','a','g','s','=','%',
+        'd',' ','M','a','x','U','s','e','s','=','%','u',' ','P','a','t','h',
+        '=','%','s',' ','P','e','r','m','i','s','s','i','o','n','s','=','%',
+        'd',' ','R','e','m','a','r','k','=','%','s',' ','T','y','p','e','=',
+        '%','d',0};
+    WCHAR           paramStr[512];
+    CHAR            tmpPath[MAX_PATH];
+    SHARE_INFO_2    *shi2;
+    LPWSTR          netname = NULL;
+    DWORD           type;
+    LPWSTR          remark = NULL;
+    DWORD           permissions;
+    DWORD           max_uses;
+    DWORD           current_uses;
+    LPWSTR          path = NULL;
+    LPWSTR          passwd = NULL;
+    HKEY            hKey;
+    INT             result;
+    DWORD           disposition;
+
+    TRACE("(%s %d %p %p) partially implemented\n", debugstr_w(servername),
+        level, buf, parm_err);
+
+    *parm_err = 0;
+
+    if (servername && lstrlenW(servername))
+    {
+        FIXME("Only local sharing is supported\n");
+        return ERROR_NOT_SUPPORTED;
+    }
+
+    switch (level)
+    {
+    case 2:
+        shi2 = (SHARE_INFO_2*) buf;
+        netname = shi2->shi2_netname;
+        type = shi2->shi2_type;
+        remark = shi2->shi2_remark;
+        permissions = shi2->shi2_permissions;
+        max_uses = shi2->shi2_max_uses;
+        current_uses = shi2->shi2_current_uses;
+        path = shi2->shi2_path;
+        passwd = shi2->shi2_passwd;
+        break;
+    case 502:
+        FIXME("Information level 502 is not implemented\n");
+        return ERROR_NOT_SUPPORTED;
+    case 503:
+        FIXME("Information level 503 is not implemented\n");
+        return ERROR_NOT_SUPPORTED;
+    default:
+        return ERROR_INVALID_LEVEL;
+    }
+
+    if (passwd) FIXME("password field is not supporded yet\n");
+
+    GetCurrentDirectoryA(MAX_PATH, tmpPath);
+    result = SetCurrentDirectoryW(path);
+    SetCurrentDirectoryA(tmpPath);
+    if (!result) return ERROR_FILE_NOT_FOUND;
+
+    result = RegCreateKeyExA(HKEY_LOCAL_MACHINE, regKey, 0, NULL, 0, KEY_WRITE,
+                NULL, &hKey, &disposition);
+    if (result != ERROR_SUCCESS)
+    {
+        TRACE("Unable to open/create key 'HKLM\\%s'\n", regKey);
+        return result;
+    }
+    if (disposition == REG_CREATED_NEW_KEY)
+        TRACE("New key 'HKLM\\%s' was created\n", regKey);
+
+    result = RegQueryValueExW(hKey, netname, NULL, NULL, NULL, NULL);
+    if (result == ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return NERR_DuplicateShare;
+    }
+
+    /* FIXME: A duplicate path checking should be implemented here */
+
+    sprintfW(paramStr, formatStr, 0, (unsigned int) max_uses, path,
+        permissions, remark, type);
+    result = RegSetValueExW(hKey, netname, 0, REG_SZ,
+        (BYTE*) paramStr, (lstrlenW(paramStr) + 1) * sizeof(WCHAR));
+    if (result != ERROR_SUCCESS)
+    {
+        RegCloseKey(hKey);
+        return result;
+    }
+
+    RegCloseKey(hKey);
+    return NERR_Success;
 }
diff --git a/include/lmshare.h b/include/lmshare.h
index def3f13..75537d8 100644
--- a/include/lmshare.h
+++ b/include/lmshare.h
@@ -34,6 +34,17 @@ typedef struct _SHARE_INFO_1 {
     LMSTR shi1_remark;
 } SHARE_INFO_1, *PSHARE_INFO_1, *LPSHARE_INFO_1;
 
+typedef struct _SHARE_INFO_2 {
+    LMSTR shi2_netname;
+    DWORD shi2_type;
+    LMSTR shi2_remark;
+    DWORD shi2_permissions;
+    DWORD shi2_max_uses;
+    DWORD shi2_current_uses;
+    LMSTR shi2_path;
+    LMSTR shi2_passwd;
+} SHARE_INFO_2, *PSHARE_INFO_2, *LPSHARE_INFO_2;
+
 NET_API_STATUS WINAPI NetShareAdd(LMSTR,DWORD,LPBYTE,LPDWORD);
 NET_API_STATUS WINAPI NetShareCheck(LMSTR,LMSTR,LPDWORD);
 NET_API_STATUS WINAPI NetShareDel(LMSTR,LMSTR,DWORD);
-- 
1.6.0.2.GIT



Reply via email to