Index: xc/Imakefile =================================================================== RCS file: /cvs/xorg/xc/Imakefile,v retrieving revision 1.1.4.2.6.1.6.1 diff -u -r1.1.4.2.6.1.6.1 Imakefile --- a/xc/Imakefile 10 Apr 2004 09:03:31 -0000 1.1.4.2.6.1.6.1 +++ b/xc/Imakefile 13 Apr 2004 05:01:07 -0000 @@ -27,7 +27,8 @@ #endif SUBDIRS = include config lib $(NLSSUBDIR) \ - programs $(FONTSDIR) $(DOCSDIR) + programs $(FONTSDIR) $(DOCSDIR) \ + packager LNINSTALLDIRS = lib #if HasParallelMake Index: xc/config/cf/xprint_site.def =================================================================== RCS file: /cvs/xorg/xc/config/cf/Attic/xprint_site.def,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 xprint_site.def --- a/xc/config/cf/xprint_site.def 13 Apr 2004 03:16:30 -0000 1.1.2.1 +++ b/xc/config/cf/xprint_site.def 13 Apr 2004 05:01:07 -0000 @@ -320,6 +320,6 @@ #ifndef InstallXpPMFFontsDir #define InstallXpPMFFontsDir(destmodelfontdir) @@\ install:: @@\ - (cd $(DESTDIR)destmodelfontdir ; PATH=$(DESTDIR)/$(PROJECTROOT)/bin:$(PROJECTROOT)/bin:$${PATH} mkfontdir) + (cd $(DESTDIR)destmodelfontdir ; $(DESTDIR)$(BINDIR)/mkfontscale -b -s -l) #endif /* InstallXpPMFFontsDir */ Index: xc/programs/xphelloworld/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/xphelloworld/Attic/Imakefile,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 Imakefile --- a/xc/programs/xphelloworld/Imakefile 13 Apr 2004 03:16:48 -0000 1.1.2.1 +++ b/xc/programs/xphelloworld/Imakefile 13 Apr 2004 05:01:31 -0000 @@ -1,20 +1,29 @@ -XCOMM $Xorg: Imakefile,v 1.3 2002/02/10 19:54:53 gisburn Exp $ - -LOCAL_LIBRARIES = $(XLIB) -lXp -lXprintAppUtil -lXprintUtil -SYS_LIBRARIES = MathLibrary -DEPLIBS = $(DEPXLIB) - -DEFINES = - SRCS = xphelloworld.c - OBJS = xphelloworld.o - -ComplexProgramTarget(xphelloworld) - -#ifdef HasDocBookTools -all:: xphelloworld.man xphelloworld.html - -ConvertDocBookToManPage(xphelloworld.sgml, xphelloworld.man) -ConvertDocBookToHTML(xphelloworld.sgml, xphelloworld.html) -#endif /* HasDocBookTools */ - +XCOMM $Xorg: Imakefile,v 1.1 2002/02/10 19:44:00 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags + +XCOMM xpxmprintshell and xpawprintshell use Motif widgets +#if HasMotif2 +XCOMM Solaris's Motif version is broken and misses XmPrintShell +XCOMM (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1366) +#ifndef SunArchitecture + XPXMHELLOWORLDDIR = xpxmhelloworld +#endif /* SunArchitecture */ + XPAWHELLOWORLDDIR = xpawhelloworld +#endif /* HasMotif2 */ + XPXTHELLOWORLDDIR = xpxthelloworld + XPHELLOWORLDDIR = xphelloworld +XPSIMPLEHELLOWORLDDIR = xpsimplehelloworld + +SUBDIRS = \ + $(XPXMHELLOWORLDDIR) \ + $(XPAWHELLOWORLDDIR) \ + $(XPXTHELLOWORLDDIR) \ + $(XPHELLOWORLDDIR) \ + $(XPSIMPLEHELLOWORLDDIR) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) +MakeLintLibSubdirs($(LINTSUBDIRS)) +MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln) Index: xc/programs/xphelloworld/xphelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.c diff -N xc/programs/xphelloworld/xphelloworld.c --- a/xc/programs/xphelloworld/xphelloworld.c 13 Apr 2004 03:16:48 -0000 1.1.2.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,273 +0,0 @@ -/* - * $Xorg: xphelloworld.c,v 1.1 2002/02/10 22:54:18 gisburn Exp $ - * - * xphelloworld - Xprint version of hello world - * - * -Copyright 2002-2004 Roland Mainz - -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 - */ - -#include -#include -#include - -#include -#include -#include - -/* Turn a NULL pointer string into an empty string */ -#define NULLSTR(x) (((x)!=NULL)?(x):("")) - -#define Log(x) { if(verbose) printf x; } - -const char *ProgramName; /* program name (from argv[0]) */ -Bool verbose = False; /* verbose output what the program is doing */ - -static -void usage( void ) -{ - fprintf (stderr, "usage: %s [options]\n", ProgramName); - fprintf (stderr, "-printer printernname\tprinter to use\n"); - fprintf (stderr, "-printargs args\t[ arg=value , ... ]\n"); - fprintf (stderr, "\targs:\ttofile=\n"); - fprintf (stderr, "\t\tpapersize=\n"); - fprintf (stderr, "\t\torientation=\n"); - fprintf (stderr, "\t\tresolution=\n"); - fprintf (stderr, "\t\tplex=\n"); - fprintf (stderr, "\t\ttitle=\n"); - fprintf (stderr, "-v\tverbose output\n"); - fprintf (stderr, "-text \ttext to print (in ISO-8859-1)\n"); - fprintf (stderr, "\n"); - exit(EXIT_FAILURE); -} - -static -int do_hello_world( const char *printername, const char *printerargs, const char *hello_world_message ) -{ - char *printerfile = NULL; - Window pwin; - XGCValues gcvalues; - XEvent ev; - GC pgc; - unsigned short dummy; - XRectangle winrect; - char fontname[256]; /* BUG: is this really big enougth ? */ - XFontStruct *font; - XpauContext *context; - XpauFlags docvalueflags = 0UL; - XpauDocValues x_docvalues; - XpauDocValues *docvalues = &x_docvalues; - XpAuErrorValue result; - - XpauFlags jobvalueflags = 0UL; - XpauJobValues x_jobvalues; - XpauJobValues *jobvalues = &x_jobvalues; - memset(&x_jobvalues, 0, sizeof(x_jobvalues)); - memset(&x_docvalues, 0, sizeof(x_docvalues)); - - context = XpauGetContext(printername); - if( !context ) - { - fprintf(stderr, "XpauGetContext() failure.\n"); - return(EXIT_FAILURE); - } - - if( (result = XpauParseArgs(context, &jobvalueflags, jobvalues, &docvalueflags, docvalues, &printerfile, printerargs)) != XpAuError_success ) - { - fprintf(stderr, "XpuParseArgs() failure: %s.\n", XpAuErrorValueToString(result)); - XpauReleaseContext(context); - return(EXIT_FAILURE); - } - - if( (result = XpauSetJobValues(context, jobvalueflags, jobvalues)) != XpAuError_success ) - { - fprintf(stderr, "XpauSetJobValues() failure: %s.\n", XpAuErrorValueToString(result)); - XpauReleaseContext(context); - return(EXIT_FAILURE); - } - - if( (result = XpauSetDocValues(context, docvalueflags, docvalues)) != XpAuError_success ) - { - fprintf(stderr, "XpauSetDocValues() failure: %s.\n", XpAuErrorValueToString(result)); - XpauReleaseContext(context); - return(EXIT_FAILURE); - } - - /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). - * This is mantatory as Xp(Start|End)(Job|Doc|Page) functions are _not_ - * syncronous !! - * Not waiting for such events may cause that subsequent data may be - * destroyed/corrupted!! - */ - XpSelectInput(context->pdpy, context->pcontext, XPPrintMask); - - if( printerfile ) - { - Log(("starting job (to file '%s').\n", printerfile)); - } - else - { - Log(("starting job.\n")); - } - - if( (result = XpauStartJob(context, printerfile)) != XpAuError_success ) - { - fprintf(stderr, "%s: Error: %s while trying to print.\n", - ProgramName, XpAuErrorValueToString(result)); - XpauReleaseContext(context); - return(EXIT_FAILURE); - } - - XpauWaitForPrintNotify(context, XPStartJobNotify); - - /* Obtain some info about page geometry */ - XpGetPageDimensions(context->pdpy, context->pcontext, &dummy, &dummy, &winrect); - - pwin = XCreateSimpleWindow(context->pdpy, XRootWindowOfScreen(context->pscreen), - winrect.x, winrect.y, winrect.width, winrect.height, - 10, - XBlackPixel(context->pdpy, context->pscreennumber), - XWhitePixel(context->pdpy, context->pscreennumber)); - - gcvalues.background = XWhitePixel(context->pdpy, context->pscreennumber); - gcvalues.foreground = XBlackPixel(context->pdpy, context->pscreennumber); - - pgc = XCreateGC(context->pdpy, pwin, GCBackground|GCForeground, &gcvalues); - - Log(("start page.\n")); - XpauStartPage(context, pwin); - XpauWaitForPrintNotify(context, XPStartPageNotify); - - /* Mapping the window inside XpStartPage()/XpEndPage() - * Set XCreateWindow/border_width to 0 or move XMapWindow in front of - * XpStartPage() to get rid of the surrounding black border lines. - * (This is usually done before XpStartPage() in real applications) - */ - XMapWindow(context->pdpy, pwin); - - /* usual rendering stuff..... */ - - sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", context->document_dpi, context->document_dpi); - font = XLoadQueryFont(context->pdpy, fontname); - XSetFont(context->pdpy, pgc, font->fid); - if (!hello_world_message) - hello_world_message = "hello world from X11 print system"; - XDrawString(context->pdpy, pwin, pgc, 100, 100, hello_world_message, strlen(hello_world_message)); - - XpauEndPage(context); - XpauWaitForPrintNotify(context, XPEndPageNotify); - Log(("end page.\n")); - - Log(("end job.\n")); - - if( (result = XpauEndJob(context)) != XpAuError_success ) - { - fprintf(stderr, "%s: Error while printing: %s.\n", - ProgramName, XpAuErrorValueToString(result)); - XpauReleaseContext(context); - return(EXIT_FAILURE); - } - - XpauWaitForPrintNotify(context, XPEndJobNotify); - - XpauReleaseContext(context); - return(EXIT_SUCCESS); -} - -int main (int argc, char *argv[]) -{ - const char *printername = NULL; /* printer to query */ - const char *printargs = NULL; - const char *hello_world_message = NULL; - Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */ - XPPrinterList plist; /* list of printers */ - int plist_count; /* number of entries in |plist|-array */ - int i; - int retval; - - 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("-printargs", arg, len)) - { - if (++i >= argc) - usage(); - - printargs = argv[i]; - } - else if (!strncmp("-text", arg, len)) - { - if (++i >= argc) - usage(); - - hello_world_message = argv[i]; - } - else if( !strncmp("-debug_use_threadsafe_api", arg, len) ) - { - use_threadsafe_api = True; - } - else if (!strncmp("-v", arg, len)) - { - verbose = 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); - } - - Log(("Using printer '%s'\n", plist[0].name)); - - retval = do_hello_world(plist[0].name, printargs, hello_world_message); - - XpuFreePrinterList(plist); - - return(retval); -} - - Index: xc/programs/xphelloworld/xphelloworld.html =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.html diff -N xc/programs/xphelloworld/xphelloworld.html --- a/xc/programs/xphelloworld/xphelloworld.html 13 Apr 2004 03:16:48 -0000 1.1.2.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -xphelloworld

