]> granicus.if.org Git - ejabberd/commitdiff
Support Erlang/OTP R15B driver (EJAB-1521)
authorBadlop <badlop@process-one.net>
Wed, 21 Dec 2011 11:13:44 +0000 (12:13 +0100)
committerBadlop <badlop@process-one.net>
Wed, 21 Dec 2011 11:13:44 +0000 (12:13 +0100)
src/tls/sha_drv.c
src/tls/tls_drv.c

index 22426703fd667698bb090d43f3a23cc38451c45e..fc8fb9a498f1adb1d0ee9bcf03da380af5035a83 100644 (file)
 #include <openssl/md2.h>
 #endif
 
+/*
+ * R15B changed several driver callbacks to use ErlDrvSizeT and
+ * ErlDrvSSizeT typedefs instead of int.
+ * This provides missing typedefs on older OTP versions.
+ */
+#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
+typedef int ErlDrvSizeT;
+typedef int ErlDrvSSizeT;
+#endif
+
 static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf)
 {
   set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY);
   return NULL;
 }
 
-static int sha_drv_control(ErlDrvData handle,
+static ErlDrvSSizeT sha_drv_control(ErlDrvData handle,
                           unsigned int command,
-                          char *buf, int len,
-                          char **rbuf, int rlen)
+                          char *buf, ErlDrvSizeT len,
+                          char **rbuf, ErlDrvSizeT rlen)
 {
   ErlDrvBinary *b = NULL;
 
@@ -89,7 +99,19 @@ ErlDrvEntry sha_driver_entry = {
   NULL,                        /* handle */
   sha_drv_control,     /* F_PTR control, port_command callback */
   NULL,                        /* F_PTR timeout, reserved */
-  NULL                 /* F_PTR outputv, reserved */
+  NULL,                        /* F_PTR outputv, reserved */
+  /* Added in Erlang/OTP R15B: */
+  NULL,                 /* ready_async */
+  NULL,                 /* flush */
+  NULL,                 /* call */
+  NULL,                 /* event */
+  ERL_DRV_EXTENDED_MARKER,        /* extended_marker */
+  ERL_DRV_EXTENDED_MAJOR_VERSION, /* major_version */
+  ERL_DRV_EXTENDED_MINOR_VERSION, /* minor_version */
+  0,                    /* driver_flags */
+  NULL,                 /* handle2 */
+  NULL,                 /* process_exit */
+  NULL                  /* stop_select */
 };
 
 DRIVER_INIT(sha_drv) /* must match name in driver_entry */
index bdb5446f2235acde953d022cbe70f84d2a252c14..c4210055a81670977638c5452ed1cc93532369a6 100644 (file)
@@ -44,6 +44,16 @@ typedef unsigned __int32 uint32_t;
 #define SSL_OP_NO_TICKET 0
 #endif
 
+/*
+ * R15B changed several driver callbacks to use ErlDrvSizeT and
+ * ErlDrvSSizeT typedefs instead of int.
+ * This provides missing typedefs on older OTP versions.
+ */
+#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
+typedef int ErlDrvSizeT;
+typedef int ErlDrvSSizeT;
+#endif
+
 /*
  * str_hash is based on the public domain code from
  * http://www.burtleburtle.net/bob/hash/doobs.html
@@ -305,10 +315,10 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
         }
 
 
-static int tls_drv_control(ErlDrvData handle,
+static ErlDrvSSizeT tls_drv_control(ErlDrvData handle,
                           unsigned int command,
-                          char *buf, int len,
-                          char **rbuf, int rlen)
+                          char *buf, ErlDrvSizeT len,
+                          char **rbuf, ErlDrvSizeT rlen)
 {
    tls_data *d = (tls_data *)handle;
    int res;
@@ -503,7 +513,19 @@ ErlDrvEntry tls_driver_entry = {
    NULL,                       /* handle */
    tls_drv_control,            /* F_PTR control, port_command callback */
    NULL,                       /* F_PTR timeout, reserved */
-   NULL                                /* F_PTR outputv, reserved */
+   NULL,                       /* F_PTR outputv, reserved */
+  /* Added in Erlang/OTP R15B: */
+  NULL,                 /* ready_async */
+  NULL,                 /* flush */
+  NULL,                 /* call */
+  NULL,                 /* event */
+  ERL_DRV_EXTENDED_MARKER,        /* extended_marker */
+  ERL_DRV_EXTENDED_MAJOR_VERSION, /* major_version */
+  ERL_DRV_EXTENDED_MINOR_VERSION, /* minor_version */
+  0,                    /* driver_flags */
+  NULL,                 /* handle2 */
+  NULL,                 /* process_exit */
+  NULL                  /* stop_select */
 };
 
 DRIVER_INIT(tls_drv) /* must match name in driver_entry */