Using openssl lib to extract the content of a PKCS#7 message with v8?

I'm trying to build a NodeJS/V8 bridge for performing openssl operations.

One of them is to extract the content of a PKCS#7 envelope. What I want is the equivalent to this cmd :

openssl smime -verify -inform DER -noverify

That just outputs the plain content inside the PKCS#7 envelope.

I was looking at CMS_* operations, but it looks like CMS_verify is only supposed to return an int (see. http://www.openssl.org/docs/crypto/CMS_verify.html), I'm looking for the string/binary content if the verify succeeds.

Here is what I got so far. If the code to achieve that is trivial to any of you... That would be really awesome as the openssl docs sucks, it looks like there is not a single C code regarding CMS on the whole web... And finally, that's the first time I do any C++ of my whole life!

PS: bonus question about the DecodeWritestuff, do so know what this does??

static Handle<Value> Verify(const Arguments& args) {
    HandleScope scope;

    ASSERT_IS_BUFFER(args[0]);
    ssize_t klen = Buffer::Length(args[0].As<Object>());

    if (klen < 0) {
        return ThrowException(Exception::TypeError(String::New("Bad argument")));
    }

    // No clue of what these three lines do !
    char* kbuf = new char[klen];
    ssize_t kwritten = DecodeWrite(kbuf, klen, args[0], BINARY);
    assert(kwritten == klen);

    Handle<Object> options = args[1]->ToObject();
    options->Get(String::New("inform"))

    //@todo!
    //int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, unsigned int flags);