s/domain/hash.h

00001 /*
00002  * Header file for hash table functions
00003  *
00004  * Copyright (C) 2002-2003 Juha Heinanen
00005  *
00006  * This file is part of sip-router, a free SIP server.
00007  *
00008  * sip-router is free software; you can redistribute it and/or modify it under
00009  * the terms of the GNU General Public License as published by the Free
00010  * Software Foundation; either version 2 of the License, or (at your option)
00011  * any later version
00012  *
00013  * sip-router is distributed in the hope that it will be useful, but WITHOUT
00014  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00016  * more details.
00017  *
00018  * You should have received a copy of the GNU General Public License along
00019  * with this program; if not, write to the Free Software Foundation, Inc.,
00020  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021  */
00022 
00023 #ifndef _HASH_H
00024 #define _HASH_H
00025 
00026 #include <stdio.h>
00027 #include "domain_mod.h"
00028 #include "domain.h"
00029 
00030 #define HASH_SIZE 128
00031 
00032 /*
00033  * Hash table entry
00034  */
00035 struct hash_entry {
00036         str key;                  /* Hash key */
00037         domain_t* domain;         /* Pointer to the domain structure */
00038         struct hash_entry* next;  /* Next element in hash table colision slot */
00039 };
00040 
00041 
00042 /*
00043  * Generate hash table, use domain names as hash keys
00044  */
00045 int gen_domain_table(struct hash_entry** table, domain_t* list);
00046 
00047 
00048 /*
00049  * Lookup key in the table
00050  */
00051 int hash_lookup(domain_t** d, struct hash_entry** table, str* key);
00052 
00053 
00054 /*
00055  * Generate hash table, use did as hash key
00056  */
00057 int gen_did_table(struct hash_entry** table, domain_t* list);
00058 
00059 
00060 /*
00061  * Free memory allocated for entire hash table
00062  */
00063 void free_table(struct hash_entry** table);
00064 
00065 #endif /* _HASH_H */