summaryrefslogtreecommitdiff
path: root/Build/source/libs/paper/libpaper-1.1.24+nmu2/src
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/paper/libpaper-1.1.24+nmu2/src')
-rw-r--r--Build/source/libs/paper/libpaper-1.1.24+nmu2/src/Makefile.am8
-rw-r--r--Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconf.c234
-rw-r--r--Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconfig.in227
3 files changed, 469 insertions, 0 deletions
diff --git a/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/Makefile.am b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/Makefile.am
new file mode 100644
index 00000000000..5d7bc85170e
--- /dev/null
+++ b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/Makefile.am
@@ -0,0 +1,8 @@
+
+bin_PROGRAMS = paperconf
+paperconf_LDADD = ../lib/libpaper.la
+paperconf_CPPFLAGS = -I$(top_srcdir)/lib
+
+sbin_SCRIPTS = paperconfig
+
+EXTRA_DIST = paperconfig.in
diff --git a/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconf.c b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconf.c
new file mode 100644
index 00000000000..d0fa34fab2f
--- /dev/null
+++ b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconf.c
@@ -0,0 +1,234 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <paper.h>
+
+
+/* needed for GNU/Hurd */
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 4096
+#endif
+
+static void usage(const char* name)
+{
+ fprintf(stderr,
+ "usage: %s [ [ -p ] papername | -d | -a ] [ -z ] [ -n | -N ] [ -s | -w | -h ] [ -c | -m | -i ]\n",
+ name);
+ exit(1);
+}
+
+#define OPT_NAME 1
+#define OPT_UPPERNAME 2
+#define OPT_WIDTH 4
+#define OPT_HEIGHT 8
+#define OPT_CM 16
+#define OPT_MM 32
+#define OPT_INCH 64
+#define OPT_CONTINUE 128
+
+#define OPT_UNIT (OPT_CM | OPT_MM | OPT_INCH)
+
+#define INCHxCM 2.54
+
+static void printinfo(const struct paper* paper, int options)
+{
+ int pr = 0;
+
+ if ((options & ~(OPT_CONTINUE)) == 0) {
+ options = OPT_NAME;
+ }
+
+ if (options & OPT_NAME) {
+ printf("%s", papername(paper));
+ pr = 1;
+ } else if (options & OPT_UPPERNAME) {
+ if (islower(*papername(paper))) {
+ printf("%c%s", toupper(*papername(paper)), papername(paper) + 1);
+ } else {
+ printf("%s", papername(paper));
+ }
+ pr = 1;
+ }
+
+ if (options & OPT_WIDTH) {
+ if (pr) putchar(' ');
+ if (options & OPT_CM)
+ printf("%g cm", paperpswidth(paper) / 72.0 * INCHxCM );
+ else if (options & OPT_MM)
+ printf("%g mm", paperpswidth(paper) / 72.0 * 10 * INCHxCM );
+ else if (options & OPT_INCH)
+ printf("%g\"", paperpswidth(paper) / 72.0 );
+ else
+ printf("%g", paperpswidth(paper) );
+ pr = 1;
+ }
+ if (options & OPT_HEIGHT) {
+ if (pr) putchar(' ');
+ if (options & OPT_CM)
+ printf("%g cm", paperpsheight(paper) / 72.0 * INCHxCM );
+ else if (options & OPT_MM)
+ printf("%g mm", paperpsheight(paper) / 72.0 * 10 * INCHxCM );
+ else if (options & OPT_INCH)
+ printf("%g\"", paperpsheight(paper) / 72.0 );
+ else
+ printf("%g", paperpsheight(paper) );
+ pr = 1;
+ }
+
+ putchar('\n');
+}
+
+int main(int argc, char** argv)
+{
+ int c;
+
+ int all = 0;
+ const char* paper = 0;
+ unsigned options = 0;
+
+ const char* progname;
+
+ progname = strrchr(*argv, '/');
+ if (progname) {
+ ++progname;
+ } else {
+ progname = *argv;
+ }
+
+ while ((c = getopt(argc, argv, "adznNswhcmip:")) != EOF) {
+ switch (c) {
+ case 'a':
+ if (paper || all) {
+ usage(progname);
+ }
+ all = 1;
+ break;
+
+ case 'd':
+ if (paper || all) {
+ usage(progname);
+ }
+ paper = defaultpapername();
+ break;
+
+ case 'p':
+ if (paper || all) {
+ usage(progname);
+ }
+ paper = optarg;
+ break;
+
+ case 'z':
+ options |= OPT_CONTINUE;
+ break;
+
+ case 'n':
+ if (options & OPT_UPPERNAME) usage(progname);
+ options |= OPT_NAME;
+ break;
+
+ case 'N':
+ if (options & OPT_NAME) usage(progname);
+ options |= OPT_UPPERNAME;
+ break;
+
+ case 's':
+ options |= OPT_WIDTH | OPT_HEIGHT;
+ break;
+
+ case 'w':
+ options |= OPT_WIDTH;
+ break;
+
+ case 'h':
+ options |= OPT_HEIGHT;
+ break;
+
+ case 'c':
+ if (options & OPT_UNIT) usage(progname);
+ options |= OPT_CM;
+ break;
+
+ case 'm':
+ if (options & OPT_UNIT) usage(progname);
+ options |= OPT_MM;
+ break;
+
+ case 'i':
+ if (options & OPT_UNIT) usage(progname);
+ options |= OPT_INCH;
+ break;
+
+ default:
+ usage(progname);
+ }
+ }
+
+ if (optind < argc - 1 || (paper && optind != argc)) {
+ usage(progname);
+ } else if (optind != argc) {
+ paper = argv[optind];
+ }
+
+ paperinit();
+
+ if (all) {
+ const struct paper* papers;
+
+ for (papers = paperfirst(); papers; papers = papernext(papers)) {
+ printinfo(papers, options);
+ }
+ } else {
+ const struct paper* syspaper;
+
+ if (!paper) paper = systempapername();
+ if (!paper) paper = defaultpapername();
+ if (!paper) {
+ char errmsg[2 * MAXPATHLEN + 64];
+
+ sprintf(errmsg, "%s: cannot get paper size from %s",
+ progname, systempapersizefile());
+
+ if (errno) {
+ perror(errmsg);
+ } else {
+ fputs(errmsg, stderr);
+ }
+
+ paperdone();
+
+ exit(3);
+ }
+
+ syspaper = paperinfo(paper);
+
+ if (syspaper) {
+ printinfo(syspaper, options);
+ } else {
+ fprintf(stderr, "%s: unknown paper `%s'\n", progname, paper);
+ if (options & OPT_CONTINUE) {
+ puts(paper);
+ }
+
+ paperdone();
+
+ exit(2);
+ }
+ }
+
+ paperdone();
+
+ return 0;
+}
+
diff --git a/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconfig.in b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconfig.in
new file mode 100644
index 00000000000..9548b4aa2f9
--- /dev/null
+++ b/Build/source/libs/paper/libpaper-1.1.24+nmu2/src/paperconfig.in
@@ -0,0 +1,227 @@
+#! /bin/sh
+
+# paperconfig: configuration of system paper name
+#
+# Copyright (C) 1996, Yves Arrouye <arrouye@debian.org>
+# 2001, Adrian Bunk <bunk@fs.tum.de>
+
+usage() {
+ if [ "$1" = -h ]
+ then
+ exec 1>&2
+ echo -n U
+ else
+ echo -n u
+ fi
+
+ echo "sage: `basename $0` [ -v, --version ] [ -h, --help ] [ -p, --paper name | --force ]"
+
+ if [ "$1" = -h ]
+ then
+ cat <<EOF
+
+Options: -v, --verbose print version information and exit
+ -h, --help print this help and exit
+ -p, --paper name specify the paper to use
+ --force force paper configuration
+EOF
+ exit 0
+ else
+ exit 1
+ fi
+}
+
+# "|| true" added below, to assure that the script does not fail even if
+# called with bash -e. (MP 22/08/98)
+
+unset @PAPERSIZEVAR@ || true
+: ${@PAPERCONFVAR@:=@PAPERCONF@}
+export @PAPERCONFVAR@
+
+unset @RUNPARTSDIRVAR@ || true
+: ${@RUNPARTSDIRVAR@:=@RUNPARTSDIR@}
+export @RUNPARTSDIRVAR@
+
+force=0
+
+if [ "$#" -eq 0 ]
+ then
+ usage
+fi
+
+while [ $# -ne 0 ]
+do
+ case "$1" in
+ -v|--version)
+ echo "`basename $0` version 1.0" \
+ "by Yves Arrouye <arrouye@debian.org>"
+ exit 0
+ ;;
+ -h|--help)
+ usage -h
+ ;;
+ -p|--paper)
+ test $# -gt 1 || usage
+ paper="$2"
+ shift
+ ;;
+ --force)
+ force=1
+ ;;
+ *)
+ usage
+ ;;
+ esac
+ shift
+done
+
+invalidpaper() {
+ ! paperconf "$1" 2>/dev/null 1>&2
+}
+
+format() {
+ _maxwidth=$1; shift
+ _start="$1"; shift
+
+ _cline=
+
+ for w
+ do
+ if [ `echo "$_start$_cline$w " | wc -c` -ge 0$_maxwidth ]
+ then
+ echo "$_cline"
+ _cline=
+ _start=
+ fi
+ _cline="$_cline$w "
+ done
+
+ if [ -n "$_cline" ]
+ then
+ echo "$_cline"
+ fi
+
+ unset _maxwidth _cline _start
+}
+
+# "chmod 644" added below, to assure that the conf file is created
+# with the right access permissions (MP 13/05/2000)
+
+setpaper() {
+ paperright=`paperconf "$1" 2>/dev/null`
+
+ ok=0
+
+ if 2>/dev/null echo "$paperright" >${@PAPERCONFVAR@}.new
+ then
+ if 2>/dev/null mv -f ${@PAPERCONFVAR@}.new $@PAPERCONFVAR@
+ then
+ if 2>/dev/null chmod 644 $@PAPERCONFVAR@
+ then
+ ok=1
+ fi
+ fi
+ fi
+
+ if [ $ok -eq 0 ]
+ then
+ echo `basename $0`: cannot create $@PAPERCONFVAR@
+ exit 2
+ else
+ #
+ # Added code for calling back applications when
+ # papersize changes. See bug #345466
+ # eppesuig@debian.org, 2006-01-05
+ if [ -d ${@RUNPARTSDIRVAR@} ]
+ then
+ run-parts ${@RUNPARTSDIRVAR@}
+ fi
+ fi
+}
+
+if [ ! -z "$paper" ]
+then
+ if invalidpaper $paper
+ then
+ >&2 echo `basename $0`: \"$paper\" is not a known paper name
+ exit 3
+ fi
+ setpaper "$paper"
+ exit 0
+fi
+
+knownpapers="`paperconf -a`"
+
+prompt=
+width=72
+
+# "|| true" added below, to assure that the script does not fail even if
+# called with bash -e. (MP 22/08/98)
+
+paper=`paperconf 2>/dev/null || true`
+dftpaper=`paperconf -d`
+
+if [ $force -eq 1 ] || [ ! -e $@PAPERCONFVAR@ ] || invalidpaper $paper
+then
+ papers="`format $width \"\" $knownpapers`"
+ echo
+
+ if [ -x /usr/bin/pager ]
+ then
+ : ${PAGER:=/usr/bin/pager}
+ fi
+ if [ -x /bin/more ]
+ then
+ : ${PAGER:=/bin/more}
+ fi
+ : ${PAGER:=cat}
+
+ LESS="-X -E $LESS"
+ export LESS
+
+ (
+ cat <<EOF
+The default (also known as system) paper can be chosen from many known
+papers that are currently recognized by programs using the libpaper
+library (with libpaper, paper names are case insensitive; if you use
+programs that use the system paper size but do not rely on the libpaper
+library, this may not be true and some of the papers listed below may
+not be known by these programs):
+
+EOF
+ echo "$papers" | sed 's/^/ /'
+ echo
+ ) | ${PAGER}
+
+ : ${paper:=$dftpaper}
+
+ echo -n "Default paper name? [$paper] "
+ read ans
+ : ${ans:=$paper}
+ paper=$ans
+fi
+
+while invalidpaper "$paper"
+do
+ if [ -z "$paper" ]
+ then
+ echo "Please choose a paper from the available papers list."
+ else
+ echo "Unknow paper \"$paper\"," \
+ "please choose one from the available papers list."
+ fi
+
+ paper=$dftpaper
+
+ echo -n "Default paper name? [$paper] "
+ read ans
+ paper=$ans
+done
+
+if [ "`paperconf 2>/dev/null`" != "$paper" ] || grep -q "[# ]" $@PAPERCONFVAR@
+then
+ setpaper "$paper"
+fi
+
+exit 0
+