emu_graph.h

Go to the documentation of this file.
00001 /********************************************************************************
00002  *                               libemu
00003  *
00004  *                    - x86 shellcode emulation -
00005  *
00006  *
00007  * Copyright (C) 2007  Paul Baecher & Markus Koetter
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00022  * 
00023  * 
00024  *             contact nepenthesdev@users.sourceforge.net  
00025  *
00026  *******************************************************************************/
00027 
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <stdint.h>
00031 
00032 #include "emu/emu_list.h"
00033 
00034 struct emu_vertex;
00035 
00036 header_list_typedefs(emu_edge_root,emu_edge,emu_edge_link);
00037 
00047 struct emu_edge
00048 {
00049         struct emu_vertex *destination;
00050         emu_edge_link link;
00051         uint32_t count;
00052         void *data;
00053 };
00054 
00055 header_list_functions(emu_edges,emu_edge_root, emu_edge, link);
00056 
00057 struct emu_edge *emu_edge_new(void);
00058 void emu_edge_free(struct emu_edge *ee);
00059 
00060 
00061 header_list_typedefs(emu_vertex_root,emu_vertex,emu_vertex_link);
00062 header_list_functions(emu_vertexes,emu_vertex_root, emu_vertex, link);
00063 
00064 
00065 
00066 
00067 enum emu_color { black, blue, cyan, green, grey, magenta, red, white, yellow };
00068 
00081 struct emu_vertex
00082 {
00083         void *data;
00084         emu_edge_root  *edges;
00085 
00086         emu_vertex_link link;
00087         enum emu_color color;
00088 
00089         emu_edge_root  *backedges;
00090         uint32_t backlinks;
00091 
00092         uint32_t distance;
00093 };
00094 
00095 
00096 struct emu_vertex *emu_vertex_new(void);
00097 void emu_vertex_free(struct emu_vertex *ev);
00098 void emu_vertex_data_set(struct emu_vertex *ev, void *data);
00099 void *emu_vertex_data_get(struct emu_vertex *ev);
00100 struct emu_edge *emu_vertex_edge_add(struct emu_vertex *ev, struct emu_vertex *to);
00101 
00102 typedef void (*emu_graph_destructor)(void *data);
00103 struct emu_graph
00104 {
00105         emu_vertex_root         *vertexes;
00106         emu_graph_destructor    vertex_destructor;
00107 };
00108 
00109 struct emu_graph *emu_graph_new(void);
00110 void emu_graph_free(struct emu_graph *eg);
00111 void emu_graph_vertex_add(struct emu_graph *eg, struct emu_vertex *ev);
00112 
00113 bool emu_graph_path_exists(struct emu_graph *eg, struct emu_vertex *from, struct emu_vertex *to);
00114 bool emu_graph_loop_detect(struct emu_graph *eg, struct emu_vertex *from);
00115 int32_t emu_graph_distance(struct emu_graph *eg, struct emu_vertex *from, struct emu_vertex *to);

Generated on Sun Jan 9 16:47:44 2011 for libemu by  doxygen 1.6.1