summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Mainz <roland.mainz@nrubsig.org>2004-06-29 17:10:13 +0000
committerRoland Mainz <roland.mainz@nrubsig.org>2004-06-29 17:10:13 +0000
commitcfb6aa3f2e0fb18914446c58a82d43ed0fc6f7e4 (patch)
tree880473838fa8d4e4521cc7ea9ecf5071c4007ccc
adminstration tool to rehash the list of available printers on demand.
-rw-r--r--xprehashprinterlist.c141
-rw-r--r--xprehashprinterlist.man53
-rw-r--r--xprehashprinterlist.sgml143
3 files changed, 337 insertions, 0 deletions
diff --git a/xprehashprinterlist.c b/xprehashprinterlist.c
new file mode 100644
index 0000000..1b7986f
--- /dev/null
+++ b/xprehashprinterlist.c
@@ -0,0 +1,141 @@
+/*
+ * $Xorg: xprehashprinterlist.c,v 1.1 2004/06/29 02:19:15 gisburn Exp $
+ *
+ * xprehashprinterlist - recalculate the list of available printers
+ *
+ *
+Copyright 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/extensions/Print.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define Log(x) { if(verbose) printf x; }
+
+/* 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 Bool verbose = False;
+
+static
+void usage(void)
+{
+ fprintf (stderr, "usage: %s [options]\n", ProgramName);
+ fprintf (stderr, "-v\tverbose\n");
+ fprintf (stderr, "\n");
+ exit(EXIT_FAILURE);
+}
+
+
+static
+void rehash_printers(const char *display)
+{
+ Display *dpy;
+ short dummy;
+
+ dpy = XOpenDisplay(display);
+ if (!dpy) {
+ fprintf(stderr, "%s: Cannot open print server display %s\n", ProgramName, display);
+ return;
+ }
+
+ if (XpQueryVersion(dpy, &dummy, &dummy)) {
+ XpRehashPrinterList(dpy);
+ } else {
+ fprintf(stderr, "%s: server does not have the XpExtension extension\n", ProgramName);
+ }
+ XCloseDisplay(dpy);
+}
+
+/* Copied from xc/lib/XprintUtil/xprintutil.c:
+ * List of tokens which can be used to seperate entries in the
+ * $XPSERVERLIST env var */
+static const char XPServerListSeparators[] = " \t\v\n\r\f";
+
+int main (int argc, char *argv[])
+{
+ int i;
+ char *tok_lasts;
+ char *display;
+ char *sl;
+ Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */
+
+ ProgramName = argv[0];
+
+ for( i = 1 ; i < argc ; i++ )
+ {
+ char *arg = argv[i];
+ int len = strlen(arg);
+
+ if (!strncmp("-v", arg, len)) {
+ verbose = True;
+ }
+ 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);
+ }
+ }
+
+ sl = getenv("XPSERVERLIST");
+ if (!sl) {
+ fprintf(stderr, "%s: XPSERVERLIST environment variable not set.\n", ProgramName);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Copy the env value since strtok_r() will write to the string */
+ sl = strdup(sl);
+ if (!sl) {
+ fprintf(stderr, "%s: Out of memory.\n", ProgramName);
+ exit(EXIT_FAILURE);
+ }
+
+ for( display = strtok_r(sl, XPServerListSeparators, &tok_lasts) ;
+ display != NULL ;
+ display = strtok_r(NULL, XPServerListSeparators, &tok_lasts) )
+ {
+ Log(("Rehashing printer list on server '%s'\n", display));
+ rehash_printers(display);
+ }
+
+ free(sl);
+
+ return EXIT_SUCCESS;
+}
+
+
diff --git a/xprehashprinterlist.man b/xprehashprinterlist.man
new file mode 100644
index 0000000..1224a78
--- /dev/null
+++ b/xprehashprinterlist.man
@@ -0,0 +1,53 @@
+.\" 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 "XPREHASHPRINTERLIST" "__mansuffix__" "29 June 2004" "" ""
+.SH NAME
+xprehashprinterlist \- Recomputes the list of available printers.
+.SH SYNOPSIS
+
+\fBxprehashprinterlist\fR [ \fB-v\fR] [ \fB-h\fR]
+
+.SH "DESCRIPTION"
+.PP
+\fBxprehashprinterlist\fR causes all Xprint servers
+to recompute (update) their lists of available printers, and update the
+attributes for the printers. The intended usage of this tool is that
+a system administrator can run it after changing the printer topology.
+.SH "OPTIONS"
+.TP
+\fB-v \fR
+generate verbose output
+.TP
+\fB-h | -? \fR
+print usage
+.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 "UPDATE THE LIST OF AVAILABLE PRINTERS"
+.PP
+
+.nf
+% \fBxprehashprinterlist -v\fR
+.fi
+.PP
+would print:
+
+.nf
+Rehashing printer list on server 'meridian:34'
+.fi
+.SH "NOTES"
+.PP
+\fBxprehashprinterlist\fR rehashes all printer lists of all print servers.
+Alternatively \fBxset rehashprinterlist\fR may be used to rehash only the
+list of printers in one print server.
+.SH "SEE ALSO"
+.PP
+\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxset\fR(__mansuffix__), \fBxplsprinters\fR(__mansuffix__), \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/xprehashprinterlist.sgml b/xprehashprinterlist.sgml
new file mode 100644
index 0000000..5acd658
--- /dev/null
+++ b/xprehashprinterlist.sgml
@@ -0,0 +1,143 @@
+<!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>xprehashprinterlist</refentrytitle>
+ <manvolnum>__mansuffix__</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xprehashprinterlist</refname>
+ <refpurpose>Recomputes the list of available printers.</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xprehashprinterlist</command>
+
+ <arg><option>-v</option></arg>
+
+ <arg><option>-h</option></arg>
+
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para>
+ <command>xprehashprinterlist</command> causes all Xprint servers
+ to recompute (update) their lists of available printers, and update the
+ attributes for the printers. The intended usage of this tool is that
+ a system administrator can run it after changing the printer topology.
+ </para>
+ </refsect1>
+
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-v</option>
+ </term>
+ <listitem>
+ <para>generate verbose output</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-h | -?</option>
+ </term>
+ <listitem>
+ <para>print usage</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>Update the list of available printers</title>
+ <para><screen>% <userinput>xprehashprinterlist -v</userinput></screen></para>
+ <para>would print:
+<screen><computeroutput>Rehashing printer list on server 'meridian:34'</computeroutput></screen>
+ </para>
+ </example>
+ </refsect1>
+
+ <refsect1>
+ <title>NOTES</title>
+ <para>
+ <command>xprehashprinterlist</command> rehashes all printer lists of all print servers.
+ Alternatively <command>xset rehashprinterlist</command> may be used to rehash only the
+ list of printers in one print server.
+ </para>
+ </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>xprehashprinterlist</refentrytitle><manvolnum>__mansuffix__</manvolnum></citerefentry></member>
+-->
+ <member><citerefentry><refentrytitle>xset</refentrytitle><manvolnum>__mansuffix__</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>
+
+