mirror of https://github.com/getdnsapi/getdns.git
Minor fixes to make it compile on Windows again
This commit is contained in:
parent
258e59242b
commit
57e2a18f94
15
src/server.c
15
src/server.c
|
@ -26,7 +26,14 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef USE_WINSOCK
|
||||
#include <netdb.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#endif
|
||||
|
||||
#include "getdns/getdns_extra.h"
|
||||
#include "context.h"
|
||||
#include "types-internal.h"
|
||||
|
@ -269,7 +276,7 @@ getdns_reply(
|
|||
else if (conn->l->transport == GETDNS_TRANSPORT_UDP) {
|
||||
listener *l = conn->l;
|
||||
|
||||
if (conn->l->fd >= 0 && sendto(conn->l->fd, buf, len, 0,
|
||||
if (conn->l->fd >= 0 && sendto(conn->l->fd, (void *)buf, len, 0,
|
||||
(struct sockaddr *)&conn->remote_in, conn->addrlen) == -1) {
|
||||
/* IO error, cleanup this listener */
|
||||
loop->vmt->clear(loop, &conn->l->event);
|
||||
|
@ -532,7 +539,7 @@ static void udp_read_cb(void *userarg)
|
|||
|
||||
conn->l = l;
|
||||
conn->addrlen = sizeof(conn->remote_in);
|
||||
if ((len = recvfrom(l->fd, buf, sizeof(buf), 0,
|
||||
if ((len = recvfrom(l->fd, (void *)buf, sizeof(buf), 0,
|
||||
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
|
||||
/* IO error, cleanup this listener. */
|
||||
loop->vmt->clear(loop, &l->event);
|
||||
|
@ -704,7 +711,11 @@ static void remove_listeners(listen_set *set)
|
|||
|
||||
static getdns_return_t add_listeners(listen_set *set)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
static const char enable = 1;
|
||||
#else
|
||||
static const int enable = 1;
|
||||
#endif
|
||||
|
||||
struct mem_funcs *mf;
|
||||
getdns_eventloop *loop;
|
||||
|
|
|
@ -55,7 +55,9 @@ static const char *default_stubby_config =
|
|||
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
||||
"}";
|
||||
static int clear_listen_list_on_arg = 0;
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
static int run_in_foreground = 1;
|
||||
#endif
|
||||
static int quiet = 0;
|
||||
static int batch_mode = 0;
|
||||
static char *query_file = NULL;
|
||||
|
@ -209,8 +211,10 @@ print_usage(FILE *out, const char *progname)
|
|||
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
||||
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
||||
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
if (i_am_stubby)
|
||||
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
||||
#endif
|
||||
fprintf(out, "\t-G\tgeneral lookup\n");
|
||||
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
||||
fprintf(out, "\t-h\tPrint this help\n");
|
||||
|
@ -995,10 +999,12 @@ getdns_return_t parse_args(int argc, char **argv)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
if (i_am_stubby && *c == 'g') {
|
||||
run_in_foreground = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr, "Unknown option "
|
||||
"\"%c\"\n", *c);
|
||||
for (i = 0; i < argc; i++)
|
||||
|
@ -1608,7 +1614,8 @@ main(int argc, char **argv)
|
|||
prg_name = prg_name ? prg_name + 1 : argv[0];
|
||||
|
||||
i_am_stubby = strcasecmp(prg_name, "stubby") == 0
|
||||
|| strcasecmp(prg_name, "lt-stubby") == 0;
|
||||
|| strcasecmp(prg_name, "lt-stubby") == 0
|
||||
|| strcasecmp(prg_name, "stubby.exe") == 0;
|
||||
|
||||
name = the_root;
|
||||
if ((r = getdns_context_create(&context, 1))) {
|
||||
|
@ -1675,6 +1682,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
else if (listen_count) {
|
||||
assert(loop);
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
if (i_am_stubby && !run_in_foreground) {
|
||||
pid_t pid = fork();
|
||||
if (pid == -1) {
|
||||
|
@ -1693,6 +1701,7 @@ main(int argc, char **argv)
|
|||
} else
|
||||
loop->vmt->run(loop);
|
||||
} else
|
||||
#endif
|
||||
loop->vmt->run(loop);
|
||||
} else
|
||||
r = do_the_call();
|
||||
|
|
Loading…
Reference in New Issue