Name

xphelloworld — sends a test page to an Xprint printer

Synopsis

xphelloworld [-printer printernname] [-printargs - arg=value [,...]] [-v] [-text text] [-h]

DESCRIPTION

xphelloworld is a utility for Xprint, the - printing system for the X Window system. It sends a test page to - the specified printer (or the default printer, if none is specified). -

OPTIONS

-printer printernname

printer to use

-printargs arg=value [,...]

Args: -

tofile=filename

papersize=paper name

orientation=orientation

resolution=DPI

plex=plex

title=string

-text text

Sample text to print. Default is "hello world from X11 print system".

-v

verbose output

-h

print usage

ENVIRONMENT

XPSERVERLIST

${XPSERVERLIST} must be set, - identifying the available Xprint servers. - See Xprint(7) - for more details. -

KNOWN BUGS

- The -text option assumes that the text is in ISO8859-1 encoding - (the ${LANG} environment variable is not honored in this case). -

- A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). -

SEE ALSO

Xprint(7), X11(7), xplsprinters(1x), xpxmhelloworld(1x), xpawhelloworld(1x), xpxthelloworld(1x), xpsimplehelloworld(1x), Xserver(1x), Xprt(1x), libXp(3x), libXprintUtils(3x), libXprintAppUtils(3x), XmPrintShell(3x), XawPrintShell(3x), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/)

