aboutsummaryrefslogtreecommitdiff
path: root/src/mail.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-17 18:36:54 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-17 18:36:54 +0200
commit317095181674a01651602ddf6817e888d0ad5280 (patch)
treeda9a84a50223918408dfb578813c6fb098c1870c /src/mail.c
parent3277cd4abfa20e8b2499f052a6eb3792d8aa6cce (diff)
downloadwydawca-317095181674a01651602ddf6817e888d0ad5280.tar.gz
wydawca-317095181674a01651602ddf6817e888d0ad5280.tar.bz2
Begin rewriting method system
* src/builtin.c, src/builtin.h: New files. * src/Makefile.am (wydawca_SOURCES): Add builtin.c and builtin.h * src/config.c: New keyword access-method.query * src/update-2.0.awk: Update. * src/meta.c: Remove quote_string (replaced by method_quote_string). (meta_escape): Add `handle' argument. * src/method.c (struct method_descr): New methods: open, close, quote. Updated methods: free, run, get. All callers updated. (method_quote_string): New function. * src/process.c (scan_directory_pair): Init all access methods at once. * src/sql.c: Take name of the SQL connection from method->parmv[0]. Adapt to changes to the method subsystem. * src/sql.h: Likewise. * src/wydawca.h (struct access_method): New members id, parmc, parmv, storage. Remove union v. (meta_escape): Take 3 arguments. (method_new): Take 2 arguments. (method_open, method_close, method_quote_string): New proto. (method_run, method_result): Change signature. * src/mail.c, src/triplet.c, src/verify.c * etc/wydawca.rc: Update.
Diffstat (limited to 'src/mail.c')
-rw-r--r--src/mail.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mail.c b/src/mail.c
index 619fba4..6b76f43 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -269,29 +269,32 @@ get_recipient (struct access_method *method, struct file_triplet *trp,
mu_address_t rcpt = NULL;
char *text;
int rc;
-
+ void *md;
+
if (method->type == method_none)
{
*errp = "access method is not configured";
return NULL;
}
- if (method_init (method))
+ md = method_open (method);
+ if (!md)
{
- *errp = "failed to initialize access method";
+ *errp = "failed to open access method";
return NULL;
}
make_default_meta (def, trp->user, trp->project);
- meta_escape (method, def);
- text = meta_expand_string (method->param[1], def, NULL);
+ meta_escape (method, md, def);
+ text = meta_expand_string (method->query, def, NULL);
meta_free (def);
- rc = method_run (method, text);
+ rc = method_run (method, md, text);
free (text);
if (rc)
{
*errp = "cannot obtain recipient emails";
+ method_close (method, md);
return NULL;
}
@@ -307,18 +310,19 @@ get_recipient (struct access_method *method, struct file_triplet *trp,
for (i = 0; i < nrows; i++)
{
mu_address_t addr;
- const char *str = method_result (method, i, 0);
+ const char *str = method_result (method, md, i, 0);
if (mu_address_create (&addr, str))
continue;
if (ncols > 0)
{
- str = method_result (method, i, 1);
+ str = method_result (method, md, i, 1);
if (str)
mu_address_set_personal (addr, 1, str);
}
mu_address_union (&rcpt, addr);
mu_address_destroy (&addr);
}
+ method_close (method, md);
return rcpt;
}

Return to:

Send suggestions and report system problems to the System administrator.