Path: blob/main/system/lib/libc/lookup_name.c
6162 views
// Emscripten-specific version of musl/src/network/lookup_name.c12#include <assert.h>3#include <string.h>4#include "musl/src/network/lookup.h"5#include "emscripten_internal.h"67int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)8{9/* We currently only support the callsite in gethostbyname2_r which10* passes AI_CANONNAME. Remove this assertion if we ever expand11* this support. */12assert(flags == AI_CANONNAME);1314if (family != AF_INET) {15return EAI_SYSTEM;16}1718/* This hunk is duplicated from musl/src/network/lookup_name.c */19*canon = 0;20if (name) {21/* reject empty name and check len so it fits into temp bufs */22size_t l = strnlen(name, 255);23if (l-1 >= 254)24return EAI_NONAME;25memcpy(canon, name, l+1);26}2728/* We only support a single address */29uint32_t addr = _emscripten_lookup_name(name);30memset(&buf[0], 0, sizeof(buf[0]));31memcpy(&buf[0].addr, &addr, sizeof(addr));32return 1;33}343536