cr_map.h

Go to the documentation of this file.
00001 /*
00002  * $Id: cr_map.h 5189 2008-11-12 15:53:01Z henningw $
00003  *
00004  * Copyright (C) 2007-2008 1&1 Internet AG
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00023 /**
00024  * \file cr_map.h
00025  * \brief Contains the functions to map domain and carrier names to ids.
00026  * \ingroup carrierroute
00027  * - Module; \ref carrierroute
00028  */
00029 
00030 #ifndef CR_MAP_H
00031 #define CR_MAP_H
00032 
00033 #include "../../str.h"
00034 
00035 
00036 /**
00037  * used to map names to numbers for faster access.
00038  */
00039 struct name_map_t {
00040    str name; /*!< name of the routing domain or carrier */
00041    int id; /*!< the corresponding id */
00042 };
00043 
00044 
00045 
00046 
00047 /**
00048  * Searches for the ID of a name
00049  *
00050  * @param map the mapping list to search in
00051  * @param size the size of the list
00052  * @param name the name, we are looking for
00053  *
00054  * @return values: on succcess the id for this name, -1 on failure
00055  */
00056 int map_name2id(struct name_map_t * map, int size, const str * name);
00057 
00058 
00059 /**
00060  * Searches for the name of an ID
00061  *
00062  * @param map the mapping list to search in
00063  * @param size the size of the list
00064  * @param id the id, we are looking for
00065  *
00066  * @return values: on succcess the name for this id, NULL on failure
00067  */
00068 str * map_id2name(struct name_map_t * map, int size, int id);
00069 
00070 
00071 /**
00072  * Compares the IDs of two name_map_t structures.
00073  *
00074  * @return -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2
00075  */
00076 int compare_name_map(const void *v1, const void *v2);
00077 
00078 
00079 #endif

Generated on Mon May 21 18:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6