Interpreting some C code

C

Chris Saunders

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
(e-mail address removed)
 
V

Vijay Kumar R Zanvar

Chris Saunders said:
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
(e-mail address removed)

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!
 
C

Chris Saunders

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
(e-mail address removed)
 
V

Vijay Kumar R Zanvar

[..]

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! :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top