OpenSSL.xs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ** OpenSSL.xs
  3. */
  4. #include "openssl.h"
  5. SV *
  6. new_ref(type, obj, mort)
  7. char *type;
  8. char *obj;
  9. {
  10. SV *ret;
  11. if (mort)
  12. ret = sv_newmortal();
  13. else
  14. ret = newSViv(0);
  15. #ifdef DEBUG
  16. printf(">new_ref %d\n",type);
  17. #endif
  18. sv_setref_pv(ret, type, (void *)obj);
  19. return(ret);
  20. }
  21. int
  22. ex_new(obj, data, ad, idx, argl, argp)
  23. char *obj;
  24. SV *data;
  25. CRYPTO_EX_DATA *ad;
  26. int idx;
  27. long argl;
  28. char *argp;
  29. {
  30. SV *sv;
  31. #ifdef DEBUG
  32. printf("ex_new %08X %s\n",obj,argp);
  33. #endif
  34. sv = sv_newmortal();
  35. sv_setref_pv(sv, argp, (void *)obj);
  36. #ifdef DEBUG
  37. printf("%d>new_ref '%s'\n", sv, argp);
  38. #endif
  39. CRYPTO_set_ex_data(ad, idx, (char *)sv);
  40. return(1);
  41. }
  42. void
  43. ex_cleanup(obj, data, ad, idx, argl, argp)
  44. char *obj;
  45. SV *data;
  46. CRYPTO_EX_DATA *ad;
  47. int idx;
  48. long argl;
  49. char *argp;
  50. {
  51. pr_name("ex_cleanup");
  52. #ifdef DEBUG
  53. printf("ex_cleanup %08X %s\n", obj, argp);
  54. #endif
  55. if (data != NULL)
  56. SvREFCNT_dec((SV *)data);
  57. }
  58. MODULE = OpenSSL PACKAGE = OpenSSL
  59. PROTOTYPES: ENABLE
  60. BOOT:
  61. boot_bio();
  62. boot_cipher();
  63. boot_digest();
  64. boot_err();
  65. boot_ssl();
  66. /* */
  67. /* The next macro is the completely correct way to call a C */
  68. /* function that uses perl calling conventions but is not */
  69. /* registered with perl. */
  70. /* */
  71. /* The second macro seems to work for this context. (We just */
  72. /* need a mark for the called function since we don't have */
  73. /* any local variables and what-not.) */
  74. /* */
  75. /* Unfortunately, we need to do this because these boot_* */
  76. /* functions are auto-generated by xsubpp and are normally */
  77. /* called from DyncLoader, but we're pulling them in here. */
  78. /* */
  79. #define FULL_callBootFunc(func) { \
  80. dSP; \
  81. ENTER; \
  82. SAVETMPS; \
  83. PUSHMARK(SP); \
  84. func(); \
  85. FREETMPS; \
  86. LEAVE; \
  87. }
  88. #define callBootFunc(func) { \
  89. PUSHMARK(SP); \
  90. func(); \
  91. }
  92. callBootFunc(boot_OpenSSL__BN);
  93. callBootFunc(boot_OpenSSL__BIO);
  94. callBootFunc(boot_OpenSSL__Cipher);
  95. callBootFunc(boot_OpenSSL__MD);
  96. callBootFunc(boot_OpenSSL__ERR);
  97. callBootFunc(boot_OpenSSL__SSL);
  98. callBootFunc(boot_OpenSSL__X509);