RPC merge (PL0)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




OK, here's a first chunk of Jürgen Schmied's RPC patches.

This is roughly equivalent to the stuff I posted recently, just
not my code anymore (which is a good thing 'cause my code
had some bugs).  Some very minor changes may exist between this
and the original patch but it's intended to be basically
the same stuff.

LICENSE: 
"OK to put it into Wine"

CHANGELOG:
* dlls/rpcrt4/rpcrt4.spec, dlls/rpcrt4/rpcrt4_main.c:
  Greg Turner <gmturner007@ameritech.net>
  Jürgen Schmied
  Ove Kaaven
- merge in a small subset of the goodies from 
  http://www.winehq.com/hypermail/wine-patches/2002/06/0103.html

just a thought:
are statics guaranteed to be zero'ed out, as this code
seems to assume?  works for me, but will it /always/ work
for everybody?  Should I add one of the dreaded "ZeroMemory"
calls to LibInit "just to be safe"?  For now, fearing the
wrath of Dimitrie, I haven't done so ;)

-- 
gmt

"If ye love wealth better than liberty, the tranquility
of servitude better than the animating contest of freedom,
go home from us in peace. We ask not your counsels or your
arms. Crouch down and lick the hands, which feed you. May
your chains set lightly upon you, and may posterity forget
that ye were our countrymen." 

-Samuel Adams

Index: dlls/rpcrt4/rpcrt4.spec
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4.spec,v
retrieving revision 1.18
diff -u -r1.18 rpcrt4.spec
--- dlls/rpcrt4/rpcrt4.spec	21 Jun 2002 19:15:49 -0000	1.18
+++ dlls/rpcrt4/rpcrt4.spec	3 Oct 2002 02:26:52 -0000
@@ -174,12 +174,12 @@
 @ stub UuidCompare
 @ stdcall UuidCreate(ptr) UuidCreate
 @ stdcall UuidCreateSequential(ptr) UuidCreateSequential # win 2000
-@ stub UuidCreateNil
-@ stub UuidEqual
-@ stdcall UuidFromStringA(ptr ptr) UuidFromStringA
-@ stdcall UuidFromStringW(ptr ptr) UuidFromStringW
+@ stdcall UuidCreateNil(ptr) UuidCreateNil
+@ stdcall UuidEqual(ptr ptr ptr) UuidEqual
+@ stdcall UuidFromStringA(str ptr) UuidFromStringA
+@ stdcall UuidFromStringW(wstr ptr) UuidFromStringW
 @ stdcall UuidHash(ptr ptr) UuidHash
-@ stub UuidIsNil
+@ stdcall UuidIsNil(ptr ptr) UuidIsNil
 @ stdcall UuidToStringA(ptr ptr) UuidToStringA
 @ stub UuidToStringW
 
Index: dlls/rpcrt4/rpcrt4_main.c
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4_main.c,v
retrieving revision 1.27
diff -u -r1.27 rpcrt4_main.c
--- dlls/rpcrt4/rpcrt4_main.c	17 Aug 2002 00:43:17 -0000	1.27
+++ dlls/rpcrt4/rpcrt4_main.c	3 Oct 2002 02:26:52 -0000
@@ -35,6 +35,7 @@
 #include "wine/windef16.h"
 #include "winerror.h"
 #include "winbase.h"
+#include "wine/unicode.h"
 #include "rpc.h"
 
 #include "ole2.h"
