summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org.ua>2013-03-10 22:12:41 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-03-10 22:12:41 (GMT)
commitdfe6343d9522cea2e6653abc267b42040925b3e6 (patch) (side-by-side diff)
tree85fe0c174281c36a241ca44f828e81148e794b08 /src
parent39a97e438dde837ada9a99cceea93a1cf97db19e (diff)
downloadwydawca-dfe6343d9522cea2e6653abc267b42040925b3e6.tar.gz
wydawca-dfe6343d9522cea2e6653abc267b42040925b3e6.tar.bz2
Put back admin and owner address expansions.
* src/meta.c (metadef_join): New function. * src/triplet.c (triplet_expand_param): Extra argument supplies an additional metadef to use together with triplet_meta. * src/wydawca.h (triplet_expand_param): Change signature. * modules/mailutils/mod_mailutils.c (t_notify): Provide extra metadef for admin and owner addresses.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/meta.c19
-rw-r--r--src/triplet.c16
-rw-r--r--src/wydawca.h4
3 files changed, 30 insertions, 9 deletions
diff --git a/src/meta.c b/src/meta.c
index 2cc263c..eac2d68 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -144,3 +144,22 @@ meta_free(struct metadef *def)
}
}
}
+
+struct metadef *
+metadef_join(struct metadef *a, struct metadef *b)
+{
+ struct metadef *np;
+ size_t i, j;
+
+ for (i = 0; a[i].kw; i++);
+ if (b)
+ for (j = 0; b[j].kw; j++);
+ else
+ j = 0;
+ np = grecs_malloc((i + j + 1) * sizeof(a[0]));
+ memcpy(np, a, i * sizeof(a[0]));
+ if (j > 0)
+ memcpy(np + i, b, j * sizeof(b[0]));
+ np[i + j].kw = NULL;
+ return np;
+}
diff --git a/src/triplet.c b/src/triplet.c
index ded09c8..0481659 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -872,10 +872,6 @@ struct metadef triplet_meta[] = {
{ "user:real-name", NULL, expand_user_real_name, NULL },
{ "user:email", NULL, expand_user_email, NULL },
{ "email:user", NULL, expand_email_user, NULL },
-#if 0 //FIXME
- { "email:admin", NULL, expand_email_admin, NULL },
- { "email:owner", NULL, expand_email_owner, NULL },
-#endif
{ "report", NULL, expand_report, NULL },
{ "comment", NULL, expand_comment, NULL },
DECL_FULL_TIMER(wydawca),
@@ -885,10 +881,14 @@ struct metadef triplet_meta[] = {
};
char *
-triplet_expand_param(const char *tmpl, struct file_triplet const *trp)
+triplet_expand_param(const char *tmpl, struct file_triplet const *trp,
+ struct metadef *xmeta)
{
- char *p = meta_expand_string(tmpl, triplet_meta, (void *)trp,
- NULL, NULL);
- meta_free(triplet_meta);
+ char *p;
+ struct metadef *mp = metadef_join(triplet_meta, xmeta);
+
+ p = meta_expand_string(tmpl, mp, (void *)trp, NULL, NULL);
+ meta_free(mp);
+ free(mp);
return p;
}
diff --git a/src/wydawca.h b/src/wydawca.h
index ea5705f..685bf3a 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -313,6 +313,7 @@ struct metadef {
char *meta_expand_string(const char *string, struct metadef *def, void *data,
struct dictionary *dict, void *handle);
void meta_free(struct metadef *def);
+struct metadef *metadef_join(struct metadef *a, struct metadef *b);
const char *expand_email_admin(struct metadef *def, void *data);
const char *expand_email_owner(struct metadef *def, void *data);
@@ -458,7 +459,8 @@ void spool_commit_triplets(struct spool *, struct file_triplet *);
struct file_triplet *link_processable_triplets(void);
size_t count_collected_triplets(void);
-char *triplet_expand_param(const char *tmpl, struct file_triplet const *trp);
+char *triplet_expand_param(const char *tmpl, struct file_triplet const *trp,
+ struct metadef *xmeta);
char *triplet_expand_dictionary_query(struct dictionary *dict, void *handle,
struct file_triplet const *trp);

Return to:

Send suggestions and report system problems to the System administrator.