summaryrefslogtreecommitdiff
path: root/gfx/fig.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-03 15:11:50 -0300
committerWerner Almesberger <werner@almesberger.net>2016-09-03 19:52:24 -0300
commitcd197d8d8b34e3770ec49dfdc808427b2e1f0963 (patch)
tree6d113a0a97979d52309e463554c2209fc8151ae0 /gfx/fig.c
parent487c2ed78ba10bdd089009fe88f21fbc276ee3b2 (diff)
downloadeeshow-cd197d8d8b34e3770ec49dfdc808427b2e1f0963.tar.gz
eeshow-cd197d8d8b34e3770ec49dfdc808427b2e1f0963.tar.bz2
eeshow-cd197d8d8b34e3770ec49dfdc808427b2e1f0963.zip
gfx/gfx.c: we now pass a combined option string to drivers
Further changes implied by this: - drivers can no longer receive arguments, only options - drivers have to ignore options they don't recognize
Diffstat (limited to 'gfx/fig.c')
-rw-r--r--gfx/fig.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gfx/fig.c b/gfx/fig.c
index c0fa470..021321e 100644
--- a/gfx/fig.c
+++ b/gfx/fig.c
@@ -288,7 +288,7 @@ static void *fig_init(void)
}
-static bool fig_args(void *ctx, int argc, char *const *argv)
+static bool fig_args(void *ctx, int argc, char *const *argv, const char *opts)
{
struct fig_ctx *fig = ctx;
static char *buf = NULL;
@@ -302,7 +302,7 @@ static bool fig_args(void *ctx, int argc, char *const *argv)
FILE *file;
int lines_to_colors = 8;
- while ((c = getopt(argc, argv, "o:t:D:")) != EOF)
+ while ((c = getopt(argc, argv, opts)) != EOF)
switch (c) {
case 'o':
colon = strchr(optarg, ':');
@@ -318,13 +318,12 @@ static bool fig_args(void *ctx, int argc, char *const *argv)
vars = realloc_type_n(vars, const char *, n_vars);
vars[n_vars - 1] = optarg;
break;
- default:
+ case '?':
usage(*argv);
+ default:
+ break;
}
- if (argc != optind)
- usage(*argv);
-
if (output && strcmp(output, "-")) {
fig->file = fopen(output, "w");
if (!fig->file)
@@ -377,6 +376,8 @@ static const char *const fig_ext[] = { "fig" };
const struct gfx_ops fig_ops = {
.ext = fig_ext,
.n_ext = ARRAY_ELEMENTS(fig_ext),
+ .opts = "o:t:D:",
+
.line = fig_line,
.rect = fig_rect,
.poly = fig_poly,