symtab.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1996-2001, 2004, 2005, 2007, 2011-2013, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id$ */
/*! \file */
#include <config.h>
#include <ctype.h>
typedef struct elt {
char * key;
unsigned int type;
} elt_t;
struct isc_symtab {
/* Unlocked. */
unsigned int magic;
unsigned int size;
unsigned int count;
unsigned int maxload;
void * undefine_arg;
};
void *undefine_arg,
{
unsigned int i;
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
}
for (i = 0; i < size; i++)
return (ISC_R_SUCCESS);
}
void
unsigned int i;
}
}
}
static inline unsigned int
const char *s;
unsigned int h = 0;
int c;
/*
* This hash function is similar to the one Ousterhout
* uses in Tcl.
*/
if (case_sensitive) {
for (s = key; *s != '\0'; s++) {
h += (h << 3) + *s;
}
} else {
for (s = key; *s != '\0'; s++) {
c = *s;
c = tolower((unsigned char)c);
h += (h << 3) + c;
}
}
return (h);
}
#define FIND(s, k, t, b, e) \
if ((s)->case_sensitive) { \
if (((t) == 0 || e->type == (t)) && \
break; \
} \
} else { \
if (((t) == 0 || e->type == (t)) && \
strcasecmp(e->key, (k)) == 0) \
break; \
} \
}
{
unsigned int bucket;
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
static void
return;
for (i = 0; i < newsize; i++)
unsigned int hv;
}
}
}
{
unsigned int bucket;
if (exists_policy == isc_symexists_reject)
return (ISC_R_EXISTS);
} else {
return (ISC_R_NOMEMORY);
}
/*
* Though the "key" can be const coming in, it is not stored as const
* so that the calling program can easily have writable access to
* it in its undefine_action function. In the event that it *was*
* truly const coming in and then the caller modified it anyway ...
* well, don't do that!
*/
/*
* We prepend so that the most recent definition will be found.
*/
return (ISC_R_SUCCESS);
}
unsigned int bucket;
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
unsigned int
}