aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-10-22 23:03:24 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-10-23 00:42:30 +0300
commit21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee (patch)
treec3204285a3ba57d590d815c682f1113b6f48d834 /src/progman.c
parenteb8797c9a28f3f4e238bad89b56d331492df7828 (diff)
downloadpies-21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee.tar.gz
pies-21ffba77b92f79a59c62728ede4ad7a4ecb5a0ee.tar.bz2
Switch to the latest Grecs.
* Makefile.am (ChangeLog): Use git2chg.awk to build it. * NEWS: Update. * bootstrap.conf (gnulib_modules): Grecs does not depend on gnulib any more. * configure.ac: Version 1.2.90. Define GRECS_HOST_PROJECT_INCLUDES, remove grecs Makefiles from AC_CONFIG_FILES: it is now done by GRECS_SETUP itself. * gnulib.modules (gitlog-to-changelog,argp): Remove. (configmake): New module. * grecs: Update to a52ab6c6. * lib/libpies.h: Remove redefinitions of _() and N_(). * src/Makefile.am: Update for the recent grecs. * src/acl.c: Rewrite using Grecs support for lists and symtabs. * src/acl.h: Likewise. * src/diag.c: Likewise. * src/inetd.c: Likewise. * src/meta1gram.y: Likewise. * src/meta1lex.h: Likewise. * src/meta1lex.l: Likewise. * src/pies.c: Likewise. * src/pies.h: Likewise. * src/progman.c: Likewise. * src/userprivs.c: Likewise.
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,5 +1,5 @@
/* This file is part of GNU Pies.
- Copyright (C) 2007, 2008, 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Sergey Poznyakoff
GNU Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,7 +15,6 @@
along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */
#include "pies.h"
-#include <hash.h>
enum prog_type
{
@@ -89,7 +88,7 @@ static size_t numcomp;
static struct prog *proghead, *progtail;
static pies_depmap_t depmap;
static int recompute_alarm;
-static Hash_table *conn_tab;
+static struct grecs_symtab *conn_tab;
void
progman_iterate_comp (int (*fun) (struct component *, void *), void *data)
@@ -357,10 +356,10 @@ prog_rebuild_prerequisites (struct prog *prog)
if (comp->prereq)
{
- 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)
{
dep_all = 1;
@@ -370,7 +369,7 @@ prog_rebuild_prerequisites (struct prog *prog)
}
else if (strcmp (item, "none") == 0)
{
- gl_list_free (comp->prereq);
+ grecs_list_free (comp->prereq);
comp->prereq = NULL;
}
}
@@ -392,13 +391,10 @@ prog_rebuild_prerequisites (struct prog *prog)
}
else
{
- 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;
}
}
prog->prereq[depc] = NULL;
@@ -521,10 +517,10 @@ 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;
size_t value = 0;
unsigned char ch;
@@ -542,15 +538,15 @@ 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)
{
struct conn_class const *p1 = data1;
struct conn_class const *p2 = 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);
}
static void
@@ -559,11 +555,20 @@ conn_class_free (void *data)
free (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 *
conn_class_lookup (const char *tag,
union pies_sockaddr_storage const *sa_storage_ptr,
size_t sa_len)
{
+ int install = 1;
struct conn_class *probe, *ret;
probe = xmalloc (sizeof (probe[0]));
@@ -586,17 +591,20 @@ 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;
}
@@ -1411,16 +1419,14 @@ progman_accept (int socket)
void
component_fixup_depend (struct component *comp)
{
- const void *p;
- gl_list_iterator_t itr;
+ struct grecs_list_entry *ep;
if (comp->depend == NULL)
return;
- 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;
tgt = progman_lookup_component (tag);
@@ -1434,16 +1440,12 @@ component_fixup_depend (struct component *comp)
}
if (!tgt->prereq)
{
- 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.