mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +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
|
@ -49,7 +49,7 @@ TEST(ResolveHostsTxt, testBasicLookups) {
|
|||
struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt));
|
||||
FILE *f = fmemopen(kInput, strlen(kInput), "r+");
|
||||
ASSERT_EQ(0, ParseHostsTxt(ht, f));
|
||||
SortHostsTxt(ht, HOSTSTXT_SORTEDBYNAME);
|
||||
SortHostsTxt(ht);
|
||||
ASSERT_EQ(5, ht->entries.i);
|
||||
EXPECT_STREQ("127.0.0.1", EzIp4Lookup(ht, "localhost"));
|
||||
EXPECT_STREQ("203.0.113.1", EzIp4Lookup(ht, "lol"));
|
||||
|
@ -66,7 +66,7 @@ TEST(ResolveHostsTxt, testCanonicalize) {
|
|||
struct HostsTxt *ht = calloc(1, sizeof(struct HostsTxt));
|
||||
FILE *f = fmemopen(kInput, strlen(kInput), "r+");
|
||||
ASSERT_EQ(0, ParseHostsTxt(ht, f));
|
||||
SortHostsTxt(ht, HOSTSTXT_SORTEDBYNAME);
|
||||
SortHostsTxt(ht);
|
||||
ASSERT_EQ(5, ht->entries.i);
|
||||
EXPECT_STREQ("localhost", EzCanonicalize(ht, "localhost"));
|
||||
EXPECT_STREQ("lol.example.", EzCanonicalize(ht, "lol"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue