unp #6 (reading notes) (Name and Address Conversion)

#include <netdb.h>
extern int h_errno;
struct hostent *gethostbyname(const char *name);

#include <sys/socket.h>
struct hostent *gethostbyaddr(const void *addr, socklen_t len, int type);
void sethostent(int stayopen);
void endhostent(void);
void herror(const char *s);
const char *hsterror(int err);

/* System V/POSIX extension */
struct hostent *gethostent(void);

/* GNU extensions */
struct hostent *gethostbyname2(const char *name, int af);
int gethostent_r(struct hostent *ret, char *buf, size_t buflen,
                 struct hostent **result, int *h_errnop);
int gethostbyaddr_r(const void *addr, socklen_t len, int type,
                    struct hostent *ret, char *buf, size_t buflen,
                    struct hostent **result, int *h_errnop);
int gethostbyname_r(const char *name,
                    struct hostent *ret, char *buf, size_t buflen,
                    struct hostent **result, int *h_errnop);
int gethostbyname2_r(const char *name, int af,
                     struct hostent *ret, char *buf, size_t buflen,
                     struct hostent **result, int *h_errnop);

struct hostent {
  char  *h_name;      /* official name of host */
  char **h_aliases;   /* alias list */
  int    h_addrtype;  /* host address type */
  int    h_length;    /* length of address */
  char **h_addr_list; /* list of address */
};
#define h_addr h_addr_list[0] /* for backward compatibility */

struct servent *getservent(void);
struct servent *getservbyname(const char *name, const char *proto);
struct servent *getservbyport(int port, const char *proto);
void setservent(int stayopen);
void endservent(void);

struct servent {
  char  *s_name;    /* official service name */
  char **s_aliases; /* alias list */
  int    s_port;    /* port number */
  char  *s_proto;   /* protocol to use */
};

#include <sys/utsname.h>
int uname(struct utsname *buf);
struct utsname {
  char sysname[];   /* Operating system name (e.g., "Linux") */
  char nodename[];  /* Name within "some implementation-defined network" */
  char release[];   /* Operating system release (e.g., "2.6.28") */
  char version[];   /* Operating system version */
  char machine[];   /* Hardware indentifier */
#ifdef _GNU_SOURCE
  char domainname[];/* NIS or YP domain name */
#endif
};
posted @ 2013-07-30 20:23  srk  阅读(150)  评论(0编辑  收藏  举报