@@ -64,6 +65,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 
+static UUID uuid_nil;
+
 /***********************************************************************
  * RPCRT4_LibMain
  *
@@ -92,6 +95,60 @@
 }
 
 /*************************************************************************
+ * UuidEqual [RPCRT4.@]
+ *
+ * PARAMS
+ *     UUID *Uuid1        [I] Uuid to compare
+ *     UUID *Uuid2        [I] Uuid to compare
+ *     RPC_STATUS *Status [O] returns RPC_S_OK
+ *
+ * RETURNS
+ *     TRUE/FALSE
+ */
+int WINAPI UuidEqual(UUID *uuid1, UUID *uuid2, RPC_STATUS *Status)
+{
+  TRACE("(%s,%s)\n", debugstr_guid(uuid1), debugstr_guid(uuid2));
+  *Status = RPC_S_OK;
+  if (!uuid1) uuid1 = &uuid_nil;
+  if (!uuid2) uuid2 = &uuid_nil;
+  if (uuid1 == uuid2) return TRUE;
+  return !memcmp(uuid1, uuid2, sizeof(UUID));
+}
+
+/*************************************************************************
+ * UuidIsNil [RPCRT4.@]
+ *
+ * PARAMS
+ *     UUID *Uuid         [I] Uuid to compare
+ *     RPC_STATUS *Status [O] retuns RPC_S_OK
+ *
+ * RETURNS
+ *     TRUE/FALSE
+ */
+int WINAPI UuidIsNil(UUID *uuid, RPC_STATUS *Status)
+{
+  TRACE("(%s)\n", debugstr_guid(uuid));
+  *Status = RPC_S_OK;
+  if (!uuid) return TRUE;
+  return !memcmp(uuid, &uuid_nil, sizeof(UUID));
+}
+
+ /*************************************************************************
+ * UuidCreateNil [RPCRT4.@]
+ *
+ * PARAMS
+ *     UUID *Uuid [O] returns a nil UUID
+ *
+ * RETURNS
+ *     RPC_S_OK
+ */
+RPC_STATUS WINAPI UuidCreateNil(UUID *Uuid)
+{
+  *Uuid = uuid_nil;
+  return RPC_S_OK;
+}
+
+/*************************************************************************
  *           UuidCreate   [RPCRT4.@]
  *
  * Creates a 128bit UUID.
@@ -109,11 +166,11 @@
    static unsigned char a[6];
    static int                      adjustment = 0;
    static struct timeval           last = {0, 0};
-   static UINT16                   clock_seq;
+   static WORD                     clock_seq;
    struct timeval                  tv;
    unsigned long long              clock_reg;
-   UINT clock_high, clock_low;
-   UINT16 temp_clock_seq, temp_clock_mid, temp_clock_hi_and_version;
+   DWORD clock_high, clock_low;
+   WORD temp_clock_seq, temp_clock_mid, temp_clock_hi_and_version;
 #ifdef HAVE_NET_IF_H
    int             sd;
    struct ifreq    ifr, *ifrp;
@@ -252,7 +309,7 @@
    clock_high = clock_reg >> 32;
    clock_low = clock_reg;
    temp_clock_seq = clock_seq | 0x8000;
-   temp_clock_mid = (UINT16)clock_high;
+   temp_clock_mid = (WORD)clock_high;
    temp_clock_hi_and_version = (clock_high >> 16) | 0x1000;
 
    /* pack the information into the GUID structure */
@@ -362,22 +419,150 @@
   return RPC_S_OK;
 }
 
+
+/***********************************************************************
+ * Inlines for hex "parsing"
+ */
+static inline int hex_d(WCHAR v)
+{
+  switch (v) {
+  case '0': case '1': case '2': case '3': case '4':
+  case '5': case '6': case '7': case '8': case '9':
+    return v - '0';
+  case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    return v - 'a' + 10;
+  case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    return v - 'A' + 10;
+  default:
+    return -1;
+  }
+}
+
+static inline unsigned char hex1A(LPSTR s)
+{
+  unsigned char v1 = hex_d(s[0]), v2 = hex_d(s[1]);
+  return (v1 << 4) | v2;
+}
+ 
+static inline unsigned char hex1W(LPWSTR s)
+{
+  unsigned char v1 = hex_d(s[0]), v2 = hex_d(s[1]);
+  return (v1 << 4) | v2;
+}
+ 
+static inline unsigned short hex2A(LPSTR s)
+{
+  unsigned char v1 = hex1A(s+0), v2 = hex1A(s+2);
+  return (unsigned short)(v1 << 8) | v2;
+}
+ 
+static inline unsigned short hex2W(LPWSTR s)
+{
+  unsigned char v1 = hex1W(s+0), v2 = hex1W(s+2);
+  return (unsigned short)(v1 << 8) | v2;
+}
+ 
+static inline unsigned long hex4A(LPSTR s)
+{
+  unsigned short v1 = hex2A(s+0), v2 = hex2A(s+4);
+  return (unsigned long)(v1 << 16) | v2;
+}
+ 
+static inline unsigned long hex4W(LPWSTR s)
+{
+  unsigned short v1 = hex2W(s+0), v2 = hex2W(s+4);
+  return (unsigned long)(v1 << 16) | v2;
+}
+
 /***********************************************************************
  *		UuidFromStringA (RPCRT4.@)
+ *
+ * Coverts a string to a UUID
+ *
+ * RETURNS
+ *
+ *   S_OK if successful.
+ *   RPC_S_INVALID_STRING_UUID if unsuccessful.
  */
