mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 05:59:10 +00:00
Add getservbyname and getservbyport (#204)
For every call of getservbyname/getservbyport the lookup of /etc/services is done by opening the file and parsing each line one-by-one. This is slow, but the implementation is simple. This change also adds fixes for the gethostbyname function.
This commit is contained in:
parent
cfbd2afc19
commit
0ea2907730
8 changed files with 412 additions and 25 deletions
|
@ -16,12 +16,25 @@ struct hostent {
|
|||
};
|
||||
#define h_addr h_addr_list[0]
|
||||
|
||||
struct servent {
|
||||
char *s_name; /* official service name */
|
||||
char **s_aliases; /* alias list */
|
||||
int s_port; /* port number (in network byte order) */
|
||||
char *s_proto; /* protocol to use */
|
||||
};
|
||||
|
||||
struct hostent *gethostent(void);
|
||||
struct hostent *gethostbyname(const char *);
|
||||
struct hostent *gethostbyaddr(const void *, socklen_t, int);
|
||||
void sethostent(int);
|
||||
void endhostent(void);
|
||||
|
||||
struct servent *getservent(void);
|
||||
struct servent *getservbyname(const char *, const char *);
|
||||
struct servent *getservbyport(int, const char *);
|
||||
void setservent(int);
|
||||
void endservent(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_DNS_ENT_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue