mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-29 05:50:27 +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
17
libc/dns/servicestxt.h
Normal file
17
libc/dns/servicestxt.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_
|
||||
#define COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int LookupServicesByPort(const int, char **, char *, size_t)
|
||||
paramsnonnull((2, 3));
|
||||
int LookupServicesByName(const char *, char **) paramsnonnull((1, 2));
|
||||
|
||||
/* TODO: implement like struct HostsTxt? */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_DNS_SERVICESTXT_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue