dns-lookup.c revision be5773cb4d6edae8a5d9f300c3c7375cdd33826e
/* Copyright (c) 2010-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "net.h"
#include "llist.h"
#include "istream.h"
#include "write-full.h"
#include "time-util.h"
#include "dns-lookup.h"
#include <stdio.h>
#include <unistd.h>
#define MAX_INBUF_SIZE 512
struct dns_lookup {
struct dns_client *client;
bool ptr_lookup;
struct timeval start_time;
unsigned int warn_msecs;
struct dns_lookup_result result;
unsigned int ip_idx;
char *name;
void *context;
};
struct dns_client {
int fd;
char *path;
unsigned int timeout_msecs, idle_timeout_msecs;
bool deinit_client_at_free;
};
{
struct dns_lookup_result result;
}
}
}
{
if (lookup->ptr_lookup) {
/* <ret> [<name>] */
} else {
return -1;
}
}
return 1;
}
/* first line: <ret> [<ip count>] */
return -1;
return 1;
}
return -1;
} else {
return -1;
return 1;
}
}
return 0;
}
{
int diff;
i_fatal("gettimeofday() failed: %m");
if (diff > 0)
}
{
const char *line;
int ret = 0;
return;
}
if (ret > 0)
break;
if (ret < 0) {
return;
}
}
/* already got the error */
return;
return;
}
if (ret > 0) {
}
if (retry)
}
{
}
struct dns_lookup **lookup_r)
{
struct dns_client *client;
return -1;
}
return 0;
}
const struct dns_lookup_settings *set,
struct dns_lookup **lookup_r)
{
struct dns_client *client;
return -1;
}
return 0;
}
{
}
{
if (client->deinit_client_at_free)
}
}
{
}
{
}
{
struct dns_client *client;
return client;
}
{
}
{
return 0;
return -1;
}
return 0;
}
static int
const char **error_r)
{
int ret;
return -1;
ret = -1;
} else {
/* already connected. if write() fails, retry connecting */
ret = 0;
}
return ret;
}
return 1;
}
static int
const char *cmd, bool ptr_lookup,
struct dns_lookup **lookup_r)
{
struct dns_lookup *lookup;
struct dns_lookup_result result;
int ret;
if (ret == 0) {
/* retry once */
}
if (ret <= 0) {
return -1;
}
}
if (client->timeout_msecs != 0) {
}
i_fatal("gettimeofday() failed: %m");
return 0;
}
struct dns_lookup **lookup_r)
{
}
struct dns_lookup **lookup_r)
{
}
{
struct dns_lookup *lookup;
}