aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c86
1 files changed, 44 insertions, 42 deletions
diff --git a/src/progman.c b/src/progman.c
index 4420a21..d24ea1a 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -1,3 +1,3 @@
/* This file is part of GNU Pies.
- Copyright (C) 2007, 2008, 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Sergey Poznyakoff
@@ -17,3 +17,2 @@
#include "pies.h"
-#include <hash.h>
@@ -91,3 +90,3 @@ static pies_depmap_t depmap;
static int recompute_alarm;
-static Hash_table *conn_tab;
+static struct grecs_symtab *conn_tab;
@@ -359,6 +358,6 @@ prog_rebuild_prerequisites (struct prog *prog)
{
- depc = gl_list_size (comp->prereq);
+ depc = grecs_list_size (comp->prereq);
if (depc == 1)
{
- const char *item = gl_list_get_at (comp->prereq, 0);
+ const char *item = grecs_list_index (comp->prereq, 0);
if (strcmp (item, "all") == 0)
@@ -372,3 +371,3 @@ prog_rebuild_prerequisites (struct prog *prog)
{
- gl_list_free (comp->prereq);
+ grecs_list_free (comp->prereq);
comp->prereq = NULL;
@@ -394,9 +393,6 @@ prog_rebuild_prerequisites (struct prog *prog)
{
- const void *p;
- gl_list_iterator_t itr = gl_list_iterator (comp->prereq);
- while (gl_list_iterator_next (&itr, &p, NULL))
- {
- prog->prereq[depc++] = (char*) p;
- }
- gl_list_iterator_free (&itr);
+ struct grecs_list_entry *ep;
+
+ for (ep = comp->prereq->head; ep; ep = ep->next)
+ prog->prereq[depc++] = (char*) ep->data;
}
@@ -523,6 +519,6 @@ open_redirector (struct prog *master, int stream)
-static size_t
-conn_class_hasher (void const *data, size_t n_buckets)
+static unsigned
+conn_class_hasher (void *data, unsigned long n_buckets)
{
- struct conn_class const *pcclass = data;
+ struct conn_class *pcclass = data;
unsigned char const *tag = (unsigned char const *)pcclass->tag;
@@ -544,3 +540,3 @@ conn_class_hasher (void const *data, size_t n_buckets)
/* Compare two strings for equality. */
-static bool
+static int
conn_class_compare (void const *data1, void const *data2)
@@ -550,5 +546,5 @@ conn_class_compare (void const *data1, void const *data2)
- return p1->sa_len == p2->sa_len &&
- memcmp (&p1->sa_storage, &p2->sa_storage, p1->sa_len) == 0 &&
- strcmp (p1->tag, p2->tag) == 0;
+ return !(p1->sa_len == p2->sa_len &&
+ memcmp (&p1->sa_storage, &p2->sa_storage, p1->sa_len) == 0 &&
+ strcmp (p1->tag, p2->tag) == 0);
}
@@ -561,2 +557,10 @@ conn_class_free (void *data)
+static int
+conn_class_copy(void *a, void *b)
+{
+ memcpy(a, b, sizeof(struct conn_class));
+ memset(a, 0, sizeof(struct conn_class));
+ return 0;
+}
+
static struct conn_class *
@@ -566,2 +570,3 @@ conn_class_lookup (const char *tag,
{
+ int install = 1;
struct conn_class *probe, *ret;
@@ -588,13 +593,16 @@ conn_class_lookup (const char *tag,
probe->count = 0;
+ if (!conn_tab)
+ {
+ conn_tab = grecs_symtab_create(sizeof (struct conn_class),
+ conn_class_hasher,
+ conn_class_compare,
+ conn_class_copy,
+ NULL,
+ conn_class_free);
+ if (!conn_tab)
+ xalloc_die ();
+ }
- if (!((conn_tab
- || (conn_tab = hash_initialize (0, 0,
- conn_class_hasher,
- conn_class_compare,
- conn_class_free)))
- && (ret = hash_insert (conn_tab, probe))))
- xalloc_die ();
-
- if (probe != ret)
- free (probe);
+ ret = grecs_symtab_lookup_or_install (conn_tab, probe, &install);
+ free (probe);
return ret;
@@ -1413,4 +1421,3 @@ component_fixup_depend (struct component *comp)
{
- const void *p;
- gl_list_iterator_t itr;
+ struct grecs_list_entry *ep;
@@ -1419,6 +1426,5 @@ component_fixup_depend (struct component *comp)
- itr = gl_list_iterator (comp->depend);
- while (gl_list_iterator_next (&itr, &p, NULL))
+ for (ep = comp->depend->head; ep; ep = ep->next)
{
- const char *tag = p;
+ const char *tag = ep->data;
struct component *tgt;
@@ -1436,12 +1442,8 @@ component_fixup_depend (struct component *comp)
{
- tgt->prereq = gl_list_create_empty(&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- false);
+ tgt->prereq = grecs_list_create();
}
/* FIXME: memory allocation */
- gl_list_add_last (tgt->prereq, xstrdup (comp->tag));
+ grecs_list_append (tgt->prereq, xstrdup (comp->tag));
}
- gl_list_free (comp->depend);
+ grecs_list_free (comp->depend);
comp->depend = NULL;

Return to:

Send suggestions and report system problems to the System administrator.