X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fio%2Fbios.h;h=3bbb66b02b660f245bf959a6bbd3f946c2c9b3f9;hb=23987db96db7962a6ee58d1aeda2bd87780ca579;hp=e1f26b481623cf2fdb011040ba48c9ae047ecfdd;hpb=f69f31caeda734d6d9c8ab00e693671ac7512bea;p=cassiopeia.git diff --git a/src/io/bios.h b/src/io/bios.h index e1f26b4..3bbb66b 100644 --- a/src/io/bios.h +++ b/src/io/bios.h @@ -2,6 +2,27 @@ #include +struct bio_st { + const BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + long (*callback) (struct bio_st *, int, const char *, int, long, long); + char *cb_arg; /* first argument for the callback */ + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + int references; + uint64_t num_read; + uint64_t num_write; + CRYPTO_EX_DATA ex_data; + CRYPTO_RWLOCK *lock; +}; + + #define BIO_TYPE_CUSTOM 0xff class OpensslBIO { @@ -47,18 +68,14 @@ BIO_METHOD* toBio() { template BIO_METHOD* toBio( int ( *newfunc )( BIO* ) ) { - static BIO_METHOD new_method = { - T::typeID, - T::getName(), - BIOWrapper::write, - BIOWrapper::read, - BIOWrapper::puts, - BIOWrapper::gets, - BIOWrapper::ctrl, - newfunc, - BIOWrapper::free, - NULL, - }; - - return &new_method; + BIO_METHOD *meth = BIO_meth_new( T::typeID, T::getName() ); + BIO_meth_set_write( meth, BIOWrapper::write ); + BIO_meth_set_read( meth, BIOWrapper::read ); + BIO_meth_set_puts( meth, BIOWrapper::puts ); + BIO_meth_set_gets( meth, BIOWrapper::gets ); + BIO_meth_set_ctrl( meth, BIOWrapper::ctrl ); + BIO_meth_set_destroy( meth, BIOWrapper::free ); + BIO_meth_set_create( meth, newfunc ); + + return meth; }