Interpreting some C code

Discussion in 'C Programming' started by Chris Saunders, Feb 6, 2004.

  1. I am attempting to write and interface from another language to
    some C code. I am having some difficulty interpreting a declaration.

    int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *);

    Any help would be appreciated.

    Regards
    Chris Saunders
    Chris Saunders, Feb 6, 2004
    #1
    1. Advertising

  2. "Chris Saunders" <> wrote

    > I am attempting to write and interface from another language to
    > some C code. I am having some difficulty interpreting a declaration.
    >
    > int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *);
    >
    > Any help would be appreciated.
    >
    > Regards
    > Chris Saunders
    >
    >


    Read the statement as follows:

    1. Find out the name of the identifier. It is:

    SSL_CTX_get_verify_callback

    2. See on it's right side. It has (SSL_CTX *ctx) on it's
    right. An identifier followed by a left parantheses,
    some declarations -- zero or more; and a right parantheses
    is a declaration of a function. So,

    " ... SSL_CTX_get_verify_callback is a function taking as
    argument a pointer to SSL_CTX ..."

    3. Now, look at it's left side. It has an asterisk on it's left;
    a probable sign of either poiter to a function or a function
    returning a poiter to _something_. But, before check that
    the asterisk, stuffs of steps 1 and 2 are enclosed within
    a parantheses? Yes, they are. So,

    ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )

    " ... SSL_CTX_get_verify_callback is a pointer to a function
    which takes pointer to an object of type SSL_CTX ... "

    4. Now, see on the right side of

    ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )

    We have again an argument list of a function! Repeat the steps
    2 and 3 to find that:

    "SSL_CTX_get_verify_callback is a pointer to a function which
    takes a pointer to an object of type SSL_CTX as an argument;
    and, it returns a pointer to function which takes an int, and
    a pointer to an object of type X509_STORE_CTX and returns an
    int."

    Oh! What a pretty thing it is!

    --
    Vijay Kumar R Zanvar
    Vijay Kumar R Zanvar, Feb 6, 2004
    #2
    1. Advertising

  3. My thanks to Vijay.

    I used to program in C a lot, and probably once could once have
    interpreted this fairly easily.

    I'd forgotten what a pretty thing it is!!!

    Regards
    Chris Saunders


    "Vijay Kumar R Zanvar" <> wrote in message
    news:bvvd4s$115ijv$-berlin.de...
    >
    > "Chris Saunders" <> wrote
    >
    > > I am attempting to write and interface from another language to
    > > some C code. I am having some difficulty interpreting a declaration.
    > >
    > > int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *);
    > >
    > > Any help would be appreciated.
    > >
    > > Regards
    > > Chris Saunders
    > >
    > >

    >
    > Read the statement as follows:
    >
    > 1. Find out the name of the identifier. It is:
    >
    > SSL_CTX_get_verify_callback
    >
    > 2. See on it's right side. It has (SSL_CTX *ctx) on it's
    > right. An identifier followed by a left parantheses,
    > some declarations -- zero or more; and a right parantheses
    > is a declaration of a function. So,
    >
    > " ... SSL_CTX_get_verify_callback is a function taking as
    > argument a pointer to SSL_CTX ..."
    >
    > 3. Now, look at it's left side. It has an asterisk on it's left;
    > a probable sign of either poiter to a function or a function
    > returning a poiter to _something_. But, before check that
    > the asterisk, stuffs of steps 1 and 2 are enclosed within
    > a parantheses? Yes, they are. So,
    >
    > ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )
    >
    > " ... SSL_CTX_get_verify_callback is a pointer to a function
    > which takes pointer to an object of type SSL_CTX ... "
    >
    > 4. Now, see on the right side of
    >
    > ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )
    >
    > We have again an argument list of a function! Repeat the steps
    > 2 and 3 to find that:
    >
    > "SSL_CTX_get_verify_callback is a pointer to a function which
    > takes a pointer to an object of type SSL_CTX as an argument;
    > and, it returns a pointer to function which takes an int, and
    > a pointer to an object of type X509_STORE_CTX and returns an
    > int."
    >
    > Oh! What a pretty thing it is!
    >
    > --
    > Vijay Kumar R Zanvar
    >
    >
    Chris Saunders, Feb 6, 2004
    #3
  4. [..]

    I have made little mistakes. I am correcting them.

    > 3. Now, look at it's left side. It has an asterisk on it's left;
    > a probable sign of either poiter to a function or a function
    > returning a poiter to _something_. But, before check that
    > the asterisk, stuffs of steps 1 and 2 are enclosed within
    > a parantheses? Yes, they are. So,
    >
    > ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )
    >
    > " ... SSL_CTX_get_verify_callback is a pointer to a function
    > which takes pointer to an object of type SSL_CTX ... "


    " ... SSL_CTX_get_verify_callback is a function
    which takes pointer to an object of type SSL_CTX ...
    and returns a pointer to ... "
    >
    > 4. Now, see on the right side of
    >
    > ( *SSL_CTX_get_verify_callback ( SSL_CTX *ctx ) )
    >
    > We have again an argument list of a function! Repeat the steps
    > 2 and 3 to find that:
    >
    > "SSL_CTX_get_verify_callback is a pointer to a function which
    > takes a pointer to an object of type SSL_CTX as an argument;
    > and, it returns a pointer to function which takes an int, and
    > a pointer to an object of type X509_STORE_CTX and returns an
    > int."
    >


    "SSL_CTX_get_verify_callback is function which takes a pointer
    to an object of type SSL_CTX as an argument; and, it returns a
    pointer to function which takes an int, and a pointer to an object
    of type X509_STORE_CTX and returns an int."


    > Oh! What a pretty thing it is!
    >


    Now, it's more prettier! :)

    --
    Vijay Kumar R Zanvar
    Vijay Kumar R Zanvar, Feb 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Meade

    Interpreting the error message?

    Rob Meade, Jan 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    385
    Rob Meade
    Jan 28, 2004
  2. yzzzzz

    Interpreting JSP code

    yzzzzz, Apr 19, 2005, in forum: Java
    Replies:
    4
    Views:
    538
    Tom Arne Orthe
    Apr 21, 2005
  3. Alec S.
    Replies:
    5
    Views:
    667
    Alec S.
    Sep 11, 2004
  4. Chris Saunders

    Interpreting some code

    Chris Saunders, Jul 23, 2003, in forum: C Programming
    Replies:
    5
    Views:
    351
    Dan Pop
    Jul 24, 2003
  5. zolli

    Interpreting mem_map init code

    zolli, Mar 27, 2005, in forum: C Programming
    Replies:
    4
    Views:
    429
    CBFalconer
    Mar 28, 2005
Loading...

Share This Page