2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_DNS_HOSTSTXT_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_DNS_HOSTSTXT_H_
|
2021-05-16 04:53:26 +00:00
|
|
|
#include "libc/sock/sock.h"
|
|
|
|
#include "libc/stdio/stdio.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
struct HostsTxtEntry {
|
2021-05-16 04:53:26 +00:00
|
|
|
uint8_t ip[4]; /* inet_ntop(AF_INET, he->ip, buf, size) */
|
|
|
|
uint32_t name; /* &ht->strings.p[he->name] */
|
|
|
|
uint32_t canon; /* &ht->strings.p[he->canon] */
|
2020-06-15 14:18:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct HostsTxtEntries {
|
2021-05-16 04:53:26 +00:00
|
|
|
size_t i, n;
|
2020-06-15 14:18:57 +00:00
|
|
|
struct HostsTxtEntry *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HostsTxtStrings {
|
2021-05-16 04:53:26 +00:00
|
|
|
size_t i, n;
|
2020-06-15 14:18:57 +00:00
|
|
|
char *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HostsTxt {
|
|
|
|
struct HostsTxtEntries entries;
|
|
|
|
struct HostsTxtStrings strings;
|
|
|
|
};
|
|
|
|
|
2021-05-16 04:53:26 +00:00
|
|
|
const struct HostsTxt *GetHostsTxt(void) returnsnonnull;
|
|
|
|
void FreeHostsTxt(struct HostsTxt **) paramsnonnull();
|
|
|
|
int ParseHostsTxt(struct HostsTxt *, FILE *) paramsnonnull();
|
|
|
|
int ResolveHostsTxt(const struct HostsTxt *, int, const char *,
|
2020-06-15 14:18:57 +00:00
|
|
|
struct sockaddr *, uint32_t, const char **)
|
|
|
|
paramsnonnull((1, 3));
|
2021-06-10 02:35:44 +00:00
|
|
|
int ResolveHostsReverse(const struct HostsTxt *, int, const uint8_t *, char *,
|
2021-06-22 19:35:58 +00:00
|
|
|
size_t) paramsnonnull((1, 3));
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_DNS_HOSTSTXT_H_ */
|