#if 0
/* reads the next line from the file /etc/protocols and returns a
 * structure protoent containing the broken out fields from the 
 * line. 
 *      struct protoent {
 *          char    *p_name;        /* official protocol name */
 *          char    **p_aliases;    /* alias list */
 *          int     p_proto;        /* protocol number */
 *      }
 */
struct protoent *getprotoent(void);

/* returns a protoent structure for the line from /etc/protocols
 * that matches the protocol name name. eg.
 *      struct protoent *pp = getprotobyname ("tcp");
 */
struct protoent *getprotobyname(const char *name);

/* returns a protoent structure for the line that matches the protocol
 * number. eg.
 *      struct protoent *pp = getprotobynumber (6);
 */
struct protoent *getprotobynumber(int proto);

/ * opens and rewinds the /etc/protocols file. If stayopen is true, then
  * the file  will not be closed between calls to getprotobyname() or 
  * getprotobynumber(). 
  */
void setprotoent(int stayopen);

/* closes /etc/protocols. */
void endprotoent(void)

#endif

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>

int main (int argc,char **argv)
{
    struct protoent *pp;
    int i;

    while (pp = getprotoent()) {
        printf("%s:\n\tProtocol: %d\n\tAliases: ", pp->p_name, pp->p_proto);
        for (i = 0; pp->p_aliases[i] != NULL; ++i )
            printf("%s ",pp->p_aliases[i]);
        printf ("\n");
    }

    return 0;
}
