db-move: moved webkitgtk-6.0 from [testing] to [extra] (x86_64)
[arch-packages.git] / libpaper / trunk / localepaper.c
blob78404a3707fcc491656063686e0066a43f717695
1 /*
2 * localepaper: print the dimensions in mm of the current locale's
3 * paper size, if possible.
5 * Based on a patch by Caolan McNamara:
6 * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=481213
8 * Copyright (C) Reuben Thomas <rrt@sc3d.org>, 2013.
10 * Copying and distribution of this file, with or without modification,
11 * are permitted in any medium without royalty provided the copyright
12 * notice and this notice are preserved.
15 #include <config.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <locale.h>
20 #if defined LC_PAPER && defined _GNU_SOURCE
21 #include <langinfo.h>
22 #endif
24 #include "progname.h"
26 int main(int argc, char *argv[])
28 set_program_name(argv[0]);
29 argc = argc; /* Avoid a compiler warning. */
31 #if defined LC_PAPER && defined _GNU_SOURCE
32 setlocale(LC_ALL, "");
34 #define NL_PAPER_GET(x) \
35 ((union { char *string; unsigned word; })nl_langinfo(x)).word
37 printf("%d %d\n", NL_PAPER_GET(_NL_PAPER_WIDTH), NL_PAPER_GET(_NL_PAPER_HEIGHT));
38 return EXIT_SUCCESS;
40 #else
41 printf("%s: locale paper size information is not supported on this system", program_name);
42 return EXIT_FAILURE;
43 #endif