mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
The UI tests, Gradle's script, the iOS app and the native test hosts (batch 6 of 8, comment lines only) and the checker's own. Every function in the app is now documented; android.yml's docs job runs tools/doc_check.py first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs
45 lines
976 B
C
45 lines
976 B
C
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* Copyright (C) 2026 Neo-Desktop
|
|
*
|
|
* SystemDNS.c - see SystemDNS.h (res_ninit: libresolv)
|
|
*/
|
|
#include <arpa/inet.h>
|
|
#include <netinet/in.h>
|
|
#include <resolv.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "SystemDNS.h"
|
|
|
|
/* see SystemDNS.h */
|
|
int dmodem_dns_servers(char *buf, int len)
|
|
{
|
|
struct __res_state st;
|
|
int i, n = 0, at = 0;
|
|
|
|
if (len <= 0)
|
|
return 0;
|
|
buf[0] = 0;
|
|
memset(&st, 0, sizeof(st));
|
|
if (res_ninit(&st) != 0)
|
|
return 0;
|
|
for (i = 0; i < st.nscount && i < MAXNS; i++) {
|
|
char a[INET_ADDRSTRLEN];
|
|
if (st.nsaddr_list[i].sin_family != AF_INET ||
|
|
!inet_ntop(AF_INET, &st.nsaddr_list[i].sin_addr, a, sizeof(a)))
|
|
continue;
|
|
int w = snprintf(buf + at, (size_t)(len - at), "%s%s", n ? "," : "", a);
|
|
if (w < 0 || w >= len - at)
|
|
break;
|
|
at += w;
|
|
n++;
|
|
}
|
|
#ifdef __APPLE__
|
|
res_ndestroy(&st); /* (Apple's: frees what res_ninit allocated) */
|
|
#else
|
|
res_nclose(&st);
|
|
#endif
|
|
return n;
|
|
}
|