summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-11-03 02:16:31 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-11-03 02:16:31 (GMT)
commit02bb8b3210667825a1fceedfb9c5b46b8177a9cb (patch)
tree2c52901239eadfbd55f931b091e2678b09e6a285
parent01a1b57cefe69a7e814bede44d61ca1f6f78151e (diff)
downloadeeshow-02bb8b3210667825a1fceedfb9c5b46b8177a9cb.zip
eeshow-02bb8b3210667825a1fceedfb9c5b46b8177a9cb.tar.gz
eeshow-02bb8b3210667825a1fceedfb9c5b46b8177a9cb.tar.bz2
gfx/pdftoc.c (pdftoc_title), pdftoc.h: support printf-style format
-rw-r--r--gfx/pdftoc.c7
-rw-r--r--gfx/pdftoc.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/gfx/pdftoc.c b/gfx/pdftoc.c
index e24edd1..efcd4b9 100644
--- a/gfx/pdftoc.c
+++ b/gfx/pdftoc.c
@@ -238,12 +238,15 @@ bool pdftoc_write(struct pdftoc *ctx, const void *data, unsigned length)
}
-void pdftoc_title(struct pdftoc *ctx, const char *title)
+void pdftoc_title(struct pdftoc *ctx, const char *fmt, ...)
{
+ va_list ap;
struct title *t;
t = alloc_type(struct title);
- t->s = stralloc(title);
+ va_start(ap, fmt);
+ alloc_vprintf(&t->s, fmt, ap);
+ va_end(ap);
*ctx->next_title = t;
t->next = NULL;
ctx->next_title = &t->next;
diff --git a/gfx/pdftoc.h b/gfx/pdftoc.h
index aabc8ef..3dd8a71 100644
--- a/gfx/pdftoc.h
+++ b/gfx/pdftoc.h
@@ -22,7 +22,8 @@ struct pdftoc;
struct pdftoc *pdftoc_begin(void);
bool pdftoc_set_file(struct pdftoc *ctx, const char *file);
bool pdftoc_write(struct pdftoc *ctx, const void *data, unsigned length);
-void pdftoc_title(struct pdftoc *ctx, const char *title);
+void pdftoc_title(struct pdftoc *ctx, const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
void pdftoc_end(struct pdftoc *ctx);
#endif /* !GFX_PDFTOC_H */