Obtaining structure definitions using man pages
For any given header:
echo '#include <netinet/in.h>' | gcc -E - | less
Which generates of relevant interest:
# 225 "/usr/include/netinet/in.h" 3 4struct sockaddr_in { sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; unsigned char sin_zero[sizeof (struct sockaddr) - (sizeof (unsigned short int)) - sizeof (in_port_t) - sizeof (struct in_addr)]; };
This can be done using any compiler with a preprocessor option (every C compiler I know of can do this).
It depends on the function. For example, you can get the definition of struct sockaddr
by looking at the man page of bind(2)
.
Unfortunately, there's no man page specifically for struct sockaddr
.
Other ways to get this information would be to search for it the appropriate header files.
man-pages is just a files written by human or generated by wish of human. Usually all related structures is mentioned in man-pages with functions they used with. Sometimes you can find pages for header-files ( time.h(0p) ). Sometimes there is pages for a whole libraries ( libsensors(3) ). Sometimes there is actual pages for structures ( XAnyEvent(3) ).
You may want to check apropos
and whatis
. Sometimes they able to find pages related with what you are looking for.