summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgbert Eich <eich@suse.de>2004-04-23 19:55:03 +0000
committerEgbert Eich <eich@suse.de>2004-04-23 19:55:03 +0000
commitaace498f6c8042e0902b5b02905df987b1f1b077 (patch)
treed7bd4510966c50ba1b037092977d678f2929ccec
parenta233cbf4cd7f194266e6ebe68e529b6fd95bbff0 (diff)
Merging XORG-CURRENT into trunkXACE-SELINUX-MERGE
-rw-r--r--xplsprinters.c322
-rw-r--r--xplsprinters.man83
-rw-r--r--xplsprinters.sgml177
3 files changed, 582 insertions, 0 deletions
diff --git a/xplsprinters.c b/xplsprinters.c
new file mode 100644
index 0000000..92fdd3d
--- /dev/null
+++ b/xplsprinters.c
@@ -0,0 +1,322 @@
+/*
+ * $Xorg: xlsprinters.c,v 1.1 2002/02/09 22:54:18 gisburn Exp $
+ *
+ * xlsprinters - print information about Xprint printers and their attributes
+ *
+ *
+Copyright 2002-2004 Roland Mainz <roland.mainz@nrubsig.org>
+
+All Rights Reserved.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ * Author: Roland Mainz <roland.mainz@nrubsig.org>
+ */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/XprintUtil/xprintutil.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Turn a NULL pointer string into an empty string */
+#define NULLSTR(x) (((x)!=NULL)?(x):(""))
+
+#define BOOL2STR(x) ((x)?("true"):("false"))
+
+static const char *ProgramName;
+
+static
+void usage(void)
+{
+ fprintf (stderr, "usage: %s [options]\n", ProgramName);
+ fprintf (stderr, "-printer printername\tprinter to use\n");
+ fprintf (stderr, "-l\tlist detailed printer info\n");
+ fprintf (stderr, "-dump\tdump all available printer attrbutes\n");
+ fprintf (stderr, "\n");
+ exit(EXIT_FAILURE);
+}
+
+static
+void dumpAttributes( Display *pdpy, XPContext pcontext )
+{
+ char *s;
+ printf("--> Job\n%s\n", s=XpuGetJobAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Doc\n%s\n", s=XpuGetDocAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Page\n%s\n", s=XpuGetPageAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Printer\n%s\n", s=XpuGetPrinterAttributes(pdpy, pcontext)); XFree(s);
+ printf("--> Server\n%s\n", s=XpuGetServerAttributes(pdpy, pcontext)); XFree(s);
+ printf("image resolution %d\n", (int)XpGetImageResolution(pdpy, pcontext));
+}
+
+static
+void print_medium_sizes( Display *pdpy, XPContext pcontext )
+{
+ XpuMediumSourceSizeList list;
+ int list_count;
+ char *value;
+ int i;
+
+ value = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-medium");
+ if( value )
+ {
+ printf("\tdefault-medium=%s\n", NULLSTR(value));
+ XFree(value);
+ }
+ value = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-input-tray");
+ if( value )
+ {
+ printf("\tdefault-input-tray=%s\n", NULLSTR(value));
+ XFree(value);
+ }
+
+ list = XpuGetMediumSourceSizeList(pdpy, pcontext, &list_count);
+ if( !list )
+ {
+ fprintf(stderr, "XpuGetMediumSourceSizeList returned NULL\n");
+ return;
+ }
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuMediumSourceSizeRec *curr = &list[i];
+ if( curr->tray_name )
+ {
+ printf("\tmedium-source-sizes-supported=%s/%s %s %g %g %g %g\n",
+ curr->tray_name, curr->medium_name, BOOL2STR(curr->mbool),
+ curr->ma1, curr->ma2, curr->ma3, curr->ma4);
+ }
+ else
+ {
+ printf("\tmedium-source-sizes-supported=%s %s %g %g %g %g\n",
+ curr->medium_name, BOOL2STR(curr->mbool),
+ curr->ma1, curr->ma2, curr->ma3, curr->ma4);
+ }
+ }
+
+ XpuFreeMediumSourceSizeList(list);
+}
+
+
+static
+void print_resolutions( Display *pdpy, XPContext pcontext )
+{
+ long dpi;
+ XpuResolutionList list;
+ int list_count;
+ int i;
+
+ if( XpuGetResolution(pdpy, pcontext, &dpi) == 1 )
+ {
+ printf("\tdefault-printer-resolution=%ld\n", dpi);
+ }
+
+ list = XpuGetResolutionList(pdpy, pcontext, &list_count);
+ if( !list )
+ {
+ fprintf(stderr, "XpuGetResolutionList returned NULL\n");
+ return;
+ }
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuResolutionRec *curr = &list[i];
+ printf("\tresolution=%ld\n", curr->dpi);
+ }
+
+ XpuFreeResolutionList(list);
+}
+
+static
+void print_orientations( Display *pdpy, XPContext pcontext )
+{
+ char *default_orientation;
+ XpuOrientationList list;
+ int list_count;
+ int i;
+
+ default_orientation = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "content-orientation");
+ if( default_orientation )
+ {
+ printf("\tdefault_orientation=%s\n", default_orientation);
+ XFree(default_orientation);
+ }
+
+ list = XpuGetOrientationList(pdpy, pcontext, &list_count);
+ if( !list || list_count == 0 )
+ {
+ fprintf(stderr, "XpuGetOrientationList returned NULL\n");
+ return;
+ }
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuOrientationRec *curr = &list[i];
+ printf("\torientation=%s\n", curr->orientation);
+ }
+
+ XpuFreeOrientationList(list);
+}
+
+static
+void print_plexes( Display *pdpy, XPContext pcontext )
+{
+ char *default_plex;
+ XpuPlexList list;
+ int list_count;
+ int i;
+
+ default_plex = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "plex");
+ if( default_plex )
+ {
+ printf("\tdefault_plex=%s\n", default_plex);
+ XFree(default_plex);
+ }
+
+ list = XpuGetPlexList(pdpy, pcontext, &list_count);
+ if( !list || list_count == 0 )
+ {
+ fprintf(stderr, "XpGetOneAttribute returned NULL\n");
+ return;
+ }
+
+ for( i = 0 ; i < list_count ; i++ )
+ {
+ XpuPlexRec *curr = &list[i];
+ printf("\tplex=%s\n", curr->plex);
+ }
+
+ XpuFreePlexList(list);
+}
+
+static
+void print_detailed_printer_info(XPPrinterRec *xp_rec, int detailLevel)
+{
+ Display *pdpy; /* X connection */
+ XPContext pcontext; /* Xprint context */
+
+ if( detailLevel < 2 )
+ return;
+
+ if( XpuGetPrinter(xp_rec->name, &pdpy, &pcontext) != 1 )
+ {
+ fprintf(stderr, "Cannot open printer '%s'\n", xp_rec->name);
+ return;
+ }
+
+ printf("printer: %s\n", xp_rec->name);
+ printf("\tcomment=%s\n", NULLSTR(xp_rec->desc));
+ printf("\tmodel-identifier=%s\n", NULLSTR(XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-model-identifier")));
+
+ print_medium_sizes(pdpy, pcontext);
+ print_resolutions(pdpy, pcontext);
+ print_orientations(pdpy, pcontext);
+ print_plexes(pdpy, pcontext);
+
+ if (detailLevel > 100)
+ dumpAttributes(pdpy, pcontext);
+
+ XpuClosePrinterDisplay(pdpy, pcontext);
+}
+
+static
+void print_printer_info(XPPrinterRec *xp_rec, int detailLevel)
+{
+ Display *pdpy; /* X connection */
+ XPContext pcontext; /* Xprint context */
+ long dpi;
+
+ printf("printer: %s\n", xp_rec->name);
+
+ if( detailLevel < 1 )
+ return;
+
+ printf("\tcomment=%s\n", NULLSTR(xp_rec->desc));
+}
+
+int main (int argc, char *argv[])
+{
+ char *printername = NULL; /* printer to query */
+ int details = 0;
+ Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */
+ int i; /* temp variable: iterator */
+ XPPrinterList plist; /* list of printers */
+ int plist_count; /* number of entries in |plist|-array */
+
+
+ ProgramName = argv[0];
+
+ for( i = 1 ; i < argc ; i++ )
+ {
+ char *arg = argv[i];
+ int len = strlen(arg);
+
+ if( !strncmp("-printer", arg, len) )
+ {
+ if (++i >= argc)
+ usage ();
+ printername = argv[i];
+ }
+ else if( !strncmp("-l", arg, len) )
+ {
+ details = 2;
+ }
+ else if( !strncmp("-dump", arg, len) )
+ {
+ details = 255;
+ }
+ else if( !strncmp("-debug_use_threadsafe_api", arg, len) )
+ {
+ use_threadsafe_api = True;
+ }
+ else
+ {
+ usage();
+ }
+ }
+
+ if( use_threadsafe_api )
+ {
+ if( !XInitThreads() )
+ {
+ fprintf(stderr, "%s: XInitThreads() failure.\n", ProgramName);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ plist = XpuGetPrinterList(printername, &plist_count);
+
+ if (!plist) {
+ fprintf(stderr, "%s: no printers found for printer spec \"%s\".\n",
+ ProgramName, NULLSTR(printername));
+ exit(EXIT_FAILURE);
+ }
+
+ for (i = 0; i < plist_count; i++)
+ {
+ if( details < 2)
+ print_printer_info(&plist[i], details);
+ else
+ print_detailed_printer_info(&plist[i], details);
+ }
+
+ XpuFreePrinterList(plist);
+
+ return(EXIT_SUCCESS);
+}
+
+
diff --git a/xplsprinters.man b/xplsprinters.man
new file mode 100644
index 0000000..3fb4f6b
--- /dev/null
+++ b/xplsprinters.man
@@ -0,0 +1,83 @@
+.\" This manpage has been automatically generated by docbook2man
+.\" from a DocBook document. This tool can be found at:
+.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/>
+.\" Please send any bug reports, improvements, comments, patches,
+.\" etc. to Steve Cheng <steve@ggi-project.org>.
+.TH "XPLSPRINTERS" "__mansuffix__" "13 February 2004" "" ""
+.SH NAME
+xplsprinters \- shows a list of Xprint printers and it's attributes
+.SH SYNOPSIS
+
+\fBxplsprinters\fR [ \fB-l\fR] [ \fB-printer \fIprintername\fB\fR] [ \fB-dump\fR] [ \fB-h\fR]
+
+.SH "DESCRIPTION"
+.PP
+\fBxplsprinters\fR is a utility for Xprint, the
+printing system for the X Window system. It can deliver both a list
+of printers and attributes supported for a specific list of
+printers.
+.SH "OPTIONS"
+.TP
+\fB-dump \fR
+dump all available printer attributes
+.TP
+\fB-h | -? \fR
+print usage
+.TP
+\fB-l \fR
+list detailed printer attribute information
+.TP
+\fB-printer \fIprintername\fB \fR
+printer to use
+.SH "ENVIRONMENT"
+.TP
+\fBXPSERVERLIST \fR
+\fB${XPSERVERLIST}\fR must be set,
+identifying the available Xprint servers.
+See \fBXprint\fR(__miscmansuffix__)
+for more details.
+.SH "EXAMPLES"
+.SS "LIST ALL AVAILABLE \&"X PRINT SPECIFIERS\&" (PRINTER NAMES)"
+.PP
+
+.nf
+% \fBxplsprinters\fR
+.fi
+.PP
+would print:
+
+.nf
+printer: hplaserjet001@puck:33
+printer: hpcolor4550_004@puck:33
+printer: laser19@meridian:19
+printer: xp_ps_spooldir_tmp_Xprintjobs@meridian:19
+printer: xp_pdf_spooldir_tmp_Xprintjobs@meridian:19
+.fi
+.SS "GET INFORMATION ABOUT THE SUPPORTED ATTRIBUTES OF PRINTER \&"PS002\&":"
+.PP
+
+.nf
+% \fBxplsprinters -printer ps002 -l\fR
+.fi
+.PP
+would print:
+
+.nf
+printer: ps002@castor:18
+ comment=
+ model-identifier=HPDJ1600C
+ default-medium=iso-a4
+ default-input-tray=
+ medium-source-sizes-supported=iso-a4 false 6.35 203.65 6.35 290.65
+ medium-source-sizes-supported=na-letter false 6.35 209.55 6.35 273.05
+ default-printer-resolution=300
+ resolution=300
+ default_orientation=
+ orientation=portrait
+ orientation=landscape
+ default_plex=
+ plex=simplex
+.fi
+.SH "SEE ALSO"
+.PP
+\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxphelloworld\fR(__mansuffix__), \fBxpxmhelloworld\fR(__mansuffix__), \fBxpawhelloworld\fR(__mansuffix__), \fBxpxthelloworld\fR(__mansuffix__), \fBxpsimplehelloworld\fR(__mansuffix__), \fBXserver\fR(__mansuffix__), \fBXprt\fR(__mansuffix__), \fBlibXp\fR(__libmansuffix__), \fBlibXprintUtils\fR(__libmansuffix__), \fBlibXprintAppUtils\fR(__libmansuffix__), \fBXmPrintShell\fR(__libmansuffix__), \fBXawPrintShell\fR(__libmansuffix__), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html <URL:http://xprint.mozdev.org/docs/Xprint_FAQ.html>), Xprint main site (http://xprint.mozdev.org/ <URL:http://xprint.mozdev.org/>)
diff --git a/xplsprinters.sgml b/xplsprinters.sgml
new file mode 100644
index 0000000..be6b044
--- /dev/null
+++ b/xplsprinters.sgml
@@ -0,0 +1,177 @@
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" '/usr/share/sgml/docbook_4.2/docbook.dtd'>
+
+<!-- Process this file with DocBook tools to generate the output format
+(such as manual pages or HTML documents).
+
+Note that strings like __mansuffix__, __filemansuffix__, __libmansuffix__,
+__miscmansuffix__ etc. have to be replaced first (in theory that's the
+job of ENTITIES but some XML tools are highly allergic to such stuff... ;-().
+A quick way to do that is to filter this document via
+/usr/bin/sed "s/__mansuffix__/${MANSUFFIX}/g;s/__filemansuffix__/${FILEMANSUFFIX}/g;s/__libmansuffix__/${LIBMANSUFFIX}/g;s/__miscmansuffix__/${MISCMANSUFFIX}/g"
+assuming that env vars like MANSUFFIX etc. have been set to the matching
+manual volume numbers.
+ -->
+
+<refentry>
+ <refmeta>
+ <refentrytitle>xplsprinters</refentrytitle>
+ <manvolnum>__mansuffix__</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xplsprinters</refname>
+ <refpurpose>shows a list of Xprint printers and it's attributes</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xplsprinters</command>
+
+ <arg><option>-l</option></arg>
+
+ <arg><option>-printer <replaceable>printername</replaceable></option></arg>
+
+ <arg><option>-dump</option></arg>
+
+ <arg><option>-h</option></arg>
+
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para>
+ <command>xplsprinters</command> is a utility for Xprint, the
+ printing system for the X Window system. It can deliver both a list
+ of printers and attributes supported for a specific list of
+ printers.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-dump</option>
+ </term>
+ <listitem>
+ <para>dump all available printer attributes</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-h | -?</option>
+ </term>
+ <listitem>
+ <para>print usage</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-l</option>
+ </term>
+ <listitem>
+ <para>list detailed printer attribute information</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-printer <replaceable>printername</replaceable></option>
+ </term>
+ <listitem>
+ <para>printer to use</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>ENVIRONMENT</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><envar>XPSERVERLIST</envar>
+ </term>
+ <listitem>
+ <para><envar>${XPSERVERLIST}</envar> must be set,
+ identifying the available Xprint servers.
+ See <citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry>
+ for more details.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1>
+ <title>EXAMPLES</title>
+
+ <example role="example">
+ <title>List all available "X Print Specifiers" (printer names)</title>
+ <para><screen>% <userinput>xplsprinters</userinput></screen></para>
+ <para>would print:
+<screen><computeroutput>printer: hplaserjet001@puck:33
+printer: hpcolor4550_004@puck:33
+printer: laser19@meridian:19
+printer: xp_ps_spooldir_tmp_Xprintjobs@meridian:19
+printer: xp_pdf_spooldir_tmp_Xprintjobs@meridian:19</computeroutput></screen>
+ </para>
+ </example>
+
+ <example role="example">
+ <title>Get information about the supported attributes of printer "ps002":</title>
+ <para><screen>% <userinput>xplsprinters -printer ps002 -l</userinput></screen></para>
+ <para>would print:
+<screen><computeroutput>
+printer: ps002@castor:18
+ comment=
+ model-identifier=HPDJ1600C
+ default-medium=iso-a4
+ default-input-tray=
+ medium-source-sizes-supported=iso-a4 false 6.35 203.65 6.35 290.65
+ medium-source-sizes-supported=na-letter false 6.35 209.55 6.35 273.05
+ default-printer-resolution=300
+ resolution=300
+ default_orientation=
+ orientation=portrait
+ orientation=landscape
+ default_plex=
+ plex=simplex
+</computeroutput></screen>
+ </para>
+ </example>
+ </refsect1>
+
+ <refsect1>
+ <title>SEE ALSO</title>
+ <para>
+ <simplelist type="inline">
+ <!-- specific references -->
+ <!-- none -->
+
+ <!-- Xprint general references -->
+ <member><citerefentry><refentrytitle>Xprint</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>X11</refentrytitle><manvolnum>__miscmansuffix__</manvolnum></citerefentry></member>
+<!--
+ <member><citerefentry><refentrytitle>xplsprinters</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+-->
+ <member><citerefentry><refentrytitle>xphelloworld</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpxmhelloworld</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpawhelloworld</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpxthelloworld</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>xpsimplehelloworld</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>Xserver</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>Xprt</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+ <!-- ToDO: Add manual pages for the single Xprint DDX implementations (PostScript/PDF/PCL/PCL-MONO/Raster/etc.) -->
+ <member><citerefentry><refentrytitle>libXp</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>libXprintUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>libXprintAppUtils</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>XmPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member><citerefentry><refentrytitle>XawPrintShell</refentrytitle><manvolnum>__libmansuffix__</manvolnum></citerefentry></member>
+ <member>Xprint FAQ (<ulink url="http://xprint.mozdev.org/docs/Xprint_FAQ.html">http://xprint.mozdev.org/docs/Xprint_FAQ.html</ulink>)</member>
+ <member>Xprint main site (<ulink url="http://xprint.mozdev.org/">http://xprint.mozdev.org/</ulink>)</member>
+ </simplelist>
+ </para>
+ </refsect1>
+</refentry>
+
+