aboutsummaryrefslogtreecommitdiff
path: root/dico
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-12-16 22:52:22 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2008-12-16 22:52:22 +0200
commita182f03cd8ac983118bb889227b3a3fab5d26560 (patch)
tree65b26b9ac5208770970b88120a132f8c41fd1335 /dico
parentf1e05b260dee71c760447c79316fd662b5988206 (diff)
downloaddico-a182f03cd8ac983118bb889227b3a3fab5d26560.tar.gz
dico-a182f03cd8ac983118bb889227b3a3fab5d26560.tar.bz2
Rewamp list and assoc support. Keep MIME headers in an assoc list.
* include/dico/assoc.h (struct dico_assoc): Key is const (DICO_ASSOC_CI, DICO_ASSOC_MULT): New defines. (dico_assoc_append,dico_assoc_find_n): New functions. (dico_assoc_iterator, dico_assoc_remove_n): New functions. (dico_header_parse): New function. * include/dico/list.h (dico_list_destroy): Change signature. (dico_list_set_free_item) (dico_list_set_comparator,dico_list_get_comparator): New functions. (dico_list_insert_sorted): Change signature. (dico_list_locate,dico_list_remove): Change signature. (_dico_list_locate): New function. (dico_iterator_create): Rename to dico_list_iterator (dico_iterator_remove_current): Change signature and return type. * dico/strat.h (dico_strat_name_cmp): Change signature. (dico_strat_free): New proto. * dico/types.h (dico_assoc_list_t): New type. * include/xdico.h (xdico_assoc_append, xdico_assoc_add): New protos. * lib/header.c: New file. * lib/Makefile.am (libdico_la_SOURCES): Add header.c * lib/assoc.c: Major rewrite. * lib/list.c: Associate free_item and compare_item functions with the list. * dicod/dicod.h (dicod_database_t): Remove content_type and content_transfer_encoding. Change type of mime_headers to dico_assoc_list_t. (CONTENT_TRANSFER_ENCODING_HEADER): New define. (dicod_ostream_create): Takes two arguments. * dicod/ostream.c: Rewrite using dico_assoc_list_t for headers. * dicod/main.c: Update calls to list/assoc functions. (kwd_load_module): Remove content-type and content-transfer-encoding. Load mime-headers through a callback, with checking. * dicod/commands.c: Update calls to dicod_ostream_create. * dicod/lang.c: Likewise. * dicod/loader.c: Likewise. * dico/autologin.c: Update calls to list/assoc functions. * dico/connect.c: Likewise. * dico/saslauth.c: Likewise. * dicod/accesslog.c: Likewise. * dicod/acl.c: Likewise. * dicod/alias.c: Likewise. * dicod/auth.c: Likewise. * dicod/capa.c: Likewise. * dicod/config-gram.y: Likewise. * dicod/dbtext.c: Likewise. * dicod/dicod.c: Likewise. * dicod/gsasl.c: Likewise. * dicod/markup.c: Likewise. * dicod/pp.c: Likewise. * dicod/udb.c: Likewise. * lib/markup.c: Likewise. * lib/strat.c: Likewise. * lib/url.c: Likewise. * lib/userprivs.c: Likewise. * lib/utf8.c: Likewise. * modules/dict.org/dictorg.c: Likewise. * modules/outline/outline.c: Likewise.
Diffstat (limited to 'dico')
-rw-r--r--dico/autologin.c8
-rw-r--r--dico/connect.c9
-rw-r--r--dico/saslauth.c25
3 files changed, 22 insertions, 20 deletions
diff --git a/dico/autologin.c b/dico/autologin.c
index ba7e6cd..07f7c05 100644
--- a/dico/autologin.c
+++ b/dico/autologin.c
@@ -127,6 +127,13 @@ findkw(const char *name)
return NULL;
}
+static int
+_cred_free(void *item, void *data)
+{
+ free(item);
+ return 0;
+}
+
/* Parse netrc-like autologin file and set up user and key accordingly. */
int
parse_autologin(const char *filename, char *host, struct auth_cred *pcred,
@@ -300,6 +307,7 @@ parse_autologin(const char *filename, char *host, struct auth_cred *pcred,
if (!(flags & AUTOLOGIN_MECH)) {
pcred->mech = xdico_list_create();
+ dico_list_set_free_item(pcred->mech, _cred_free, NULL);
flags |= AUTOLOGIN_MECH;
}
if (dico_argcv_get(arg, ",", NULL, &c, &v)) {
diff --git a/dico/connect.c b/dico/connect.c
index 940446d..00cb276 100644
--- a/dico/connect.c
+++ b/dico/connect.c
@@ -182,19 +182,12 @@ auth_cred_dup(struct auth_cred *dst, const struct auth_cred *src)
dst->pass = src->pass ? xstrdup(src->pass) : NULL;
}
-static int
-_cred_free(void *item, void *data)
-{
- free(item);
- return 0;
-}
-
void
auth_cred_free(struct auth_cred *cred)
{
free(cred->user);
free(cred->pass);
- dico_list_destroy(&cred->mech, _cred_free, NULL);
+ dico_list_destroy(&cred->mech);
free(cred->service);
free(cred->realm);
free(cred->hostname);
diff --git a/dico/saslauth.c b/dico/saslauth.c
index 2d05771..16cf1fa 100644
--- a/dico/saslauth.c
+++ b/dico/saslauth.c
@@ -19,6 +19,13 @@
#ifdef WITH_GSASL
#include <gsaslstr.h>
+static int
+_free_el(void *item, void *data DICO_ARG_UNUSED)
+{
+ free(item);
+ return 0;
+}
+
static dico_list_t
get_implemented_mechs(Gsasl *ctx)
{
@@ -39,6 +46,7 @@ get_implemented_mechs(Gsasl *ctx)
if (dico_argcv_get(listmech, "", NULL, &mechc, &mechv) == 0) {
int i;
supp = xdico_list_create();
+ dico_list_set_free_item(supp, _free_el, NULL);
for (i = 0; i < mechc; i++)
xdico_list_append(supp, mechv[i]);
free(mechv);
@@ -47,13 +55,6 @@ get_implemented_mechs(Gsasl *ctx)
return supp;
}
-static int
-_free_el(void *item, void *data DICO_ARG_UNUSED)
-{
- free(item);
- return 0;
-}
-
static char *
mech_intersect_first(dico_iterator_t itr, struct dict_connection *conn)
{
@@ -69,7 +70,7 @@ mech_intersect_first(dico_iterator_t itr, struct dict_connection *conn)
}
static int
-str_str_cmp(const void *item, const void *data)
+str_str_cmp(const void *item, void *data)
{
return c_strcasecmp(item, data);
}
@@ -93,14 +94,14 @@ selectmech(struct dict_connection *conn, Gsasl *ctx, struct auth_cred *cred)
return NULL;
if (cred->mech) {
dico_list_t supp = dico_list_intersect(cred->mech, impl, str_str_cmp);
- dico_list_destroy(&impl, _free_el, NULL);
+ dico_list_destroy(&impl);
impl = supp;
}
- itr = xdico_iterator_create(impl);
+ itr = xdico_list_iterator(impl);
mech = mech_intersect_first(itr, conn);
dico_iterator_destroy(&itr);
- /* FIXME: Revise 2nd argument. */
- dico_list_destroy(&impl, NULL, NULL);
+ /* FIXME: Revise impl->free_item. */
+ dico_list_destroy(&impl);
if (mech)
upcase(mech);
return mech;

Return to:

Send suggestions and report system problems to the System administrator.