sync against trunc
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: entropy.c,v 1.3.2.2.2.4 2003/09/24 03:47:17 marka Exp $ */
|
||||
/* $Id: entropy.c,v 1.3.2.2.2.5 2003/10/07 03:28:32 marka Exp $ */
|
||||
|
||||
/*
|
||||
* This is the system independent part of the entropy module. It is
|
||||
@@ -384,7 +384,7 @@ estimate_entropy(sample_queue_t *sq, isc_uint32_t t) {
|
||||
|
||||
/*
|
||||
* If the time counter has overflowed, calculate the real difference.
|
||||
* If it has not, it is simplier.
|
||||
* If it has not, it is simpler.
|
||||
*/
|
||||
if (t < sq->last_time)
|
||||
delta = UINT_MAX - sq->last_time + t;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.50.12.2 2003/09/02 02:10:51 marka Exp $
|
||||
# $Id: Makefile.in,v 1.50.12.3 2003/10/07 03:28:34 marka Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
@@ -37,7 +37,7 @@ HEADERS = app.h assertions.h base64.h bitstring.h boolean.h buffer.h \
|
||||
refcount.h region.h resource.h \
|
||||
result.h resultclass.h rwlock.h serial.h sha1.h sockaddr.h \
|
||||
socket.h stdio.h stdlib.h string.h symtab.h task.h taskpool.h \
|
||||
timer.h types.h util.h
|
||||
timer.h types.h util.h version.h
|
||||
|
||||
SUBDIRS =
|
||||
TARGETS =
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: ipv6.h,v 1.17.12.1 2003/08/14 04:25:09 marka Exp $ */
|
||||
/* $Id: ipv6.h,v 1.17.12.2 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
#ifndef ISC_IPV6_H
|
||||
#define ISC_IPV6_H 1
|
||||
@@ -75,8 +75,8 @@ struct in6_addr {
|
||||
#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
|
||||
|
||||
extern const struct in6_addr in6addr_any;
|
||||
extern const struct in6_addr in6addr_loopback;
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
|
||||
|
||||
struct sockaddr_in6 {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lib.h,v 1.6 2001/01/09 21:57:06 bwelling Exp $ */
|
||||
/* $Id: lib.h,v 1.6.12.1 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
#ifndef ISC_LIB_H
|
||||
#define ISC_LIB_H 1
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
extern isc_msgcat_t *isc_msgcat;
|
||||
LIBISC_EXTERNAL_DATA extern isc_msgcat_t *isc_msgcat;
|
||||
|
||||
void
|
||||
isc_lib_initmsgcat(void);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.h,v 1.39.2.4.2.3 2003/08/21 02:02:04 marka Exp $ */
|
||||
/* $Id: log.h,v 1.39.2.4.2.4 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
#ifndef ISC_LOG_H
|
||||
#define ISC_LOG_H 1
|
||||
@@ -739,9 +739,6 @@ isc_log_settag(isc_logconfig_t *lcfg, const char *tag);
|
||||
* ISC_LOG_PRINTTAG channel flag to not print anything. If tag equals the
|
||||
* empty string, calls to isc_log_gettag will return NULL.
|
||||
*
|
||||
* Because the name is used by ISC_LOG_PRINTTAG, it should not be
|
||||
* altered or destroyed after isc_log_settag().
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS Success
|
||||
* ISC_R_NOMEMORY Resource Limit: Out of memory
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: mem.h,v 1.54 2001/07/12 05:58:25 mayer Exp $ */
|
||||
/* $Id: mem.h,v 1.54.12.1 2003/10/07 03:28:35 marka Exp $ */
|
||||
|
||||
#ifndef ISC_MEM_H
|
||||
#define ISC_MEM_H 1
|
||||
@@ -37,18 +37,20 @@ typedef void * (*isc_memalloc_t)(void *, size_t);
|
||||
typedef void (*isc_memfree_t)(void *, void *);
|
||||
|
||||
/*
|
||||
* ISC_MEM_DEBUG is enabled by default; set ISC_MEM_DEBUG=0 to disable it.
|
||||
* Define ISC_MEM_DEBUG=1 to make all functions that free memory
|
||||
* set the pointer being freed to NULL after being freed.
|
||||
* This is the default; set ISC_MEM_DEBUG=0 to disable it.
|
||||
*/
|
||||
#ifndef ISC_MEM_DEBUG
|
||||
#define ISC_MEM_DEBUG 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory allocation
|
||||
* and freeing by file and line number.
|
||||
* Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory
|
||||
* allocation and freeing by file and line number.
|
||||
*/
|
||||
#ifndef ISC_MEM_TRACKLINES
|
||||
#define ISC_MEM_TRACKLINES 0
|
||||
#define ISC_MEM_TRACKLINES 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -60,7 +62,7 @@ typedef void (*isc_memfree_t)(void *, void *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define ISC_MEM_FILL to fill each block of memory returned to the system
|
||||
* Define ISC_MEM_FILL=1 to fill each block of memory returned to the system
|
||||
* with the byte string '0xbe'. This helps track down uninitialized pointers
|
||||
* and the like. On freeing memory, the space is filled with '0xde' for
|
||||
* the same reasons.
|
||||
@@ -70,27 +72,36 @@ typedef void (*isc_memfree_t)(void *, void *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define this to turn on memory pool names.
|
||||
* Define ISC_MEMPOOL_NAMES=1 to make memory pools store a symbolic
|
||||
* name so that the leaking pool can be more readily identified in
|
||||
* case of a memory leak.
|
||||
*/
|
||||
#ifndef ISC_MEMPOOL_NAMES
|
||||
#define ISC_MEMPOOL_NAMES 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* _DEBUGTRACE
|
||||
* log (to isc_lctx) each allocation and free.
|
||||
*
|
||||
* _DEBUGRECORD
|
||||
* remember each allocation, and match them up on free. Crash if
|
||||
* a free doesn't match an allocation
|
||||
* _DEBUGUSAGE
|
||||
* if a hi_water mark is set print the maximium inuse memory every
|
||||
* time it is raised once it exceeds the hi_water mark
|
||||
*/
|
||||
LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_debugging;
|
||||
#define ISC_MEM_DEBUGTRACE 0x00000001U
|
||||
#define ISC_MEM_DEBUGRECORD 0x00000002U
|
||||
#define ISC_MEM_DEBUGUSAGE 0x00000004U
|
||||
/*
|
||||
* The variable isc_mem_debugging holds a set of flags for
|
||||
* turning certain memory debugging options on or off at
|
||||
* runtime. Its is intialized to the value ISC_MEM_DEGBUGGING,
|
||||
* which is 0 by default but may be overridden at compile time.
|
||||
* The following flags can be specified:
|
||||
*
|
||||
* ISC_MEM_DEBUGTRACE
|
||||
* Log each allocation and free to isc_lctx.
|
||||
*
|
||||
* ISC_MEM_DEBUGRECORD
|
||||
* Remember each allocation, and match them up on free.
|
||||
* Crash if a free doesn't match an allocation.
|
||||
*
|
||||
* ISC_MEM_DEBUGUSAGE
|
||||
* If a hi_water mark is set, print the maximium inuse memory
|
||||
* every time it is raised once it exceeds the hi_water mark.
|
||||
*/
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
#define _ISC_MEM_FILELINE , __FILE__, __LINE__
|
||||
@@ -161,12 +172,12 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_debugging;
|
||||
|
||||
isc_result_t
|
||||
isc_mem_create(size_t max_size, size_t target_size,
|
||||
isc_mem_t **mctxp);
|
||||
isc_mem_t **mctxp);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_createx(size_t max_size, size_t target_size,
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree,
|
||||
void *arg, isc_mem_t **mctxp);
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree,
|
||||
void *arg, isc_mem_t **mctxp);
|
||||
/*
|
||||
* Create a memory context.
|
||||
*
|
||||
@@ -176,8 +187,12 @@ isc_mem_createx(size_t max_size, size_t target_size,
|
||||
* 'target_size' from the system allocator and breaking them up into
|
||||
* pieces; larger allocations will use the system allocator directly.
|
||||
* If 'max_size' and/or 'target_size' are zero, default values will be
|
||||
* used. When ISC_MEM_USE_INTERNAL_MALLOC is false, 'max_size' and
|
||||
* 'target_size' are ignored.
|
||||
* used. When ISC_MEM_USE_INTERNAL_MALLOC is false, 'target_size' is
|
||||
* ignored.
|
||||
*
|
||||
* 'max_size' is also used to size the statistics arrays and the array
|
||||
* used to record active memory when ISC_MEM_DEBUGRECORD is set. Settin
|
||||
* 'max_size' too low can have detrimental effects on performance.
|
||||
*
|
||||
* A memory context created using isc_mem_createx() will obtain
|
||||
* memory from the system by calling 'memalloc' and 'memfree',
|
||||
@@ -213,8 +228,8 @@ isc_mem_destroy(isc_mem_t **);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_ondestroy(isc_mem_t *ctx,
|
||||
isc_task_t *task,
|
||||
isc_event_t **event);
|
||||
isc_task_t *task,
|
||||
isc_event_t **event);
|
||||
/*
|
||||
* Request to be notified with an event when a memory context has
|
||||
* been successfully destroyed.
|
||||
@@ -228,7 +243,7 @@ isc_mem_stats(isc_mem_t *mctx, FILE *out);
|
||||
|
||||
void
|
||||
isc_mem_setdestroycheck(isc_mem_t *mctx,
|
||||
isc_boolean_t on);
|
||||
isc_boolean_t on);
|
||||
/*
|
||||
* Iff 'on' is ISC_TRUE, 'mctx' will check for memory leaks when
|
||||
* destroyed and abort the program if any are present.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: platform.h.in,v 1.24.2.1.10.8 2003/09/10 05:12:53 marka Exp $ */
|
||||
/* $Id: platform.h.in,v 1.24.2.1.10.9 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
#ifndef ISC_PLATFORM_H
|
||||
#define ISC_PLATFORM_H 1
|
||||
@@ -173,6 +173,12 @@
|
||||
*/
|
||||
@ISC_PLATFORM_HAVELONGLONG@
|
||||
|
||||
/*
|
||||
* Define if the system has struct lifconf which is a extended struct ifconf
|
||||
* for IPv6.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVELIFCONF@
|
||||
|
||||
/*
|
||||
* Define if the system has struct if_laddrconf which is a extended struct
|
||||
* ifconf for IPv6.
|
||||
@@ -184,12 +190,6 @@
|
||||
*/
|
||||
@ISC_PLATFORM_HAVEIF_LADDRREQ@
|
||||
|
||||
/*
|
||||
* Define if the system has struct lifconf which is a extended struct ifconf
|
||||
* for IPv6.
|
||||
*/
|
||||
@ISC_PLATFORM_HAVELIFCONF@
|
||||
|
||||
/*
|
||||
* Used to control how extern data is linked; needed for Win32 platforms.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: sockaddr.h,v 1.35.12.2 2003/08/14 04:25:09 marka Exp $ */
|
||||
/* $Id: sockaddr.h,v 1.35.12.3 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
#ifndef ISC_SOCKADDR_H
|
||||
#define ISC_SOCKADDR_H 1
|
||||
@@ -64,6 +64,9 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only);
|
||||
/*
|
||||
* Return a hash value for the socket address 'sockaddr'. If 'address_only'
|
||||
* is ISC_TRUE, the hash value will not depend on the port.
|
||||
*
|
||||
* IPv6 addresses containing mapped IPv4 addresses generate the same hash
|
||||
* value as the equivalent IPv4 address.
|
||||
*/
|
||||
|
||||
void
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: util.h,v 1.21.12.2 2003/08/11 05:28:21 marka Exp $ */
|
||||
/* $Id: util.h,v 1.21.12.3 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
#ifndef ISC_UTIL_H
|
||||
#define ISC_UTIL_H 1
|
||||
@@ -175,9 +175,6 @@
|
||||
#define DESTROYMUTEXBLOCK(bp, n) \
|
||||
RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS)
|
||||
|
||||
#define DESTROYMUTEXBLOCK(bp, n) \
|
||||
RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS)
|
||||
|
||||
/*
|
||||
* List Macros.
|
||||
*/
|
||||
@@ -225,9 +222,4 @@
|
||||
*/
|
||||
#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS)
|
||||
|
||||
/*
|
||||
* Time
|
||||
*/
|
||||
#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS)
|
||||
|
||||
#endif /* ISC_UTIL_H */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: version.h,v 1.2 2001/11/19 03:08:27 mayer Exp $ */
|
||||
/* $Id: version.h,v 1.2.220.1 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
#include <isc/platform.h>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: lib.c,v 1.8 2001/01/09 21:56:12 bwelling Exp $ */
|
||||
/* $Id: lib.c,v 1.8.12.1 2003/10/07 03:28:33 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*** Globals
|
||||
***/
|
||||
|
||||
isc_msgcat_t * isc_msgcat = NULL;
|
||||
LIBISC_EXTERNAL_DATA isc_msgcat_t * isc_msgcat = NULL;
|
||||
|
||||
|
||||
/***
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.c,v 1.70.2.8.2.5 2003/08/27 07:22:36 marka Exp $ */
|
||||
/* $Id: log.c,v 1.70.2.8.2.6 2003/10/07 03:28:33 marka Exp $ */
|
||||
|
||||
/* Principal Authors: DCL */
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <isc/mem.h>
|
||||
#include <isc/msgs.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/stat.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/time.h>
|
||||
@@ -302,9 +301,6 @@ isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp) {
|
||||
if (result == ISC_R_SUCCESS)
|
||||
result = sync_channellist(lcfg);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
result = sync_channellist(lcfg);
|
||||
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
lctx->logconfig = lcfg;
|
||||
|
||||
@@ -1047,10 +1043,6 @@ isc_log_closefilelogs(isc_log_t *lctx) {
|
||||
**** Internal functions
|
||||
****/
|
||||
|
||||
/*
|
||||
* This would ideally be part of isc_log_registercategories(), except then
|
||||
* that function would have to return isc_result_t instead of void.
|
||||
*/
|
||||
static isc_result_t
|
||||
assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
|
||||
const isc_logmodule_t *module, isc_logchannel_t *channel)
|
||||
|
||||
168
lib/isc/mem.c
168
lib/isc/mem.c
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: mem.c,v 1.98.2.7.2.2 2003/09/24 03:47:17 marka Exp $ */
|
||||
/* $Id: mem.c,v 1.98.2.7.2.3 2003/10/07 03:28:33 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -68,6 +68,7 @@ typedef struct debuglink debuglink_t;
|
||||
struct debuglink {
|
||||
ISC_LINK(debuglink_t) link;
|
||||
const void *ptr[DEBUGLIST_COUNT];
|
||||
unsigned int size[DEBUGLIST_COUNT];
|
||||
const char *file[DEBUGLIST_COUNT];
|
||||
unsigned int line[DEBUGLIST_COUNT];
|
||||
unsigned int count;
|
||||
@@ -107,6 +108,10 @@ struct stats {
|
||||
#define MEM_MAGIC ISC_MAGIC('M', 'e', 'm', 'C')
|
||||
#define VALID_CONTEXT(c) ISC_MAGIC_VALID(c, MEM_MAGIC)
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
typedef ISC_LIST(debuglink_t) debuglist_t;
|
||||
#endif
|
||||
|
||||
struct isc_mem {
|
||||
unsigned int magic;
|
||||
isc_ondestroy_t ondestroy;
|
||||
@@ -141,8 +146,7 @@ struct isc_mem {
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
ISC_LIST(debuglink_t) debuglist;
|
||||
unsigned int debugging;
|
||||
debuglist_t * debuglist;
|
||||
#endif
|
||||
|
||||
unsigned int memalloc_failures;
|
||||
@@ -183,12 +187,14 @@ struct isc_mempool {
|
||||
#define DELETE_TRACE(a, b, c, d, e)
|
||||
#else
|
||||
#define ADD_TRACE(a, b, c, d, e) \
|
||||
do { if (b != NULL) add_trace_entry(a, b, c, d, e); } while (0)
|
||||
do { \
|
||||
if ((isc_mem_debugging & (ISC_MEM_DEBUGTRACE | \
|
||||
ISC_MEM_DEBUGRECORD)) != 0 && \
|
||||
b != NULL) \
|
||||
add_trace_entry(a, b, c, d, e); \
|
||||
} while (0)
|
||||
#define DELETE_TRACE(a, b, c, d, e) delete_trace_entry(a, b, c, d, e)
|
||||
|
||||
#define MEM_TRACE ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0)
|
||||
#define MEM_RECORD ((mctx->debugging & ISC_MEM_DEBUGRECORD) != 0)
|
||||
|
||||
static void
|
||||
print_active(isc_mem_t *ctx, FILE *out);
|
||||
|
||||
@@ -202,23 +208,27 @@ add_trace_entry(isc_mem_t *mctx, const void *ptr, unsigned int size
|
||||
debuglink_t *dl;
|
||||
unsigned int i;
|
||||
|
||||
if (MEM_TRACE)
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0)
|
||||
fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_ADDTRACE,
|
||||
"add %p size %u "
|
||||
"file %s line %u mctx %p\n"),
|
||||
ptr, size, file, line, mctx);
|
||||
|
||||
if (!MEM_RECORD)
|
||||
if (mctx->debuglist == NULL)
|
||||
return;
|
||||
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist);
|
||||
if (size > mctx->max_size)
|
||||
size = mctx->max_size;
|
||||
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist[size]);
|
||||
while (dl != NULL) {
|
||||
if (dl->count == DEBUGLIST_COUNT)
|
||||
goto next;
|
||||
for (i = 0; i < DEBUGLIST_COUNT; i++) {
|
||||
if (dl->ptr[i] == NULL) {
|
||||
dl->ptr[i] = ptr;
|
||||
dl->size[i] = size;
|
||||
dl->file[i] = file;
|
||||
dl->line[i] = line;
|
||||
dl->count++;
|
||||
@@ -235,16 +245,18 @@ add_trace_entry(isc_mem_t *mctx, const void *ptr, unsigned int size
|
||||
ISC_LINK_INIT(dl, link);
|
||||
for (i = 1; i < DEBUGLIST_COUNT; i++) {
|
||||
dl->ptr[i] = NULL;
|
||||
dl->size[i] = 0;
|
||||
dl->file[i] = NULL;
|
||||
dl->line[i] = 0;
|
||||
}
|
||||
|
||||
dl->ptr[0] = ptr;
|
||||
dl->size[0] = size;
|
||||
dl->file[0] = file;
|
||||
dl->line[0] = line;
|
||||
dl->count = 1;
|
||||
|
||||
ISC_LIST_PREPEND(mctx->debuglist, dl, link);
|
||||
ISC_LIST_PREPEND(mctx->debuglist[size], dl, link);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -254,28 +266,32 @@ delete_trace_entry(isc_mem_t *mctx, const void *ptr, unsigned int size,
|
||||
debuglink_t *dl;
|
||||
unsigned int i;
|
||||
|
||||
if (MEM_TRACE)
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0)
|
||||
fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_DELTRACE,
|
||||
"del %p size %u "
|
||||
"file %s line %u mctx %p\n"),
|
||||
ptr, size, file, line, mctx);
|
||||
|
||||
if (!MEM_RECORD)
|
||||
if (mctx->debuglist == NULL)
|
||||
return;
|
||||
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist);
|
||||
if (size > mctx->max_size)
|
||||
size = mctx->max_size;
|
||||
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist[size]);
|
||||
while (dl != NULL) {
|
||||
for (i = 0; i < DEBUGLIST_COUNT; i++) {
|
||||
if (dl->ptr[i] == ptr) {
|
||||
dl->ptr[i] = NULL;
|
||||
dl->size[i] = 0;
|
||||
dl->file[i] = NULL;
|
||||
dl->line[i] = 0;
|
||||
|
||||
INSIST(dl->count > 0);
|
||||
dl->count--;
|
||||
if (dl->count == 0) {
|
||||
ISC_LIST_UNLINK(mctx->debuglist,
|
||||
ISC_LIST_UNLINK(mctx->debuglist[size],
|
||||
dl, link);
|
||||
free(dl);
|
||||
}
|
||||
@@ -722,6 +738,9 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
ctx->arg = arg;
|
||||
ctx->stats = NULL;
|
||||
ctx->checkfree = ISC_TRUE;
|
||||
#if ISC_MEM_TRACKLINES
|
||||
ctx->debuglist = NULL;
|
||||
#endif
|
||||
ISC_LIST_INIT(ctx->pools);
|
||||
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
@@ -766,8 +785,18 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
ISC_LIST_INIT(ctx->debuglist);
|
||||
ctx->debugging = isc_mem_debugging;
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0) {
|
||||
unsigned int i;
|
||||
|
||||
ctx->debuglist = (memalloc)(arg,
|
||||
(ctx->max_size+1) * sizeof(debuglist_t));
|
||||
if (ctx->debuglist == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i <= ctx->max_size; i++)
|
||||
ISC_LIST_INIT(ctx->debuglist[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
ctx->memalloc_failures = 0;
|
||||
@@ -783,6 +812,10 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
if (ctx->freelists)
|
||||
(memfree)(arg, ctx->freelists);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ctx->debuglist)
|
||||
(ctx->memfree)(ctx->arg, ctx->debuglist);
|
||||
#endif /* ISC_MEM_TRACKLINES */
|
||||
(memfree)(arg, ctx);
|
||||
}
|
||||
|
||||
@@ -810,19 +843,26 @@ destroy(isc_mem_t *ctx) {
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ctx->checkfree) {
|
||||
if (!ISC_LIST_EMPTY(ctx->debuglist))
|
||||
print_active(ctx, stderr);
|
||||
INSIST(ISC_LIST_EMPTY(ctx->debuglist));
|
||||
} else {
|
||||
debuglink_t *dl;
|
||||
if (ctx->debuglist != NULL) {
|
||||
if (ctx->checkfree) {
|
||||
for (i = 0; i <= ctx->max_size; i++) {
|
||||
if (!ISC_LIST_EMPTY(ctx->debuglist[i]))
|
||||
print_active(ctx, stderr);
|
||||
INSIST(ISC_LIST_EMPTY(ctx->debuglist[i]));
|
||||
}
|
||||
} else {
|
||||
debuglink_t *dl;
|
||||
|
||||
for (dl = ISC_LIST_HEAD(ctx->debuglist);
|
||||
dl != NULL;
|
||||
dl = ISC_LIST_HEAD(ctx->debuglist)) {
|
||||
ISC_LIST_UNLINK(ctx->debuglist, dl, link);
|
||||
free(dl);
|
||||
for (i = 0; i <= ctx->max_size; i++)
|
||||
for (dl = ISC_LIST_HEAD(ctx->debuglist[i]);
|
||||
dl != NULL;
|
||||
dl = ISC_LIST_HEAD(ctx->debuglist[i])) {
|
||||
ISC_LIST_UNLINK(ctx->debuglist[i],
|
||||
dl, link);
|
||||
free(dl);
|
||||
}
|
||||
}
|
||||
(ctx->memfree)(ctx->arg, ctx->debuglist);
|
||||
}
|
||||
#endif
|
||||
INSIST(ctx->references == 0);
|
||||
@@ -987,7 +1027,7 @@ isc__mem_get(isc_mem_t *ctx, size_t size FLARG) {
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
ptr = mem_get(ctx, size);
|
||||
LOCK(&ctx->lock);
|
||||
if (ptr)
|
||||
if (ptr != NULL)
|
||||
mem_getstats(ctx, size);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
@@ -1006,9 +1046,8 @@ isc__mem_get(isc_mem_t *ctx, size_t size FLARG) {
|
||||
}
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
if (call_water) {
|
||||
if (call_water)
|
||||
(ctx->water)(ctx->water_arg, ISC_MEM_HIWATER);
|
||||
}
|
||||
|
||||
return (ptr);
|
||||
}
|
||||
@@ -1046,41 +1085,47 @@ isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size FLARG)
|
||||
}
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
if (call_water) {
|
||||
if (call_water)
|
||||
(ctx->water)(ctx->water_arg, ISC_MEM_LOWATER);
|
||||
}
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
static void
|
||||
print_active(isc_mem_t *mctx, FILE *out) {
|
||||
if (MEM_RECORD) {
|
||||
if (mctx->debuglist != NULL) {
|
||||
debuglink_t *dl;
|
||||
unsigned int i;
|
||||
unsigned int i, j;
|
||||
const char *format;
|
||||
isc_boolean_t found;
|
||||
|
||||
fprintf(out, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_DUMPALLOC,
|
||||
"Dump of all outstanding "
|
||||
"memory allocations:\n"));
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist);
|
||||
if (dl == NULL)
|
||||
fprintf(out, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_NONE,
|
||||
"\tNone.\n"));
|
||||
while (dl != NULL) {
|
||||
for (i = 0; i < DEBUGLIST_COUNT; i++)
|
||||
if (dl->ptr[i] != NULL)
|
||||
fprintf(out,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_MEM,
|
||||
ISC_MSG_PTRFILELINE,
|
||||
"\tptr %p "
|
||||
"file %s "
|
||||
"line %u\n"),
|
||||
dl->ptr[i], dl->file[i],
|
||||
dl->line[i]);
|
||||
dl = ISC_LIST_NEXT(dl, link);
|
||||
found = ISC_FALSE;
|
||||
format = isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_PTRFILELINE,
|
||||
"\tptr %p size %u file %s line %u\n");
|
||||
for (i = 0; i <= mctx->max_size; i++) {
|
||||
dl = ISC_LIST_HEAD(mctx->debuglist[i]);
|
||||
|
||||
if (dl != NULL)
|
||||
found = ISC_TRUE;
|
||||
|
||||
while (dl != NULL) {
|
||||
for (j = 0; j < DEBUGLIST_COUNT; j++)
|
||||
if (dl->ptr[j] != NULL)
|
||||
fprintf(out, format,
|
||||
dl->ptr[j],
|
||||
dl->size[j],
|
||||
dl->file[j],
|
||||
dl->line[j]);
|
||||
dl = ISC_LIST_NEXT(dl, link);
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
fprintf(out, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||
ISC_MSG_NONE, "\tNone.\n"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1198,8 +1243,7 @@ isc__mem_allocate(isc_mem_t *ctx, size_t size FLARG) {
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (si != NULL)
|
||||
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
||||
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
||||
#endif
|
||||
|
||||
UNLOCK(&ctx->lock);
|
||||
@@ -1423,6 +1467,7 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
/*
|
||||
* Return any items on the free list
|
||||
*/
|
||||
LOCK(&mctx->lock);
|
||||
while (mpctx->items != NULL) {
|
||||
INSIST(mpctx->freecount > 0);
|
||||
mpctx->freecount--;
|
||||
@@ -1430,13 +1475,13 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
mpctx->items = item->next;
|
||||
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
LOCK(&mctx->lock);
|
||||
mem_putunlocked(mctx, item, mpctx->size);
|
||||
UNLOCK(&mctx->lock);
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
mem_put(mctx, item, mpctx->size);
|
||||
mem_putstats(mctx, item, mpctx->size);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
}
|
||||
UNLOCK(&mctx->lock);
|
||||
|
||||
/*
|
||||
* Remove our linked list entry from the memory context.
|
||||
@@ -1502,13 +1547,14 @@ isc__mempool_get(isc_mempool_t *mpctx FLARG) {
|
||||
* We need to dip into the well. Lock the memory context here and
|
||||
* fill up our free list.
|
||||
*/
|
||||
LOCK(&mctx->lock);
|
||||
for (i = 0; i < mpctx->fillcount; i++) {
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
LOCK(&mctx->lock);
|
||||
item = mem_getunlocked(mctx, mpctx->size);
|
||||
UNLOCK(&mctx->lock);
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
item = mem_get(mctx, mpctx->size);
|
||||
if (item != NULL)
|
||||
mem_getstats(mctx, mpctx->size);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
if (item == NULL)
|
||||
break;
|
||||
@@ -1516,6 +1562,7 @@ isc__mempool_get(isc_mempool_t *mpctx FLARG) {
|
||||
mpctx->items = item;
|
||||
mpctx->freecount++;
|
||||
}
|
||||
UNLOCK(&mctx->lock);
|
||||
|
||||
/*
|
||||
* If we didn't get any items, return NULL.
|
||||
@@ -1576,6 +1623,9 @@ isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) {
|
||||
UNLOCK(&mctx->lock);
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
mem_put(mctx, mem, mpctx->size);
|
||||
LOCK(&mctx->lock);
|
||||
mem_putstats(mctx, mem, mpctx->size);
|
||||
UNLOCK(&mctx->lock);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
if (mpctx->lock != NULL)
|
||||
UNLOCK(mpctx->lock);
|
||||
|
||||
@@ -15,18 +15,8 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: condition.c,v 1.4 2001/04/13 02:26:30 tale Exp $ */
|
||||
/* $Id: condition.c,v 1.4.12.1 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
/*
|
||||
* This file intentionally left blank.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Well, not completely. The stupid hack below shuts up compilers
|
||||
* from complaining about an empty file.
|
||||
*/
|
||||
static void
|
||||
isc_condition_nothreads(void) {
|
||||
isc_condition_nothreads();
|
||||
}
|
||||
#include <isc/util.h>
|
||||
|
||||
EMPTY_TRANSLATION_UNIT
|
||||
|
||||
@@ -15,14 +15,9 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: mutex.c,v 1.4 2001/04/13 02:26:32 tale Exp $ */
|
||||
/* $Id: mutex.c,v 1.4.12.1 2003/10/07 03:28:36 marka Exp $ */
|
||||
|
||||
/*
|
||||
* Well, not completely. The stupid hack below shuts up compilers
|
||||
* from complaining about an empty file.
|
||||
*/
|
||||
static void
|
||||
isc_mutex_nothreads(void) {
|
||||
isc_mutex_nothreads();
|
||||
}
|
||||
#include <isc/util.h>
|
||||
|
||||
EMPTY_TRANSLATION_UNIT
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: sockaddr.c,v 1.48.2.1.2.5 2003/09/11 00:18:14 marka Exp $ */
|
||||
/* $Id: sockaddr.c,v 1.48.2.1.2.6 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -184,6 +184,7 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only) {
|
||||
const struct in6_addr *in6;
|
||||
|
||||
REQUIRE(sockaddr != NULL);
|
||||
|
||||
switch (sockaddr->type.sa.sa_family) {
|
||||
case AF_INET:
|
||||
s = (const unsigned char *)&sockaddr->type.sin.sin_addr;
|
||||
@@ -204,8 +205,8 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only) {
|
||||
default:
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_SOCKADDR,
|
||||
ISC_MSG_UNKNOWNFAMILY,
|
||||
ISC_MSGSET_SOCKADDR,
|
||||
ISC_MSG_UNKNOWNFAMILY,
|
||||
"unknown address family: %d"),
|
||||
(int)sockaddr->type.sa.sa_family);
|
||||
s = (const unsigned char *)&sockaddr->type;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: timer.c,v 1.64.12.6 2003/09/11 00:18:14 marka Exp $ */
|
||||
/* $Id: timer.c,v 1.64.12.7 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -132,7 +132,8 @@ schedule(isc_timer_t *timer, isc_time_t *now, isc_boolean_t signal_ok) {
|
||||
* If the manager was timed wait, we may need to signal the
|
||||
* manager to force a wakeup.
|
||||
*/
|
||||
timedwait = ISC_TF(manager->nscheduled > 0 && manager->due.seconds != 0);
|
||||
timedwait = ISC_TF(manager->nscheduled > 0 &&
|
||||
isc_time_seconds(&manager->due) != 0);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: app.c,v 1.43.2.3.8.2 2003/09/11 00:18:15 marka Exp $ */
|
||||
/* $Id: app.c,v 1.43.2.3.8.3 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -528,9 +528,6 @@ isc_app_run(void) {
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
while (isc__taskmgr_ready())
|
||||
(void)isc__taskmgr_dispatch();
|
||||
|
||||
#endif /* ISC_PLATFORM_USETHREADS */
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.4 2003/09/24 03:47:18 marka Exp $ */
|
||||
/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.5 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
/*
|
||||
* Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
|
||||
* See netintro(4).
|
||||
*/
|
||||
#ifdefined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
|
||||
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
|
||||
#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
|
||||
#define lifc_len iflc_len
|
||||
#define lifc_buf iflc_buf
|
||||
@@ -45,8 +46,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define IFITER_MAGIC ISC_MAGIC('I', 'F', 'I', 'T')
|
||||
#define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC)
|
||||
|
||||
@@ -97,6 +96,7 @@ getbuf4(isc_interfaceiter_t *iter) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
iter->bufsize = IFCONF_BUFSIZE_INITIAL;
|
||||
|
||||
for (;;) {
|
||||
iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
|
||||
if (iter->buf == NULL)
|
||||
@@ -116,10 +116,10 @@ getbuf4(isc_interfaceiter_t *iter) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"get interface "
|
||||
"configuration: %s"),
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_GETIFCONFIG,
|
||||
"get interface "
|
||||
"configuration: %s"),
|
||||
strbuf);
|
||||
goto unexpected;
|
||||
}
|
||||
@@ -143,7 +143,11 @@ getbuf4(isc_interfaceiter_t *iter) {
|
||||
if (iter->bufsize >= IFCONF_BUFSIZE_MAX) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERIOCTL, ISC_MSG_BUFFERMAX, "get interface " "configuration: " "maximum buffer "
|
||||
ISC_MSGSET_IFITERIOCTL,
|
||||
ISC_MSG_BUFFERMAX,
|
||||
"get interface "
|
||||
"configuration: "
|
||||
"maximum buffer "
|
||||
"size exceeded"));
|
||||
goto unexpected;
|
||||
}
|
||||
@@ -685,21 +689,6 @@ internal_current6(isc_interfaceiter_t *iter) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the interface does not have a address ignore it.
|
||||
*/
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (memcmp(&iter->current.address.type.in6, &in6addr_any,
|
||||
sizeof(in6addr_any)) == 0)
|
||||
return (ISC_R_IGNORE);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get interface flags.
|
||||
*/
|
||||
@@ -805,9 +794,9 @@ internal_current6(isc_interfaceiter_t *iter) {
|
||||
iter->current.netmask.family = family;
|
||||
for (i = 0; i < lifreq.lifr_addrlen; i += 8) {
|
||||
bits = lifreq.lifr_addrlen - i;
|
||||
bits = (bits < 8 ) ? (8-bits) : 0;
|
||||
iter->current.netmask.type.in6.s6_addr[i/8] =
|
||||
(~0 << bits) &0xff;
|
||||
bits = (bits < 8) ? (8 - bits) : 0;
|
||||
iter->current.netmask.type.in6.s6_addr[i / 8] =
|
||||
(~0 << bits) & 0xff;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: ifiter_sysctl.c,v 1.14.12.3 2003/09/11 00:18:16 marka Exp $ */
|
||||
/* $Id: ifiter_sysctl.c,v 1.14.12.4 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
/*
|
||||
* Obtain the list of network interfaces using sysctl.
|
||||
@@ -69,6 +69,8 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
isc_result_t result;
|
||||
size_t bufsize;
|
||||
size_t bufused;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(iterp != NULL);
|
||||
REQUIRE(*iterp == NULL);
|
||||
@@ -85,13 +87,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
*/
|
||||
bufsize = 0;
|
||||
if (sysctl(mib, 6, NULL, &bufsize, NULL, (size_t) 0) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERSYSCTL,
|
||||
ISC_MSG_GETIFLISTSIZE,
|
||||
"getting interface "
|
||||
"list size: sysctl: %s"),
|
||||
strerror(errno));
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto failure;
|
||||
}
|
||||
@@ -105,13 +108,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
|
||||
bufused = bufsize;
|
||||
if (sysctl(mib, 6, iter->buf, &bufused, NULL, (size_t) 0) < 0) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_IFITERSYSCTL,
|
||||
ISC_MSG_GETIFLIST,
|
||||
"getting interface list: "
|
||||
"sysctl: %s"),
|
||||
strerror(errno));
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto failure;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: strerror.h,v 1.2 2001/08/31 05:57:58 marka Exp $ */
|
||||
/* $Id: strerror.h,v 1.2.12.1 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
#ifndef ISC_STRERROR_H
|
||||
#define ISC_STRERROR_H
|
||||
@@ -30,12 +30,11 @@ ISC_LANG_BEGINDECLS
|
||||
|
||||
/*
|
||||
* Provide a thread safe wrapper to strerrror().
|
||||
* 'buf' is always returned.
|
||||
*
|
||||
* Requires:
|
||||
* 'buf' to be non NULL.
|
||||
*/
|
||||
char *
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t bufsize);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: time.h,v 1.25.2.1.10.1 2003/08/12 05:34:06 marka Exp $ */
|
||||
/* $Id: time.h,v 1.25.2.1.10.2 2003/10/07 03:28:38 marka Exp $ */
|
||||
|
||||
#ifndef ISC_TIME_H
|
||||
#define ISC_TIME_H 1
|
||||
@@ -57,7 +57,7 @@ isc_interval_set(isc_interval_t *i,
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_interval_iszero(isc_interval_t *i);
|
||||
isc_interval_iszero(const isc_interval_t *i);
|
||||
/*
|
||||
* Returns ISC_TRUE iff. 'i' is the zero interval.
|
||||
*
|
||||
@@ -115,7 +115,7 @@ isc_time_settoepoch(isc_time_t *t);
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_time_isepoch(isc_time_t *t);
|
||||
isc_time_isepoch(const isc_time_t *t);
|
||||
/*
|
||||
* Returns ISC_TRUE iff. 't' is the epoch ("time zero").
|
||||
*
|
||||
@@ -144,7 +144,7 @@ isc_time_now(isc_time_t *t);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i);
|
||||
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i);
|
||||
/*
|
||||
* Set *t to the current absolute time + i.
|
||||
*
|
||||
@@ -169,7 +169,7 @@ isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i);
|
||||
*/
|
||||
|
||||
int
|
||||
isc_time_compare(isc_time_t *t1, isc_time_t *t2);
|
||||
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*
|
||||
* Compare the times referenced by 't1' and 't2'
|
||||
*
|
||||
@@ -185,7 +185,7 @@ isc_time_compare(isc_time_t *t1, isc_time_t *t2);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result);
|
||||
/*
|
||||
* Add 'i' to 't', storing the result in 'result'.
|
||||
*
|
||||
@@ -201,7 +201,8 @@ isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
|
||||
isc_time_t *result);
|
||||
/*
|
||||
* Subtract 'i' from 't', storing the result in 'result'.
|
||||
*
|
||||
@@ -216,7 +217,7 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
*/
|
||||
|
||||
isc_uint64_t
|
||||
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2);
|
||||
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*
|
||||
* Find the difference in microseconds between time t1 and time t2.
|
||||
* t2 is the subtrahend of t1; ie, difference = t1 - t2.
|
||||
@@ -230,7 +231,7 @@ isc_time_microdiff(isc_time_t *t1, isc_time_t *t2);
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_seconds(isc_time_t *t);
|
||||
isc_time_seconds(const isc_time_t *t);
|
||||
/*
|
||||
* Return the number of seconds since the epoch stored in a time structure.
|
||||
*
|
||||
@@ -240,7 +241,7 @@ isc_time_seconds(isc_time_t *t);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_secondsastimet(isc_time_t *t, time_t *secondsp);
|
||||
isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp);
|
||||
/*
|
||||
* Ensure the number of seconds in an isc_time_t is representable by a time_t.
|
||||
*
|
||||
@@ -263,7 +264,7 @@ isc_time_secondsastimet(isc_time_t *t, time_t *secondsp);
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_nanoseconds(isc_time_t *t);
|
||||
isc_time_nanoseconds(const isc_time_t *t);
|
||||
/*
|
||||
* Return the number of nanoseconds stored in a time structure.
|
||||
*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: interfaceiter.c,v 1.22.2.1.10.7 2003/09/11 00:18:16 marka Exp $ */
|
||||
/* $Id: interfaceiter.c,v 1.22.2.1.10.8 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -63,6 +63,9 @@ static void
|
||||
get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
||||
struct sockaddr_in6 *sa6;
|
||||
|
||||
/* clear any remaining value for safety */
|
||||
memset(dst, 0, sizeof(*dst));
|
||||
|
||||
dst->family = family;
|
||||
switch (family) {
|
||||
case AF_INET:
|
||||
@@ -77,9 +80,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
||||
#ifdef ISC_PLATFORM_HAVESCOPEID
|
||||
if (sa6->sin6_scope_id != 0)
|
||||
isc_netaddr_setzone(dst, sa6->sin6_scope_id);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
else {
|
||||
/*
|
||||
* BSD variants embed scope zone IDs in the 128bit
|
||||
* address as a kernel internal form. Unfortunately,
|
||||
@@ -105,6 +106,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: strerror.c,v 1.1.2.1 2001/10/22 23:28:25 gson Exp $ */
|
||||
/* $Id: strerror.c,v 1.1.2.1.10.1 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -41,7 +41,7 @@ extern const char * const sys_errlist[];
|
||||
extern const int sys_nerr;
|
||||
#endif
|
||||
|
||||
char *
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t size) {
|
||||
#ifdef HAVE_STRERROR
|
||||
char *msg;
|
||||
@@ -59,7 +59,6 @@ isc__strerror(int num, char *buf, size_t size) {
|
||||
else
|
||||
snprintf(buf, size, "Unknown error: %u", unum);
|
||||
UNLOCK(&isc_strerror_lock);
|
||||
return (buf);
|
||||
#else
|
||||
unsigned int unum = num;
|
||||
|
||||
@@ -69,6 +68,5 @@ isc__strerror(int num, char *buf, size_t size) {
|
||||
snprintf(buf, size, "%s", sys_errlist[num]);
|
||||
else
|
||||
snprintf(buf, size, "Unknown error: %u", unum);
|
||||
return (buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: time.c,v 1.34.2.6.2.2 2003/08/12 05:34:05 marka Exp $ */
|
||||
/* $Id: time.c,v 1.34.2.6.2.3 2003/10/07 03:28:37 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -93,7 +93,7 @@ isc_interval_set(isc_interval_t *i,
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_interval_iszero(isc_interval_t *i) {
|
||||
isc_interval_iszero(const isc_interval_t *i) {
|
||||
REQUIRE(i != NULL);
|
||||
INSIST(i->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -129,7 +129,7 @@ isc_time_settoepoch(isc_time_t *t) {
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_time_isepoch(isc_time_t *t) {
|
||||
isc_time_isepoch(const isc_time_t *t) {
|
||||
REQUIRE(t != NULL);
|
||||
INSIST(t->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -183,7 +183,7 @@ isc_time_now(isc_time_t *t) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
|
||||
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
|
||||
struct timeval tv;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
@@ -234,7 +234,7 @@ isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
|
||||
}
|
||||
|
||||
int
|
||||
isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
|
||||
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
|
||||
REQUIRE(t1 != NULL && t2 != NULL);
|
||||
INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -250,7 +250,8 @@ isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
|
||||
{
|
||||
REQUIRE(t != NULL && i != NULL && result != NULL);
|
||||
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -275,7 +276,9 @@ isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
|
||||
isc_time_t *result)
|
||||
{
|
||||
REQUIRE(t != NULL && i != NULL && result != NULL);
|
||||
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -297,7 +300,7 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
}
|
||||
|
||||
isc_uint64_t
|
||||
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
|
||||
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
|
||||
isc_uint64_t i1, i2, i3;
|
||||
|
||||
REQUIRE(t1 != NULL && t2 != NULL);
|
||||
@@ -320,7 +323,7 @@ isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_seconds(isc_time_t *t) {
|
||||
isc_time_seconds(const isc_time_t *t) {
|
||||
REQUIRE(t != NULL);
|
||||
INSIST(t->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -328,7 +331,7 @@ isc_time_seconds(isc_time_t *t) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_secondsastimet(isc_time_t *t, time_t *secondsp) {
|
||||
isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) {
|
||||
isc_uint64_t i;
|
||||
time_t seconds;
|
||||
|
||||
@@ -383,7 +386,7 @@ isc_time_secondsastimet(isc_time_t *t, time_t *secondsp) {
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_nanoseconds(isc_time_t *t) {
|
||||
isc_time_nanoseconds(const isc_time_t *t) {
|
||||
REQUIRE(t != NULL);
|
||||
|
||||
ENSURE(t->nanoseconds < NS_PER_S);
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: version.c,v 1.9 2001/01/09 21:56:38 bwelling Exp $ */
|
||||
/* $Id: version.c,v 1.9.12.1 2003/10/07 03:28:34 marka Exp $ */
|
||||
|
||||
char isc_version[] = VERSION;
|
||||
#include <isc/version.h>
|
||||
|
||||
unsigned int isc_libinterface = LIBINTERFACE;
|
||||
unsigned int isc_librevision = LIBREVISION;
|
||||
unsigned int isc_libage = LIBAGE;
|
||||
const char isc_version[] = VERSION;
|
||||
|
||||
const unsigned int isc_libinterface = LIBINTERFACE;
|
||||
const unsigned int isc_librevision = LIBREVISION;
|
||||
const unsigned int isc_libage = LIBAGE;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2000-2003 Internet Software Consortium.
|
||||
* Copyright (C) 2000-2002 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
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: errno2result.c,v 1.4.2.5 2003/07/22 04:03:50 marka Exp $ */
|
||||
/* $Id: errno2result.c,v 1.4.2.5.2.1 2003/10/07 03:28:38 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -38,13 +38,17 @@ isc__errno2result(int posixerrno) {
|
||||
switch (posixerrno) {
|
||||
case ENOTDIR:
|
||||
case WSAELOOP:
|
||||
case WSAEINVAL:
|
||||
case EINVAL: /* XXX sometimes this is not for files */
|
||||
case ENAMETOOLONG:
|
||||
case WSAENAMETOOLONG:
|
||||
case EBADF:
|
||||
case WSAEBADF:
|
||||
return (ISC_R_INVALIDFILE);
|
||||
case ENOENT:
|
||||
return (ISC_R_FILENOTFOUND);
|
||||
case EACCES:
|
||||
case WSAEACCES:
|
||||
case EPERM:
|
||||
return (ISC_R_NOPERM);
|
||||
case EEXIST:
|
||||
@@ -55,6 +59,7 @@ isc__errno2result(int posixerrno) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
case ENFILE:
|
||||
case EMFILE:
|
||||
case WSAEMFILE:
|
||||
return (ISC_R_TOOMANYOPENFILES);
|
||||
default:
|
||||
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
||||
@@ -71,3 +76,4 @@ isc__errno2result(int posixerrno) {
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: errno2result.h,v 1.4 2001/07/17 20:29:25 gson Exp $ */
|
||||
/* $Id: errno2result.h,v 1.4.12.1 2003/10/07 03:28:38 marka Exp $ */
|
||||
|
||||
#ifndef UNIX_ERRNO2RESULT_H
|
||||
#define UNIX_ERRNO2RESULT_H 1
|
||||
@@ -32,15 +32,6 @@ ISC_LANG_BEGINDECLS
|
||||
isc_result_t
|
||||
isc__errno2result(int posixerrno);
|
||||
|
||||
char *
|
||||
isc_FormatError(int error);
|
||||
|
||||
char *
|
||||
GetWSAErrorMessage(int errval);
|
||||
|
||||
char * __cdecl
|
||||
NTstrerror(int err);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* UNIX_ERRNO2RESULT_H */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: file.c,v 1.20.2.4 2002/03/26 00:55:11 marka Exp $ */
|
||||
/* $Id: file.c,v 1.20.2.4.8.1 2003/10/07 03:28:38 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -183,9 +183,8 @@ isc_file_safemovefile(const char *oldname, const char *newname) {
|
||||
*/
|
||||
if (exists == TRUE) {
|
||||
filestatus = MoveFile(buf, newname);
|
||||
if (filestatus == 0) {
|
||||
if (filestatus == 0)
|
||||
errno = EACCES;
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
@@ -488,3 +487,21 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen) {
|
||||
return (ISC_R_NOSPACE);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_file_truncate(const char *filename, isc_offset_t size) {
|
||||
int fh;
|
||||
|
||||
REQUIRE(filename != NULL && size >= 0);
|
||||
|
||||
if ((fh = open(filename, _O_RDWR | _O_BINARY)) < 0)
|
||||
return (isc__errno2result(errno));
|
||||
|
||||
if(_chsize(fh, size) != 0) {
|
||||
close(fh);
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
close(fh);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: fsaccess.c,v 1.9 2001/07/09 21:06:07 gson Exp $ */
|
||||
/* $Id: fsaccess.c,v 1.9.12.1 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
/*
|
||||
* Note that Win32 does not have the concept of files having access
|
||||
@@ -29,11 +29,14 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <aclapi.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <isc/file.h>
|
||||
#include <isc/stat.h>
|
||||
|
||||
#include "errno2result.h"
|
||||
@@ -43,25 +46,74 @@
|
||||
*/
|
||||
#include "../fsaccess.c"
|
||||
|
||||
/* Store the user account name locally */
|
||||
static char username[255] = "\0";
|
||||
static DWORD namelen = 0;
|
||||
|
||||
/*
|
||||
* In order to set or retrieve access information, we need to obtain
|
||||
* the File System type. These could be UNC-type shares.
|
||||
*/
|
||||
|
||||
BOOL
|
||||
is_ntfs(const char * file) {
|
||||
|
||||
char drive[255];
|
||||
char FSType[20];
|
||||
char tmpbuf[256];
|
||||
char *machinename;
|
||||
char *sharename;
|
||||
char filename[1024];
|
||||
|
||||
REQUIRE(filename != NULL);
|
||||
|
||||
if (isc_file_absolutepath(file, filename,
|
||||
sizeof(filename)) != ISC_R_SUCCESS) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for c:\path\... style, c:/path/... or \\computer\shar\path...
|
||||
* the UNC style file specs
|
||||
*/
|
||||
if (isalpha(filename[0]) && filename[1] == ':' &&
|
||||
(filename[2] == '\\' || filename[2] == '/')) {
|
||||
strncpy(drive, filename, 3);
|
||||
drive[3] = '\0';
|
||||
}
|
||||
|
||||
else if ((filename[0] == '\\') && (filename[1] == '\\')) {
|
||||
/* Find the machine and share name and rebuild the UNC */
|
||||
strcpy(tmpbuf, filename);
|
||||
machinename = strtok(tmpbuf, "\\");
|
||||
sharename = strtok(NULL, "\\");
|
||||
strcpy(drive, "\\\\");
|
||||
strcat(drive, machinename);
|
||||
strcat(drive, "\\");
|
||||
strcat(drive, sharename);
|
||||
strcat(drive, "\\");
|
||||
|
||||
}
|
||||
else /* Not determinable */
|
||||
return (FALSE);
|
||||
|
||||
GetVolumeInformation(drive, NULL, 0, NULL, 0, NULL, FSType,
|
||||
sizeof(FSType));
|
||||
if(strcmp(FSType,"NTFS") == 0)
|
||||
return (TRUE);
|
||||
else
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* If it's not NTFS, we assume that it is FAT and proceed
|
||||
* with almost nothing to do. Only the write flag can be set or
|
||||
* cleared.
|
||||
*/
|
||||
isc_result_t
|
||||
isc_fsaccess_set(const char *path, isc_fsaccess_t access) {
|
||||
struct stat statb;
|
||||
FAT_fsaccess_set(const char *path, isc_fsaccess_t access) {
|
||||
int mode;
|
||||
isc_boolean_t is_dir = ISC_FALSE;
|
||||
isc_fsaccess_t bits;
|
||||
isc_result_t result;
|
||||
|
||||
if (stat(path, &statb) != 0)
|
||||
return (isc__errno2result(errno));
|
||||
|
||||
if ((statb.st_mode & S_IFDIR) != 0)
|
||||
is_dir = ISC_TRUE;
|
||||
else if ((statb.st_mode & S_IFREG) == 0)
|
||||
return (ISC_R_INVALIDFILE);
|
||||
|
||||
result = check_bad_bits(access, is_dir);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Done with checking bad bits. Set mode_t.
|
||||
@@ -90,16 +142,6 @@ isc_fsaccess_set(const char *path, isc_fsaccess_t access) {
|
||||
|
||||
SET_AND_CLEAR(S_IWUSR, S_IWGRP, S_IWOTH);
|
||||
|
||||
#ifdef notyet
|
||||
/*
|
||||
* WIN32 doesn't have the concept of execute bits. We leave this here
|
||||
* for when we review this module.
|
||||
*/
|
||||
bits = ISC_FSACCESS_EXECUTE |
|
||||
ISC_FSACCESS_ACCESSCHILD;
|
||||
|
||||
SET_AND_CLEAR(S_IXUSR, S_IXGRP, S_IXOTH);
|
||||
#endif
|
||||
INSIST(access == 0);
|
||||
|
||||
if (_chmod(path, mode) < 0)
|
||||
@@ -107,3 +149,227 @@ isc_fsaccess_set(const char *path, isc_fsaccess_t access) {
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
NTFS_Access_Control(const char *filename, const char *user, int access,
|
||||
isc_boolean_t isdir) {
|
||||
SECURITY_DESCRIPTOR sd;
|
||||
BYTE aclBuffer[1024];
|
||||
PACL pacl=(PACL)&aclBuffer;
|
||||
BYTE sidBuffer[100];
|
||||
PSID psid=(PSID) &sidBuffer;
|
||||
DWORD sidBufferSize = sizeof(sidBuffer);
|
||||
BYTE adminSidBuffer[100];
|
||||
PSID padminsid=(PSID) &adminSidBuffer;
|
||||
DWORD adminSidBufferSize = sizeof(adminSidBuffer);
|
||||
BYTE otherSidBuffer[100];
|
||||
PSID pothersid=(PSID) &otherSidBuffer;
|
||||
DWORD otherSidBufferSize = sizeof(otherSidBuffer);
|
||||
char domainBuffer[100];
|
||||
DWORD domainBufferSize = sizeof(domainBuffer);
|
||||
SID_NAME_USE snu;
|
||||
int errval;
|
||||
DWORD NTFSbits;
|
||||
int caccess;
|
||||
|
||||
|
||||
/* Initialize an ACL */
|
||||
if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
|
||||
return (ISC_R_NOPERM);
|
||||
if (!InitializeAcl(pacl, sizeof(aclBuffer), ACL_REVISION))
|
||||
return (ISC_R_NOPERM);
|
||||
if (!LookupAccountName(0, user, psid, &sidBufferSize, domainBuffer,
|
||||
&domainBufferSize, &snu))
|
||||
return (ISC_R_NOPERM);
|
||||
domainBufferSize = sizeof(domainBuffer);
|
||||
if (!LookupAccountName(0, "Administrators", padminsid,
|
||||
&adminSidBufferSize, domainBuffer, &domainBufferSize, &snu)) {
|
||||
errval = GetLastError();
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
domainBufferSize = sizeof(domainBuffer);
|
||||
if (!LookupAccountName(0, "Everyone", pothersid,
|
||||
&otherSidBufferSize, domainBuffer, &domainBufferSize, &snu)) {
|
||||
errval = GetLastError();
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
|
||||
caccess = access;
|
||||
/* Owner check */
|
||||
|
||||
NTFSbits = 0;
|
||||
if (caccess & ISC_FSACCESS_READ)
|
||||
NTFSbits |= FILE_GENERIC_READ;
|
||||
if (caccess & ISC_FSACCESS_WRITE)
|
||||
NTFSbits |= FILE_GENERIC_WRITE;
|
||||
if (caccess & ISC_FSACCESS_EXECUTE)
|
||||
NTFSbits |= FILE_GENERIC_EXECUTE;
|
||||
|
||||
/* For directories check the directory-specific bits */
|
||||
if (isdir == ISC_TRUE) {
|
||||
if (caccess & ISC_FSACCESS_CREATECHILD)
|
||||
NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE;
|
||||
if (caccess & ISC_FSACCESS_DELETECHILD)
|
||||
NTFSbits |= FILE_DELETE_CHILD;
|
||||
if (caccess & ISC_FSACCESS_LISTDIRECTORY)
|
||||
NTFSbits |= FILE_LIST_DIRECTORY;
|
||||
if (caccess & ISC_FSACCESS_ACCESSCHILD)
|
||||
NTFSbits |= FILE_TRAVERSE;
|
||||
}
|
||||
|
||||
if (NTFSbits == (FILE_GENERIC_READ | FILE_GENERIC_WRITE
|
||||
| FILE_GENERIC_EXECUTE))
|
||||
NTFSbits |= FILE_ALL_ACCESS;
|
||||
/*
|
||||
* Owner and Administrator also get STANDARD_RIGHTS_ALL
|
||||
* to ensure that they have full control
|
||||
*/
|
||||
|
||||
NTFSbits |= STANDARD_RIGHTS_ALL;
|
||||
|
||||
/* Add the ACE to the ACL */
|
||||
if (!AddAccessAllowedAce(pacl, ACL_REVISION, NTFSbits, psid))
|
||||
return (ISC_R_NOPERM);
|
||||
if (!AddAccessAllowedAce(pacl, ACL_REVISION, NTFSbits, padminsid))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
/*
|
||||
* Group is ignored since we can be in multiple groups or no group
|
||||
* and its meaning is not clear on Win32
|
||||
*/
|
||||
|
||||
caccess = caccess >> STEP;
|
||||
|
||||
/*
|
||||
* Other check. We translate this to be the same as Everyone
|
||||
*/
|
||||
|
||||
caccess = caccess >> STEP;
|
||||
|
||||
NTFSbits = 0;
|
||||
if (caccess & ISC_FSACCESS_READ)
|
||||
NTFSbits |= FILE_GENERIC_READ;
|
||||
if (caccess & ISC_FSACCESS_WRITE)
|
||||
NTFSbits |= FILE_GENERIC_WRITE;
|
||||
if (caccess & ISC_FSACCESS_EXECUTE)
|
||||
NTFSbits |= FILE_GENERIC_EXECUTE;
|
||||
|
||||
/* For directories check the directory-specific bits */
|
||||
if (isdir == TRUE) {
|
||||
if (caccess & ISC_FSACCESS_CREATECHILD)
|
||||
NTFSbits |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE;
|
||||
if (caccess & ISC_FSACCESS_DELETECHILD)
|
||||
NTFSbits |= FILE_DELETE_CHILD;
|
||||
if (caccess & ISC_FSACCESS_LISTDIRECTORY)
|
||||
NTFSbits |= FILE_LIST_DIRECTORY;
|
||||
if (caccess & ISC_FSACCESS_ACCESSCHILD)
|
||||
NTFSbits |= FILE_TRAVERSE;
|
||||
}
|
||||
/* Add the ACE to the ACL */
|
||||
if (!AddAccessAllowedAce(pacl, ACL_REVISION, NTFSbits,
|
||||
pothersid))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
if (!SetSecurityDescriptorDacl(&sd, TRUE, pacl, FALSE))
|
||||
return (ISC_R_NOPERM);
|
||||
if (!SetFileSecurity(filename, DACL_SECURITY_INFORMATION, &sd)) {
|
||||
return (ISC_R_NOPERM);
|
||||
}
|
||||
|
||||
return(ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
NTFS_fsaccess_set(const char *path, isc_fsaccess_t access,
|
||||
isc_boolean_t isdir){
|
||||
|
||||
/*
|
||||
* For NTFS we first need to get the name of the account under
|
||||
* which BIND is running
|
||||
*/
|
||||
if (namelen <= 0) {
|
||||
namelen = sizeof(username);
|
||||
if (GetUserName(username, &namelen) == 0)
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
return (NTFS_Access_Control(path, username, access, isdir));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_fsaccess_set(const char *path, isc_fsaccess_t access) {
|
||||
struct stat statb;
|
||||
isc_boolean_t is_dir = ISC_FALSE;
|
||||
isc_result_t result;
|
||||
|
||||
if (stat(path, &statb) != 0)
|
||||
return (isc__errno2result(errno));
|
||||
|
||||
if ((statb.st_mode & S_IFDIR) != 0)
|
||||
is_dir = ISC_TRUE;
|
||||
else if ((statb.st_mode & S_IFREG) == 0)
|
||||
return (ISC_R_INVALIDFILE);
|
||||
|
||||
result = check_bad_bits(access, is_dir);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
/*
|
||||
* Determine if this is a FAT or NTFS disk and
|
||||
* call the appropriate function to set the permissions
|
||||
*/
|
||||
if (is_ntfs(path))
|
||||
return (NTFS_fsaccess_set(path, access, is_dir));
|
||||
else
|
||||
return (FAT_fsaccess_set(path, access));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_fsaccess_changeowner(const char *filename, const char *user) {
|
||||
SECURITY_DESCRIPTOR psd;
|
||||
BYTE sidBuffer[500];
|
||||
BYTE groupBuffer[500];
|
||||
PSID psid=(PSID) &sidBuffer;
|
||||
DWORD sidBufferSize = sizeof(sidBuffer);
|
||||
char domainBuffer[100];
|
||||
DWORD domainBufferSize = sizeof(domainBuffer);
|
||||
SID_NAME_USE snu;
|
||||
PSID pSidGroup = (PSID) &groupBuffer;
|
||||
DWORD groupBufferSize = sizeof(groupBuffer);
|
||||
|
||||
|
||||
/*
|
||||
* Determine if this is a FAT or NTFS disk and
|
||||
* call the appropriate function to set the ownership
|
||||
* FAT disks do not have ownership attributes so it's
|
||||
* a noop.
|
||||
*/
|
||||
if (is_ntfs(filename) == FALSE)
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
if (!InitializeSecurityDescriptor(&psd, SECURITY_DESCRIPTOR_REVISION))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
if (!LookupAccountName(0, user, psid, &sidBufferSize, domainBuffer,
|
||||
&domainBufferSize, &snu))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
/* Make sure administrators can get to it */
|
||||
domainBufferSize = sizeof(domainBuffer);
|
||||
if (!LookupAccountName(0, "Administrators", pSidGroup,
|
||||
&groupBufferSize, domainBuffer, &domainBufferSize, &snu))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
if (!SetSecurityDescriptorOwner(&psd, psid, FALSE))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
if (!SetSecurityDescriptorGroup(&psd, pSidGroup, FALSE))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
if (!SetFileSecurity(filename,
|
||||
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
|
||||
&psd))
|
||||
return (ISC_R_NOPERM);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: bind_registry.h,v 1.4 2001/07/09 21:34:41 gson Exp $ */
|
||||
/* $Id: bind_registry.h,v 1.4.12.1 2003/10/07 03:28:40 marka Exp $ */
|
||||
|
||||
#ifndef ISC_BINDREGISTRY_H
|
||||
#define ISC_BINDREGISTRY_H
|
||||
@@ -37,6 +37,10 @@
|
||||
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\named"
|
||||
#define BIND_MESSAGE_NAME "named"
|
||||
|
||||
#define BIND_SERVICE_SUBKEY \
|
||||
"SYSTEM\\CurrentControlSet\\Services\\named"
|
||||
|
||||
|
||||
#define BIND_CONFIGFILE 0
|
||||
#define BIND_DEBUGLEVEL 1
|
||||
#define BIND_QUERYLOG 2
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: ipv6.h,v 1.9.2.2 2003/07/22 04:03:52 marka Exp $ */
|
||||
/* $Id: ipv6.h,v 1.9.2.2.2.1 2003/10/07 03:28:40 marka Exp $ */
|
||||
|
||||
#ifndef ISC_IPV6_H
|
||||
#define ISC_IPV6_H 1
|
||||
@@ -25,18 +25,24 @@
|
||||
*****/
|
||||
|
||||
/*
|
||||
* This file defines additional information necessary for IP v6 support
|
||||
* IPv6 definitions for systems which do not support IPv6.
|
||||
*
|
||||
* MP:
|
||||
* No impact.
|
||||
*
|
||||
* Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
* N/A.
|
||||
*
|
||||
* Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* Standards:
|
||||
* RFC 2553.
|
||||
*/
|
||||
|
||||
#ifndef AF_INET6
|
||||
#define AF_INET6 99
|
||||
#endif
|
||||
|
||||
#ifndef PF_INET6
|
||||
#define PF_INET6 AF_INET6
|
||||
#endif
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#define s6_addr8 s6_addr
|
||||
#define in6_addr in_addr6
|
||||
|
||||
@@ -46,52 +52,45 @@
|
||||
LIBISC_EXTERNAL_DATA extern const struct in_addr6 in6addr_any;
|
||||
LIBISC_EXTERNAL_DATA extern const struct in_addr6 in6addr_loopback;
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
struct in6_pktinfo {
|
||||
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
||||
unsigned int ipi6_ifindex; /* send/recv interface index */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Unspecified
|
||||
*/
|
||||
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(x) \
|
||||
*((u_long *)((x)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 3) == 1 \
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
*((u_long *)((a)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 3) == 0 \
|
||||
)
|
||||
|
||||
/*
|
||||
* Loopback
|
||||
*/
|
||||
#define IN6_IS_ADDR_LOOPBACK(x) (\
|
||||
*((u_long *)((x)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 3) == 1 \
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) (\
|
||||
*((u_long *)((a)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 3) == htonl(1) \
|
||||
)
|
||||
|
||||
/*
|
||||
* IPv4 compatible
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4COMPAT(x) (\
|
||||
*((u_long *)((x)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 3) != 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 3) != htonl(1) \
|
||||
#define IN6_IS_ADDR_V4COMPAT(a) (\
|
||||
*((u_long *)((a)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 2) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 3) != 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 3) != htonl(1) \
|
||||
)
|
||||
|
||||
/*
|
||||
* Mapped
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4MAPPED(x) (\
|
||||
*((u_long *)((x)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((x)->s6_addr) + 2) == htonl(0x0000ffff))
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) (\
|
||||
*((u_long *)((a)->s6_addr) ) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 1) == 0 && \
|
||||
*((u_long *)((a)->s6_addr) + 2) == htonl(0x0000ffff))
|
||||
|
||||
/*
|
||||
* Multicast
|
||||
@@ -99,8 +98,14 @@ struct in6_pktinfo {
|
||||
#define IN6_IS_ADDR_MULTICAST(a) \
|
||||
((a)->s6_addr8[0] == 0xffU)
|
||||
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
/*
|
||||
* Unicast link / site local.
|
||||
*/
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) (\
|
||||
(*((u_long *)((a)->s6_addr) ) == 0xfe) && \
|
||||
((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0x80))
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) (\
|
||||
(*((u_long *)((a)->s6_addr) ) == 0xfe) && \
|
||||
((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0xc0))
|
||||
|
||||
#endif /* ISC_IPV6_H */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: net.h,v 1.15.12.3 2003/09/24 03:47:20 marka Exp $ */
|
||||
/* $Id: net.h,v 1.15.12.4 2003/10/07 03:28:40 marka Exp $ */
|
||||
|
||||
#ifndef ISC_NET_H
|
||||
#define ISC_NET_H 1
|
||||
@@ -105,6 +105,18 @@
|
||||
* a variable
|
||||
*/
|
||||
#undef interface
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
#define INADDR_LOOPBACK 0x7f000001UL
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
struct in6_pktinfo {
|
||||
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
||||
unsigned int ipi6_ifindex; /* send/recv interface index */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ensure type in_port_t is defined.
|
||||
*/
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 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.
|
||||
*/
|
||||
|
||||
/* $Id: ntfile.h,v 1.5 2001/07/16 03:52:14 mayer Exp $ */
|
||||
|
||||
#ifndef ISC_NTFILE_H
|
||||
#define ISC_NTFILE_H 1
|
||||
|
||||
/*
|
||||
* This file has been necessitated by the fact that the iov array is local
|
||||
* to the module, so passing the FILE ptr to a file I/O function in a
|
||||
* different module or DLL will cause the application to fail to find the
|
||||
* I/O channel and the application will terminate. The standard file I/O
|
||||
* functions are redefined to call these routines instead and there will
|
||||
* be just the one iov to deal with.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Outside of lib isc we need to redefine these functions
|
||||
* This is due to the way _iob is set up.
|
||||
* liblwres should not use this.
|
||||
*/
|
||||
|
||||
#if !defined(LIBISC_EXPORTS) && !defined(LIBLWRES_EXPORTS)
|
||||
|
||||
#undef fdopen
|
||||
#undef getc
|
||||
|
||||
#define fopen isc_ntfile_fopen
|
||||
#define fclose isc_ntfile_fclose
|
||||
#define fwrite isc_ntfile_fwrite
|
||||
#define fread isc_ntfile_fread
|
||||
#define fseek isc_ntfile_fseek
|
||||
#define fflush isc_ntfile_flush
|
||||
#define fsync isc_ntfile_sync
|
||||
#define printf isc_ntfile_printf
|
||||
#define fprintf isc_ntfile_fprintf
|
||||
#define vfprintf isc_ntfile_vfprintf
|
||||
#define getc isc_ntfile_getc
|
||||
#define fgetc isc_ntfile_fgetc
|
||||
#define fgets isc_ntfile_fgets
|
||||
#define fputc isc_ntfile_fputc
|
||||
#define fputs isc_ntfile_fputs
|
||||
#define fgetpos isc_ntfile_fgetpos
|
||||
#define freopen isc_ntfile_freopen
|
||||
#define fdopen isc_ntfile_fdopen
|
||||
#define open isc_ntfile_open
|
||||
#define close isc_ntfile_close
|
||||
#define read isc_ntfile_read
|
||||
#define write isc_ntfile_write
|
||||
|
||||
#undef stdin
|
||||
#undef stdout
|
||||
#undef stderr
|
||||
|
||||
#define stdin isc_ntfile_getaddress(0)
|
||||
#define stdout isc_ntfile_getaddress(1)
|
||||
#define stderr isc_ntfile_getaddress(2)
|
||||
|
||||
#endif
|
||||
|
||||
FILE*
|
||||
isc_ntfile_fopen(const char *filename, const char *mode);
|
||||
|
||||
int
|
||||
isc_ntfile_fclose(FILE *f);
|
||||
|
||||
int
|
||||
isc_ntfile_fseek(FILE *f, long offset, int whence);
|
||||
|
||||
size_t
|
||||
isc_ntfile_fread(void *ptr, size_t size, size_t nmemb, FILE *f);
|
||||
|
||||
size_t
|
||||
isc_ntfile_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f);
|
||||
|
||||
int
|
||||
isc_ntfile_flush(FILE *f);
|
||||
|
||||
int
|
||||
isc_ntfile_sync(FILE *f);
|
||||
|
||||
FILE*
|
||||
isc_ntfile_getaddress(int r);
|
||||
|
||||
int
|
||||
isc_ntfile_printf(const char *format, ...);
|
||||
|
||||
int
|
||||
isc_ntfile_fprintf(FILE *fp, const char *format, ...);
|
||||
|
||||
int
|
||||
isc_ntfile_vfprintf(FILE *, const char *, va_list);
|
||||
|
||||
int
|
||||
isc_ntfile_fputc(int iv, FILE *fp);
|
||||
|
||||
int
|
||||
isc_ntfile_fputs(const char *bf, FILE *fp);
|
||||
|
||||
int
|
||||
isc_ntfile_fgetc(FILE *fp);
|
||||
|
||||
int
|
||||
isc_ntfile_fgetpos(FILE *, fpos_t *pos);
|
||||
|
||||
char *
|
||||
isc_ntfile_fgets(char *ch, int r, FILE *fp);
|
||||
|
||||
int
|
||||
isc_ntfile_getc(FILE *fp);
|
||||
|
||||
FILE *
|
||||
isc_ntfile_freopen(const char *path, const char *mode, FILE *fp);
|
||||
|
||||
FILE *
|
||||
isc_ntfile_fdopen(int handle, const char *mode);
|
||||
|
||||
int
|
||||
isc_ntfile_open(const char *fn, int flags, ...);
|
||||
|
||||
int
|
||||
isc_ntfile_close(int fd);
|
||||
|
||||
int
|
||||
isc_ntfile_read(int fd, char *buf, int len);
|
||||
|
||||
int
|
||||
isc_ntfile_write(int fd, char *buf, int len);
|
||||
|
||||
#endif /* ISC_NTFILE_H */
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: platform.h,v 1.5 2001/07/26 03:15:15 mayer Exp $ */
|
||||
/* $Id: platform.h,v 1.5.12.1 2003/10/07 03:28:41 marka Exp $ */
|
||||
|
||||
#ifndef ISC_PLATFORM_H
|
||||
#define ISC_PLATFORM_H 1
|
||||
@@ -56,27 +56,33 @@
|
||||
*/
|
||||
|
||||
#ifdef LIBISC_EXPORTS
|
||||
#define LIBISC_EXTERNAL_DATA __declspec( dllexport )
|
||||
#define LIBISC_EXTERNAL_DATA __declspec(dllexport)
|
||||
#else
|
||||
#define LIBISC_EXTERNAL_DATA __declspec( dllimport )
|
||||
#define LIBISC_EXTERNAL_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef LIBISCCFG_EXPORTS
|
||||
#define LIBISCCFG_EXTERNAL_DATA __declspec( dllexport )
|
||||
#define LIBISCCFG_EXTERNAL_DATA __declspec(dllexport)
|
||||
#else
|
||||
#define LIBISCCFG_EXTERNAL_DATA __declspec( dllimport )
|
||||
#define LIBISCCFG_EXTERNAL_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef LIBISCCC_EXPORTS
|
||||
#define LIBISCCC_EXTERNAL_DATA __declspec( dllexport )
|
||||
#define LIBISCCC_EXTERNAL_DATA __declspec(dllexport)
|
||||
#else
|
||||
#define LIBISCCC_EXTERNAL_DATA __declspec( dllimport )
|
||||
#define LIBISCCC_EXTERNAL_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef LIBDNS_EXPORTS
|
||||
#define LIBDNS_EXTERNAL_DATA __declspec( dllexport )
|
||||
#define LIBDNS_EXTERNAL_DATA __declspec(dllexport)
|
||||
#else
|
||||
#define LIBDNS_EXTERNAL_DATA __declspec( dllimport )
|
||||
#define LIBDNS_EXTERNAL_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef LIBBIND9_EXPORTS
|
||||
#define LIBBIND9_EXTERNAL_DATA __declspec(dllexport)
|
||||
#else
|
||||
#define LIBBIND9_EXTERNAL_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif /* ISC_PLATFORM_H */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: time.h,v 1.19.2.1.10.1 2003/08/12 05:34:06 marka Exp $ */
|
||||
/* $Id: time.h,v 1.19.2.1.10.2 2003/10/07 03:28:41 marka Exp $ */
|
||||
|
||||
#ifndef ISC_TIME_H
|
||||
#define ISC_TIME_H 1
|
||||
@@ -39,7 +39,7 @@ struct isc_interval {
|
||||
isc_int64_t interval;
|
||||
};
|
||||
|
||||
extern isc_interval_t *isc_interval_zero;
|
||||
LIBISC_EXTERNAL_DATA extern isc_interval_t *isc_interval_zero;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
@@ -58,7 +58,7 @@ isc_interval_set(isc_interval_t *i,
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_interval_iszero(isc_interval_t *i);
|
||||
isc_interval_iszero(const isc_interval_t *i);
|
||||
/*
|
||||
* Returns ISC_TRUE iff. 'i' is the zero interval.
|
||||
*
|
||||
@@ -82,7 +82,7 @@ struct isc_time {
|
||||
FILETIME absolute;
|
||||
};
|
||||
|
||||
extern isc_time_t *isc_time_epoch;
|
||||
LIBISC_EXTERNAL_DATA extern isc_time_t *isc_time_epoch;
|
||||
|
||||
void
|
||||
isc_time_settoepoch(isc_time_t *t);
|
||||
@@ -98,7 +98,7 @@ isc_time_settoepoch(isc_time_t *t);
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_time_isepoch(isc_time_t *t);
|
||||
isc_time_isepoch(const isc_time_t *t);
|
||||
/*
|
||||
* Returns ISC_TRUE iff. 't' is the epoch ("time zero").
|
||||
*
|
||||
@@ -127,7 +127,7 @@ isc_time_now(isc_time_t *t);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i);
|
||||
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i);
|
||||
/*
|
||||
* Set *t to the current absolute time + i.
|
||||
*
|
||||
@@ -152,7 +152,7 @@ isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i);
|
||||
*/
|
||||
|
||||
int
|
||||
isc_time_compare(isc_time_t *t1, isc_time_t *t2);
|
||||
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*
|
||||
* Compare the times referenced by 't1' and 't2'
|
||||
*
|
||||
@@ -168,7 +168,7 @@ isc_time_compare(isc_time_t *t1, isc_time_t *t2);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result);
|
||||
/*
|
||||
* Add 'i' to 't', storing the result in 'result'.
|
||||
*
|
||||
@@ -184,7 +184,8 @@ isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
|
||||
isc_time_t *result);
|
||||
/*
|
||||
* Subtract 'i' from 't', storing the result in 'result'.
|
||||
*
|
||||
@@ -199,7 +200,7 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
|
||||
*/
|
||||
|
||||
isc_uint64_t
|
||||
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2);
|
||||
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*
|
||||
* Find the difference in milliseconds between time t1 and time t2.
|
||||
* t2 is the subtrahend of t1; ie, difference = t1 - t2.
|
||||
@@ -213,7 +214,7 @@ isc_time_microdiff(isc_time_t *t1, isc_time_t *t2);
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_nanoseconds(isc_time_t *t);
|
||||
isc_time_nanoseconds(const isc_time_t *t);
|
||||
/*
|
||||
* Return the number of nanoseconds stored in a time structure.
|
||||
*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: interfaceiter.c,v 1.4.12.1 2003/09/11 00:18:16 marka Exp $ */
|
||||
/* $Id: interfaceiter.c,v 1.4.12.2 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
/*
|
||||
* Note that this code will need to be revisited to support IPv6 Interfaces.
|
||||
@@ -35,9 +35,9 @@
|
||||
#include <isc/mem.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
#include "errno2result.h"
|
||||
|
||||
/* Common utility functions */
|
||||
|
||||
@@ -101,6 +101,7 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
isc_interfaceiter_t *iter;
|
||||
isc_result_t result;
|
||||
int error;
|
||||
@@ -122,9 +123,11 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
* SIO_GET_INTERFACE_LIST WSAIoctl on.
|
||||
*/
|
||||
if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
error = WSAGetLastError();
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"making interface scan socket: %s",
|
||||
strerror(errno));
|
||||
"making interface scan socket: %s",
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto socket_failure;
|
||||
}
|
||||
@@ -144,15 +147,15 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
|
||||
|
||||
if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST,
|
||||
0, 0, iter->buf, iter->bufsize,
|
||||
&bytesReturned, 0, 0)
|
||||
== SOCKET_ERROR)
|
||||
&bytesReturned, 0, 0) == SOCKET_ERROR)
|
||||
{
|
||||
error = WSAGetLastError();
|
||||
if (error != WSAEFAULT && error != WSAENOBUFS) {
|
||||
errno = error;
|
||||
isc__strerror(error, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"get interface configuration: %s",
|
||||
NTstrerror(error));
|
||||
"get interface configuration: %s",
|
||||
strbuf);
|
||||
result = ISC_R_UNEXPECTED;
|
||||
goto ioctl_failure;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: net.c,v 1.3.2.2.4.2 2003/08/26 03:24:13 marka Exp $ */
|
||||
/* $Id: net.c,v 1.3.2.2.4.3 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <isc/msgs.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/once.h>
|
||||
#include <isc/strerror.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
@@ -43,22 +44,26 @@ static isc_result_t
|
||||
try_proto(int domain) {
|
||||
SOCKET s;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
int errval;
|
||||
|
||||
s = socket(domain, SOCK_STREAM, 0);
|
||||
if (s == INVALID_SOCKET) {
|
||||
switch (WSAGetLastError()) {
|
||||
errval = WSAGetLastError();
|
||||
switch (errval) {
|
||||
case WSAEAFNOSUPPORT:
|
||||
case WSAEPROTONOSUPPORT:
|
||||
case WSAEINVAL:
|
||||
return (ISC_R_NOTFOUND);
|
||||
default:
|
||||
isc__strerror(errval, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
isc_msgcat_get(isc_msgcat,
|
||||
ISC_MSGSET_GENERAL,
|
||||
ISC_MSG_FAILED,
|
||||
"failed"),
|
||||
strerror(errno));
|
||||
strbuf);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
}
|
||||
@@ -146,7 +151,8 @@ isc_net_probeipv6(void) {
|
||||
static void
|
||||
try_ipv6only(void) {
|
||||
#ifdef IPV6_V6ONLY
|
||||
int s, on;
|
||||
SOCKET s;
|
||||
int on;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
#endif
|
||||
isc_result_t result;
|
||||
@@ -163,7 +169,7 @@ try_ipv6only(void) {
|
||||
#else
|
||||
/* check for TCP sockets */
|
||||
s = socket(PF_INET6, SOCK_STREAM, 0);
|
||||
if (s == -1) {
|
||||
if (s == INVALID_SOCKET) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
@@ -186,7 +192,7 @@ try_ipv6only(void) {
|
||||
|
||||
/* check for UDP sockets */
|
||||
s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
if (s == -1) {
|
||||
if (s == INVALID_SOCKET) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"socket() %s: %s",
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2001 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.
|
||||
*/
|
||||
|
||||
/* $Id: ntfile.c,v 1.5 2001/07/16 04:09:45 gson Exp $ */
|
||||
|
||||
/*
|
||||
* This file has been necessitated by the fact that the iov array is local
|
||||
* to the module, so passing the FILE ptr to a file I/O function in a
|
||||
* different module or DLL will cause the application to fail to find the
|
||||
* I/O channel and the application will terminate. The standard file I/O
|
||||
* functions are redefined to call these routines instead and there will
|
||||
* be just the one iov to deal with.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#include <isc/ntfile.h>
|
||||
|
||||
FILE *
|
||||
isc_ntfile_fopen(const char *filename, const char *mode) {
|
||||
return (fopen(filename, mode));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fclose(FILE *f) {
|
||||
return (fclose(f));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fseek(FILE *f, long offset, int whence) {
|
||||
return (fseek(f, offset, whence));
|
||||
}
|
||||
|
||||
size_t
|
||||
isc_ntfile_fread(void *ptr, size_t size, size_t nmemb, FILE *f) {
|
||||
return (fread(ptr, size, nmemb, f));
|
||||
}
|
||||
|
||||
size_t
|
||||
isc_ntfile_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f) {
|
||||
int r;
|
||||
r = fwrite(ptr, size, nmemb, f);
|
||||
fflush(f);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_flush(FILE *f) {
|
||||
return (fflush(f));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_sync(FILE *f) {
|
||||
return (_commit(_fileno(f)));
|
||||
}
|
||||
|
||||
FILE *
|
||||
isc_ntfile_getaddress(int r) {
|
||||
return (&_iob[r]);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_printf(const char *format, ...) {
|
||||
int r;
|
||||
FILE *fp = stdout;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
r = vfprintf(fp, format, ap);
|
||||
va_end(ap);
|
||||
fflush(fp);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fprintf(FILE *fp, const char *format, ...) {
|
||||
int r;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
r = vfprintf(fp, format, ap);
|
||||
va_end(ap);
|
||||
fflush(fp);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_vfprintf(FILE *fp, const char *format, va_list alist) {
|
||||
int r;
|
||||
r = vfprintf(fp, format, alist);
|
||||
fflush(fp);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fputc(int iv, FILE *fp) {
|
||||
int r;
|
||||
r = fputc(iv, fp);
|
||||
fflush(fp);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fputs(const char *bf, FILE *fp) {
|
||||
int r;
|
||||
r = fputs(bf, fp);
|
||||
fflush(fp);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fgetc(FILE *fp) {
|
||||
return (fgetc(fp));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_fgetpos(FILE *fp, fpos_t *pos) {
|
||||
return (fgetpos(fp, pos));
|
||||
}
|
||||
|
||||
char *
|
||||
isc_ntfile_fgets(char *ch, int r, FILE *fp) {
|
||||
return (fgets(ch,r, fp));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_getc(FILE *fp) {
|
||||
return (getc(fp));
|
||||
}
|
||||
|
||||
FILE *
|
||||
isc_ntfile_freopen(const char *path, const char *mode, FILE *fp) {
|
||||
return (freopen(path, mode,fp));
|
||||
}
|
||||
|
||||
FILE *
|
||||
isc_ntfile_fdopen(int handle, const char *mode) {
|
||||
return (fdopen(handle, mode));
|
||||
}
|
||||
|
||||
/*
|
||||
* open(), close(), read(), write(), fsync()
|
||||
* sockets are file descriptors in UNIX. This is not so in NT
|
||||
* We keep track of what is a socket and what is an FD to
|
||||
* make everything flow right.
|
||||
*/
|
||||
int
|
||||
isc_ntfile_open(const char *fn, int flags, ...){
|
||||
va_list args;
|
||||
int pmode;
|
||||
int fd;
|
||||
|
||||
/* Extract the cmd parameter */
|
||||
va_start(args, flags);
|
||||
pmode = va_arg(args, int);
|
||||
fd = _open(fn, flags, pmode);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_close(int fd){
|
||||
return (_close(fd));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_read(int fd, char *buf, int len) {
|
||||
return (_read(fd, buf, len));
|
||||
}
|
||||
|
||||
int
|
||||
isc_ntfile_write(int fd, char *buf, int len){
|
||||
int r;
|
||||
r = _write(fd, buf, len);
|
||||
_commit(fd);
|
||||
return (r);
|
||||
}
|
||||
@@ -15,24 +15,21 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.4 2001/07/17 20:29:30 gson Exp $ */
|
||||
/* $Id: os.c,v 1.4.14.1 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <isc/os.h>
|
||||
|
||||
static BOOL bInit = FALSE;
|
||||
static SYSTEM_INFO SystemInfo;
|
||||
static OSVERSIONINFO osVer;
|
||||
|
||||
static void
|
||||
initialize_action(void) {
|
||||
BOOL bSuccess;
|
||||
|
||||
if (bInit)
|
||||
return;
|
||||
|
||||
GetSystemInfo(&SystemInfo);
|
||||
osVer.dwOSVersionInfoSize = sizeof(osVer);
|
||||
bSuccess = GetVersionEx(&osVer);
|
||||
bInit = TRUE;
|
||||
}
|
||||
|
||||
@@ -46,15 +43,3 @@ isc_os_ncpus(void) {
|
||||
|
||||
return ((unsigned int)ncpus);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_os_majorversion(void) {
|
||||
initialize_action();
|
||||
return ((unsigned int)osVer.dwMajorVersion);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_os_minorversion(void) {
|
||||
initialize_action();
|
||||
return ((unsigned int)osVer.dwMinorVersion);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: resource.c,v 1.2 2001/07/06 19:40:33 gson Exp $ */
|
||||
/* $Id: resource.c,v 1.2.12.1 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/platform.h>
|
||||
#include <isc/resource.h>
|
||||
#include <isc/result.h>
|
||||
@@ -26,13 +28,40 @@
|
||||
|
||||
#include "errno2result.h"
|
||||
|
||||
/*
|
||||
* Windows limits the maximum number of open files to 2048
|
||||
*/
|
||||
|
||||
#define WIN32_MAX_OPEN_FILES 2048
|
||||
|
||||
isc_result_t
|
||||
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
isc_resourcevalue_t rlim_value;
|
||||
int wresult;
|
||||
|
||||
if (resource != isc_resource_openfiles)
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
|
||||
if (value == ISC_RESOURCE_UNLIMITED)
|
||||
rlim_value = WIN32_MAX_OPEN_FILES;
|
||||
else
|
||||
rlim_value = min(value, WIN32_MAX_OPEN_FILES);
|
||||
|
||||
wresult = _setmaxstdio((int) rlim_value);
|
||||
|
||||
if (wresult > 0)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (isc__errno2result(errno));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
if (resource != isc_resource_openfiles)
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
*value = WIN32_MAX_OPEN_FILES;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: syslog.c,v 1.3.12.1 2003/09/24 03:47:20 marka Exp $ */
|
||||
/* $Id: syslog.c,v 1.3.12.2 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -159,4 +159,23 @@ InitNTLogging(FILE *stream, int debug) {
|
||||
log_stream = stream;
|
||||
ModifyLogLevel(debug);
|
||||
}
|
||||
/*
|
||||
* This function is for reporting errors to the application
|
||||
* event log in case the regular syslog is not available
|
||||
* mainly during startup. It should not be used under normal
|
||||
* circumstances.
|
||||
*/
|
||||
void
|
||||
NTReportError(const char *name, const char *str) {
|
||||
HANDLE hNTAppLog = NULL;
|
||||
const char *buf[1];
|
||||
|
||||
buf[0] = str;
|
||||
|
||||
hNTAppLog = RegisterEventSource(NULL, name);
|
||||
|
||||
ReportEvent(hNTAppLog, EVENTLOG_ERROR_TYPE, 0,
|
||||
BIND_ERR_MSG, NULL, 1, 0, buf, NULL);
|
||||
|
||||
DeregisterEventSource(hNTAppLog);
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: syslog.h,v 1.3 2001/07/09 21:06:20 gson Exp $ */
|
||||
/* $Id: syslog.h,v 1.3.14.1 2003/10/07 03:28:39 marka Exp $ */
|
||||
|
||||
#ifndef _SYSLOG_H
|
||||
#define _SYSLOG_H
|
||||
@@ -66,6 +66,8 @@ ModifyLogLevel(int level);
|
||||
void
|
||||
InitNTLogging(FILE *, int);
|
||||
|
||||
void
|
||||
NTReportError(const char *, const char *);
|
||||
/*
|
||||
* Include the event codes required for logging.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: time.c,v 1.24.2.3.10.1 2003/08/12 05:34:06 marka Exp $ */
|
||||
/* $Id: time.c,v 1.24.2.3.10.2 2003/10/07 03:28:40 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
***/
|
||||
|
||||
static isc_time_t epoch = { { 0, 0 } };
|
||||
isc_time_t *isc_time_epoch = &epoch;
|
||||
LIBISC_EXTERNAL_DATA isc_time_t *isc_time_epoch = &epoch;
|
||||
|
||||
/***
|
||||
*** Intervals
|
||||
***/
|
||||
|
||||
static isc_interval_t zero_interval = { 0 };
|
||||
isc_interval_t *isc_interval_zero = &zero_interval;
|
||||
LIBISC_EXTERNAL_DATA isc_interval_t *isc_interval_zero = &zero_interval;
|
||||
|
||||
void
|
||||
isc_interval_set(isc_interval_t *i, unsigned int seconds,
|
||||
@@ -69,7 +69,7 @@ isc_interval_set(isc_interval_t *i, unsigned int seconds,
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_interval_iszero(isc_interval_t *i) {
|
||||
isc_interval_iszero(const isc_interval_t *i) {
|
||||
REQUIRE(i != NULL);
|
||||
if (i->interval == 0)
|
||||
return (ISC_TRUE);
|
||||
@@ -86,7 +86,7 @@ isc_time_settoepoch(isc_time_t *t) {
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_time_isepoch(isc_time_t *t) {
|
||||
isc_time_isepoch(const isc_time_t *t) {
|
||||
REQUIRE(t != NULL);
|
||||
|
||||
if (t->absolute.dwLowDateTime == 0 &&
|
||||
@@ -106,7 +106,7 @@ isc_time_now(isc_time_t *t) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
|
||||
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
|
||||
ULARGE_INTEGER i1;
|
||||
|
||||
REQUIRE(t != NULL);
|
||||
@@ -129,14 +129,15 @@ isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
|
||||
}
|
||||
|
||||
int
|
||||
isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
|
||||
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
|
||||
REQUIRE(t1 != NULL && t2 != NULL);
|
||||
|
||||
return ((int)CompareFileTime(&t1->absolute, &t2->absolute));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
|
||||
{
|
||||
ULARGE_INTEGER i1;
|
||||
|
||||
REQUIRE(t != NULL && i != NULL && result != NULL);
|
||||
@@ -156,7 +157,8 @@ isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
|
||||
isc_time_t *result) {
|
||||
ULARGE_INTEGER i1;
|
||||
|
||||
REQUIRE(t != NULL && i != NULL && result != NULL);
|
||||
@@ -176,7 +178,7 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
|
||||
}
|
||||
|
||||
isc_uint64_t
|
||||
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
|
||||
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
|
||||
ULARGE_INTEGER i1, i2;
|
||||
LONGLONG i3;
|
||||
|
||||
@@ -199,7 +201,7 @@ isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_nanoseconds(isc_time_t *t) {
|
||||
isc_time_nanoseconds(const isc_time_t *t) {
|
||||
SYSTEMTIME st;
|
||||
|
||||
/*
|
||||
@@ -217,20 +219,20 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
|
||||
SYSTEMTIME st;
|
||||
char DateBuf[50];
|
||||
char TimeBuf[50];
|
||||
|
||||
|
||||
static const char badtime[] = "99-Bad-9999 99:99:99.999";
|
||||
|
||||
REQUIRE(len > 0);
|
||||
if (FileTimeToLocalFileTime(&t->absolute, &localft) &&
|
||||
FileTimeToSystemTime(&localft, &st))
|
||||
{
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "dd-MMM-yyyy".
|
||||
FileTimeToSystemTime(&localft, &st)) {
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "dd-MMM-yyyy",
|
||||
DateBuf, 50);
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER|
|
||||
TIME_FORCE24HOURFORMAT, &st, NULL, TimeBuf, 50);
|
||||
|
||||
|
||||
snprintf(buf, len, "%s %s.%03u", DateBuf, TimeBuf,
|
||||
st.wMilliseconds);
|
||||
|
||||
} else
|
||||
snprintf(buf, len, badtime);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: version.c,v 1.2 2001/07/08 05:09:20 mayer Exp $ */
|
||||
/* $Id: version.c,v 1.2.12.1 2003/10/07 03:28:40 marka Exp $ */
|
||||
|
||||
#include <versions.h>
|
||||
|
||||
char isc_version[] = VERSION;
|
||||
#include <isc/version.h>
|
||||
|
||||
unsigned int isc_libinterface = LIBINTERFACE;
|
||||
unsigned int isc_librevision = LIBREVISION;
|
||||
unsigned int isc_libage = LIBAGE;
|
||||
LIBISC_EXTERNAL_DATA const char isc_version[] = VERSION;
|
||||
|
||||
LIBISC_EXTERNAL_DATA const unsigned int isc_libinterface = LIBINTERFACE;
|
||||
LIBISC_EXTERNAL_DATA const unsigned int isc_librevision = LIBREVISION;
|
||||
LIBISC_EXTERNAL_DATA const unsigned int isc_libage = LIBAGE;
|
||||
|
||||
Reference in New Issue
Block a user