aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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.