Alexandre Julliard : secur32: Move the pull/push callbacks to the Unix side.

Alexandre Julliard julliard at winehq.org
Mon Dec 6 16:07:58 CST 2021


Module: wine
Branch: master
Commit: 37eab1f496b1e7540631760956a5ca97ef4d4b76
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=37eab1f496b1e7540631760956a5ca97ef4d4b76

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Dec  3 11:59:44 2021 +0100

secur32: Move the pull/push callbacks to the Unix side.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/secur32/schannel.c        | 80 ------------------------------------------
 dlls/secur32/schannel_gnutls.c | 38 ++++++++++----------
 dlls/secur32/secur32_priv.h    |  2 --
 3 files changed, 20 insertions(+), 100 deletions(-)

diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c
index 895364a3fc7..e3c5ab76088 100644
--- a/dlls/secur32/schannel.c
+++ b/dlls/secur32/schannel.c
@@ -745,84 +745,6 @@ static char * CDECL schan_get_buffer(const struct schan_transport *t, struct sch
     return (char *)buffer->pvBuffer + s->offset;
 }
 
-/* schan_pull
- *      Read data from the transport input buffer.
- *
- * t - The session transport object.
- * buff - The buffer into which to store the read data.  Must be at least
- *        *buff_len bytes in length.
- * buff_len - On input, *buff_len is the desired length to read.  On successful
- *            return, *buff_len is the number of bytes actually read.
- *
- * Returns:
- *  0 on success, in which case:
- *      *buff_len == 0 indicates end of file.
- *      *buff_len > 0 indicates that some data was read.  May be less than
- *          what was requested, in which case the caller should call again if/
- *          when they want more.
- *  -1 when no data could be read without blocking
- *  another errno-style error value on failure
- */
-static int CDECL schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
-{
-    char *b;
-    SIZE_T local_len = *buff_len;
-
-    TRACE("Pull %lu bytes\n", local_len);
-
-    *buff_len = 0;
-
-    b = schan_get_buffer(t, &t->in, &local_len);
-    if (!b)
-        return -1;
-
-    memcpy(buff, b, local_len);
-    t->in.offset += local_len;
-
-    TRACE("Read %lu bytes\n", local_len);
-
-    *buff_len = local_len;
-    return 0;
-}
-
-/* schan_push
- *      Write data to the transport output buffer.
- *
- * t - The session transport object.
- * buff - The buffer of data to write.  Must be at least *buff_len bytes in length.
- * buff_len - On input, *buff_len is the desired length to write.  On successful
- *            return, *buff_len is the number of bytes actually written.
- *
- * Returns:
- *  0 on success
- *      *buff_len will be > 0 indicating how much data was written.  May be less
- *          than what was requested, in which case the caller should call again
- *          if/when they want to write more.
- * -1 when no data could be written without blocking
- *  another errno-style error value on failure
- */
-static int CDECL schan_push(struct schan_transport *t, const void *buff, size_t *buff_len)
-{
-    char *b;
-    SIZE_T local_len = *buff_len;
-
-    TRACE("Push %lu bytes\n", local_len);
-
-    *buff_len = 0;
-
-    b = schan_get_buffer(t, &t->out, &local_len);
-    if (!b)
-        return -1;
-
-    memcpy(b, buff, local_len);
-    t->out.offset += local_len;
-
-    TRACE("Wrote %lu bytes\n", local_len);
-
-    *buff_len = local_len;
-    return 0;
-}
-
 static schan_session CDECL schan_get_session_for_transport(struct schan_transport* t)
 {
     return t->ctx->session;
@@ -1654,8 +1576,6 @@ const struct schan_callbacks schan_callbacks =
 {
     schan_get_buffer,
     schan_get_session_for_transport,
-    schan_pull,
-    schan_push,
 };
 
 void SECUR32_initSchannelSP(void)
diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index e02b1643e30..117a9da42d5 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -203,40 +203,42 @@ static ssize_t pull_adapter(gnutls_transport_ptr_t transport, void *buff, size_t
 {
     struct schan_transport *t = (struct schan_transport*)transport;
     gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
+    SIZE_T len = buff_len;
+    char *b;
 
-    int ret = callbacks->pull(transport, buff, &buff_len);
-    if (ret == -1)
+    TRACE("Push %lu bytes\n", len);
+
+    b = callbacks->get_buffer(t, &t->in, &len);
+    if (!b)
     {
         pgnutls_transport_set_errno(s, EAGAIN);
         return -1;
     }
-    if (ret < 0)
-    {
-        FIXME("unhandled error from pull callback %d\n", ret);
-        return -1;
-    }
-
-    return buff_len;
+    memcpy(buff, b, len);
+    t->in.offset += len;
+    TRACE("Wrote %lu bytes\n", len);
+    return len;
 }
 
 static ssize_t push_adapter(gnutls_transport_ptr_t transport, const void *buff, size_t buff_len)
 {
     struct schan_transport *t = (struct schan_transport*)transport;
     gnutls_session_t s = (gnutls_session_t)callbacks->get_session_for_transport(t);
+    SIZE_T len = buff_len;
+    char *b;
 
-    int ret = callbacks->push(transport, buff, &buff_len);
-    if (ret == -1)
+    TRACE("Push %lu bytes\n", len);
+
+    b = callbacks->get_buffer(t, &t->out, &len);
+    if (!b)
     {
         pgnutls_transport_set_errno(s, EAGAIN);
         return -1;
     }
-    if (ret < 0)
-    {
-        FIXME("unhandled error from push callback %d\n", ret);
-        return -1;
-    }
-
-    return buff_len;
+    memcpy(b, buff, len);
+    t->out.offset += len;
+    TRACE("Wrote %lu bytes\n", len);
+    return len;
 }
 
 static const struct {
diff --git a/dlls/secur32/secur32_priv.h b/dlls/secur32/secur32_priv.h
index 75c6cde2e42..eedb1f4bfb2 100644
--- a/dlls/secur32/secur32_priv.h
+++ b/dlls/secur32/secur32_priv.h
@@ -140,8 +140,6 @@ struct schan_callbacks
 {
     char * (CDECL *get_buffer)(const struct schan_transport *, struct schan_buffers *, SIZE_T *);
     schan_session (CDECL *get_session_for_transport)(struct schan_transport *);
-    int CDECL (CDECL *pull)(struct schan_transport *, void *, size_t *);
-    int CDECL (CDECL *push)(struct schan_transport *, const void *, size_t *);
 };
 
 extern const struct schan_funcs *schan_funcs;




More information about the wine-cvs mailing list