sub_list.c

Go to the documentation of this file.
00001 /*
00002  * $Id: sub_list.c 4518 2008-07-28 15:39:28Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
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 /* History:
00023  * --------
00024  *  2003-03-19  all mallocs/frees replaced w/ pkg_malloc/pkg_free (andrei)
00025  */
00026 
00027 #include <stdlib.h>
00028 #include <string.h>
00029 #include "../../mem/mem.h"
00030 #include "sub_list.h"
00031 
00032 struct node*   append_to_list(struct node *head, char *offset, char *name)
00033 {
00034    struct node *new_node;
00035 
00036    new_node = pkg_malloc(sizeof(struct node));
00037    if (!new_node)
00038       return 0;
00039    new_node->offset = offset;
00040    new_node->name = name;
00041    new_node->next = head;
00042 
00043    return new_node;
00044 }
00045 
00046 
00047 
00048 
00049 char* search_the_list(struct node *head, char *name)
00050 {
00051    struct node *n;
00052 
00053    n = head;
00054    while (n) {
00055       if (strcasecmp(n->name,name)==0)
00056          return n->offset;
00057       n = n->next;
00058    }
00059    return 0;
00060 }
00061 
00062 
00063 
00064 
00065 void delete_list(struct node* head)
00066 {
00067    struct node *n;
00068 ;
00069    while (head) {
00070       n=head->next;
00071       pkg_free(head);
00072       head = n;
00073    }
00074 }
00075 
00076 

Generated on Thu May 24 20:00:32 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6