/*
* Portions Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 2001 Internet Software Consortium.
*
* 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 ISC AND NOMINUM DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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.
*
* Portions Copyright (C) 2001 Nominum, Inc.
*
* 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 ISC AND NOMINUM DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC 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: symtab.c,v 1.11 2007/09/13 04:45:18 each Exp $ */
/*! \file */
#include <config.h>
#include <ctype.h>
#include <stdlib.h>
#include <isc/assertions.h>
typedef struct elt {
char * key;
unsigned int type;
} elt_t;
struct isccc_symtab {
unsigned int magic;
unsigned int size;
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);
}
static inline void
}
void
unsigned int i;
}
}
}
static inline unsigned int
const char *s;
unsigned int h = 0;
unsigned int g;
int c;
/*
* P. J. Weinberger's hash function, adapted from p. 436 of
* _Compilers: Principles, Techniques, and Tools_, Aho, Sethi
* and Ullman, Addison-Wesley, 1986, ISBN 0-201-10088-6.
*/
if (case_sensitive) {
for (s = key; *s != '\0'; s++) {
h = ( h << 4 ) + *s;
if ((g = ( h & 0xf0000000 )) != 0) {
h = h ^ (g >> 24);
h = h ^ g;
}
}
} else {
for (s = key; *s != '\0'; s++) {
c = *s;
c = tolower((unsigned char)c);
h = ( h << 4 ) + c;
if ((g = ( h & 0xf0000000 )) != 0) {
h = h ^ (g >> 24);
h = h ^ g;
}
}
}
return (h);
}
#define FIND(s, k, t, b, e) \
if ((s)->case_sensitive) { \
for (e = ISC_LIST_HEAD((s)->table[b]); \
e != NULL; \
e = ISC_LIST_NEXT(e, link)) { \
if (((t) == 0 || e->type == (t)) && \
break; \
} \
} else { \
for (e = ISC_LIST_HEAD((s)->table[b]); \
e != NULL; \
e = ISC_LIST_NEXT(e, link)) { \
if (((t) == 0 || e->type == (t)) && \
strcasecmp(e->key, (k)) == 0) \
break; \
} \
}
{
unsigned int bucket;
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
{
unsigned int bucket;
if (exists_policy == isccc_symexists_reject)
return (ISC_R_EXISTS);
} else {
return (ISC_R_NOMEMORY);
}
/*
* 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);
}
void
void *arg)
{
unsigned int i;
}
}
}