From bd82d030011cd8b9655e5ded6b6df9343b42a6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 4 Feb 2015 14:09:54 +0100 Subject: Imported Upstream version 3.22 --- assorted/unit2any.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 assorted/unit2any.c (limited to 'assorted/unit2any.c') diff --git a/assorted/unit2any.c b/assorted/unit2any.c new file mode 100644 index 0000000..74e87d3 --- /dev/null +++ b/assorted/unit2any.c @@ -0,0 +1,49 @@ +#include +#include +#include + +static double dpi = 96; + +static void px2any(const struct HXoptcb *cbi) +{ + double px = cbi->data_dbl; + + printf("%f px are (at %f DPI) equal to:\n", px, dpi); + printf("\t%f inch\n", px / dpi); + printf("\t%f pt\n", px * 72 / dpi); + printf("\t%f cm\n", px * 2.54 / dpi); +} + +static void pt2any(const struct HXoptcb *cbi) +{ + double pt = cbi->data_dbl; + + printf("%f pt are equal to:\n", pt); + printf("\t%f inch\n", pt / 72); + printf("\t%f px (at %f DPI)\n", dpi * pt / 72, dpi); + printf("\t%f cm\n", pt * 2.54 / 72); +} + +static const struct HXoption option_table[] = { + {.sh = 'D', .ln = "dpi", .type = HXTYPE_DOUBLE, .ptr = &dpi, + .help = "Resolution (default: 96 dpi)"}, + {.sh = 'P', .ln = "px", .type = HXTYPE_DOUBLE, .cb = px2any}, + {.sh = 'p', .ln = "pt", .type = HXTYPE_DOUBLE, .cb = pt2any}, + HXOPT_AUTOHELP, + HXOPT_TABLEEND, +}; + +static bool get_options(int *argc, const char ***argv) +{ +} + +int main(int argc, const char **argv) +{ + int ret; + + ret = HX_getopt(option_table, &argc, &argv, HXOPT_USAGEONERR); + if (ret != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + + +} -- cgit v1.2.3