mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-02 16:00:30 +00:00
Simplify getnameinfo (#196)
The getnameinfo implementation requires an address -> name lookup on the hosts file (ie struct HostsTxt) and the previous implementation used flags to check whether HostsTxt was sorted according to address or name, and then re-sorted it if necessary. Now getnameinfo lookup does not require sorting, it does a simple linear lookup, and so the related code was simplified See #172 for discussion.
This commit is contained in:
parent
1f87640d17
commit
98c53ae526
7 changed files with 21 additions and 46 deletions
|
@ -21,12 +21,7 @@ struct HostsTxtStrings {
|
|||
char *p;
|
||||
};
|
||||
|
||||
#define HOSTSTXT_NOT_SORTED 0
|
||||
#define HOSTSTXT_SORTEDBYNAME 1
|
||||
#define HOSTSTXT_SORTEDBYADDR 2
|
||||
|
||||
struct HostsTxt {
|
||||
int sorted_by;
|
||||
struct HostsTxtEntries entries;
|
||||
struct HostsTxtStrings strings;
|
||||
};
|
||||
|
@ -34,12 +29,12 @@ struct HostsTxt {
|
|||
const struct HostsTxt *GetHostsTxt(void) returnsnonnull;
|
||||
void FreeHostsTxt(struct HostsTxt **) paramsnonnull();
|
||||
int ParseHostsTxt(struct HostsTxt *, FILE *) paramsnonnull();
|
||||
void SortHostsTxt(struct HostsTxt *, int) paramsnonnull();
|
||||
void SortHostsTxt(struct HostsTxt *) paramsnonnull();
|
||||
int ResolveHostsTxt(const struct HostsTxt *, int, const char *,
|
||||
struct sockaddr *, uint32_t, const char **)
|
||||
paramsnonnull((1, 3));
|
||||
int ResolveHostsReverse(const struct HostsTxt *, int, const uint8_t *, char *,
|
||||
size_t);
|
||||
size_t) paramsnonnull((1, 3));
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue