context.c revision 8764af86f7ec1641d8b79d9a21c6c13f0a5122fd
/*
* Copyright (C) 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "context_p.h"
#include "assert_p.h"
static void *lwres_malloc(void *, size_t);
static void lwres_free(void *, void *, size_t);
{
/*
* If we were not given anything special to use, use our own
* functions. These are just wrappers around malloc() and free().
*/
}
return (LWRES_R_NOMEMORY);
/*
* Set up the context.
*/
/*
* Init resolv.conf bits.
*/
return (LWRES_R_SUCCESS);
}
void
}
}
}
void
}
void
}
void *
}
static void *
void *mem;
(void)arg;
return (NULL);
return (mem);
}
static void
(void)arg;
}
static lwres_result_t
int s;
int ret;
struct sockaddr_in localhost;
if (s < 0)
return (LWRES_R_IOERROR);
if (ret != 0) {
close(s);
return (LWRES_R_IOERROR);
}
return (LWRES_R_SUCCESS);
}
int *recvd_len)
{
int ret;
int ret2;
int flags;
struct sockaddr_in sin;
unsigned int fromlen;
if (ret < 0)
return (LWRES_R_IOERROR);
return (LWRES_R_IOERROR);
flags |= O_NONBLOCK;
if (ret < 0)
return (LWRES_R_IOERROR);
flags &= ~O_NONBLOCK;
if (ret < 0)
return (LWRES_R_IOERROR);
/*
* What happened with select?
*/
if (ret2 < 0)
return (LWRES_R_IOERROR);
if (ret2 == 0)
return (LWRES_R_TIMEOUT);
/*
* Compilers that use an older prototype for recvfrom() will
* warn about the type of the sixth parameter, fromlen. It
* is now standardized as unsigned, specifically as socklen_t.
*/
if (ret < 0)
return (LWRES_R_IOERROR);
/*
* If we got something other than what we expect, re-issue our
* recvfrom() call. This can happen if an old result comes in,
* or if someone is sending us random stuff.
*/
goto again;
return (LWRES_R_SUCCESS);
}