Index: xc/programs/xphelloworld/xphelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.man diff -N xc/programs/xphelloworld/xphelloworld.man --- a/xc/programs/xphelloworld/xphelloworld.man 13 Apr 2004 03:16:48 -0000 1.1.2.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,64 +0,0 @@ -.\" This manpage has been automatically generated by docbook2man -.\" from a DocBook document. This tool can be found at: -.\" -.\" Please send any bug reports, improvements, comments, patches, -.\" etc. to Steve Cheng . -.TH "XPHELLOWORLD" "__mansuffix__" "13 February 2004" "" "" -.SH NAME -xphelloworld \- sends a test page to an Xprint printer -.SH SYNOPSIS - -\fBxphelloworld\fR [ \fB-printer \fIprinternname\fB\fR] [ \fB-printargs -\fIarg\fB=\fIvalue\fB [,...]\fR] [ \fB-v\fR] [ \fB-text \fItext\fB\fR] [ \fB-h\fR] - -.SH "DESCRIPTION" -.PP -\fBxphelloworld\fR is a utility for Xprint, the -printing system for the X Window system. It sends a test page to -the specified printer (or the default printer, if none is specified). -.SH "OPTIONS" -.TP -\fB-printer \fIprinternname\fB \fR -printer to use -.TP -\fB-printargs \fIarg\fB=\fIvalue\fB [,...] \fR -Args: -.RS -.TP -\fBtofile=\fIfilename\fB\fR -.TP -\fBpapersize=\fIpaper name\fB\fR -.TP -\fBorientation=\fIorientation\fB\fR -.TP -\fBresolution=\fIDPI\fB\fR -.TP -\fBplex=\fIplex\fB\fR -.TP -\fBtitle=\fIstring\fB\fR -.RE -.TP -\fB-text \fItext\fB \fR -Sample text to print. Default is "hello world from X11 print system". -.TP -\fB-v \fR -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 "KNOWN BUGS" -.PP - -The \fB-text\fR option assumes that the text is in ISO8859-1 encoding -(the \fB${LANG}\fR environment variable is not honored in this case). -A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html ). -.SH "SEE ALSO" -.PP -\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\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 ), Xprint main site (http://xprint.mozdev.org/ ) Index: xc/programs/xphelloworld/xphelloworld.sgml =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.sgml diff -N xc/programs/xphelloworld/xphelloworld.sgml --- a/xc/programs/xphelloworld/xphelloworld.sgml 13 Apr 2004 03:16:48 -0000 1.1.2.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,187 +0,0 @@ - - - - - - - xphelloworld - __mansuffix__ - - - xphelloworld - - sends a test page to an Xprint printer - - - - xphelloworld - - - - - - - - - - - - - - - DESCRIPTION - - xphelloworld is a utility for Xprint, the - printing system for the X Window system. It sends a test page to - the specified printer (or the default printer, if none is specified). - - - - - - OPTIONS - - - - - - - printer to use - - - - - - - Args: - - - tofile=filename - - - - papersize=paper name - - - - orientation=orientation - - - - resolution=DPI - - - - plex=plex - - - - title=string - - - - - - - - - - - Sample text to print. Default is "hello world from X11 print system". - - - - - - - verbose output - - - - - - - print usage - - - - - - - ENVIRONMENT - - - XPSERVERLIST - - - - ${XPSERVERLIST} must be set, - identifying the available Xprint servers. - See Xprint__miscmansuffix__ - for more details. - - - - - - - - KNOWN BUGS - - - - The option assumes that the text is in ISO8859-1 encoding - (the ${LANG} environment variable is not honored in this case). - - - A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). - - - - - SEE ALSO - - - - - - - Xprint__miscmansuffix__ - X11__miscmansuffix__ - xplsprinters__mansuffix__ - - xpxmhelloworld__mansuffix__ - xpawhelloworld__mansuffix__ - xpxthelloworld__mansuffix__ - xpsimplehelloworld__mansuffix__ - Xserver__mansuffix__ - Xprt__mansuffix__ - - libXp__libmansuffix__ - libXprintUtils__libmansuffix__ - libXprintAppUtils__libmansuffix__ - XmPrintShell__libmansuffix__ - XawPrintShell__libmansuffix__ - Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html) - Xprint main site (http://xprint.mozdev.org/) - - - - - - - - Index: xc/programs/xphelloworld/xphelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld/Imakefile diff -N xc/programs/xphelloworld/xphelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xphelloworld/Imakefile 13 Apr 2004 05:01:31 -0000 @@ -0,0 +1,20 @@ +XCOMM $Xorg: Imakefile,v 1.3 2002/02/10 19:54:53 gisburn Exp $ + +LOCAL_LIBRARIES = $(XLIB) -lXp -lXprintAppUtil -lXprintUtil +SYS_LIBRARIES = MathLibrary +DEPLIBS = $(DEPXLIB) + +DEFINES = + SRCS = xphelloworld.c + OBJS = xphelloworld.o + +ComplexProgramTarget(xphelloworld) + +#ifdef HasDocBookTools +all:: xphelloworld.man xphelloworld.html + +ConvertDocBookToManPage(xphelloworld.sgml, xphelloworld.man) +ConvertDocBookToHTML(xphelloworld.sgml, xphelloworld.html) +#endif /* HasDocBookTools */ + + Index: xc/programs/xphelloworld/xphelloworld/xphelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld/xphelloworld.c diff -N xc/programs/xphelloworld/xphelloworld/xphelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xphelloworld/xphelloworld.c 13 Apr 2004 05:01:31 -0000 @@ -0,0 +1,273 @@ +/* + * $Xorg: xphelloworld.c,v 1.1 2002/02/10 22:54:18 gisburn Exp $ + * + * xphelloworld - Xprint version of hello world + * + * +Copyright 2002-2004 Roland Mainz + +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 + */ + +#include +#include +#include + +#include +#include +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Log(x) { if(verbose) printf x; } + +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ + +static +void usage( void ) +{ + fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-printer printernname\tprinter to use\n"); + fprintf (stderr, "-printargs args\t[ arg=value , ... ]\n"); + fprintf (stderr, "\targs:\ttofile=\n"); + fprintf (stderr, "\t\tpapersize=\n"); + fprintf (stderr, "\t\torientation=\n"); + fprintf (stderr, "\t\tresolution=\n"); + fprintf (stderr, "\t\tplex=\n"); + fprintf (stderr, "\t\ttitle=\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "-text \ttext to print (in ISO-8859-1)\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +static +int do_hello_world( const char *printername, const char *printerargs, const char *hello_world_message ) +{ + char *printerfile = NULL; + Window pwin; + XGCValues gcvalues; + XEvent ev; + GC pgc; + unsigned short dummy; + XRectangle winrect; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *font; + XpauContext *context; + XpauFlags docvalueflags = 0UL; + XpauDocValues x_docvalues; + XpauDocValues *docvalues = &x_docvalues; + XpAuErrorValue result; + + XpauFlags jobvalueflags = 0UL; + XpauJobValues x_jobvalues; + XpauJobValues *jobvalues = &x_jobvalues; + memset(&x_jobvalues, 0, sizeof(x_jobvalues)); + memset(&x_docvalues, 0, sizeof(x_docvalues)); + + context = XpauGetContext(printername); + if( !context ) + { + fprintf(stderr, "XpauGetContext() failure.\n"); + return(EXIT_FAILURE); + } + + if( (result = XpauParseArgs(context, &jobvalueflags, jobvalues, &docvalueflags, docvalues, &printerfile, printerargs)) != XpAuError_success ) + { + fprintf(stderr, "XpuParseArgs() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + if( (result = XpauSetJobValues(context, jobvalueflags, jobvalues)) != XpAuError_success ) + { + fprintf(stderr, "XpauSetJobValues() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + if( (result = XpauSetDocValues(context, docvalueflags, docvalues)) != XpAuError_success ) + { + fprintf(stderr, "XpauSetDocValues() failure: %s.\n", XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + /* Listen to XP(Start|End)(Job|Doc|Page)Notify events). + * This is mantatory as Xp(Start|End)(Job|Doc|Page) functions are _not_ + * syncronous !! + * Not waiting for such events may cause that subsequent data may be + * destroyed/corrupted!! + */ + XpSelectInput(context->pdpy, context->pcontext, XPPrintMask); + + if( printerfile ) + { + Log(("starting job (to file '%s').\n", printerfile)); + } + else + { + Log(("starting job.\n")); + } + + if( (result = XpauStartJob(context, printerfile)) != XpAuError_success ) + { + fprintf(stderr, "%s: Error: %s while trying to print.\n", + ProgramName, XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + XpauWaitForPrintNotify(context, XPStartJobNotify); + + /* Obtain some info about page geometry */ + XpGetPageDimensions(context->pdpy, context->pcontext, &dummy, &dummy, &winrect); + + pwin = XCreateSimpleWindow(context->pdpy, XRootWindowOfScreen(context->pscreen), + winrect.x, winrect.y, winrect.width, winrect.height, + 10, + XBlackPixel(context->pdpy, context->pscreennumber), + XWhitePixel(context->pdpy, context->pscreennumber)); + + gcvalues.background = XWhitePixel(context->pdpy, context->pscreennumber); + gcvalues.foreground = XBlackPixel(context->pdpy, context->pscreennumber); + + pgc = XCreateGC(context->pdpy, pwin, GCBackground|GCForeground, &gcvalues); + + Log(("start page.\n")); + XpauStartPage(context, pwin); + XpauWaitForPrintNotify(context, XPStartPageNotify); + + /* Mapping the window inside XpStartPage()/XpEndPage() + * Set XCreateWindow/border_width to 0 or move XMapWindow in front of + * XpStartPage() to get rid of the surrounding black border lines. + * (This is usually done before XpStartPage() in real applications) + */ + XMapWindow(context->pdpy, pwin); + + /* usual rendering stuff..... */ + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", context->document_dpi, context->document_dpi); + font = XLoadQueryFont(context->pdpy, fontname); + XSetFont(context->pdpy, pgc, font->fid); + if (!hello_world_message) + hello_world_message = "hello world from X11 print system"; + XDrawString(context->pdpy, pwin, pgc, 100, 100, hello_world_message, strlen(hello_world_message)); + + XpauEndPage(context); + XpauWaitForPrintNotify(context, XPEndPageNotify); + Log(("end page.\n")); + + Log(("end job.\n")); + + if( (result = XpauEndJob(context)) != XpAuError_success ) + { + fprintf(stderr, "%s: Error while printing: %s.\n", + ProgramName, XpAuErrorValueToString(result)); + XpauReleaseContext(context); + return(EXIT_FAILURE); + } + + XpauWaitForPrintNotify(context, XPEndJobNotify); + + XpauReleaseContext(context); + return(EXIT_SUCCESS); +} + +int main (int argc, char *argv[]) +{ + const char *printername = NULL; /* printer to query */ + const char *printargs = NULL; + const char *hello_world_message = NULL; + Bool use_threadsafe_api = False; /* Use threadsafe API (for debugging) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + + 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("-printargs", arg, len)) + { + if (++i >= argc) + usage(); + + printargs = argv[i]; + } + else if (!strncmp("-text", arg, len)) + { + if (++i >= argc) + usage(); + + hello_world_message = argv[i]; + } + else if( !strncmp("-debug_use_threadsafe_api", arg, len) ) + { + use_threadsafe_api = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = 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); + } + + Log(("Using printer '%s'\n", plist[0].name)); + + retval = do_hello_world(plist[0].name, printargs, hello_world_message); + + XpuFreePrinterList(plist); + + return(retval); +} + + Index: xc/programs/xphelloworld/xphelloworld/xphelloworld.html =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld/xphelloworld.html diff -N xc/programs/xphelloworld/xphelloworld/xphelloworld.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xphelloworld/xphelloworld.html 13 Apr 2004 05:01:31 -0000 @@ -0,0 +1,15 @@ +xphelloworld

Name

xphelloworld — sends a test page to an Xprint printer

Synopsis

xphelloworld [-printer printernname] [-printargs + arg=value [,...]] [-v] [-text text] [-h]

DESCRIPTION

xphelloworld is a utility for Xprint, the + printing system for the X Window system. It sends a test page to + the specified printer (or the default printer, if none is specified). +

OPTIONS

-printer printernname

printer to use

-printargs arg=value [,...]

Args: +

tofile=filename

papersize=paper name

orientation=orientation

resolution=DPI

plex=plex

title=string

-text text

Sample text to print. Default is "hello world from X11 print system".

-v

verbose output

-h

print usage

ENVIRONMENT

XPSERVERLIST

${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint(7) + for more details. +

KNOWN BUGS

+ The -text option assumes that the text is in ISO8859-1 encoding + (the ${LANG} environment variable is not honored in this case). +

+ A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). +

SEE ALSO

Xprint(7), X11(7), xplsprinters(1x), xpxmhelloworld(1x), xpawhelloworld(1x), xpxthelloworld(1x), xpsimplehelloworld(1x), Xserver(1x), Xprt(1x), libXp(3x), libXprintUtils(3x), libXprintAppUtils(3x), XmPrintShell(3x), XawPrintShell(3x), Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html), Xprint main site (http://xprint.mozdev.org/)

Index: xc/programs/xphelloworld/xphelloworld/xphelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld/xphelloworld.man diff -N xc/programs/xphelloworld/xphelloworld/xphelloworld.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xphelloworld/xphelloworld.man 13 Apr 2004 05:01:31 -0000 @@ -0,0 +1,64 @@ +.\" This manpage has been automatically generated by docbook2man +.\" from a DocBook document. This tool can be found at: +.\" +.\" Please send any bug reports, improvements, comments, patches, +.\" etc. to Steve Cheng . +.TH "XPHELLOWORLD" "__mansuffix__" "13 February 2004" "" "" +.SH NAME +xphelloworld \- sends a test page to an Xprint printer +.SH SYNOPSIS + +\fBxphelloworld\fR [ \fB-printer \fIprinternname\fB\fR] [ \fB-printargs +\fIarg\fB=\fIvalue\fB [,...]\fR] [ \fB-v\fR] [ \fB-text \fItext\fB\fR] [ \fB-h\fR] + +.SH "DESCRIPTION" +.PP +\fBxphelloworld\fR is a utility for Xprint, the +printing system for the X Window system. It sends a test page to +the specified printer (or the default printer, if none is specified). +.SH "OPTIONS" +.TP +\fB-printer \fIprinternname\fB \fR +printer to use +.TP +\fB-printargs \fIarg\fB=\fIvalue\fB [,...] \fR +Args: +.RS +.TP +\fBtofile=\fIfilename\fB\fR +.TP +\fBpapersize=\fIpaper name\fB\fR +.TP +\fBorientation=\fIorientation\fB\fR +.TP +\fBresolution=\fIDPI\fB\fR +.TP +\fBplex=\fIplex\fB\fR +.TP +\fBtitle=\fIstring\fB\fR +.RE +.TP +\fB-text \fItext\fB \fR +Sample text to print. Default is "hello world from X11 print system". +.TP +\fB-v \fR +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 "KNOWN BUGS" +.PP + +The \fB-text\fR option assumes that the text is in ISO8859-1 encoding +(the \fB${LANG}\fR environment variable is not honored in this case). +A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html ). +.SH "SEE ALSO" +.PP +\fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\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 ), Xprint main site (http://xprint.mozdev.org/ ) Index: xc/programs/xphelloworld/xphelloworld/xphelloworld.sgml =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld/xphelloworld.sgml diff -N xc/programs/xphelloworld/xphelloworld/xphelloworld.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xphelloworld/xphelloworld.sgml 13 Apr 2004 05:01:32 -0000 @@ -0,0 +1,187 @@ + + + + + + + xphelloworld + __mansuffix__ + + + xphelloworld + + sends a test page to an Xprint printer + + + + xphelloworld + + + + + + + + + + + + + + + DESCRIPTION + + xphelloworld is a utility for Xprint, the + printing system for the X Window system. It sends a test page to + the specified printer (or the default printer, if none is specified). + + + + + + OPTIONS + + + + + + + printer to use + + + + + + + Args: + + + tofile=filename + + + + papersize=paper name + + + + orientation=orientation + + + + resolution=DPI + + + + plex=plex + + + + title=string + + + + + + + + + + + Sample text to print. Default is "hello world from X11 print system". + + + + + + + verbose output + + + + + + + print usage + + + + + + + ENVIRONMENT + + + XPSERVERLIST + + + + ${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + KNOWN BUGS + + + + The option assumes that the text is in ISO8859-1 encoding + (the ${LANG} environment variable is not honored in this case). + + + A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). + + + + + SEE ALSO + + + + + + + Xprint__miscmansuffix__ + X11__miscmansuffix__ + xplsprinters__mansuffix__ + + xpxmhelloworld__mansuffix__ + xpawhelloworld__mansuffix__ + xpxthelloworld__mansuffix__ + xpsimplehelloworld__mansuffix__ + Xserver__mansuffix__ + Xprt__mansuffix__ + + libXp__libmansuffix__ + libXprintUtils__libmansuffix__ + libXprintAppUtils__libmansuffix__ + XmPrintShell__libmansuffix__ + XawPrintShell__libmansuffix__ + Xprint FAQ (http://xprint.mozdev.org/docs/Xprint_FAQ.html) + Xprint main site (http://xprint.mozdev.org/) + + + + + + + +