Perl code patch contributed by "Kurt J. Pires" <kjpires@iat.com>
[openssl.git] / perl / openssl_ssl.xs
index 7022c46..146c1ac 100644 (file)
@@ -60,6 +60,7 @@ int boot_ssl()
 
 MODULE =  OpenSSL::SSL PACKAGE = OpenSSL::SSL::CTX PREFIX = p5_SSL_CTX_
 
+PROTOTYPES: ENABLE
 VERSIONCHECK: DISABLE
 
 void
@@ -71,11 +72,11 @@ p5_SSL_CTX_new(...)
        PPCODE:
                pr_name("p5_SSL_CTX_new");
                if ((items == 1) && SvPOK(ST(0)))
-                       method=SvPV(ST(0),na);
+                       method=SvPV_nolen(ST(0));
                else if ((items == 2) && SvPOK(ST(1)))
-                       method=SvPV(ST(1),na);
+                       method=SvPV_nolen(ST(1));
                else
-                       croak("Usage: OpenSSL::SSL_CTX::new(type)");
+                       croak("Usage: OpenSSL::SSL::CTX::new(type)");
                        
                if (strcmp(method,"SSLv3") == 0)
                        meth=SSLv3_method();
@@ -95,9 +96,15 @@ p5_SSL_CTX_new(...)
                        meth=SSLv2_client_method();
                else if (strcmp(method,"SSLv2_server") == 0)
                        meth=SSLv2_server_method();
+               else if (strcmp(method,"TLSv1") == 0)
+                       meth=TLSv1_method();
+               else if (strcmp(method,"TLSv1_client") == 0)
+                       meth=TLSv1_client_method();
+               else if (strcmp(method,"TLSv1_server") == 0)
+                       meth=TLSv1_server_method();
                else
                        {
-                       croak("Not passed a valid SSL method name, should be 'SSLv[23] [client|server]'");
+                       croak("Not a valid SSL method name, should be 'SSLv[23] [client|server]'");
                        }
                EXTEND(sp,1);
                PUSHs(sv_newmortal());
@@ -117,7 +124,7 @@ p5_SSL_CTX_use_PrivateKey_file(ctx,file,...)
                        croak("OpenSSL::SSL::CTX::use_PrivateKey_file(ssl_ctx,file[,type])");
                if (items == 3)
                        {
-                       ptr=SvPV(ST(2),na);
+                       ptr=SvPV_nolen(ST(2));
                        if (strcmp(ptr,"der") == 0)
                                i=SSL_FILETYPE_ASN1;
                        else
@@ -141,7 +148,7 @@ p5_SSL_CTX_set_options(ctx,...)
                        {
                        if (!SvPOK(ST(i)))
                                croak("Usage: OpenSSL::SSL_CTX::set_options(ssl_ctx[,option,value]+)");
-                       ptr=SvPV(ST(i),na);
+                       ptr=SvPV_nolen(ST(i));
                        if (strcmp(ptr,"-info_callback") == 0)
                                {
                                SSL_CTX_set_info_callback(ctx,
@@ -176,7 +183,6 @@ p5_SSL_new(...)
                SV *sv_ctx;
                SSL_CTX *ctx;
                SSL *ssl;
-               int i;
                SV *arg;
        PPCODE:
                pr_name("p5_SSL_new");
@@ -198,8 +204,8 @@ p5_SSL_new(...)
 
                /* Now this is being a little hairy, we keep a pointer to
                 * our perl reference.  We need to do a different one
-                * to the one we return because it will have it's reference
-                * count droped to 0 apon return and if we up its reference
+                * to the one we return because it will have its reference
+                * count dropped to 0 upon return and if we up its reference
                 * count, it will never be DESTROYED */
                arg=newSVsv(ST(0));
                SSL_set_ex_data(ssl,p5_ssl_ex_ssl_ptr,(char *)arg);
@@ -319,7 +325,7 @@ p5_SSL_set_options(ssl,...)
                        {
                        if (!SvPOK(ST(i)))
                                croak("Usage: OpenSSL::SSL::set_options(ssl[,option,value]+)");
-                       ptr=SvPV(ST(i),na);
+                       ptr=SvPV_nolen(ST(i));
                        if (strcmp(ptr,"-info_callback") == 0)
                                {
                                SSL_set_info_callback(ssl,
@@ -363,7 +369,9 @@ p5_SSL_DESTROY(ssl)
        SSL *ssl;
        CODE:
        pr_name_dd("p5_SSL_DESTROY",ssl->references,ssl->ctx->references);
+#ifdef DEBUG
        fprintf(stderr,"SSL_DESTROY %d\n",ssl->references);
+#endif
        SSL_free(ssl);
 
 int
@@ -469,7 +477,7 @@ p5_BIO_get_ssl(bio)
                        ret=sv_mortalcopy(ret);
                        }
                else
-                       ret= &sv_undef;
+                       ret= &PL_sv_undef;
                EXTEND(sp,1);
                PUSHs(ret);