regfi
range_list.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008-2010 Timothy D. Morgan
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; version 3 of the License.
00007  * 
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  * 
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
00016  *
00017  * $Id: range_list.h 253 2011-06-13 02:27:42Z tim $
00018  */
00019 
00030 #ifndef _RANGE_LIST_H
00031 #define _RANGE_LIST_H
00032 
00033 #include <stdlib.h>
00034 #include <stdbool.h>
00035 #include <stdint.h>
00036 #include <string.h>
00037 #include <math.h>
00038 #include <talloc.h>
00039 
00040 #include "compat.h"
00041 
00042 typedef struct _range_list_element
00043 {
00044   uint32_t offset;
00045   uint32_t length;
00046   void* data;
00047 } range_list_element;
00048 
00049 
00051 typedef struct _range_list
00052 {
00053   range_list_element** elements;
00054   uint32_t elem_alloced;
00055   uint32_t size;
00056 } range_list;
00057 
00058 
00063 _EXPORT()
00064 range_list* range_list_new();
00065 
00066 
00074 _EXPORT()
00075 void range_list_free(range_list* rl);
00076 
00077 
00084 _EXPORT()
00085 uint32_t range_list_size(const range_list* rl);
00086 
00087 
00104 _EXPORT()
00105 bool range_list_add(range_list* rl, uint32_t offset, uint32_t length, void* data);
00106 
00107 
00117 _EXPORT()
00118 bool range_list_remove(range_list* rl, uint32_t index);
00119 
00120 
00129 _EXPORT()
00130 const range_list_element* range_list_get(const range_list* rl, uint32_t index);
00131 
00132 
00140 _EXPORT()
00141 int32_t range_list_find(const range_list* rl, uint32_t offset);
00142 
00143 
00155 _EXPORT()
00156 void* range_list_find_data(const range_list* rl, uint32_t offset);
00157 
00158 
00177 _EXPORT()
00178 bool range_list_split_element(range_list* rl, uint32_t index, uint32_t offset);
00179 
00180 
00190 _EXPORT()
00191 bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length);
00192 
00193 #endif
 All Data Structures Files Functions Variables