-RPC_STATUS WINAPI UuidFromStringA(LPSTR str, UUID *uuid)
+RPC_STATUS WINAPI UuidFromStringA(LPSTR StringUuid, UUID *Uuid)
 {
-    FIXME("%s %p\n",debugstr_a(str),uuid);
+  unsigned i;
+
+  TRACE("%s\n", StringUuid);
+
+  if(!StringUuid)
+    return UuidCreateNil(Uuid);
+
+  if (strlen(StringUuid) != 36)
     return RPC_S_INVALID_STRING_UUID;
+
+  if (StringUuid[8]!='-' || StringUuid[13]!='-' || StringUuid[18]!='-' || StringUuid[23]!='-')
+    return RPC_S_INVALID_STRING_UUID;
+
+  for (i=0; i<36; i++) {
+    if (i==8 || i == 13 || i == 18 || i == 23) continue;
+    if (hex_d(StringUuid[i]) == -1)
+      return RPC_S_INVALID_STRING_UUID;
+  }
+
+  Uuid->Data1 = hex4A(StringUuid);
+  Uuid->Data2 = hex2A(StringUuid+9);
+  Uuid->Data3 = hex2A(StringUuid+14);
+  Uuid->Data4[0] = hex1A(StringUuid+19);
+  Uuid->Data4[1] = hex1A(StringUuid+21);
+  Uuid->Data4[2] = hex1A(StringUuid+24);
+  Uuid->Data4[3] = hex1A(StringUuid+26);
+  Uuid->Data4[4] = hex1A(StringUuid+28);
+  Uuid->Data4[5] = hex1A(StringUuid+30);
+  Uuid->Data4[6] = hex1A(StringUuid+32);
+  Uuid->Data4[7] = hex1A(StringUuid+34);
+  return RPC_S_OK;
 }
 
 /***********************************************************************
  *		UuidFromStringW (RPCRT4.@)
+ *
+ * Coverts a wide string to a UUID
+ *
+ * RETURNS
+ *
+ *   S_OK if successful.
+ *   RPC_S_INVALID_STRING_UUID if unsuccessful.
  */
-RPC_STATUS WINAPI UuidFromStringW(LPWSTR str, UUID *uuid)
+RPC_STATUS WINAPI UuidFromStringW(LPWSTR StringUuid, UUID *Uuid)
 {
-    FIXME("%s %p\n",debugstr_w(str),uuid);
+  unsigned i;
+
+  TRACE("%s\n", debugstr_w(StringUuid));
+ 
+  if(!StringUuid)
+    return UuidCreateNil(Uuid);
+ 
+  if (strlenW(StringUuid) != 36)
+    return RPC_S_INVALID_STRING_UUID;
+ 
+  if (StringUuid[8]!='-' || StringUuid[13]!='-' || StringUuid[18]!='-' || StringUuid[23]!='-')
     return RPC_S_INVALID_STRING_UUID;
+
+  for (i=0; i<36; i++) {
+    if (i==8 || i == 13 || i == 18 || i == 23) continue;
+    if (hex_d(StringUuid[i]) == -1)
+      return RPC_S_INVALID_STRING_UUID;
+  }
+ 
+  Uuid->Data1 = hex4W(StringUuid);
+  Uuid->Data2 = hex2W(StringUuid+9);
+  Uuid->Data3 = hex2W(StringUuid+14);
+  Uuid->Data4[0] = hex1W(StringUuid+19);
+  Uuid->Data4[1] = hex1W(StringUuid+21);
+  Uuid->Data4[2] = hex1W(StringUuid+24);
+  Uuid->Data4[3] = hex1W(StringUuid+26);
+  Uuid->Data4[4] = hex1W(StringUuid+28);
+  Uuid->Data4[5] = hex1W(StringUuid+30);
+  Uuid->Data4[6] = hex1W(StringUuid+32);
+  Uuid->Data4[7] = hex1W(StringUuid+34);
+ 
+  return RPC_S_OK;
 }
 
 /***********************************************************************

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux