"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/datastructs.c" between
etherape-0.9.17.tar.gz and etherape-0.9.18.tar.gz

About: EtherApe is a GNOME/pcap-based graphical network monitor (etherman clone).

datastructs.c  (etherape-0.9.17):datastructs.c  (etherape-0.9.18)
skipping to change at line 53 skipping to change at line 53
/************************************************************************ /************************************************************************
* *
* proto->color hash table support functions * proto->color hash table support functions
* *
************************************************************************/ ************************************************************************/
static GHashTable *protohash = NULL; /* the hash table containing proto,color pa irs*/ static GHashTable *protohash = NULL; /* the hash table containing proto,color pa irs*/
static GList *cycle_color_list = NULL; /* the list of colors without protocol */ static GList *cycle_color_list = NULL; /* the list of colors without protocol */
static GList *current_cycle = NULL; /* current ptr to free color */ static GList *current_cycle = NULL; /* current ptr to free color */
/* adds or replaces the protoname item */ /* adds or replaces the protoname item */
static gboolean protohash_set(gchar *protoname, GdkColor protocolor); static gboolean protohash_set(gchar *protoname, const GdkRGBA *protocolor);
static void freehash(gpointer data) static void freehash(gpointer data)
{ {
g_free(data); g_free(data);
} }
static gboolean static gboolean
protohash_init(void) protohash_init(void)
{ {
if (protohash) if (protohash)
skipping to change at line 93 skipping to change at line 93
while (cycle_color_list) while (cycle_color_list)
{ {
g_free(cycle_color_list->data); g_free(cycle_color_list->data);
cycle_color_list = g_list_delete_link(cycle_color_list,cycle_color_list); cycle_color_list = g_list_delete_link(cycle_color_list,cycle_color_list);
} }
current_cycle = NULL; current_cycle = NULL;
} }
/* adds or replaces the protoname item */ /* adds or replaces the protoname item */
static gboolean static gboolean
protohash_set(gchar *protoname, GdkColor protocolor) protohash_set(gchar *protoname, const GdkRGBA *protocolor)
{ {
ColorHashItem item; ColorHashItem item;
g_assert(protocolor);
if (!protohash && ! protohash_init()) if (!protohash && ! protohash_init())
return FALSE; return FALSE;
item.color = protocolor; item.color = *protocolor;
/* if a protocol is specified, we put the pair (proto,color) in the hash, /* if a protocol is specified, we put the pair (proto,color) in the hash,
* marking it as preferred (a color obtained from user mappings) */ * marking it as preferred (a color obtained from user mappings) */
if (protoname && *protoname) if (protoname && *protoname)
{ {
item.preferred = TRUE; item.preferred = TRUE;
g_hash_table_insert(protohash, g_strdup(protoname), g_hash_table_insert(protohash, g_strdup(protoname),
g_memdup(&item, sizeof(ColorHashItem))); g_memdup(&item, sizeof(ColorHashItem)));
} }
skipping to change at line 124 skipping to change at line 126
item.preferred = FALSE; item.preferred = FALSE;
cycle_color_list = g_list_prepend(cycle_color_list, cycle_color_list = g_list_prepend(cycle_color_list,
g_memdup(&item, sizeof(ColorHashItem))); g_memdup(&item, sizeof(ColorHashItem)));
current_cycle = cycle_color_list; current_cycle = cycle_color_list;
} }
return TRUE; return TRUE;
} }
/* resets the cycle color to start of list */ /* resets the cycle color to start of list */
void void protohash_reset_cycle(void)
protohash_reset_cycle(void)
{ {
current_cycle = cycle_color_list; current_cycle = cycle_color_list;
} }
/* returns the proto color */ /* returns the colorhash item from the named protocol, creating a new entry if
GdkColor protohash_color(const gchar *protoname) needed. Internal use only */
static const ColorHashItem *protohash_itemproto(const gchar *protoname)
{ {
const ColorHashItem *item; const ColorHashItem *item;
g_assert(protoname); /* proto must be valid - note: empty IS valid, NULL no*/ g_assert(protoname); /* proto must be valid - note: empty IS valid, NULL no*/
g_assert(protohash); g_assert(protohash);
item = (ColorHashItem *)g_hash_table_lookup(protohash, protoname); item = (ColorHashItem *)g_hash_table_lookup(protohash, protoname);
if (!item) if (!item)
{ {
/* color not found, take from cycle list */ /* color not found, take from cycle list */
item = (ColorHashItem *)current_cycle->data; item = (ColorHashItem *)current_cycle->data;
skipping to change at line 154 skipping to change at line 156
g_hash_table_insert(protohash, g_strdup(protoname), g_hash_table_insert(protohash, g_strdup(protoname),
g_memdup(item, sizeof(ColorHashItem))); g_memdup(item, sizeof(ColorHashItem)));
/* advance cycle */ /* advance cycle */
current_cycle = current_cycle->next; current_cycle = current_cycle->next;
if (!current_cycle) if (!current_cycle)
current_cycle = cycle_color_list; current_cycle = cycle_color_list;
} }
/* g_my_debug ("Protocol %s in color 0x%2.2x%2.2x%2.2x", /* g_my_debug ("Protocol %s in color 0x%2.2x%2.2x%2.2x",
protoname, color->red, color->green, color->blue); */ protoname, color->red, color->green, color->blue); */
return item->color; return item;
}
const GdkRGBA *protohash_color(const gchar *protoname)
{
g_assert(protoname); /* proto must be valid - note: empty IS valid, NULL no*/
g_assert(protohash);
return &(protohash_itemproto(protoname)->color);
} }
/* returns the preferred flag */ /* returns the preferred flag */
gboolean protohash_is_preferred(const gchar *protoname) gboolean protohash_is_preferred(const gchar *protoname)
{ {
const ColorHashItem *item; const ColorHashItem *item;
g_assert(protoname); /* proto must be valid - note: empty IS valid, NULL no*/ g_assert(protoname); /* proto must be valid - note: empty IS valid, NULL no*/
g_assert(protohash); g_assert(protohash);
item = (ColorHashItem *)g_hash_table_lookup(protohash, protoname); item = (ColorHashItem *)g_hash_table_lookup(protohash, protoname);
skipping to change at line 176 skipping to change at line 185
return FALSE; return FALSE;
return item->preferred; return item->preferred;
} }
/* fills the hash from a pref vector */ /* fills the hash from a pref vector */
gboolean gboolean
protohash_read_prefvect(gchar **colors) protohash_read_prefvect(gchar **colors)
{ {
int i; int i;
GdkColor gdk_color; GdkRGBA color;
protohash_clear(); protohash_clear();
/* fills with colors */ /* fills with colors */
for (i = 0; colors[i]; ++i) for (i = 0; colors[i]; ++i)
{ {
gchar **colors_protocols, **protos; gchar **colors_protocols, **protos;
int j; int j;
colors_protocols = g_strsplit_set(colors[i], "; \t\n", 0); colors_protocols = g_strsplit_set(colors[i], "; \t\n", 0);
if (!colors_protocols[0]) if (!colors_protocols[0])
continue; continue;
/* converting color */ /* converting color */
gdk_color_parse (colors_protocols[0], &gdk_color); gdk_rgba_parse(&color, colors_protocols[0]);
if (!colors_protocols[1] || !strlen(colors_protocols[1])) if (!colors_protocols[1] || !strlen(colors_protocols[1]))
protohash_set(colors_protocols[1], gdk_color); protohash_set(colors_protocols[1], &color);
else else
{ {
/* multiple protos, split them */ /* multiple protos, split them */
protos = g_strsplit_set(colors_protocols[1], ", \t\n", 0); protos = g_strsplit_set(colors_protocols[1], ", \t\n", 0);
for (j = 0 ; protos[j] ; ++j) for (j = 0 ; protos[j] ; ++j)
if (protos[j] && *protos[j]) if (protos[j] && *protos[j])
protohash_set(protos[j], gdk_color); protohash_set(protos[j], &color);
g_strfreev(protos); g_strfreev(protos);
} }
g_strfreev(colors_protocols); g_strfreev(colors_protocols);
} }
if (!cycle_color_list) if (!cycle_color_list)
{ {
/* the list of color available for unmapped protocols is empty, /* the list of color available for unmapped protocols is empty,
* so we add a grey */ * so we add a grey */
gdk_color_parse ("#7f7f7f", &gdk_color); gdk_rgba_parse(&color, "#7f7f7f");
protohash_set(NULL, gdk_color); protohash_set(NULL, &color);
} }
else else
cycle_color_list = g_list_reverse(cycle_color_list); /* list was reversed */ cycle_color_list = g_list_reverse(cycle_color_list); /* list was reversed */
/* update preferred flag on services tree */ /* update preferred flag on services tree */
services_fill_preferred(); services_fill_preferred();
return TRUE; return TRUE;
} }
/* compacts the array of colors/protocols mappings by collapsing identical /* compacts the array of colors/protocols mappings by collapsing identical
 End of changes. 12 change blocks. 
14 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)