Index: xc/lib/Imakefile =================================================================== RCS file: /cvs/xorg/xc/lib/Imakefile,v retrieving revision 1.1.4.4 diff -u -r1.1.4.4 Imakefile --- a/xc/lib/Imakefile 15 Apr 2004 10:14:52 -0000 1.1.4.4 +++ b/xc/lib/Imakefile 21 Apr 2004 09:34:36 -0000 @@ -8,7 +8,7 @@ #define IHaveSubdirs #define PassCDebugFlags -#if BuildXaw6 && BuildLibraries +#if BuildXaw6 && BuildXprintLib && BuildLibraries XAW6LIBDIR = Xaw6 #endif @@ -153,7 +153,7 @@ #endif #if BuildXprintLib -XPRINTLIBDIR = Xp +XPRINTLIBDIRS = Xp XprintUtil XprintAppUtil #endif #if BuildFontCacheLib @@ -190,7 +190,9 @@ XMULIBDIR = Xmu XMUULIBDIR = Xmuu XPMLIBDIR = Xpm +#if BuildXprintLib XAWLIBDIR = Xaw +#endif XTSTLIBDIR = Xtst FSLIBDIR = FS #endif @@ -200,9 +202,9 @@ $(OLDXLIBDIR) $(ICELIBDIR) $(SMLIBDIR) $(XEXTLIBDIR) $(XTLIBDIR) \ $(SSLIBDIR) $(XF86MISCLIBDIR) $(XF86VMLIBDIR) $(XF86DGALIBDIR) \ $(XF86RUSHLIBDIR) $(XMULIBDIR) $(XMUULIBDIR) $(XPMLIBDIR) \ - $(XAW6LIBDIR) $(XAWLIBDIR) $(XINPUTLIBDIR) \ + $(XPRINTLIBDIRS) $(XAW6LIBDIR) $(XAWLIBDIR) $(XINPUTLIBDIR) \ $(XTSTLIBDIR) $(FSLIBDIR) $(XKBLIBDIR) \ - $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) $(XPRINTLIBDIR) \ + $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) \ $(XVLIBDIR) $(GLXLIBDIR) $(GLULIBDIR) $(GLWLIBDIR) \ $(DPSLIBDIR) $(DPSTKLIBDIR) $(PSRESLIBDIR) $(XINERAMADIR) \ $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) $(FREETYPE2BUILDDIR) \ Index: xc/lib/Xaw/AllWidgets.c =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/AllWidgets.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 AllWidgets.c --- a/xc/lib/Xaw/AllWidgets.c 5 Mar 2004 13:39:20 -0000 1.1.4.2 +++ b/xc/lib/Xaw/AllWidgets.c 21 Apr 2004 09:34:37 -0000 @@ -67,6 +67,7 @@ extern WidgetClass vendorShellWidgetClass; extern WidgetClass viewportWidgetClass; extern WidgetClass wmShellWidgetClass; +extern WidgetClass xawPrintShellWidgetClass; XmuWidgetNode XawWidgetArray[] = { { "applicationShell", &applicationShellWidgetClass }, @@ -111,6 +112,7 @@ { "vendorShell", &vendorShellWidgetClass }, { "viewport", &viewportWidgetClass }, { "wmShell", &wmShellWidgetClass }, +{ "printShell", &xawPrintShellWidgetClass }, }; int XawWidgetCount = XtNumber(XawWidgetArray); Index: xc/lib/Xaw/Imakefile =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/Imakefile,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 Imakefile --- a/xc/lib/Xaw/Imakefile 5 Mar 2004 13:39:20 -0000 1.1.4.3 +++ b/xc/lib/Xaw/Imakefile 21 Apr 2004 09:34:43 -0000 @@ -94,6 +94,8 @@ VendorEP.h \ Viewport.h \ ViewportP.h \ + Print.h \ + PrintSP.h \ XawImP.h \ XawInit.h @@ -139,6 +141,7 @@ Tree.c \ Vendor.c \ Viewport.c \ + PrintShell.c \ XawIm.c \ XawInit.c \ XawI18n.c \ @@ -190,6 +193,7 @@ Tree.o \ Vendor.o \ Viewport.o \ + PrintShell.o \ XawIm.o \ XawI18n.o \ XawInit.o Index: xc/lib/Xaw/Print.h =================================================================== RCS file: xc/lib/Xaw/Print.h diff -N xc/lib/Xaw/Print.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/Xaw/Print.h 21 Apr 2004 09:34:47 -0000 @@ -0,0 +1,128 @@ +/* $Xorg: Print.h,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */ +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2003 Danny Backx + ** (c) Copyright 2003-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + + +#ifndef _XAW_PRINT_H +#define _XAW_PRINT_H 1 + +#include + +/* XawPrintConfigureLayoutMode - define how the shell resizes/moves itself + * to match the paper size + * Values: + * - XawPrintLAYOUTMODE_NONE + * do nothing + * - XawPrintLAYOUTMODE_PAGESIZE + * set width/height to page size + * (this is the default (mainly for compatibilty to XmPrintShell)) + * - XawPrintLAYOUTMODE_DRAWABLEAREA + * set x/y/width/height to drawable area of pag + */ +typedef +enum +{ + XawPrintLAYOUTMODE_NONE, + XawPrintLAYOUTMODE_PAGESIZE, + XawPrintLAYOUTMODE_DRAWABLEAREA +} XawPrintConfigureLayoutMode; + + +#define XawNstartJobCallback "XawNstartJobCallback" +#define XawNendJobCallback "XawNendJobCallback" +#define XawNdocSetupCallback "XawNdocSetupCallback" +#define XawNpageSetupCallback "XawNpageSetupCallback" +#define XawNlayoutMode "XawNlayoutMode" +#define XawCLayoutMode "XawCLayoutMode" +#define XawNminX "XawNminX" +#define XawCMinX "XawCMinX" +#define XawNminY "XawNminY" +#define XawCMinY "XawCMinY" +#define XawNmaxX "XawNmaxX" +#define XawCMaxX "XawCMaxX" +#define XawNmaxY "XawNmaxY" +#define XawCMaxY "XawCMaxY" +#define XawNcurrDocNumInJob "XawNcurrDocNumInJob" +#define XawCCurrDocNumInJob "XawCCurrDocNumInJob" +#define XawNcurrPageNumInDoc "XawNcurrPageNumInDoc" +#define XawCCurrPageNumInDoc "XawCCurrPageNumInDoc" +#define XawNcurrPageNumInJob "XawNcurrPageNumInJob" +#define XawCCurrPageNumInJob "XawCCurrPageNumInJob" +#define XawNdefaultPixmapResolution "XawNdefaultPixmapResolution" +#define XawCDefaultPixmapResolution "XawCDefaultPixmapResolution" + +#define XawCR_START_JOB 70 +#define XawCR_END_JOB 71 +#define XawCR_DOC_SETUP 72 +#define XawCR_PAGE_SETUP 73 + +typedef struct +{ + int reason; + XEvent *event; + XPContext context; + Boolean last_page_in_doc; + Boolean last_page_in_job; + XtPointer detail; +} XawPrintShellCallbackStruct; + +extern WidgetClass xawPrintShellWidgetClass; +typedef struct XawPrintShellRec *XawPrintShellWidget; + +/************************************************************ + * + * Public Functions. + * + ************************************************************/ + +_XFUNCPROTOBEGIN + +/* Returns whether the widget passed in is a print shell or "print shell"-like + * widget (e.g. print preview). + * Note that this will return |True| for more classes than |XawPrintShell| in + * the future (like for |XmPrintShell| etc.) + */ +extern Boolean XawIsPrintShell( +#if NeedFunctionPrototypes + Widget w +#endif +); + +extern void XawPrintRedisplayWidget( +#if NeedFunctionPrototypes + Widget w /* Widget */ +#endif +); + +_XFUNCPROTOEND + +#endif /* !_XAW_PRINT_H */ + Index: xc/lib/Xaw/PrintSP.h =================================================================== RCS file: xc/lib/Xaw/PrintSP.h diff -N xc/lib/Xaw/PrintSP.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/Xaw/PrintSP.h 21 Apr 2004 09:34:47 -0000 @@ -0,0 +1,135 @@ +/* $Xorg: PrintSP.h,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */ +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2003 Danny Backx + ** (c) Copyright 2003-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + +#ifndef _XAW_PRINTSP_H +#define _XAW_PRINTSP_H 1 + +#include +#include + +_XFUNCPROTOBEGIN + +/* New fields for the XawPrintShell widget class record */ + +typedef struct { + XtPointer extension; /* pointer to extension record */ +} XawPrintShellClassPart; + +typedef struct XawPrintShellClassRec { + CoreClassPart core_class; + CompositeClassPart composite_class; + ShellClassPart shell_class; + WMShellClassPart wm_shell_class; + VendorShellClassPart vendor_shell_class; + TopLevelShellClassPart top_level_shell_class; + ApplicationShellClassPart application_shell_class; + XawPrintShellClassPart print_shell_class; +} XawPrintShellClassRec; + +extern XawPrintShellClassRec xawPrintShellClassRec; + +/* New fields for the XawPrint shell widget */ + +typedef struct { + XtCallbackList start_job_callback, + end_job_callback, + doc_setup_callback, + page_setup_callback; + XtEnum layoutmode; /* see XawPrintConfigureLayoutMode */ + unsigned short page_width, + page_height; + Dimension min_x, + min_y, + max_x, + max_y; + unsigned int curr_doc_num_in_job, /* Current document number in job */ + curr_page_num_in_doc, /* Current page number in doc */ + curr_page_num_in_job; /* Current page number in job */ + unsigned short default_pixmap_resolution; + long print_resolution; + Boolean last_page_in_doc; + Boolean last_page_in_job; +} XawPrintShellPart; + +typedef struct XawPrintShellRec { + CorePart core; + CompositePart composite; + ShellPart shell; + WMShellPart wm; + VendorShellPart vendor; + TopLevelShellPart topLevel; + ApplicationShellPart application; + XawPrintShellPart print; +} XawPrintShellRec; +extern WidgetClass xawPrintShellWidgetClass; + +#define PS_StartJobCallback(w) \ + (((XawPrintShellWidget) (w))->print.start_job_callback) +#define PS_EndJobCallback(w) \ + (((XawPrintShellWidget) (w))->print.end_job_callback) +#define PS_DocSetupCallback(w) \ + (((XawPrintShellWidget) (w))->print.doc_setup_callback) +#define PS_PageSetupCallback(w) \ + (((XawPrintShellWidget) (w))->print.page_setup_callback) +#define PS_LayoutMode(w) \ + (((XawPrintShellWidget) (w))->print.layoutmode) +#define PS_PageWidth(w) \ + (((XawPrintShellWidget) (w))->print.page_width) +#define PS_PageHeight(w) \ + (((XawPrintShellWidget) (w))->print.page_height) +#define PS_MinX(w) \ + (((XawPrintShellWidget) (w))->print.min_x) +#define PS_MinY(w) \ + (((XawPrintShellWidget) (w))->print.min_y) +#define PS_MaxX(w) \ + (((XawPrintShellWidget) (w))->print.max_x) +#define PS_MaxY(w) \ + (((XawPrintShellWidget) (w))->print.max_y) +#define PS_CurrDocNumInJob(w) \ + (((XawPrintShellWidget) (w))->print.curr_doc_num_in_job) +#define PS_CurrPageNumInDoc(w) \ + (((XawPrintShellWidget) (w))->print.curr_page_num_in_doc) +#define PS_CurrPageNumInJob(w) \ + (((XawPrintShellWidget) (w))->print.curr_page_num_in_job) +#define PS_DefaultPixmapResolution(w) \ + (((XawPrintShellWidget) (w))->print.default_pixmap_resolution) +#define PS_PrintResolution(w) \ + (((XawPrintShellWidget) (w))->print.print_resolution) +#define PS_LastPageInDoc(w) \ + (((XawPrintShellWidget) (w))->print.last_page_in_doc) +#define PS_LastPageInJob(w) \ + (((XawPrintShellWidget) (w))->print.last_page_in_job) + +_XFUNCPROTOEND + +#endif /* !_XAW_PRINTSP_H */ + Index: xc/lib/Xaw/PrintShell.c =================================================================== RCS file: xc/lib/Xaw/PrintShell.c diff -N xc/lib/Xaw/PrintShell.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/Xaw/PrintShell.c 21 Apr 2004 09:34:47 -0000 @@ -0,0 +1,747 @@ +/* $Xorg: PrintShell.c,v 1.1 2003/07/11 19:46:06 gisburn Exp $ */ +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2003 Danny Backx + ** (c) Copyright 2003-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + + +#include +#include +#include + +#include +#include + +#include "Print.h" +#include "PrintSP.h" + +/* Local prototypes */ +static void class_initialize(void); +static void class_part_initialize(WidgetClass w_class); +static void initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args); +static void destroy(Widget w); +static Boolean set_values(Widget current, Widget request, Widget new_w, ArgList args, Cardinal *num_args); +static void XawPrintNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont); +static void XawAttributesNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont); +static void XawUpdateLayout(Widget w); +static void XawUpdateResources(Widget w, XPContext pcontext); + +#define Offset(field) XtOffsetOf(XawPrintShellRec, print.field) + +#ifdef XAWDEBUG +#define DEBUGOUT(x) XawDebug x ; + +static void +XawDebug(const char *fn, Widget w, const char *fmt, ...) +{ + va_list ap; + + if (w) { + fprintf(stderr, "%s %s: ", + w->core.widget_class->core_class.class_name, XtName(w)); + } else { + fprintf(stderr, "(null widget): "); + } + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} +#else +#define DEBUGOUT(x) +#endif /* XAWDEBUG */ + +/* Resources for the PrintShell class */ +static XtResource resources[] = +{ + { + XawNstartJobCallback, XtCCallback, XtRCallback, + sizeof(XtCallbackList), Offset(start_job_callback), + XtRImmediate, (XtPointer)NULL + }, + { + XawNendJobCallback, XtCCallback, XtRCallback, + sizeof(XtCallbackList), Offset(end_job_callback), + XtRImmediate, (XtPointer)NULL + }, + { + XawNdocSetupCallback, XtCCallback, XtRCallback, + sizeof(XtCallbackList), Offset(doc_setup_callback), + XtRImmediate, (XtPointer)NULL + }, + { + XawNpageSetupCallback, XtCCallback, XtRCallback, + sizeof(XtCallbackList), Offset(page_setup_callback), + XtRImmediate, (XtPointer)NULL + }, + { + XawNlayoutMode, XawCLayoutMode, XtREnum, + sizeof(XtEnum), Offset(layoutmode), + XtRImmediate, (XtPointer)XawPrintLAYOUTMODE_PAGESIZE + }, + { + XawNminX, XawCMinX, XtRDimension, + sizeof(Dimension), Offset(min_x), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNminY, XawCMinY, XtRDimension, + sizeof(Dimension), Offset(min_y), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNmaxX, XawCMaxX, XtRDimension, + sizeof(Dimension), Offset(max_x), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNmaxY, XawCMaxY, XtRDimension, + sizeof(Dimension), Offset(max_y), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNcurrDocNumInJob, XawCCurrDocNumInJob, XtRInt, + sizeof(unsigned int), Offset(curr_doc_num_in_job), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNcurrPageNumInDoc, XawCCurrPageNumInDoc, XtRInt, + sizeof(unsigned int), Offset(curr_page_num_in_doc), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNcurrPageNumInJob, XawCCurrPageNumInJob, XtRInt, + sizeof(unsigned int), Offset(curr_page_num_in_job), + XtRImmediate, (XtPointer)NULL /* dynamic */ + }, + { + XawNdefaultPixmapResolution, XawCDefaultPixmapResolution, XtRShort, + sizeof(unsigned short), Offset(default_pixmap_resolution), + XtRImmediate, (XtPointer)0 + }, +}; + +static XtActionsRec actions[] = +{ + { NULL, NULL } +}; + +XawPrintShellClassRec xawPrintShellClassRec = { + /* Core class part */ + { + /* superclass */ (WidgetClass) &applicationShellClassRec, + /* class_name */ "XawPrintShell", + /* widget_size */ sizeof(XawPrintShellRec), + /* class_initialize */ class_initialize, + /* class_part_initialize */ class_part_initialize, + /* class_inited */ False, + /* initialize */ initialize, + /* initialize_hook */ NULL, + /* realize */ XtInheritRealize, + /* actions */ actions, + /* num_actions */ XtNumber(actions), + /* resources */ resources, + /* num_resources */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ False, + /* compress_exposure */ XtExposeCompressSeries, + /* compress_enterleave */ False, + /* visible_interest */ False, + /* destroy */ destroy, + /* resize */ XtInheritResize, + /* expose */ XtInheritExpose, + /* set_values */ set_values, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback offsets */ NULL, + /* tm_table */ XtInheritTranslations, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ NULL, + /* extension */ NULL /* (XtPointer)&_XawPrintShellCoreClassExtRec */ + }, + /* Composite class part */ + { + /* geometry manager */ XtInheritGeometryManager, + /* change_managed */ XtInheritChangeManaged, + /* insert_child */ XtInheritInsertChild, + /* delete_child */ XtInheritDeleteChild, + /* extension */ NULL, + }, + /* Shell class part */ + { + /* extension */ NULL, + }, + /* WM Shell class part */ + { + /* extension */ NULL, + }, + /* VendorShell class part */ + { + /* extension */ NULL, + }, + /* TopLevelShell class part */ + { + /* extension */ NULL, + }, + /* ApplicationShell class part */ + { + /* extension */ NULL, + }, + { + /* ?? */ NULL, + }, +}; + +WidgetClass xawPrintShellWidgetClass = (WidgetClass)&xawPrintShellClassRec; + + +static void +class_initialize(void) +{ +} + + +static void +class_part_initialize(WidgetClass widget_class) +{ +} + +/* + * This is a static table to keep the link between widgets and XPContexts. + * Yeah - this is probably not a very bright idea. Maybe it should also + * contain the Display. + */ +typedef struct { + Widget w; + XPContext c; +} WidgetContext; +static WidgetContext *w_ctxt = NULL; +static int wc_nfields = 0; + +static void +XawStoreWidgetContext(Widget w, XPContext c) +{ + wc_nfields++; + w_ctxt = (WidgetContext *)XtRealloc((XtPointer)w_ctxt, sizeof(WidgetContext) * wc_nfields); + w_ctxt[wc_nfields-1].w = w; + w_ctxt[wc_nfields-1].c = c; +} + +/* FIXME: This is not threadsafe... */ +static Widget +XawPrintContextToWidget(XPContext c) +{ + int i; + + for( i = 0 ; i < wc_nfields ; i++ ) { + if( w_ctxt[i].c == c ) { + return w_ctxt[i].w; + } + } + return NULL; +} + +/* FIXME: This is not threadsafe... */ +static XPContext +XawPrintWidgetToContext(Widget w) +{ + int i; + + for( i = 0 ; i < wc_nfields ; i++ ) { + if (w_ctxt[i].w == w) { + return w_ctxt[i].c; + } + } + return (XPContext)None; +} + +/* FIXME: This is not threadsafe... */ +static void +XawPrintDeleteWidgetContext(Widget w) +{ + int i; + + for( i = 0 ; i < wc_nfields ; i++ ) { + if( w_ctxt[i].w == w ) { + w_ctxt[i].w = NULL; + w_ctxt[i].c = None; + } + } +} + +static void +SelectNotify(Widget w, int *e, XtPointer *s, int n, XtPointer client) +{ + XPContext c = XpGetContext(XtDisplay(w)); + + if (!c) { + XtAppWarning(XtWidgetToApplicationContext(w), + "XawPrintShell: SelectNotify: no print context\n"); + return; + } + + XpSelectInput(XtDisplay(w), c, XPPrintMask|XPAttributeMask); +} + + +static Boolean +DispatchEvent(XEvent *evp) +{ + XPPrintEvent *e = (XPPrintEvent*)evp; + + Widget w = XawPrintContextToWidget(e->context); + + /* Make sure this event is really for this window... */ + if (XFilterEvent(evp, XtWindow(w))) + { + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent *** filter XFilterEvent() matched.\n")); + return True; + } + + /* Only for debugging */ +#ifdef XAWDEBUG + { + int error_base, + event_base; + + if (!XpQueryExtension(XtDisplay(w), &event_base, &error_base)) { + return False; + } + + if (e->type == event_base + XPPrintNotify) { + switch (e->detail) { + case XPStartJobNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartJobNotify\n")); + break; + case XPEndJobNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndJobNotify\n")); + break; + case XPStartDocNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartDocNotify\n")); + break; + case XPStartPageNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPStartPageNotify\n")); + break; + case XPEndPageNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndPageNotify\n")); + break; + case XPEndDocNotify: + DEBUGOUT((__FILE__, w, "XawPrintShell-DispatchEvent XPEndDocNotify\n")); + break; + default: + DEBUGOUT((__FILE__, w, "XawPrintShell DispatchEvent\n")); + } + } + } +#endif /* XAWDEBUG */ + + return XtDispatchEventToWidget(w, evp); +} + + +static void +initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args) +{ + int error_base, + event_base; + XPContext pcontext; + + DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize\n")); + + if (!XpQueryExtension(XtDisplay(new_w), &event_base, &error_base)) { + DEBUGOUT((__FILE__, new_w, "XawPrintShell initialize: failed!!\n")); + XtAppWarning(XtWidgetToApplicationContext(new_w), + "XawPrintShell: initialize: XpQueryExtension() failed. BAD.\n"); + return; + } + + DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize event_base %d error_base %d\n", + event_base, error_base)); + + pcontext = XpGetContext(XtDisplay(new_w)); + + if( pcontext == None ) { + XtAppWarning(XtWidgetToApplicationContext(new_w), + "XawPrintShell: initialize: No print content. BAD.\n"); + return; + } + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if( XpGetScreenOfContext(XtDisplay(new_w), pcontext) != XtScreen(new_w) ) { + XtAppWarning(XtWidgetToApplicationContext(new_w), + "XawPrintShell: initialize: Widget's screen != print screen. BAD.\n"); + return; + } + + XawStoreWidgetContext(new_w, pcontext); + + XtInsertEventTypeHandler(new_w, + event_base + XPPrintNotify, + (XtPointer)XPPrintMask, + XawPrintNotify, NULL, + XtListTail); + XtInsertEventTypeHandler(new_w, + event_base + XPAttributeNotify, + (XtPointer)XPAttributeMask, + XawAttributesNotify, NULL, + XtListTail); + + XtRegisterExtensionSelector(XtDisplay(new_w), + event_base + XPPrintNotify, + event_base + XPAttributeNotify, + SelectNotify, + NULL); + + XtSetEventDispatcher(XtDisplay(new_w), + event_base + XPPrintNotify, + DispatchEvent); + XtSetEventDispatcher(XtDisplay(new_w), + event_base + XPAttributeNotify, + DispatchEvent); + + PS_LastPageInDoc(new_w) = False; + PS_LastPageInJob(new_w) = False; + + XawUpdateResources(new_w, pcontext); + XawUpdateLayout(new_w); + + DEBUGOUT((__FILE__, new_w, "XawPrintShell Initialize x %d y %d wid %d ht %d\n", + new_w->core.x, + new_w->core.y, + new_w->core.width, + new_w->core.height)); +} + + +static void +destroy(Widget w) +{ + DEBUGOUT((__FILE__, w, "XawPrintShell Destroy\n")); + XawPrintDeleteWidgetContext(w); +} + +static Boolean +set_values(Widget current, Widget request, Widget new_w, + ArgList args, Cardinal *num_args) +{ + DEBUGOUT((__FILE__, new_w, "XawPrintShell SetValues\n")); + return True; +} + +void XawPrintRedisplayWidget(Widget w) +{ + XExposeEvent xev; + Region region; + + xev.type = Expose; + xev.serial = XLastKnownRequestProcessed(XtDisplay(w)); + xev.send_event = False; + xev.display = XtDisplay(w); + xev.window = XtWindowOfObject(w); + xev.x = 0; + xev.y = 0; + xev.width = w->core.width; + xev.height = w->core.height; + xev.count = 0; + + region = XCreateRegion(); + if (!region) + return; + + XtAddExposureToRegion((XEvent*)&xev, region); + + if (w->core.widget_class->core_class.expose) + (*(w->core.widget_class->core_class.expose))(w, (XEvent *)&xev, region); + + XDestroyRegion(region); +} + +/* Returns whether the widget passed in is a print shell or "print shell"-like + * widget (e.g. print preview). + * Note that this will return |True| for more classes than |XawPrintShell| in + * the future (like for |XmPrintShell| etc.) + */ +Boolean +XawIsPrintShell(Widget w) +{ + return XtIsSubclass(w, xawPrintShellWidgetClass); +} + + +static void +XawPrintNotify(Widget w, XtPointer client, XEvent *evp, Boolean *cont) +{ + XPPrintEvent *e = (XPPrintEvent *)evp; + XawPrintShellCallbackStruct cbs; + + switch (e->detail) { + case XPStartPageNotify: + DEBUGOUT((__FILE__, w, "XPStartPageNotify\n")); + + /* Re do not have to call |XawPrintRedisplayWidget(w)| here since + * Xprint triggers an expose event anyway + */ + + DEBUGOUT((__FILE__, w, "XpEndPage\n")); + XpEndPage(XtDisplay(w)); + break; + + case XPEndPageNotify: + DEBUGOUT((__FILE__, w, "XPEndPageNotify\n")); + + if (PS_LastPageInDoc(w) || PS_LastPageInJob(w)) { + DEBUGOUT((__FILE__, w, "XpEndDoc\n")); + XpEndDoc(XtDisplay(w)); + } + else { + /* Increment page numbers... */ + PS_CurrPageNumInDoc(w) += 1; + PS_CurrPageNumInJob(w) += 1; + + /* ... do the page setup callback ... */ + cbs.reason = XawCR_PAGE_SETUP; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = XawPrintWidgetToContext(w); + cbs.last_page_in_doc = False; + cbs.last_page_in_job = False; + + if (PS_PageSetupCallback(w)) + XtCallCallbackList(w, PS_PageSetupCallback(w), &cbs); + + PS_LastPageInDoc(w) = cbs.last_page_in_doc; + PS_LastPageInJob(w) = cbs.last_page_in_job; + + /* ... and start the new page */ + DEBUGOUT((__FILE__, w, "XpStartPage\n")); + XpStartPage(XtDisplay(w), XtWindow(w)); + } + break; + + case XPStartDocNotify: + DEBUGOUT((__FILE__, w, "XPStartDocNotify\n")); + + cbs.reason = XawCR_PAGE_SETUP; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = XawPrintWidgetToContext(w); + cbs.last_page_in_doc = False; + cbs.last_page_in_job = False; + + if (PS_PageSetupCallback(w)) + XtCallCallbackList(w, PS_PageSetupCallback(w), &cbs); + + PS_LastPageInDoc(w) = cbs.last_page_in_doc; + PS_LastPageInJob(w) = cbs.last_page_in_job; + + DEBUGOUT((__FILE__, w, "XpStartPage\n")); + XpStartPage(XtDisplay(w), XtWindow(w)); + break; + + case XPEndDocNotify: + DEBUGOUT((__FILE__, w, "XPEndDocNotify\n")); + + /* Start a new document (via XpStartDoc()) if we are not done with the job yet, + * otherwise finish the job (via XpEndJob()) + */ + if (PS_LastPageInJob(w)) { + DEBUGOUT((__FILE__, w, "XpEndJob\n")); + XpEndJob(XtDisplay(w)); + } + else { + PS_CurrDocNumInJob(w) += 1; + PS_CurrPageNumInDoc(w) = 1; + + cbs.reason = XawCR_DOC_SETUP; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = XawPrintWidgetToContext(w); + cbs.last_page_in_doc = False; + cbs.last_page_in_job = False; + + if (PS_DocSetupCallback(w)) + XtCallCallbackList(w, PS_DocSetupCallback(w), &cbs); + + PS_LastPageInDoc(w) = cbs.last_page_in_doc; + PS_LastPageInJob(w) = cbs.last_page_in_job; + + DEBUGOUT((__FILE__, w, "XpStartDoc\n")); + XpStartDoc(XtDisplay(w), XPDocNormal); + } + break; + + case XPStartJobNotify: + DEBUGOUT((__FILE__, w, "XPStartJobNotify\n")); + PS_LastPageInJob(w) = False; + PS_LastPageInDoc(w) = False; + PS_CurrDocNumInJob(w) = 1; + PS_CurrPageNumInDoc(w) = 1; + PS_CurrPageNumInJob(w) = 1; + + cbs.reason = XawCR_START_JOB; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = XawPrintWidgetToContext(w); + cbs.last_page_in_doc = False; + cbs.last_page_in_job = False; + + if (PS_StartJobCallback(w)) + XtCallCallbackList(w, PS_StartJobCallback(w), &cbs); + + PS_LastPageInDoc(w) = cbs.last_page_in_doc; + PS_LastPageInJob(w) = cbs.last_page_in_job; + + /* Start a document (which will trigger the first page in + * |XPStartDocNotify| above) */ + if (PS_LastPageInDoc(w) || PS_LastPageInJob(w)) { + DEBUGOUT((__FILE__, w, "XpEndJob\n")); + XpEndJob(XtDisplay(w)); + } + else + { + cbs.reason = XawCR_DOC_SETUP; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = XawPrintWidgetToContext(w); + cbs.last_page_in_doc = False; + cbs.last_page_in_job = False; + + if (PS_DocSetupCallback(w)) + XtCallCallbackList(w, PS_DocSetupCallback(w), &cbs); + + PS_LastPageInDoc(w) = cbs.last_page_in_doc; + PS_LastPageInJob(w) = cbs.last_page_in_job; + + DEBUGOUT((__FILE__, w, "XpStartDoc\n")); + XpStartDoc(XtDisplay(w), XPDocNormal); + } + break; + + case XPEndJobNotify: + DEBUGOUT((__FILE__, w, "XPEndJobNotify\n")); + cbs.reason = XawCR_END_JOB; + cbs.event = evp; + cbs.detail = NULL; + cbs.context = None; + cbs.last_page_in_doc = True; + cbs.last_page_in_job = True; + + if (PS_EndJobCallback(w)) + XtCallCallbackList(w, PS_EndJobCallback(w), &cbs); + break; + + default: + DEBUGOUT((__FILE__, w, "XawPrintNotify(default)\n")); + break; + } +} + +static void +XawUpdateResources(Widget w, XPContext pcontext) +{ + XawPrintShellWidget print_shell = (XawPrintShellWidget)w; + String string_resolution; + XRectangle drawable_paper_area; + + string_resolution = XpGetOneAttribute(XtDisplay(w), pcontext, XPDocAttr, "default-printer-resolution"); + if (!string_resolution) { + XtAppWarning(XtWidgetToApplicationContext(w), + "XawPrintShell: XawUpdateResources: Could not get 'default-printer-resolution' XPDocAttr\n"); + } + print_shell->print.print_resolution = atol(string_resolution); + XFree(string_resolution); + + if (print_shell->print.print_resolution == 0) { + XtAppWarning(XtWidgetToApplicationContext(w), + "XawPrintShell: XawUpdateResources: Resolution '0' invalid\n"); + } + + /* Get the paper size... */ + XpGetPageDimensions(XtDisplay(w), pcontext, + &print_shell->print.page_width, &print_shell->print.page_height, + &drawable_paper_area); + /* ... and store it in the widget */ + print_shell->print.min_x = drawable_paper_area.x; + print_shell->print.min_y = drawable_paper_area.y; + print_shell->print.max_x = drawable_paper_area.x + drawable_paper_area.width; + print_shell->print.max_y = drawable_paper_area.y + drawable_paper_area.height; +} + +static void +XawUpdateLayout(Widget w) +{ + XawPrintShellWidget print_shell = (XawPrintShellWidget)w; + + switch( print_shell->print.layoutmode ) + { + case XawPrintLAYOUTMODE_NONE: + break; + case XawPrintLAYOUTMODE_PAGESIZE: + XtResizeWidget(w, + print_shell->print.page_width, + print_shell->print.page_height, + w->core.border_width); + break; + case XawPrintLAYOUTMODE_DRAWABLEAREA: + XtConfigureWidget(w, + print_shell->print.min_x, + print_shell->print.min_y, + print_shell->print.max_x - print_shell->print.min_x, + print_shell->print.max_y - print_shell->print.min_y, + w->core.border_width); + break; + default: + XtAppWarning(XtWidgetToApplicationContext(w), + "XawPrintShell: XawUpdateResources: Invalid layout mode\n"); + break; + } +} + + +/* Update widget attributes+properties when the we receive + * "Xp attribute change"-events (e.g. paper (size/orientation/etc.) + * changed etc.) */ +static void +XawAttributesNotify(Widget w, + XtPointer client, + XEvent *evp, + Boolean *cont) +{ + XawPrintShellWidget print_shell = (XawPrintShellWidget)w; + XPAttributeEvent *xpevp = (XPAttributeEvent *)evp; + + XawUpdateResources(w, xpevp->context); + XawUpdateLayout(w); +} + + + Index: xc/lib/Xaw/XawI18n.h =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/XawI18n.h,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 XawI18n.h --- a/xc/lib/Xaw/XawI18n.h 5 Mar 2004 13:39:20 -0000 1.1.4.3 +++ b/xc/lib/Xaw/XawI18n.h 21 Apr 2004 09:34:57 -0000 @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/lib/Xaw/XawI18n.h,v 1.1.4.3 2004/03/05 13:39:20 eich Exp $ */ +/* $XdotOrg: xc/lib/Xaw/XawI18n.h,v 1.1.4.2.4.1 2004/03/04 17:46:50 eich Exp $ */ /* $Xorg: XawI18n.h,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ */ /************************************************************ Index: xc/lib/Xaw/XawInit.c =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/XawInit.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 XawInit.c --- a/xc/lib/Xaw/XawInit.c 5 Mar 2004 13:39:20 -0000 1.1.4.2 +++ b/xc/lib/Xaw/XawInit.c 21 Apr 2004 09:34:58 -0000 @@ -2,6 +2,7 @@ * $Xorg: XawInit.c,v 1.4 2001/02/09 02:03:47 xorgcvs Exp $ * Copyright 1989, 1998 The Open Group +Copyright 2003-2004 Roland Mainz Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -37,6 +38,8 @@ #include #include #include +#include +#include #include "Private.h" void @@ -53,3 +56,42 @@ XtInitializeWidgetClass(vendorShellWidgetClass); } } + +/* XawOpenApplication() - mainly identical to XtOpenApplication() but + * takes a |Display *| and |Screen *| as arguments, too... */ +Widget XawOpenApplication(XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv) +{ + Widget toplevel; + Cardinal n; + Arg args[2]; + + XtToolkitInitialize(); + *app_context_return = XtCreateApplicationContext(); + if( *app_context_return == NULL ) + return NULL; + + XtDisplayInitialize(*app_context_return, dpy, + application_name, application_class, + NULL, 0, + argc, argv); + + n = 0; + if (screen) { + XtSetArg(args[n], XtNscreen, screen); n++; + } + toplevel = XtAppCreateShell(application_name, + application_class, + widget_class, + dpy, + args, n); + + return toplevel; +} + Index: xc/lib/Xaw/XawInit.h =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/XawInit.h,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 XawInit.h --- a/xc/lib/Xaw/XawInit.h 15 Apr 2004 10:14:59 -0000 1.1.4.3 +++ b/xc/lib/Xaw/XawInit.h 21 Apr 2004 09:34:58 -0000 @@ -1,6 +1,7 @@ /* $Xorg: XawInit.h,v 1.5 2001/02/09 02:03:47 xorgcvs Exp $ * Copyright 1989, 1994, 1998 The Open Group +Copyright 2003-2004 Roland Mainz Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that @@ -24,7 +25,7 @@ */ /* $XFree86: xc/lib/Xaw/XawInit.h,v 1.12 2001/01/17 19:42:36 dawes Exp $ */ -/* $XdotOrg: xc/lib/Xaw/XawInit.h,v 1.1.4.3 2004/04/15 10:14:59 eich Exp $ */ +/* $XdotOrg: xc/lib/Xaw/XawInit.h,v 1.1.4.1.6.1.6.2 2004/04/12 12:20:50 gisburn Exp $ */ #ifndef _XawInit_h #define _XawInit_h @@ -47,6 +48,17 @@ void XawInitializeDefaultConverters(void); #endif +extern Widget XawOpenApplication( + XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv +); + _XFUNCPROTOEND #endif /* _XawInit_h */ Index: xc/lib/Xaw/sharedlib.c =================================================================== RCS file: /cvs/xorg/xc/lib/Xaw/sharedlib.c,v retrieving revision 1.1 diff -u -r1.1 sharedlib.c --- a/xc/lib/Xaw/sharedlib.c 14 Nov 2003 15:54:38 -0000 1.1 +++ b/xc/lib/Xaw/sharedlib.c 21 Apr 2004 09:34:58 -0000 @@ -59,6 +59,7 @@ #include #include #include +#include extern AsciiSinkClassRec asciiSinkClassRec; WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec; @@ -168,4 +169,7 @@ extern ViewportClassRec viewportClassRec; WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec; +extern XawPrintShellClassRec xawPrintShellClassRec; +WidgetClass xawPrintShellWidgetClass = (WidgetClass) &xawPrintShellClassRec; + #endif /* SUNSHLIB */ Index: xc/lib/XprintAppUtil/Imakefile =================================================================== RCS file: xc/lib/XprintAppUtil/Imakefile diff -N xc/lib/XprintAppUtil/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintAppUtil/Imakefile 21 Apr 2004 09:34:58 -0000 @@ -0,0 +1,21 @@ +#define DoNormalLib YES +# XprintAppUtil is not a stable interface yet, therefore avoid shipping it +# as shared lib for now +#define DoSharedLib NO +#define DoDebugLib NO +#define DoProfileLib NO +#define HasSharedData NO +#define LibName XprintAppUtil +#define SoRev SOZLIBREV +#define IncSubdir X11 +#define IncSubSubdir XprintAppUtil + + +HEADERS = xpapputil.h + +SRCS = xpapputil.c +OBJS = xpapputil.o + +#include + +DependTarget() Index: xc/lib/XprintAppUtil/xpapputil.c =================================================================== RCS file: xc/lib/XprintAppUtil/xpapputil.c diff -N xc/lib/XprintAppUtil/xpapputil.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintAppUtil/xpapputil.c 21 Apr 2004 09:34:58 -0000 @@ -0,0 +1,551 @@ + +/* + * $Xorg:xpapputil.c,v 1.1 2002/06/10 02:54:18 gisburn Exp $ + * + * xpapputil - Application level utility library for Xprint + * + * +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 + +XpauContext *XpauGetContext( const char *printername ) +{ + Display *pdpy; + XPContext pcontext; + XpauContext *context; + + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + return NULL; + + if( context = (XpauContext *)malloc(sizeof(XpauContext)) ) + { + memset(context, 0, sizeof(XpauContext)); + + context->pdpy = pdpy; + context->pcontext = pcontext; + + if( XpQueryExtension(pdpy, &context->xp_event_base, &context->xp_error_base) == False ) + { + fprintf(stderr, "XpauGetContext: XpQueryExtension() failed.\n"); + XpauReleaseContext(context); + return NULL; + } + + /* It may be better to fetch all this info on demand... */ + context->medium_list = XpuGetMediumSourceSizeList(pdpy, pcontext, &context->medium_num_list_entries); + context->resolution_list = XpuGetResolutionList(pdpy, pcontext, &context->resolution_num_list_entries); + context->orientation_list = XpuGetOrientationList(pdpy, pcontext, &context->orientation_num_list_entries); + context->plex_list = XpuGetPlexList(pdpy, pcontext, &context->plex_num_list_entries); + context->supported_job_attributes = XpuGetSupportedJobAttributes(pdpy, pcontext); + context->supported_doc_attributes = XpuGetSupportedDocAttributes(pdpy, pcontext); + context->supported_page_attributes = XpuGetSupportedPageAttributes(pdpy, pcontext); + + return context; + } + + XpuClosePrinterDisplay(pdpy, pcontext); + + return NULL; +} + +void XpauReleaseContext( XpauContext *context ) +{ + if( context ) + { + if( context->medium_list ) + XpuFreeMediumSourceSizeList(context->medium_list); + + if( context->resolution_list ) + XpuFreeResolutionList(context->resolution_list); + + if( context->orientation_list ) + XpuFreeOrientationList(context->orientation_list); + + if( context->plex_list ) + XpuFreePlexList(context->plex_list); + + XpuClosePrinterDisplay(context->pdpy, context->pcontext); + + free(context); + } +} + +static +XpAuErrorValue XpauParseArg( const char *arg_name, const char *arg_value, XpauContext *context, + XpauFlags *jobvaluemask, XpauJobValues *jobvalues, + XpauFlags *docvaluemask, XpauDocValues *docvalues, + char **jobfilename ) +{ + XPAU_DEBUG(printf("XpauParseArg: name='%s', value='%s'\n", arg_name, arg_value)); + + if( !strcasecmp(arg_name, "file") || + !strcasecmp(arg_name, "tofile") ) + { + if( *jobfilename ) + free((char *)*jobfilename); + + *jobfilename = strdup(arg_value); + if( !*jobfilename ) + return XpAuError_error_no_memory; + + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "medium") || + !strcasecmp(arg_name, "papersize")) + { + if( !(context->medium_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM)) ) + return XpAuError_unsupported_medium; + + /* XXX: What about the tray name ? */ + docvalues->medium = XpuFindMediumSourceSizeByName(context->medium_list, + context->medium_num_list_entries, + NULL, arg_value); + + if( !docvalues->medium ) + return XpAuError_unsupported_medium; + + *docvaluemask |= XpauVMedium; + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "resolution") ) + { + int arg_res = atoi(arg_value); + + if( !(context->resolution_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION)) ) + return XpAuError_unsupported_resolution; + + docvalues->resolution = XpuFindResolution(context->resolution_list, + context->resolution_num_list_entries, + arg_res, arg_res); + + if( !docvalues->resolution ) + return XpAuError_unsupported_resolution; + + *docvaluemask |= XpauVResolution; + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "orientation") ) + { + if( !(context->orientation_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION)) ) + return XpAuError_unsupported_orientation; + + docvalues->orientation = XpuFindOrientationByName(context->orientation_list, + context->orientation_num_list_entries, + arg_value); + + if( !docvalues->orientation ) + return XpAuError_unsupported_orientation; + + *docvaluemask |= XpauVOrientation; + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "plex") ) + { + if( !(context->plex_list && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_PLEX)) ) + return XpAuError_unsupported_plex; + + docvalues->plex = XpuFindPlexByName(context->plex_list, + context->plex_num_list_entries, + arg_value); + + if( !docvalues->plex ) + return XpAuError_unsupported_plex; + + *docvaluemask |= XpauVPlex; + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "copies") ) + { + if( !(context->supported_job_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT) ) + return XpAuError_unsupported_copy_count; + + jobvalues->copies = atoi(arg_value); + if( jobvalues->copies <= 1 ) + return XpAuError_unsupported_copy_count; + + *jobvaluemask |= XpauVCopies; + return XpAuError_success; + } + else if( !strcasecmp(arg_name, "title") ) + { + if( !(context->supported_job_attributes & XPUATTRIBUTESUPPORTED_JOB_NAME) ) + return XpAuError_unsupported_job_name; + + if( jobvalues->title ) + free((char *)jobvalues->title); + + jobvalues->title = strdup(arg_value); + if( !jobvalues->title ) + return XpAuError_error_no_memory; + + *jobvaluemask |= XpauVTitle; + return XpAuError_success; + } + + return XpAuError_unknown_argument; +} + +XpAuErrorValue XpauParseArgs( XpauContext *context, + XpauFlags *jobvaluemask, XpauJobValues *jobvalues, + XpauFlags *docvaluemask, XpauDocValues *docvalues, + char **jobfilename, + const char *argument_string ) +{ + char *args_string, + *arg_name, + *arg_value, + *start, + *s; + int result; + + if( !argument_string ) + return XpAuError_success; + + args_string = strdup(argument_string); /* Create copy of read-only string that we can write into it... */ + if( !args_string ) + return XpAuError_error_no_memory; + + s = args_string; + + while( s != NULL ) + { + /* Fetch argument name */ + start = s; + while( *s != '\0' && *s != '=' ) + s++; + if( *s == '\0' ) + { + free(args_string); + return XpAuError_unexpected_eos; + } + *s++ = '\0'; + arg_name = start; + + /* Fetch argument value */ + start = s; + while( *s != '\0' && *s != ',' ) + s++; + if( *s == '\0' ) + s = NULL; + else + *s++ = '\0'; + arg_value = start; + + result = XpauParseArg(arg_name, arg_value, context, jobvaluemask, jobvalues, docvaluemask, docvalues, jobfilename); + if( result != XpAuError_success ) + { + free(args_string); + return result; + } + } + + free(args_string); + return XpAuError_success; +} + +XpAuErrorValue +XpauSetJobValues( XpauContext *context, XpauFlags valuemask, XpauJobValues *jobvalues ) +{ + /* "Dry-run" tests */ + + /* We can't change job attributes while we are at the "job level" + * (e.g. after |XpStartJob()| and before |XpEndJob()| */ + XPAU_RETURN_IF_FAIL(context->inJob == False, XpAuError_inside_job); + + if( valuemask & XpauVTitle ) + XPAU_RETURN_IF_FAIL(jobvalues->title && (context->supported_job_attributes & XPUATTRIBUTESUPPORTED_JOB_NAME), XpAuError_unsupported_job_name); + + if( valuemask & XpauVCopies ) + XPAU_RETURN_IF_FAIL((jobvalues->copies > 0) && (context->supported_job_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT), XpAuError_unsupported_copy_count); + + /* Set values */ + + if( valuemask & XpauVTitle ) + XpuSetJobTitle(context->pdpy, context->pcontext, jobvalues->title); + +#ifdef NOTNOW + if( valuemask & XpauVResolution ) + XpuJobDocumentCopies(context->pdpy, context->pcontext, jobvalues->copies); +#endif /* NOTNOW */ + + return XpAuError_success; +} + +XpAuErrorValue +XpauSetDocValues( XpauContext *context, XpauFlags valuemask, XpauDocValues *docvalues ) +{ + /* "Dry-run" tests */ + + /* We can't change document attributes while we are at the "document level" + * (e.g. after |XpStartDoc()| and before |XpEndDoc()| */ + XPAU_RETURN_IF_FAIL(context->inDocument == False, XpAuError_inside_document); + + if( valuemask & XpauVMedium ) + XPAU_RETURN_IF_FAIL(docvalues->medium && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM), XpAuError_unsupported_medium); + + if( valuemask & XpauVOrientation ) + XPAU_RETURN_IF_FAIL(docvalues->orientation && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION), XpAuError_unsupported_orientation); + + if( valuemask & XpauVPlex ) + XPAU_RETURN_IF_FAIL(docvalues->plex && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_PLEX), XpAuError_unsupported_plex); + + if( valuemask & XpauVResolution ) + XPAU_RETURN_IF_FAIL(docvalues->resolution && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION), XpAuError_unsupported_resolution); + + if( valuemask & XpauVCopies ) + XPAU_RETURN_IF_FAIL((docvalues->copies > 0) && (context->supported_doc_attributes & XPUATTRIBUTESUPPORTED_COPY_COUNT), XpAuError_unsupported_copy_count); + + /* Set values */ + + if( valuemask & XpauVMedium ) + XpuSetDocMediumSourceSize(context->pdpy, context->pcontext, docvalues->medium); + + if( valuemask & XpauVOrientation ) + XpuSetDocOrientation(context->pdpy, context->pcontext, docvalues->orientation); + + if( valuemask & XpauVPlex ) + XpuSetDocPlex(context->pdpy, context->pcontext, docvalues->plex); + + if( valuemask & XpauVResolution ) + XpuSetDocResolution(context->pdpy, context->pcontext, docvalues->resolution); + + if( valuemask & XpauVCopies ) + XpuSetDocumentCopies(context->pdpy, context->pcontext, docvalues->copies); + + return XpAuError_success; +} + +XpAuErrorValue +XpauSetPageValues( XpauContext *context, XpauFlags valuemask, XpauPageValues *pagevalues ) +{ + /* "Dry-run" tests */ + + /* We can't change page attributes while we are at the "page level" + * (e.g. after |XpStartPage()| and before |XpEndPage()| */ + XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page); + + if( valuemask & XpauVMedium ) + XPAU_RETURN_IF_FAIL(pagevalues->medium && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM), XpAuError_unsupported_medium); + + if( valuemask & XpauVOrientation ) + XPAU_RETURN_IF_FAIL(pagevalues->orientation && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION), XpAuError_unsupported_orientation); + + if( valuemask & XpauVPlex ) + XPAU_RETURN_IF_FAIL(pagevalues->plex && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_PLEX), XpAuError_unsupported_plex); + + if( valuemask & XpauVResolution ) + XPAU_RETURN_IF_FAIL(pagevalues->resolution && (context->supported_page_attributes & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION), XpAuError_unsupported_resolution); + + /* Set values */ + + if( valuemask & XpauVMedium ) + XpuSetPageMediumSourceSize(context->pdpy, context->pcontext, pagevalues->medium); + + if( valuemask & XpauVOrientation ) + XpuSetPageOrientation(context->pdpy, context->pcontext, pagevalues->orientation); + + if( valuemask & XpauVPlex ) + XpuSetPagePlex(context->pdpy, context->pcontext, pagevalues->plex); + + if( valuemask & XpauVResolution ) + XpuSetPageResolution(context->pdpy, context->pcontext, pagevalues->resolution); + + return XpAuError_success; +} + +XpAuErrorValue XpauStartJob( XpauContext *context, const char *printerfile ) +{ + void *handle; + XpAuErrorValue result = XpAuError_unspecified_error; + + XPAU_RETURN_IF_FAIL(context->inJob == False, XpAuError_inside_job); + + /* Set print context + * Note that this modifies the available fonts, including build-in printer prints. + * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print + * context to obtain the proper fonts. + */ + XpSetContext(context->pdpy, context->pcontext); + + if( printerfile ) + { + context->print_to_filehandle = XpuStartJobToFile(context->pdpy, context->pcontext, printerfile); + if( context->print_to_filehandle ) + { + result = XpAuError_success; + } + else + { + result = XpAuError_errno; + } + } + else + { + XpuStartJobToSpooler(context->pdpy); + result = XpAuError_success; + } + + /* Get default printer resolution */ + if( XpuGetResolution(context->pdpy, context->pcontext, &context->document_dpi) != 1 ) + { + result = XpAuError_no_dpi_set; + } + + if( result == XpAuError_success ) + { + context->inJob = True; + context->pscreen = XpGetScreenOfContext(context->pdpy, context->pcontext); + context->pscreennumber = XScreenNumberOfScreen(context->pscreen); + } + + return result; +} + +XpAuErrorValue XpauEndJob( XpauContext *context ) +{ + XPAU_RETURN_IF_FAIL(context->inJob, XpAuError_not_inside_job); + + /* End the print job - the final results are sent by the X print + * server to the spooler sub system. + */ + XpEndJob(context->pdpy); + + /* Be sure to process the X traffic (remember that we registered a + * "consumer" hook via Xlib internal magic when we print to a + * file) + * FixMe: |XpuWaitForPrintFileChild()| should call XFlush() instead! + */ + XFlush(context->pdpy); + + context->inJob = False; + context->pscreen = NULL; + context->pscreennumber = -1; + context->document_dpi = 0L; + + if( context->print_to_filehandle ) + { + if( XpuWaitForPrintFileChild(context->print_to_filehandle) != XPGetDocFinished ) + { + return XpAuError_errno; + } + } + + return XpAuError_success; +} + +XpAuErrorValue XpauStartDocument( XpauContext *context, XPDocumentType type ) +{ + XPAU_RETURN_IF_FAIL(context->inJob == True, XpAuError_not_inside_job); + XPAU_RETURN_IF_FAIL(context->inDocument == False, XpAuError_inside_document); + XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page); + + XpStartDoc(context->pdpy, type); + context->inDocument = True; + + return XpAuError_success; +} + +XpAuErrorValue XpauEndDocument( XpauContext *context ) +{ + XPAU_RETURN_IF_FAIL(context->inDocument, XpAuError_not_inside_document); + + XpEndDoc(context->pdpy); + context->inDocument = False; + + return XpAuError_success; +} + +XpAuErrorValue XpauStartPage( XpauContext *context, Window pwin ) +{ + XPAU_RETURN_IF_FAIL(context->inPage == False, XpAuError_inside_page); + XPAU_RETURN_IF_FAIL(context->inJob == True, XpAuError_not_inside_job); + + XpStartPage(context->pdpy, pwin); + + /* |XpStartPage()| will generate a "synthetic" |XpStartDoc()| + * if it was not called yet */ + if( context->inDocument == False ) + { + context->inDocument = True; + } + + context->inPage = True; + + return XpAuError_success; +} + +XpAuErrorValue XpauEndPage( XpauContext *context ) +{ + XPAU_RETURN_IF_FAIL(context->inPage, XpAuError_not_inside_page); + + XpEndPage(context->pdpy); + context->inPage = False; + + return XpAuError_success; +} + +void XpauWaitForPrintNotify(XpauContext *context, int type) +{ + XpuWaitForPrintNotify(context->pdpy, context->xp_event_base, type); +} + + +const char *XpAuErrorValueToString(XpAuErrorValue value) +{ + char *msg; + + switch(value) + { + case XpAuError_success: msg = "success" ; break; + case XpAuError_errno: msg = strerror(errno) ; break; + case XpAuError_error_no_memory: msg = "out of memory" ; break; + case XpAuError_unexpected_eos: msg = "unexpected end of string" ; break; + case XpAuError_unknown_argument: msg = "unknown argument" ; break; + case XpAuError_unsupported_medium: msg = "unsupported print medium" ; break; + case XpAuError_unsupported_resolution: msg = "unsupported print resolution" ; break; + case XpAuError_unsupported_orientation: msg = "unsupported orientation" ; break; + case XpAuError_unsupported_plex: msg = "unsupported plex" ; break; + case XpAuError_unsupported_copy_count: msg = "unsupported copy count" ; break; + case XpAuError_unsupported_job_name: msg = "unsupported job name" ; break; + case XpAuError_no_dpi_set: msg = "no DPI set (or no default DPI provided by server)" ; break; + case XpAuError_not_inside_job: msg = "state error: not inside job" ; break; + case XpAuError_not_inside_document: msg = "state error: not inside document" ; break; + case XpAuError_not_inside_page: msg = "stage error: not inside page" ; break; + case XpAuError_inside_job: msg = "state error: (already) inside job" ; break; + case XpAuError_inside_document: msg = "state error: (already) inside document" ; break; + case XpAuError_inside_page: msg = "stage error: (already) inside page" ; break; + case XpAuError_unspecified_error: msg = "unspecified error" ; break; + default: + msg = "unknown error" ; + break; + } + + return msg; +} + + + + Index: xc/lib/XprintAppUtil/xpapputil.h =================================================================== RCS file: xc/lib/XprintAppUtil/xpapputil.h diff -N xc/lib/XprintAppUtil/xpapputil.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintAppUtil/xpapputil.h 21 Apr 2004 09:34:59 -0000 @@ -0,0 +1,174 @@ + +/* + * $Xorg:xpapputil.h,v 1.1 2002/06/10 02:54:18 gisburn Exp $ + * + * xpapputil - Application level utility library for Xprint + * + * +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 + */ + +#ifndef XPAPPUTILS_H +#define XPAPPUTILS_H 1 + +#include +#include +#include +#include + +#ifdef DEBUG +#define XPAU_RETURN_IF_FAIL(expr, return_code) \ + if( !(expr) ) { \ + printf("XPAU_RETURN_IF_FAIL(file %s, line %d): " #expr ", returning " #return_code "\n", __FILE__, __LINE__); \ + return (return_code); \ + } + +#define XPAU_DEBUG(x) x + +#else + +#define XPAU_RETURN_IF_FAIL(expr, return_code) \ + if( !(expr) ) { \ + return (return_code); \ + } + +#define XPAU_DEBUG(x) +#endif /* DEBUG */ + +/* + * Struct for XpauGetContext(), XpauReleaseContext() + * + */ +typedef struct +{ + Display *pdpy; + XPContext pcontext; + int xp_event_base, + xp_error_base; + + Bool inJob; + Bool inDocument; + Bool inPage; + + void *print_to_filehandle; + Screen *pscreen; + int pscreennumber; + long document_dpi; + + XpuSupportedFlags supported_job_attributes; + XpuSupportedFlags supported_doc_attributes; + XpuSupportedFlags supported_page_attributes; + + XpuMediumSourceSizeList medium_list; + int medium_num_list_entries; + XpuResolutionList resolution_list; + int resolution_num_list_entries; + XpuOrientationList orientation_list; + int orientation_num_list_entries; + XpuPlexList plex_list; + int plex_num_list_entries; +} XpauContext; + + +#define XpauVFilename (1L<<0) +#define XpauVMedium (1L<<1) +#define XpauVResolution (1L<<2) +#define XpauVOrientation (1L<<3) +#define XpauVPlex (1L<<4) +#define XpauVCopies (1L<<5) +#define XpauVTitle (1L<<6) +#define XpauVAll (XpauVFilename | \ + XpauVMedium | \ + XpauVResolution | \ + XpauVOrientation | \ + XpauVPlex | \ + XpauVCopies | \ + XpauVTitle) + +typedef unsigned long XpauFlags; + +typedef struct +{ + const char *title; + long copies; +} XpauJobValues; + +typedef struct +{ + XpuMediumSourceSizeRec *medium; + XpuResolutionRec *resolution; + XpuOrientationRec *orientation; + XpuPlexRec *plex; + long copies; +} XpauDocValues; + +typedef struct +{ + XpuMediumSourceSizeRec *medium; + XpuResolutionRec *resolution; + XpuOrientationRec *orientation; + XpuPlexRec *plex; +} XpauPageValues; + +typedef enum { + XpAuError_success = 0, + XpAuError_unspecified_error, + XpAuError_errno, /* check |errno| for error */ + XpAuError_error_no_memory, + XpAuError_unexpected_eos, + XpAuError_unknown_argument, + XpAuError_unsupported_medium, + XpAuError_unsupported_resolution, + XpAuError_unsupported_orientation, + XpAuError_unsupported_plex, + XpAuError_unsupported_copy_count, + XpAuError_unsupported_job_name, + XpAuError_no_dpi_set, + XpAuError_not_inside_job, + XpAuError_not_inside_document, + XpAuError_not_inside_page, + XpAuError_inside_job, + XpAuError_inside_document, + XpAuError_inside_page +} XpAuErrorValue; + +/* Prototypes */ +XpauContext * XpauGetContext( const char *printername ); +void XpauReleaseContext( XpauContext *context ); +XpAuErrorValue XpauParseArgs( XpauContext *context, + XpauFlags *jobvaluemask, XpauJobValues *jobvalues, + XpauFlags *docvaluemask, XpauDocValues *docvalues, + char **jobfilename, + const char *argument_string ); +XpAuErrorValue XpauSetJobValues( XpauContext *context, XpauFlags valuemask, XpauJobValues *Xpaujobvalues ); +XpAuErrorValue XpauSetDocValues( XpauContext *context, XpauFlags valuemask, XpauDocValues *Xpaudocvalues ); +XpAuErrorValue XpauSetPageValues( XpauContext *context, XpauFlags valuemask, XpauPageValues *Xpaupagevalues ); +XpAuErrorValue XpauStartJob( XpauContext *context, const char *printerfile ); +XpAuErrorValue XpauEndJob( XpauContext *context ); +XpAuErrorValue XpauStartDocument( XpauContext *context, XPDocumentType type ); +XpAuErrorValue XpauEndDocument( XpauContext *context ); +XpAuErrorValue XpauStartPage( XpauContext *context, Window pwin ); +XpAuErrorValue XpauEndPage( XpauContext *context ); +void XpauWaitForPrintNotify(XpauContext *context, int type); +const char *XpAuErrorValueToString(XpAuErrorValue value); +#endif /* !XPAPPUTILS_H */ + + Index: xc/lib/XprintUtil/Imakefile =================================================================== RCS file: xc/lib/XprintUtil/Imakefile diff -N xc/lib/XprintUtil/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintUtil/Imakefile 21 Apr 2004 09:34:59 -0000 @@ -0,0 +1,21 @@ +#define DoNormalLib YES +# XprintUtil is not a stable interface yet, therefore avoid shipping it +# as shared lib for now +#define DoSharedLib NO +#define DoDebugLib NO +#define DoProfileLib NO +#define HasSharedData NO +#define LibName XprintUtil +#define SoRev SOZLIBREV +#define IncSubdir X11 +#define IncSubSubdir XprintUtil + + +HEADERS = xprintutil.h + +SRCS = xprintutil.c xprintutil_printtofile.c +OBJS = xprintutil.o xprintutil_printtofile.o + +#include + +DependTarget() Index: xc/lib/XprintUtil/xprintutil.c =================================================================== RCS file: xc/lib/XprintUtil/xprintutil.c diff -N xc/lib/XprintUtil/xprintutil.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintUtil/xprintutil.c 21 Apr 2004 09:34:59 -0000 @@ -0,0 +1,1678 @@ +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2001-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + +#include "xprintutil.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef XPU_USE_NSPR +#include "plstr.h" +#undef strtok_r +#define strtok_r(s1, s2, x) PL_strtok_r((s1), (s2), (x)) +#endif /* USE_MOZILLA_TYPES */ + +/* List of tokens which can be used to seperate entries in the + * $XPSERVERLIST env var */ +static const char XPServerListSeparators[] = " \t\v\n\r\f"; + +/* conformace only; X11 API does (currrently) not make use of |const|. + * If Xlib API gets fixed these macros can be turned into empty + * placeholders... (|#define MAKE_STRING_WRITABLE(x)|) :-) + */ +#define MAKE_STRING_WRITABLE(str) (((str)?((str) = strdup(str)):0)) +#define FREE_WRITABLE_STRING(str) free((void *)(str)) +#define STRING_AS_WRITABLE(str) ((char *)(str)) + +/* Local prototypes */ +static const char *XpuGetDefaultXpPrintername(void); +static const char *XpuGetXpServerList( void ); +static const char *XpuEnumerateXpAttributeValue( const char *value, void **vcptr ); +static const char *XpuGetCurrentAttributeGroup( void **vcptr ); +static void XpuDisposeEnumerateXpAttributeValue( void **vc ); +static Bool XpuEnumerateMediumSourceSizes( Display *pdpy, XPContext pcontext, + const char **tray_name, + const char **medium_name, int *mbool, + float *ma1, float *ma2, float *ma3, float *ma4, + void **vcptr ); +static void XpuDisposeEnumerateMediumSourceSizes( void **vc ); + +/* +** XprintUtil functions start with Xpu +** +*/ + +int XpuCheckExtension( Display *pdpy ) +{ + char *display = XDisplayString(pdpy); + short major = 0, + minor = 0; + + if( XpQueryVersion(pdpy, &major, &minor) != 0 ) + { + XPU_DEBUG_ONLY(printf("XpuCheckExtension: XpQueryVersion '%s' %d %d\n", XPU_NULLXSTR(display), (int)major, (int)minor)); + return(1); + } + else + { + XPU_DEBUG_ONLY(printf("XpuCheckExtension: XpQueryVersion '%s' returned 0(=Xprint not supported)\n", XPU_NULLXSTR(display))); + } + + return(0); +} + +/* Get the default printer name from the XPRINTER env var. + * If XPRINTER env var is not present looks for PDPRINTER, LPDEST, and + * PRINTER (in that order) + * See CDE's DtPrintSetupBox(3) manual page, too... + */ +static +const char *XpuGetDefaultXpPrintername(void) +{ + const char *s; + /* BUG/TODO: XpPrinter resource needs to be sourced, too... */ + s = getenv("XPRINTER"); + if( !s ) + { + s = getenv("PDPRINTER"); + if( !s ) + { + s = getenv("LPDEST"); + if( !s ) + { + s = getenv("PRINTER"); + } + } + } + return s; +} + +static +const char *XpuGetXpServerList( void ) +{ + const char *s; + /* BUG/TODO: XpServerList resource needs to be sourced first, then append + * contents of XPSERVERLIST, then remove duplicates... + */ + s = getenv("XPSERVERLIST"); + if( s == NULL ) + s = ""; + + return(s); +} + + +static +int XpuGetPrinter2( char *printer, char *display, Display **pdpyptr, XPContext *pcontextptr ) +{ + Display *pdpy; + XPContext pcontext; + + XPU_DEBUG_ONLY(printf("XpuGetPrinter2: probing display '%s' for '%s'\n", XPU_NULLXSTR(display), XPU_NULLXSTR(printer))); + + if( (pdpy = XOpenDisplay(display)) != NULL ) + { + if( XpuCheckExtension(pdpy) ) + { + XPPrinterList list; + int list_count; + + /* get list of available printers... */ + list = XpGetPrinterList(pdpy, printer, &list_count); + if( list != NULL ) XpFreePrinterList(list); + + /* ...and check if printer exists... */ + if( (list != NULL) && (list_count > 0) ) + { + if( (pcontext = XpCreateContext(pdpy, printer)) != None ) + { + *pdpyptr = pdpy; + *pcontextptr = pcontext; + return(1); + } + + XPU_DEBUG_ONLY(printf("XpuGetPrinter2: could not create print context for '%s'\n", XPU_NULLXSTR(printer))); + } + } + else + { + XPU_DEBUG_ONLY(printf("display '%s' does not support the Xprint extension\n", XPU_NULLXSTR(display))); + } + + XCloseDisplay(pdpy); + return(0); + } + else + { + XPU_DEBUG_ONLY(printf("could not open display '%s'\n", XPU_NULLXSTR(display))); + return(0); + } +} + + +/* acceps "printer" or "printer@display" */ +int XpuGetPrinter( const char *arg_printername, Display **pdpyptr, XPContext *pcontextptr ) +{ + Display *pdpy; + XPContext pcontext; + char *printername; + char *s; + char *tok_lasts; + + *pdpyptr = NULL; + *pcontextptr = None; + + XPU_DEBUG_ONLY(printf("XpuGetPrinter: looking for '%s'\n", XPU_NULLXSTR(arg_printername))); + + /* strtok_r will modify string - duplicate it first... */ + printername = strdup(arg_printername); + if( printername == NULL ) + return(0); + + if( (s = strtok_r(printername, "@", &tok_lasts)) != NULL ) + { + char *name = s; + char *display = strtok_r(NULL, "@", &tok_lasts); + + /* if we have a display - open it and grab printer */ + if( display != NULL ) + { + if( XpuGetPrinter2(name, display, pdpyptr, pcontextptr) ) + { + free(printername); + return(1); + } + } + /* if we did not get a display, travel througth all displays */ + else + { + char *sl = strdup(XpuGetXpServerList()); + + if( sl != NULL ) + { + for( display = strtok_r(sl, XPServerListSeparators, &tok_lasts) ; + display != NULL ; + display = strtok_r(NULL, XPServerListSeparators, &tok_lasts) ) + { + if( XpuGetPrinter2(name, display, pdpyptr, pcontextptr) ) + { + free(sl); + free(printername); + return(1); + } + } + + free(sl); + } + } + } + + free(printername); + XPU_DEBUG_ONLY(printf("XpuGetPrinter: failure\n")); + + return(0); +} + + +void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext) +{ + if( pdpy ) + { + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + + XCloseDisplay(pdpy); + } +} + +void XpuSetOneAttribute( Display *pdpy, XPContext pcontext, + XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule ) +{ + /* Alloc buffer for sprintf() stuff below */ + char *buffer = (char *)malloc(strlen(attribute_name)+strlen(value)+4); + + if( buffer != NULL ) + { + sprintf(buffer, "%s: %s", attribute_name, value); + XpSetAttributes(pdpy, pcontext, type, buffer, replacement_rule); + free(buffer); + } +} + +void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext, + XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule ) +{ + /* Alloc buffer for sprintf() stuff below */ + char *buffer = (char *)malloc(strlen(attribute_name)+32+4); + + if( buffer != NULL ) + { + sprintf(buffer, "%s: %ld", attribute_name, value); + XpSetAttributes(pdpy, pcontext, type, buffer, replacement_rule); + free(buffer); + } +} + +/* Check if attribute value is supported or not + * Use this function _only_ if XpuGetSupported{Job,Doc,Page}Attributes() + * does not help you... + */ +int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query ) +{ + char *value; + void *tok_lasts; + + MAKE_STRING_WRITABLE(attribute_name); + if( attribute_name == NULL ) + return(0); + + value = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name)); + + XPU_DEBUG_ONLY(printf("XpuCheckSupported: XpGetOneAttribute(%s) returned '%s'\n", XPU_NULLXSTR(attribute_name), XPU_NULLXSTR(value))); + + FREE_WRITABLE_STRING(attribute_name); + + if( value != NULL ) + { + const char *s; + + for( s = XpuEnumerateXpAttributeValue(value, &tok_lasts) ; s != NULL ; s = XpuEnumerateXpAttributeValue(NULL, &tok_lasts) ) + { + XPU_DEBUG_ONLY(printf("XpuCheckSupported: probing '%s'=='%s'\n", XPU_NULLXSTR(s), XPU_NULLXSTR(query))); + if( !strcmp(s, query) ) + { + XFree(value); + XpuDisposeEnumerateXpAttributeValue(&tok_lasts); + return(1); + } + } + + XpuDisposeEnumerateXpAttributeValue(&tok_lasts); + XFree(value); + } + + return(0); +} + + +int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title ) +{ + if( XpuGetSupportedJobAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_JOB_NAME ) + { + XpuSetOneAttribute(pdpy, pcontext, XPJobAttr, "*job-name", title, XPAttrMerge); + return(1); + } + else + { + XPU_DEBUG_ONLY(printf("XpuSetJobTitle: XPUATTRIBUTESUPPORTED_JOB_NAME not supported ('%s')\n", XPU_NULLXSTR(title))); + return(0); + } +} + +int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result ) +{ + char *s; + + MAKE_STRING_WRITABLE(attribute_name); + if( attribute_name == NULL ) + return(0); + s = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name)); + + if(s && *s) + { + long tmp; + + XPU_DEBUG_ONLY(printf("XpuGetOneLongAttribute: '%s' got '%s'\n", XPU_NULLXSTR(attribute_name), XPU_NULLXSTR(s))); + + tmp = strtol(s, (char **)NULL, 10); + + if( !(((tmp == 0L) || (tmp == LONG_MIN) || (tmp == LONG_MAX)) && + ((errno == ERANGE) || (errno == EINVAL))) ) + { + *result = tmp; + XFree(s); + XPU_DEBUG_ONLY(printf("XpuGetOneLongAttribute: result %ld\n", *result)); + FREE_WRITABLE_STRING(attribute_name); + return(1); + } + } + + if( s != NULL ) + XFree(s); + + FREE_WRITABLE_STRING(attribute_name); + + return(0); +} + + +#ifdef DEBUG +/* debug only */ +void dumpXpAttributes( Display *pdpy, XPContext pcontext ) +{ + char *s; + printf("------------------------------------------------\n"); + 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)); + printf("------------------------------------------------\n"); +} +#endif /* DEBUG */ + + +typedef struct XpuIsNotifyEventContext_ +{ + int event_base; + int detail; +} XpuIsNotifyEventContext; + +static +Bool IsXpNotifyEvent( Display *pdpy, XEvent *ev, XPointer arg ) +{ + Bool match; + XpuIsNotifyEventContext *context = (XpuIsNotifyEventContext *)arg; + XPPrintEvent *pev = (XPPrintEvent *)ev; + + match = pev->type == (context->event_base+XPPrintNotify) && + pev->detail == context->detail; + + XPU_DEBUG_ONLY(printf("XpuWaitForPrintNotify: %d=IsXpNotifyEvent(%d,%d)\n", + (int)match, + (int)pev->type, + (int)pev->detail)); + return match; +} + +void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail ) +{ + XEvent dummy; + XpuIsNotifyEventContext matchcontext; + + matchcontext.event_base = xp_event_base; + matchcontext.detail = detail; + XIfEvent(pdpy, &dummy, IsXpNotifyEvent, (XPointer)&matchcontext); +} + +static +const char *skip_matching_brackets(const char *start) +{ + const char *s = start; + int level = 0; + + if( !start ) + return(NULL); + + do + { + switch(*s++) + { + case '\0': return(NULL); + case '{': level++; break; + case '}': level--; break; + } + } while(level > 0); + + return(s); +} + + +static +const char *search_next_space(const char *start) +{ + const char *s = start; + int level = 0; + + if( !start ) + return(NULL); + + for(;;) + { + if( isspace(*s) ) + return(s); + + if( *s=='\0' ) + return(NULL); + + s++; + } +} + +/* PRIVATE context data for XpuEnumerateXpAttributeValue() */ +typedef struct _XpuAttributeValueEnumeration +{ + char *value; + size_t original_value_len; /* original length of value */ + char *group; + char *start; + char *s; +} XpuAttributeValueEnumeration; + + +/* Hacked parser for Xp values and enumerations */ +static +const char *XpuEnumerateXpAttributeValue( const char *value, void **vcptr ) +{ + XpuAttributeValueEnumeration **cptr = (XpuAttributeValueEnumeration **)vcptr; + XpuAttributeValueEnumeration *context; + const char *tmp; + + if( !cptr ) + return(NULL); + + if( value ) + { + XpuAttributeValueEnumeration *e; + const char *s = value; + Bool isGroup = FALSE; + + e = (XpuAttributeValueEnumeration *)malloc(sizeof(XpuAttributeValueEnumeration)); + if( !e ) + return NULL; + + /* Skip leading '{'. */ + while(*s=='{' && isGroup==FALSE) + { + s++; + isGroup = TRUE; + } + /* Skip leading blanks. */ + while(isspace(*s)) + s++; + + e->group = NULL; + + /* Read group name. */ + if( isGroup ) + { + tmp = s; + while(!isspace(*s)) + s++; + if(strncmp(tmp, "''", s-tmp) != 0) + { + e->group = strdup(tmp); + e->group[s-tmp] = '\0'; + } + } + + e->original_value_len = strlen(s); + e->value = (char *)malloc(e->original_value_len+4); /* We may look up to three bytes beyond the string */ + strcpy(e->value, s); + memset(e->value+e->original_value_len+1, 0, 3); /* quad termination */ + e->start = e->s = e->value; + + *cptr = e; + } + + context = *cptr; + + if( !context || !context->s ) + return(NULL); + + /* Skip leading blanks, '\'' or '}' */ + while(isspace(*(context->s)) || *(context->s)=='\'' /*|| *(context->s)=='}'*/ ) + context->s++; + + if( *(context->s) == '\0' ) + return(NULL); + + context->start = context->s; + if( *(context->start) == '{' ) + context->s = (char *)skip_matching_brackets(context->start); + else + context->s = (char *)search_next_space(context->start); + + /* end of string reached ? */ + if( context->s ) + { + *(context->s) = '\0'; + context->s++; + } + + /* Check if we reached a new attribute group */ + tmp = context->start; + while(isspace(*tmp)) + tmp++; + if( *tmp=='}' ) + { + void *prev_cptr = *vcptr; + + tmp+=2; /* We have 3*'\0' at the end of the string - this is legal! */ + if( *tmp!='\0' ) + { + const char *ret; + + /* Start the parser again */ + *vcptr = NULL; + ret = XpuEnumerateXpAttributeValue(tmp, vcptr); + + /* Free old context */ + XpuDisposeEnumerateXpAttributeValue(&prev_cptr); + + return(ret); + } + else + { + return(NULL); + } + } + + return(context->start); +} + +/* Get enumeration group for last string returned by |XpuEnumerateXpAttributeValue|... */ +static +const char *XpuGetCurrentAttributeGroup( void **vcptr ) +{ + XpuAttributeValueEnumeration **cptr = (XpuAttributeValueEnumeration **)vcptr; + if( !cptr ) + return(NULL); + if( !*cptr ) + return(NULL); + + return((*cptr)->group); +} + + +static +void XpuDisposeEnumerateXpAttributeValue( void **vc ) +{ + if( vc ) + { + XpuAttributeValueEnumeration *context = *((XpuAttributeValueEnumeration **)vc); + free(context->value); + if(context->group) + free(context->group); + free(context); + } +} + +/* parse a paper size string + * (example: '{na-letter False {6.3500 209.5500 6.3500 273.0500}}') */ +static +Bool XpuParseMediumSourceSize( const char *value, + const char **medium_name, int *mbool, + float *ma1, float *ma2, float *ma3, float *ma4 ) +{ + const char *s; + char *d, + *name; + char *boolbuf; + size_t value_len; + int num_input_items; + const char *cur_locale; + + if( value && value[0]!='{' && value[0]!='\0' ) + return(False); + + value_len = strlen(value); + + /* alloc buffer for |medium_name| and |boolbuf| in one step + * (both must be large enougth to hold at least |strlen(value)+1| bytes) */ + name = (char *)malloc(value_len*2 + 4); + boolbuf = name + value_len+2; /* |boolbuf| starts directly after |name| */ + + /* remove '{' && '}' */ + s = value; + d = name; + do + { + *d = tolower(*s); + + if( *s!='{' && *s!='}' ) + d++; + + s++; + } + while(*s); + *d = '\0'; + + /* seperate medium name from string */ + d = (char *)search_next_space(name); + if( !d ) + { + free(name); + return(False); + } + *d = '\0'; + *medium_name = name; + + /* ... continue to parse the remaining string... */ + d++; + + + /* Force C/POSIX radix for scanf()-parsing (see bug 131831 ("Printing + * does not work in de_AT@euro locale")), do the parsing and restore + * the original locale. + * XXX: This may affect all threads and not only the calling one... + */ + { +#define CUR_LOCALE_SIZE 256 + char cur_locale[CUR_LOCALE_SIZE+1]; + strncpy(cur_locale, setlocale(LC_NUMERIC, NULL), CUR_LOCALE_SIZE); + cur_locale[CUR_LOCALE_SIZE]='\0'; + setlocale(LC_NUMERIC, "C"); + num_input_items = sscanf(d, "%s %f %f %f %f", boolbuf, ma1, ma2, ma3, ma4); + setlocale(LC_NUMERIC, cur_locale); +#undef CUR_LOCALE_SIZE + } + + if( num_input_items != 5 ) + { + free(name); + return(False); + } + + if( !strcmp(boolbuf, "true") ) + *mbool = True; + else if( !strcmp(boolbuf, "false") ) + *mbool = False; + else + { + free(name); + return(False); + } + return(True); +} + + +/* parse a paper size string + * (example: '{na-letter False {6.3500 209.5500 6.3500 273.0500}}') */ +static +Bool XpuEnumerateMediumSourceSizes( Display *pdpy, XPContext pcontext, + const char **tray_name, + const char **medium_name, int *mbool, + float *ma1, float *ma2, float *ma3, float *ma4, + void **vcptr ) +{ + const char *medium_spec; + const char *value = NULL; + + if( pdpy && pcontext ) + { + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "medium-source-sizes-supported"); + if( !value ) + return(False); + } + + while(1) + { + medium_spec = XpuEnumerateXpAttributeValue(value, vcptr); + + if( value ) + { + XFree((void *)value); + value = NULL; + } + + /* enumeration done? */ + if( !medium_spec ) + return(False); + + if (XpuParseMediumSourceSize(medium_spec, + medium_name, mbool, + ma1, ma2, ma3, ma4)) + { + *tray_name = XpuGetCurrentAttributeGroup(vcptr); + return(True); + } + else + { + /* Should never ever happen! */ + fprintf(stderr, "XpuEnumerateMediumSourceSize: error parsing '%s'\n", medium_spec); + } + } + /* not reached */ +} + +static +void XpuDisposeEnumerateMediumSourceSizes( void **vc ) +{ + XpuDisposeEnumerateXpAttributeValue(vc); +} + + +/* future: Migrate this functionality into |XpGetPrinterList| - just do + * not pass a |Display *| to |XpGetPrinterList| + */ +XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count ) +{ + XPPrinterRec *rec = NULL; + int rec_count = 1; /* Allocate one more |XPPrinterRec| structure + * as terminator */ + char *sl; + const char *default_printer_name = XpuGetDefaultXpPrintername(); + int default_printer_rec_index = -1; + + if( !res_list_count ) + return(NULL); + + sl = strdup(XpuGetXpServerList()); + MAKE_STRING_WRITABLE(printer); + + if( sl != NULL ) + { + char *display; + char *tok_lasts; + + for( display = strtok_r(sl, XPServerListSeparators, &tok_lasts) ; + display != NULL ; + display = strtok_r(NULL, XPServerListSeparators, &tok_lasts) ) + { + Display *pdpy; + + if( (pdpy = XOpenDisplay(display)) != NULL ) + { + XPPrinterList list; + int list_count; + size_t display_len = strlen(display); + + /* get list of available printers... */ + list = XpGetPrinterList(pdpy, STRING_AS_WRITABLE(printer), &list_count); + + if( list && list_count ) + { + int i; + + for( i = 0 ; i < list_count ; i++ ) + { + char *s; + + /* Workaround for http://bugzilla.mozilla.org/show_bug.cgi?id=193499 + * ("Xprint print/print preview crashes Mozilla") where the Solaris + * Xprt may create invalid entries (e.g. |XpGetPrinterList| will + * return |list[i].name==NULL| due to empty lines in the printer list. + */ + if( !list[i].name ) + continue; + + rec_count++; + rec = (XPPrinterRec *)realloc(rec, sizeof(XPPrinterRec)*rec_count); + if( !rec ) /* failure */ + break; + + s = (char *)malloc(strlen(list[i].name)+display_len+4); + sprintf(s, "%s@%s", list[i].name, display); + rec[rec_count-2].name = s; + rec[rec_count-2].desc = (list[i].desc)?(strdup(list[i].desc)):(NULL); + + /* Test for default printer (if the user set one).*/ + if( default_printer_name ) + { + /* Default_printer_name may either contain the FQPN(=full + * qualified printer name ("foo@myhost:5") or just the name + * ("foo")) */ + if( (!strcmp(list[i].name, default_printer_name)) || + (!strcmp(s, default_printer_name)) ) + { + /* Remember index of default printer that we can swap it to + * the head of the array below... */ + default_printer_rec_index = rec_count-2; + } + } + } + + XpFreePrinterList(list); + } + + XCloseDisplay(pdpy); + } + } + + free(sl); + } + + if( rec ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuFreePrinterList() easier) + * I may remove this implementation detail in a later revision of + * the library! + */ + rec[rec_count-1].name = NULL; + rec[rec_count-1].desc = NULL; + rec_count--; + } + else + { + rec_count = 0; + } + + /* The default printer is always the first one in the printer list... */ + if( (default_printer_rec_index != -1) && rec ) + { + XPPrinterRec tmp; + tmp = rec[0]; + rec[0] = rec[default_printer_rec_index]; + rec[default_printer_rec_index] = tmp; + } + + *res_list_count = rec_count; + FREE_WRITABLE_STRING(printer); + return(rec); +} + + +void XpuFreePrinterList( XPPrinterList list ) +{ + if( list ) + { + XPPrinterRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->name != NULL ) + { + free(curr->name); + if(curr->desc) + free(curr->desc); + curr++; + } + + free(list); + } +} + +/* Set number of copies to print from this document */ +int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies ) +{ + if( XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_COPY_COUNT) + { + XpuSetOneLongAttribute(pdpy, pcontext, XPDocAttr, "*copy-count", num_copies, XPAttrMerge); + return(1); + } + else + { + XPU_DEBUG_ONLY(printf("XpuSetContentOrientation: XPUATTRIBUTESUPPORTED_COPY_COUNT not supported\n")); + + /* Failure... */ + return(0); + } +} + +XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) +{ + XpuMediumSourceSizeList list = NULL; + int rec_count = 1; /* allocate one more |XpuMediumSourceSizeRec| structure + * as terminator */ + Bool status; + float ma1, + ma2, + ma3, + ma4; + char *value; + void *tok_lasts; + const char *tray_name, + *medium_name; + int mbool; + const char *default_tray, + *default_medium; + int default_medium_rec_index = -1; + + default_tray = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-input-tray"); + if(!default_tray) + { + fprintf(stderr, "XpuGetMediumSourceSizeList: Internal error, no 'default-input-tray' found.\n"); + return(NULL); + } + default_medium = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "default-medium"); + if(!default_medium) + { + fprintf(stderr, "XpuGetMediumSourceSizeList: Internal error, no 'default-medium' found.\n"); + XFree((void *)default_tray); + return(NULL); + } + + for( status = XpuEnumerateMediumSourceSizes(pdpy, pcontext, &tray_name, &medium_name, &mbool, + &ma1, &ma2, &ma3, &ma4, &tok_lasts) ; + status != False ; + status = XpuEnumerateMediumSourceSizes(NULL, None, &tray_name, &medium_name, &mbool, + &ma1, &ma2, &ma3, &ma4, &tok_lasts) ) + { + rec_count++; + list = (XpuMediumSourceSizeRec *)realloc(list, sizeof(XpuMediumSourceSizeRec)*rec_count); + if( !list ) + return(NULL); + + list[rec_count-2].tray_name = (tray_name)?(strdup(tray_name)):(NULL); + list[rec_count-2].medium_name = strdup(medium_name); + list[rec_count-2].mbool = mbool; + list[rec_count-2].ma1 = ma1; + list[rec_count-2].ma2 = ma2; + list[rec_count-2].ma3 = ma3; + list[rec_count-2].ma4 = ma4; + + /* Default medium ? */ + if( (!strcmp(medium_name, default_medium)) && + ((tray_name && (*default_tray))?(!strcmp(tray_name, default_tray)):(True)) ) + { + default_medium_rec_index = rec_count-2; + } + } + + XpuDisposeEnumerateMediumSourceSizes(&tok_lasts); + + if( list ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuFreeMediumSourceSizeList() easier) + * I may remove this implementation detail in a later revision of + * the library! */ + list[rec_count-1].tray_name = NULL; + list[rec_count-1].medium_name = NULL; + rec_count--; + } + else + { + rec_count = 0; + } + + /* Make the default medium always the first item in the list... */ + if( (default_medium_rec_index != -1) && list ) + { + XpuMediumSourceSizeRec tmp; + tmp = list[0]; + list[0] = list[default_medium_rec_index]; + list[default_medium_rec_index] = tmp; + } + + *numEntriesPtr = rec_count; + return(list); +} + +void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list ) +{ + if( list ) + { + XpuMediumSourceSizeRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->medium_name != NULL ) + { + if( curr->tray_name) + free((void *)curr->tray_name); + free((void *)curr->medium_name); + curr++; + } + + free(list); + } +} + +static +int XpuSetMediumSourceSize( Display *pdpy, XPContext pcontext, XPAttributes type, XpuMediumSourceSizeRec *medium_spec ) +{ + /* Set the "default-medium" and "*default-input-tray" + * (if |XpuEnumerateMediumSourceSizes| returned one) XPDocAttr's + * attribute and return */ + if (medium_spec->tray_name) + { + XpuSetOneAttribute(pdpy, pcontext, type, "*default-input-tray", medium_spec->tray_name, XPAttrMerge); + } + XpuSetOneAttribute(pdpy, pcontext, type, "*default-medium", medium_spec->medium_name, XPAttrMerge); + + return( 1 ); +} + +/* Set document medium size */ +int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ) +{ + XpuSupportedFlags doc_supported_flags; + + doc_supported_flags = XpuGetSupportedDocAttributes(pdpy, pcontext); + + if( (doc_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM) == 0 ) + return( 0 ); + + if (medium_spec->tray_name) + { + if( (doc_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY) == 0 ) + return( 0 ); + } + + return XpuSetMediumSourceSize(pdpy, pcontext, XPDocAttr, medium_spec); +} + +/* Set page medium size */ +int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ) +{ + XpuSupportedFlags page_supported_flags; + + page_supported_flags = XpuGetSupportedPageAttributes(pdpy, pcontext); + + if( (page_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM) == 0 ) + return( 0 ); + + if (medium_spec->tray_name) + { + if( (page_supported_flags & XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY) == 0 ) + return( 0 ); + } + + return XpuSetMediumSourceSize(pdpy, pcontext, XPPageAttr, medium_spec); +} + +#ifndef ABS +#define ABS(x) ((x)<0?-(x):(x)) +#endif /* ABS */ +#define MORE_OR_LESS_EQUAL(a, b, tolerance) (ABS((a) - (b)) <= (tolerance)) + +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count, + float page_width_mm, float page_height_mm, float tolerance ) +{ + int i; + for( i = 0 ; i < mlist_count ; i++ ) + { + XpuMediumSourceSizeRec *curr = &mlist[i]; + float total_width = curr->ma1 + curr->ma2, + total_height = curr->ma3 + curr->ma4; + + /* Match width/height*/ + if( ((page_width_mm !=-1.f)?(MORE_OR_LESS_EQUAL(total_width, page_width_mm, tolerance)):(True)) && + ((page_height_mm!=-1.f)?(MORE_OR_LESS_EQUAL(total_height, page_height_mm, tolerance)):(True)) ) + { + return(curr); + } + } + + return(NULL); +} + +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count, + float m1, float m2, float m3, float m4, float tolerance ) +{ + int i; + for( i = 0 ; i < mlist_count ; i++ ) + { + XpuMediumSourceSizeRec *curr = &mlist[i]; + + /* Match bounds */ + if( ((m1!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma1, m1, tolerance)):(True)) && + ((m2!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma2, m2, tolerance)):(True)) && + ((m3!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma3, m3, tolerance)):(True)) && + ((m4!=-1.f)?(MORE_OR_LESS_EQUAL(curr->ma4, m4, tolerance)):(True)) ) + { + return(curr); + } + } + + return(NULL); +} + +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count, + const char *tray_name, const char *medium_name ) +{ + int i; + for( i = 0 ; i < mlist_count ; i++ ) + { + XpuMediumSourceSizeRec *curr = &mlist[i]; + + /* Match by tray name and/or medium name */ + if( ((tray_name && curr->tray_name)?(!strcasecmp(curr->tray_name, tray_name)):(tray_name==NULL)) && + ((medium_name)?(!strcasecmp(curr->medium_name, medium_name)):(True)) ) + { + return(curr); + } + } + + return(NULL); +} + +XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) +{ + XpuResolutionList list = NULL; + int rec_count = 1; /* Allocate one more |XpuResolutionRec| structure + * as terminator */ + char *value; + char *tok_lasts; + const char *s; + long default_resolution = -1; + int default_resolution_rec_index = -1; + + /* Get default document resolution */ + if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &default_resolution) != 1 ) + { + default_resolution = -1; + } + + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "printer-resolutions-supported"); + if (!value) + { + fprintf(stderr, "XpuGetResolutionList: Internal error, no 'printer-resolutions-supported' XPPrinterAttr found.\n"); + return(NULL); + } + + for( s = strtok_r(value, " ", &tok_lasts) ; + s != NULL ; + s = strtok_r(NULL, " ", &tok_lasts) ) + { + long tmp; + + tmp = strtol(s, (char **)NULL, 10); + + if( ((tmp == 0L) || (tmp == LONG_MIN) || (tmp == LONG_MAX)) && + ((errno == ERANGE) || (errno == EINVAL)) ) + { + fprintf(stderr, "XpuGetResolutionList: Internal parser errror for '%s'.\n", s); + continue; + } + + rec_count++; + list = (XpuResolutionRec *)realloc(list, sizeof(XpuResolutionRec)*rec_count); + if( !list ) + return(NULL); + + list[rec_count-2].dpi = tmp; + + if( default_resolution != -1 ) + { + /* Is this the default resolution ? */ + if( list[rec_count-2].dpi == default_resolution ) + { + default_resolution_rec_index = rec_count-2; + } + } + } + + XFree(value); + + if( list ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuFreeMediumSourceSizeList() easier) + * I may remove this implementation detail in a later revision of + * the library! */ + list[rec_count-1].dpi = -1; + rec_count--; + } + else + { + rec_count = 0; + } + + /* Make the default resolution always the first item in the list... */ + if( (default_resolution_rec_index != -1) && list ) + { + XpuResolutionRec tmp; + tmp = list[0]; + list[0] = list[default_resolution_rec_index]; + list[default_resolution_rec_index] = tmp; + } + + *numEntriesPtr = rec_count; + return(list); +} + +void XpuFreeResolutionList( XpuResolutionList list ) +{ + if( list ) + { + free(list); + } +} + +/* Find resolution in resolution list. + * Lower resolutions are preferred over larger resolution if |dpi_a| <= |dpi_b|, + * otherwise larger resolutions are preferred over small resolutions + */ +XpuResolutionRec *XpuFindResolution( XpuResolutionList list, int list_count, long dpi_a, long dpi_b ) +{ + XpuResolutionRec *match = NULL; + int i; + + if( dpi_a <= dpi_b ) + { + /* Search list, lower resolutions are better... */ + for( i = 0 ; i < list_count ; i++ ) + { + XpuResolutionRec *curr = &list[i]; + + if( curr->dpi >= dpi_a && curr->dpi <= dpi_b ) + { + if( !match || (curr->dpi < match->dpi) ) + { + match = curr; + } + } + } + } + else + { + /* Search list, higher resolutions are better... */ + for( i = 0 ; i < list_count ; i++ ) + { + XpuResolutionRec *curr = &list[i]; + + if( curr->dpi >= dpi_b && curr->dpi <= dpi_a ) + { + if( !match || (curr->dpi > match->dpi) ) + { + match = curr; + } + } + } + } + + return(match); +} + +/* Get default page (if defined) or document resolution + * this function may fail in the following conditions: + * - No default resolution set yet + * - X DPI != Y DPI (not yet implemented in Xprt) + */ +Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *dpi_ptr ) +{ + /* Try to get the current page's resolution (pages may differ in resolution if the DDX supports this) */ + if( XpuGetOneLongAttribute(pdpy, pcontext, XPPageAttr, "default-printer-resolution", dpi_ptr) == 1 ) + { + return True; + } + + /* Get document resolution */ + if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", dpi_ptr) == 1 ) + { + return True; + } + + return False; +} + +static +int XpuSetResolution( Display *pdpy, XPContext pcontext, XPAttributes type, XpuResolutionRec *rec ) +{ + XpuSetOneLongAttribute(pdpy, pcontext, type, "*default-printer-resolution", rec->dpi, XPAttrMerge); + return( 1 ); +} + +/* Set document resolution + * Retun error if printer does not support setting a resolution + */ +int XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec ) +{ + if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 ) + return( 0 ); + + return XpuSetResolution(pdpy, pcontext, XPDocAttr, rec); +} + +/* Set page medium size + * Retun error if printer does not support setting a resolution or if per-page + * resolution changes are not allowed. + */ +int XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec *rec ) +{ + if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 ) + return( 0 ); + + return XpuSetResolution(pdpy, pcontext, XPPageAttr, rec); +} + +XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) +{ + XpuOrientationList list = NULL; + int rec_count = 1; /* Allocate one more |XpuOrientationRec| + * structure as terminator */ + char *value; + char *tok_lasts; + const char *s; + const char *default_orientation = NULL; + int default_orientation_rec_index = -1; + + /* Get default document orientation */ + default_orientation = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "content-orientation"); + if( !default_orientation ) + { + fprintf(stderr, "XpuGetOrientationList: Internal error, no 'content-orientation' XPDocAttr found.\n"); + return(NULL); + } + + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "content-orientations-supported"); + if (!value) + { + fprintf(stderr, "XpuGetOrientationList: Internal error, no 'content-orientations-supported' XPPrinterAttr found.\n"); + return(NULL); + } + + for( s = strtok_r(value, " ", &tok_lasts) ; + s != NULL ; + s = strtok_r(NULL, " ", &tok_lasts) ) + { + rec_count++; + list = (XpuOrientationRec *)realloc(list, sizeof(XpuOrientationRec)*rec_count); + if( !list ) + return(NULL); + + list[rec_count-2].orientation = strdup(s); + + /* Default resolution ? */ + if( !strcmp(list[rec_count-2].orientation, default_orientation) ) + { + default_orientation_rec_index = rec_count-2; + } + } + + XFree(value); + XFree((void *)default_orientation); + + if( list ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuFreeOrientationList() easier) + * I may remove this implementation detail in a later revision of + * the library! */ + list[rec_count-1].orientation = NULL; + rec_count--; + } + else + { + rec_count = 0; + } + + /* Make the default orientation always the first item in the list... */ + if( (default_orientation_rec_index != -1) && list ) + { + XpuOrientationRec tmp; + tmp = list[0]; + list[0] = list[default_orientation_rec_index]; + list[default_orientation_rec_index] = tmp; + } + + *numEntriesPtr = rec_count; + return(list); +} + +void XpuFreeOrientationList( XpuOrientationList list ) +{ + if( list ) + { + XpuOrientationRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->orientation != NULL ) + { + free((void *)curr->orientation); + curr++; + } + free(list); + } +} + +XpuOrientationRec * +XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation ) +{ + int i; + + for( i = 0 ; i < list_count ; i++ ) + { + XpuOrientationRec *curr = &list[i]; + if (!strcasecmp(curr->orientation, orientation)) + return curr; + } + + return(NULL); +} + +static +int XpuSetOrientation( Display *pdpy, XPContext pcontext, XPAttributes type, XpuOrientationRec *rec ) +{ + XpuSetOneAttribute(pdpy, pcontext, type, "*content-orientation", rec->orientation, XPAttrMerge); + return(1); +} + +/* Set document orientation + * Retun error if printer does not support setting an orientation + */ +int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ) +{ + if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 ) + return( 0 ); + + return XpuSetOrientation(pdpy, pcontext, XPDocAttr, rec); +} + +/* Set page orientation + * Retun error if printer does not support setting an orientation or if + * per-page orientations changes are not allowed + */ +int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ) +{ + if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 ) + return( 0 ); + + return XpuSetOrientation(pdpy, pcontext, XPPageAttr, rec); +} + +XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ) +{ + XpuPlexList list = NULL; + int rec_count = 1; /* Allocate one more |XpuPlexList| structure + * as terminator */ + char *value; + char *tok_lasts; + const char *s; + const char *default_plex = NULL; + int default_plex_rec_index = -1; + + /* Get default document plex */ + default_plex = XpGetOneAttribute(pdpy, pcontext, XPDocAttr, "plex"); + if( !default_plex ) + { + fprintf(stderr, "XpuGetPlexList: Internal error, no 'plex' XPDocAttr found.\n"); + return(NULL); + } + + value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "plexes-supported"); + if (!value) + { + fprintf(stderr, "XpuGetPlexList: Internal error, no 'plexes-supported' XPPrinterAttr found.\n"); + return(NULL); + } + + for( s = strtok_r(value, " ", &tok_lasts) ; + s != NULL ; + s = strtok_r(NULL, " ", &tok_lasts) ) + { + rec_count++; + list = (XpuPlexRec *)realloc(list, sizeof(XpuPlexRec)*rec_count); + if( !list ) + return(NULL); + + list[rec_count-2].plex = strdup(s); + + /* Default plex ? */ + if( !strcmp(list[rec_count-2].plex, default_plex) ) + { + default_plex_rec_index = rec_count-2; + } + } + + XFree(value); + XFree((void *)default_plex); + + if( list ) + { + /* users: DO NOT COUNT ON THIS DETAIL + * (this is only to make current impl. of XpuFreePlexList() easier) + * I may remove this implementation detail in a later revision of + * the library! */ + list[rec_count-1].plex = NULL; + rec_count--; + } + else + { + rec_count = 0; + } + + /* Make the default plex always the first item in the list... */ + if( (default_plex_rec_index != -1) && list ) + { + XpuPlexRec tmp; + tmp = list[0]; + list[0] = list[default_plex_rec_index]; + list[default_plex_rec_index] = tmp; + } + + *numEntriesPtr = rec_count; + return(list); +} + +void XpuFreePlexList( XpuPlexList list ) +{ + if( list ) + { + XpuPlexRec *curr = list; + + /* See the warning abouve about using this implementation detail for + * checking for the list's end... */ + while( curr->plex != NULL ) + { + free((void *)curr->plex); + curr++; + } + free(list); + } +} + +XpuPlexRec * +XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex ) +{ + int i; + + for( i = 0 ; i < list_count ; i++ ) + { + XpuPlexRec *curr = &list[i]; + if (!strcasecmp(curr->plex, plex)) + return curr; + } + + return(NULL); +} + +static +int XpuSetContentPlex( Display *pdpy, XPContext pcontext, XPAttributes type, XpuPlexRec *rec ) +{ + XpuSetOneAttribute(pdpy, pcontext, type, "*plex", rec->plex, XPAttrMerge); + return(1); +} + +/* Set document plex + * Retun error if printer does not support setting an plex + */ +int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ) +{ + if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 ) + return( 0 ); + + return XpuSetContentPlex(pdpy, pcontext, XPDocAttr, rec); +} + +/* Set page plex + * Retun error if printer does not support setting an plex or if + * per-page plex changes are not allowed + */ +int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ) +{ + if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 ) + return( 0 ); + + return XpuSetContentPlex(pdpy, pcontext, XPPageAttr, rec); +} + + +/* Return flags to indicate which attributes are supported and which not... */ +static +XpuSupportedFlags XpuGetSupportedAttributes( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name ) +{ + char *value; + void *tok_lasts; + XpuSupportedFlags flags = 0; + + MAKE_STRING_WRITABLE(attribute_name); + if( attribute_name == NULL ) + return(0); + + value = XpGetOneAttribute(pdpy, pcontext, type, STRING_AS_WRITABLE(attribute_name)); + + FREE_WRITABLE_STRING(attribute_name); + + if( value != NULL ) + { + const char *s; + + for( s = XpuEnumerateXpAttributeValue(value, &tok_lasts) ; s != NULL ; s = XpuEnumerateXpAttributeValue(NULL, &tok_lasts) ) + { + if( !strcmp(s, "job-name") ) flags |= XPUATTRIBUTESUPPORTED_JOB_NAME; + else if( !strcmp(s, "job-owner") ) flags |= XPUATTRIBUTESUPPORTED_JOB_OWNER; + else if( !strcmp(s, "notification-profile") ) flags |= XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE; + else if( !strcmp(s, "copy-count") ) flags |= XPUATTRIBUTESUPPORTED_COPY_COUNT; + else if( !strcmp(s, "document-format") ) flags |= XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT; + else if( !strcmp(s, "content-orientation") ) flags |= XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION; + else if( !strcmp(s, "default-printer-resolution") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION; + else if( !strcmp(s, "default-input-tray") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY; + else if( !strcmp(s, "default-medium") ) flags |= XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM; + else if( !strcmp(s, "plex") ) flags |= XPUATTRIBUTESUPPORTED_PLEX; + } + + XpuDisposeEnumerateXpAttributeValue(&tok_lasts); + XFree(value); + } + + return(flags); +} + +XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext) +{ + return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "job-attributes-supported"); +} + +XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext) +{ + return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "document-attributes-supported"); +} + +XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext) +{ + return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "xp-page-attributes-supported"); +} + +/* EOF. */ Index: xc/lib/XprintUtil/xprintutil.h =================================================================== RCS file: xc/lib/XprintUtil/xprintutil.h diff -N xc/lib/XprintUtil/xprintutil.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintUtil/xprintutil.h 21 Apr 2004 09:34:59 -0000 @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +#ifndef XPRINTUTIL_H +#define XPRINTUTIL_H 1 +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2001-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + + +/* Force ANSI C prototypes from X11 headers */ +#ifndef FUNCPROTO +#define FUNCPROTO 15 +#endif /* !FUNCPROTO */ + +#include +#include +#include + +/* I don't know how to make this "better" yet... ;-( */ +#ifdef USE_MOZILLA_TYPES +#include +#include +#include +#define XPU_USE_NSPR 1 +/* + * Disabled for now - Threaded codepath does not work properly always. + * See bug 134570 ("Print-to-file not working with threaded XprintUtil") + * #define XPU_USE_THREADS 1 + */ +#endif /* USE_MOZILLA_TYPES */ + +#ifdef DEBUG +/* trace function calls */ +#define XPU_TRACE(EX) (puts(#EX),EX) +/* trace function calls in child */ +#define XPU_TRACE_CHILD(EX) (puts("child: " #EX),EX) +/* execute function EX only in debug mode */ +#define XPU_DEBUG_ONLY(EX) (EX) +#else +#define XPU_TRACE(EX) (EX) +#define XPU_TRACE_CHILD(EX) (EX) +#define XPU_DEBUG_ONLY(EX) +#endif /* DEBUG */ + +/* debug/logging: replace NULLptrs with "" string */ +#define XPU_NULLXSTR(s) (((s)!=NULL)?(s):("")) + +/* + * Struct for XpuGetMediumSourceSizeList(), XpuFreeMediumSourceSizeList(), + * XpuSetDocMediumSourceSize(), XpuSetPageMediumSourceSize(), + * XpuFindMediumSourceSizeBy*() + */ +typedef struct { + const char *tray_name; + const char *medium_name; + int mbool; + float ma1; + float ma2; + float ma3; + float ma4; +} XpuMediumSourceSizeRec, *XpuMediumSourceSizeList; + +/* + * Struct for XpuGetResolutionList(), XpuFreeResolutionList(), + * XpuGetResolution(), XpuSetPageResolution(), XpuSetDocResolution(), + * XpuFindResolution() + */ +typedef struct { + long dpi; + /* ToDo: Support for Xdpi != Ydpi */ +} XpuResolutionRec, *XpuResolutionList; + +/* + * Struct for XpuGetOrientationList(), XpuFreeOrientationList(), + * XpuFindOrientationBy*(), XpuSetPageResolution(), + * XpuSetDocOrientation() + */ +typedef struct { + const char *orientation; +} XpuOrientationRec, *XpuOrientationList; + +/* + * Struct for XpuGetPlexList(), XpuFreePlexList(), XpuFindPlexBy*(), + * XpuSetDocPlex(), XpuSetPagePlex() + */ +typedef struct { + const char *plex; +} XpuPlexRec, *XpuPlexList; + + +/* XPUATTRIBUTESUPPORTED_*: + * Flags which indicate whether it is allowed to set/change a specific attribute + */ +typedef long XpuSupportedFlags; +/* Job attributes */ +#define XPUATTRIBUTESUPPORTED_JOB_NAME (1L<<0) +#define XPUATTRIBUTESUPPORTED_JOB_OWNER (1L<<1) +#define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE (1L<<2) +/* Document/Page attributes */ +#define XPUATTRIBUTESUPPORTED_COPY_COUNT (1L<<3) +#define XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT (1L<<4) +#define XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION (1L<<5) +#define XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION (1L<<6) +#define XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY (1L<<7) +#define XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM (1L<<8) +#define XPUATTRIBUTESUPPORTED_PLEX (1L<<9) + +/* prototypes */ +_XFUNCPROTOBEGIN + +int XpuCheckExtension( Display *pdpy ); + +/* Create/destroy connection to printer */ +int XpuGetPrinter( const char *printername, Display **pdpyptr, XPContext *pcontextptr ); +void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext); + +/* Misc. functions */ +void XpuSetOneAttribute( Display *pdpy, XPContext pcontext, + XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule ); +void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext, + XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule ); +int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query ); +int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title ); +int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result ); +#ifdef DEBUG +void dumpXpAttributes( Display *pdpy, XPContext pcontext ); +#endif /* DEBUG */ +void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail ); + +/* Get list of printers */ +XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count ); +void XpuFreePrinterList( XPPrinterList list ); + +/* Set number of document copies */ +int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies ); + +/* Get/Set/Query supported mediums (paper sizes) */ +XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); +void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list ); +int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ); +int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec ); +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count, + float page_width_mm, float page_height_mm, float tolerance ); +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count, + float m1, float m2, float m3, float m4, float tolerance ); +XpuMediumSourceSizeRec * +XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count, + const char *tray_name, const char *medium_name ); + +/* Get/Set resolution */ +XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); +void XpuFreeResolutionList( XpuResolutionList list ); +Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *dpi ); +Bool XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * ); +Bool XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * ); +XpuResolutionRec *XpuFindResolution( XpuResolutionList list, int list_count, long min_dpi, long max_dpi ); + +/* Get/Set orientation */ +XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); +void XpuFreeOrientationList( XpuOrientationList list ); +XpuOrientationRec * +XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation ); +int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ); +int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec ); + +/* Get/set plex modes */ +XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr ); +void XpuFreePlexList( XpuPlexList list ); +XpuPlexRec *XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex ); +int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ); +int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec ); + +/* Start job to printer (spooler) or file */ +void XpuStartJobToSpooler(Display *pdpy); +void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename ); +XPGetDocStatus XpuWaitForPrintFileChild( void *handle ); + +/* Get flags which indicate whether it is allowed to set/change a specific attribute */ +XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext); +XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext); +XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext); + +_XFUNCPROTOEND + +#define XpuGetJobAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPJobAttr ) +#define XpuGetDocAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPDocAttr ) +#define XpuGetPageAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPageAttr ) +#define XpuGetPrinterAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr ) +#define XpuGetServerAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPServerAttr ) + +#endif /* !XPRINTUTIL_H */ +/* EOF. */ Index: xc/lib/XprintUtil/xprintutil_printtofile.c =================================================================== RCS file: xc/lib/XprintUtil/xprintutil_printtofile.c diff -N xc/lib/XprintUtil/xprintutil_printtofile.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/lib/XprintUtil/xprintutil_printtofile.c 21 Apr 2004 09:34:59 -0000 @@ -0,0 +1,498 @@ +/****************************************************************************** + ****************************************************************************** + ** + ** (c) Copyright 2001-2004 Roland Mainz + ** + ** Permission is hereby granted, free of charge, to any person obtaining a copy + ** of this software and associated documentation files (the "Software"), to deal + ** in the Software without restriction, including without limitation the rights + ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + ** copies of the Software, and to permit persons to whom the Software is + ** furnished to do so, subject to the following conditions: + ** + ** 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 + ** COPYRIGHT HOLDERS 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 names of the copyright holders shall + ** not be used in advertising or otherwise to promote the sale, use or other + ** dealings in this Software without prior written authorization from said + ** copyright holders. + ** + ****************************************************************************** + *****************************************************************************/ + +#include "xprintutil.h" + +#include +#include +#include +#include +#include +#ifdef XPU_USE_THREADS +#include +#ifdef XPU_USE_NSPR +#include +#else +#include +#endif /* XPU_USE_NSPR */ +#endif /* XPU_USE_THREADS */ +#include +#include +#include +#include + +/* local prototypes */ +#ifdef DEBUG +static void PrintXPGetDocStatus( XPGetDocStatus status ); +#endif +static Bool XNextEventTimeout( Display *display, XEvent *event_return, struct timeval *timeout ); +static void *XpuPrintToFile( Display *pdpy, XPContext pcontext, const char *filename ); +static void MyPrintToFileProc( Display *pdpy, XPContext pcontext, unsigned char *data, unsigned int data_len, XPointer client_data ); +static void MyFinishProc( Display *pdpy, XPContext pcontext, XPGetDocStatus status, XPointer client_data ); +#ifdef XPU_USE_NSPR +static void PrintToFile_Consumer( void *handle ); +#else +static void *PrintToFile_Consumer( void *handle ); +#endif + +void XpuStartJobToSpooler(Display *pdpy) +{ + XpStartJob(pdpy, XPSpool); +} + +void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename ) +{ + void *handle; + + XpStartJob(pdpy, XPGetData); + handle = XpuPrintToFile(pdpy, pcontext, filename); + + if (!handle) + { + /* Cancel the print job and discard all events... */ + XpCancelJob(pdpy, True); + } + + return(handle); +} + +#ifdef DEBUG +/* DEBUG: Print XPGetDocStatus */ +static +void PrintXPGetDocStatus( XPGetDocStatus status ) +{ + switch(status) + { + case XPGetDocFinished: puts("PrintXPGetDocStatus: XPGetDocFinished"); break; + case XPGetDocSecondConsumer: puts("PrintXPGetDocStatus: XPGetDocSecondConsumer"); break; + case XPGetDocError: puts("PrintXPGetDocStatus: XPGetDocError"); break; + default: puts("PrintXPGetDocStatus: parent_pdpy = pdpy; + mpfd->displayname = XDisplayString(pdpy); + mpfd->pdpy = NULL; + mpfd->pcontext = pcontext; + mpfd->file_name = filename; + mpfd->file = NULL; + mpfd->status = XPGetDocError; + + /* make sure we can open the file for writing */ + if( (mpfd->file = fopen(mpfd->file_name, "w")) == NULL ) + { + /* fopen() error */ + free(mpfd); + return(NULL); + } + + /* its important to flush before we start the consumer thread, + * to make sure that the XpStartJob gets through first in the parent + */ + XFlush(pdpy); +#ifdef XPU_USE_NSPR + if( (mpfd->prthread = PR_CreateThread(PR_SYSTEM_THREAD, PrintToFile_Consumer, mpfd, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0)) == NULL ) +#else + if( pthread_create(&(mpfd->tid), NULL, PrintToFile_Consumer, mpfd) != 0 ) +#endif + { + /* pthread_create() error */ + fclose(mpfd->file); + free(mpfd); + return(NULL); + } + + /* we're still in the parent */ + XPU_DEBUG_ONLY(printf("### parent started consumer thread.\n" )); + return(mpfd); +} + + +XPGetDocStatus XpuWaitForPrintFileChild( void *handle ) +{ + MyPrintFileData *mpfd = (MyPrintFileData *)handle; + void *res; + XPGetDocStatus status; + + /* Flush data a last time to make sure we send all data to Xprt and that + * the Xlib internal hooks have called a last time */ + XFlush(mpfd->parent_pdpy); + +#ifdef XPU_USE_NSPR + if( PR_JoinThread(mpfd->prthread) != PR_SUCCESS ) + perror("XpuWaitForPrintFileChild: PR_JoinThread() failure"); /* fixme(later): use NSPR error handling calls... */ +#else + if( XPU_TRACE(pthread_join(mpfd->tid, &res)) != 0 ) + perror("XpuWaitForPrintFileChild: pthread_join() failure"); +#endif + + status = mpfd->status; + free(handle); + + XPU_DEBUG_ONLY(PrintXPGetDocStatus(status)); + return(status); +} + +#else /* XPU_USE_THREADS */ +/** + ** XpuPrintToFile() - fork() version + ** Create consumer thread which creates it's own display connection to print server + ** (a 2nd display connection/process is required to avoid deadlocks within Xlib), + ** registers (Xlib-internal) consumer callback (via XpGetDocumentData(3Xp)) and + ** processes/eats all incoming events via MyPrintToFileProc(). A final call to + ** MyPrintToFileProc() cleans-up all stuff and sets the "done" flag. + ** Note that these callbacks are called directly by Xlib while waiting for events in + ** XNextEvent() because XpGetDocumentData() registeres them as "internal" callbacks, + ** e.g. XNextEvent() does _not_ return before/after processing these events !! + ** + ** Usage: + ** XpStartJob(pdpy, XPGetData); + ** handle = XpuPrintToFile(pdpy, pcontext, "myfile"); + ** // render something + ** XpEndJob(); // or XpCancelJob() + ** status = XpuWaitForPrintFileChild(handle); + ** + */ +typedef struct +{ + pid_t pid; + int pipe[2]; /* child-->parent communication pipe */ + const char *displayname; + Display *pdpy; + Display *parent_pdpy; + XPContext pcontext; + const char *file_name; + FILE *file; + XPGetDocStatus status; + Bool done; +} MyPrintFileData; + + +static +void *XpuPrintToFile( Display *pdpy, XPContext pcontext, const char *filename ) +{ + MyPrintFileData *mpfd; + + if( (mpfd = (MyPrintFileData *)malloc(sizeof(MyPrintFileData))) == NULL ) + return(NULL); + + /* create pipe */ + if( pipe(mpfd->pipe) == -1 ) + { + /* this should never happen, but... */ + perror("XpuPrintToFile: cannot create pipe"); + free(mpfd); + return(NULL); + } + + mpfd->parent_pdpy = pdpy; + mpfd->displayname = XDisplayString(pdpy); + mpfd->pcontext = pcontext; + mpfd->file_name = filename; + mpfd->file = NULL; + mpfd->status = XPGetDocError; + + /* make sure we can open the file for writing */ + if( (mpfd->file = fopen(mpfd->file_name, "w")) == NULL ) + { + /* fopen() error */ + close(mpfd->pipe[1]); + close(mpfd->pipe[0]); + free(mpfd); + return(NULL); + } + + /* its important to flush before we fork, to make sure that the + * XpStartJob gets through first in the parent + */ + XFlush(pdpy); + + mpfd->pid = fork(); + + if( mpfd->pid == 0 ) + { + /* we're now in the fork()'ed child */ + PrintToFile_Consumer(mpfd); + } + else if( mpfd->pid < 0 ) + { + /* fork() error */ + close(mpfd->pipe[1]); + close(mpfd->pipe[0]); + fclose(mpfd->file); + free(mpfd); + return(NULL); + } + + /* we're still in the parent */ + XPU_DEBUG_ONLY(printf("### parent fork()'ed consumer child.\n")); + + /* child will write into file - we don't need it anymore here... :-) */ + fclose(mpfd->file); + close(mpfd->pipe[1]); + return(mpfd); +} + + +XPGetDocStatus XpuWaitForPrintFileChild( void *handle ) +{ + MyPrintFileData *mpfd = (MyPrintFileData *)handle; + int res; + XPGetDocStatus status = XPGetDocError; /* used when read() from pipe fails */ + + /* Flush data a last time to make sure we send all data to Xprt and that + * the Xlib internal hooks have called a last time */ + XFlush(mpfd->parent_pdpy); + + if( XPU_TRACE(waitpid(mpfd->pid, &res, 0)) == -1 ) + perror("XpuWaitForPrintFileChild: waitpid failure"); + + /* read the status from the child */ + if( read(mpfd->pipe[0], &status, sizeof(XPGetDocStatus)) != sizeof(XPGetDocStatus) ) + { + perror("XpuWaitForPrintFileChild: can't read XPGetDocStatus"); + } + close(mpfd->pipe[0]); + + free(handle); + + XPU_DEBUG_ONLY(PrintXPGetDocStatus(status)); + return(status); +} +#endif /* XPU_USE_THREADS */ + + +static +void MyPrintToFileProc( Display *pdpy, + XPContext pcontext, + unsigned char *data, + unsigned int data_len, + XPointer client_data ) +{ + MyPrintFileData *mpfd = (MyPrintFileData *)client_data; + + /* write to the file */ + XPU_TRACE_CHILD((void)fwrite(data, data_len, 1, mpfd->file)); /* what about error handling ? */ +} + + +static +void MyFinishProc( Display *pdpy, + XPContext pcontext, + XPGetDocStatus status, + XPointer client_data ) +{ + MyPrintFileData *mpfd = (MyPrintFileData *)client_data; + + /* remove the file if unsuccessful */ + if( status != XPGetDocFinished ) + { + XPU_DEBUG_ONLY(printf("MyFinishProc: error %d\n", (int)status)); + XPU_TRACE_CHILD(remove(mpfd->file_name)); + } + + XPU_TRACE_CHILD((void)fclose(mpfd->file)); /* what about error handling ? */ + + mpfd->status = status; + mpfd->done = True; +} + + +static +#ifdef XPU_USE_NSPR +void PrintToFile_Consumer( void *handle ) +#else +void *PrintToFile_Consumer( void *handle ) +#endif +{ + MyPrintFileData *mpfd = (MyPrintFileData *)handle; + XEvent dummy; + struct timeval timeout; + + timeout.tv_sec = 0; + timeout.tv_usec = 100000; /* 1/10 s */ + + XPU_DEBUG_ONLY(printf("### child running, getting data from '%s'.\n", mpfd->displayname)); + + /* we cannot reuse fork()'ed display handles - our child needs his own one */ + if( (mpfd->pdpy = XPU_TRACE_CHILD(XOpenDisplay(mpfd->displayname))) == NULL ) + { + perror("child cannot open display"); +#ifdef XPU_USE_NSPR + return; +#else + return(NULL); +#endif + } + + mpfd->done = False; + + /* register "consumer" callbacks */ + if( XPU_TRACE_CHILD(XpGetDocumentData(mpfd->pdpy, mpfd->pcontext, + MyPrintToFileProc, MyFinishProc, + (XPointer)mpfd)) == 0 ) + { + XPU_DEBUG_ONLY(printf("XpGetDocumentData cannot register callbacks\n")); +#ifdef XPU_USE_NSPR + return; +#else + return(NULL); +#endif + } + + /* loop forever - libXp has registered hidden event callbacks for the consumer + * callbacks - the finishCB will call set the "done" boolean after all... + */ + while( mpfd->done != True ) + { + XNextEventTimeout(mpfd->pdpy, &dummy, &timeout); + } + + XCloseDisplay(mpfd->pdpy); + +#ifdef XPU_USE_THREADS +#ifdef XPU_USE_NSPR + return; +#else + return(NULL); +#endif +#else + /* write the status to the parent */ + if( XPU_TRACE_CHILD(write(mpfd->pipe[1], &mpfd->status, sizeof(XPGetDocStatus))) != sizeof(XPGetDocStatus) ) + { + perror("PrintToFile_Consumer: can't write XPGetDocStatus"); + } + + /* we don't do any free's or close's, as we are just + * going to exit, in fact, get out without calling any C++ + * destructors, etc., as we don't want anything funny to happen + * to the parent + */ + XPU_TRACE_CHILD(_exit(EXIT_SUCCESS)); +#endif /* XPU_USE_THREADS */ +} + +/* EOF. */ Index: xc/lib/dpstk/Imakefile =================================================================== RCS file: /cvs/xorg/xc/lib/dpstk/Imakefile,v retrieving revision 1.1.4.1 diff -u -r1.1.4.1 Imakefile --- a/xc/lib/dpstk/Imakefile 5 Mar 2004 13:39:31 -0000 1.1.4.1 +++ b/xc/lib/dpstk/Imakefile 21 Apr 2004 09:35:00 -0000 @@ -16,6 +16,8 @@ PSWRAP = PsWrap #if HasMotif +INCLUDES = -I/usr/X11R6/include + MOTIFSRCS = FSBwraps.c FontSample.c FontSB.c FontCreato.c \ CSBwraps.c ColorSB.c DSWwraps.c DPSScrollW.c MOTIFOBJS = FSBwraps.o FontSample.o FontSB.o FontCreato.o \ Index: xc/lib/font/FreeType/ftfuncs.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/FreeType/ftfuncs.c,v retrieving revision 1.1.4.6 diff -u -r1.1.4.6 ftfuncs.c --- a/xc/lib/font/FreeType/ftfuncs.c 15 Apr 2004 10:15:07 -0000 1.1.4.6 +++ b/xc/lib/font/FreeType/ftfuncs.c 21 Apr 2004 09:35:01 -0000 @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XdotOrg: xc/lib/font/FreeType/ftfuncs.c,v 1.1.4.6 2004/04/15 10:15:07 eich Exp $ */ +/* $XdotOrg: xc/lib/font/FreeType/ftfuncs.c,v 1.1.4.4.2.2.6.3 2004/04/13 03:16:31 gisburn Exp $ */ /* $XFree86: xc/lib/font/FreeType/ftfuncs.c,v 1.43 2004/02/07 04:37:18 dawes Exp $ */ @@ -122,7 +122,7 @@ static int ftypeInitP = 0; /* is the engine initialised? */ -static FT_Library ftypeLibrary; +FT_Library ftypeLibrary; static FTFacePtr faceTable[NUMFACEBUCKETS]; Index: xc/lib/font/bitmap/pcfread.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/bitmap/pcfread.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 pcfread.c --- a/xc/lib/font/bitmap/pcfread.c 5 Mar 2004 13:39:37 -0000 1.1.4.3 +++ b/xc/lib/font/bitmap/pcfread.c 21 Apr 2004 09:35:02 -0000 @@ -908,7 +908,6 @@ if (IS_EOF(file)) goto Bail; if (encodingOffset == 0xFFFF) { pFont->info.allExist = FALSE; - encoding[i] = 0; } else { if(!encoding[SEGMENT_MAJOR(i)]) { encoding[SEGMENT_MAJOR(i)]= Index: xc/lib/font/util/Imakefile =================================================================== RCS file: /cvs/xorg/xc/lib/font/util/Imakefile,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Imakefile --- a/xc/lib/font/util/Imakefile 5 Mar 2004 13:39:42 -0000 1.1.4.2 +++ b/xc/lib/font/util/Imakefile 21 Apr 2004 09:35:02 -0000 @@ -19,7 +19,16 @@ it doesn't break anything. */ SYS_DEFINES = -D__XPG4_CHAR_CLASS__ #endif - DEFINES = StrcasecmpDefines $(SYS_DEFINES) +/* See xc/lib/font/FreeType/Imakefile - if we build the internal version of + * FreeType we should not implement functions already defined by it + * (see http://pdx.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=513) + */ +#if !HasFreetype2 && !SharedLibFreetype2 +INTERNALDEFINES = -DUSE_INTERNAL_FREETYPE +#endif + + + DEFINES = StrcasecmpDefines $(SYS_DEFINES) $(INTERNALDEFINES) SRCS = utilbitmap.c fontnames.c fontutil.c fontxlfd.c format.c \ fontaccel.c atom.c miscutil.c private.c patcache.c Index: xc/lib/font/util/utilbitmap.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/util/utilbitmap.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 utilbitmap.c --- a/xc/lib/font/util/utilbitmap.c 5 Mar 2004 13:39:42 -0000 1.1.4.2 +++ b/xc/lib/font/util/utilbitmap.c 21 Apr 2004 09:35:02 -0000 @@ -27,6 +27,8 @@ */ /* $XFree86: xc/lib/font/util/utilbitmap.c,v 1.4 2001/01/17 19:43:34 dawes Exp $ */ +#ifndef USE_INTERNAL_FREETYPE + /* * Author: Keith Packard, MIT X Consortium */ @@ -181,3 +183,6 @@ } return dstWidthBytes * height; } + +#endif /* !USE_INTERNAL_FREETYPE */ + Index: xc/programs/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Imakefile,v retrieving revision 1.1.4.4 diff -u -r1.1.4.4 Imakefile --- a/xc/programs/Imakefile 15 Apr 2004 10:15:12 -0000 1.1.4.4 +++ b/xc/programs/Imakefile 21 Apr 2004 09:35:02 -0000 @@ -38,6 +38,9 @@ #if BuildLBX LBXPROXYSRCDIR = lbxproxy #endif +#if BuildXprint + XPSRCDIRS = xplsprinters xphelloworld +#endif PROXYMGRSRCDIR = proxymngr RSTARTSRCDIR = rstart SMPROXYSRCDIR = smproxy @@ -131,7 +134,7 @@ xsetroot $(XSMSRCDIR) xstdcmap $(XINPUTCLIENTDIRS) \ $(XTERMSRCDIR) $(XTRAPCLIENTDIRS) $(XVIDTUNESRCDIR) xwd xwininfo xwud \ $(XPMCLIENTDIRS) $(XVINFOSRCDIR) \ - $(XSSRCDIR) $(XASSRCDIR) $(LBXPROXYSRCDIR) $(SCRIPTSDIR) \ + $(XSSRCDIR) $(XASSRCDIR) $(LBXPROXYSRCDIR) $(XPSRCDIRS) $(SCRIPTSDIR) \ $(GLXCLIENTDIRS) $(XRANDRDIR) $(XCURSORGENDIR) #endif Index: xc/programs/Xserver/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Imakefile,v retrieving revision 1.1.4.8 diff -u -r1.1.4.8 Imakefile --- a/xc/programs/Xserver/Imakefile 15 Apr 2004 10:15:12 -0000 1.1.4.8 +++ b/xc/programs/Xserver/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -1,4 +1,4 @@ -XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.1.4.8 2004/04/15 10:15:12 eich Exp $ +XCOMM $XdotOrg: xc/programs/Xserver/Imakefile,v 1.1.4.4.2.2.6.3 2004/04/13 03:16:34 gisburn Exp $ XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:42:02 pookie Exp $ /* * Server Master Makefile @@ -124,6 +124,8 @@ #if BuildXprint +XPCONFIGDIR = XpConfig + #ifndef XpRasterDDX #define XpRasterDDX YES #endif @@ -184,7 +186,7 @@ #endif EXTDIRS = Xext $(XKBDIR) $(XIDIR) $(GLXDIR) \ $(LBXDIRS) $(DBEDIR) $(RECORDDIR) $(SITEEXTDIRS) \ - $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) + $(RANDRDIR) $(RENDERDIR) $(XTRAPDIR) $(XPCONFIGDIR) #if BuildLBX || GzipFontCompression ZLIB = GzipLibrary #endif Index: xc/programs/Xserver/XpConfig/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/Imakefile diff -N xc/programs/Xserver/XpConfig/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,691 @@ +XCOMM $Xorg: Imakefile,v 1.3 2003/12/12 03:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = \ + C \ + en_US + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) + +InstallNonExecFile(README,$(XPRINTDIR)/) + +## Locale mappings +## Notes: +## - only ASCII chars are allowed +## - "C" and "en_US" should not be used, they are real directories + +# List of locales which should be linked to the "C" locale +C_LOCALES= \ + POSIX \ + af_ZA \ + af_ZA.iso88591 \ + ar \ + ar_AE \ + ar_AE.iso88596 \ + ar_AE.utf8 \ + ar_BH \ + ar_BH.iso88596 \ + ar_BH.utf8 \ + ar_DZ \ + ar_DZ.iso88596 \ + ar_DZ.utf8 \ + ar_EG \ + ar_EG.ISO8859-6 \ + ar_EG.UTF-8 \ + ar_EG.iso88596 \ + ar_EG.utf8 \ + ar_IN.utf8 \ + ar_IQ \ + ar_IQ.iso88596 \ + ar_IQ.utf8 \ + ar_JO \ + ar_JO.iso88596 \ + ar_JO.utf8 \ + ar_KW \ + ar_KW.iso88596 \ + ar_KW.utf8 \ + ar_LB \ + ar_LB.iso88596 \ + ar_LB.utf8 \ + ar_LY \ + ar_LY.iso88596 \ + ar_LY.utf8 \ + ar_MA \ + ar_MA.iso88596 \ + ar_MA.utf8 \ + ar_OM \ + ar_OM.iso88596 \ + ar_OM.utf8 \ + ar_QA \ + ar_QA.iso88596 \ + ar_QA.utf8 \ + ar_SA \ + ar_SA.iso88596 \ + ar_SA.utf8 \ + ar_SD \ + ar_SD.iso88596 \ + ar_SD.utf8 \ + ar_SY \ + ar_SY.iso88596 \ + ar_SY.utf8 \ + ar_TN \ + ar_TN.iso88596 \ + ar_TN.utf8 \ + ar_YE \ + ar_YE.iso88596 \ + ar_YE.utf8 \ + be_BY \ + be_BY.cp1251 \ + be_BY.utf8 \ + bg_BG \ + bg_BG.ISO8859-5 \ + bg_BG.cp1251 \ + bg_BG.utf8 \ + br_FR \ + br_FR.iso88591 \ + bs_BA \ + bs_BA.iso88592 \ + bokmal \ + ca \ + ca.ISO8859-1 \ + ca.ISO8859-15 \ + ca_ES \ + ca_ES.ISO8859-1 \ + ca_ES.ISO8859-15 \ + ca_ES.iso88591 \ + ca_ES.iso885915@euro \ + ca_ES.utf8 \ + ca_ES@euro \ + catalan \ + croatian \ + cs_CZ \ + cs_CZ.ISO8859-2 \ + cs_CZ.iso88592 \ + cs_CZ.utf8 \ + cy_GB \ + cy_GB.iso885914 \ + cz \ + cz.ISO8859-2 \ + czech \ + da \ + da.ISO8859-1 \ + da.ISO8859-15 \ + danish \ + dansk \ + da_DK \ + da_DK.ISO8859-1 \ + da_DK.ISO8859-15 \ + da_DK.iso88591 \ + da_DK.iso885915 \ + da_DK.utf8 \ + de \ + de.ISO8859-1 \ + de.ISO8859-15 \ + de.UTF-8 \ + deutsch \ + de_AT \ + de_AT.ISO8859-1 \ + de_AT.ISO8859-15 \ + de_AT.iso88591 \ + de_AT.iso885915@euro \ + de_AT.utf8 \ + de_AT@euro \ + de_BE \ + de_BE.iso88591 \ + de_BE.iso885915@euro \ + de_BE@euro \ + de_CH \ + de_CH.ISO8859-1 \ + de_CH.iso88591 \ + de_CH.utf8 \ + de_DE \ + de_DE.ISO8859-1 \ + de_DE.ISO8859-15 \ + de_DE.UTF-8 \ + de_DE.iso88591 \ + de_DE.iso885915@euro \ + de_DE.utf8 \ + de_DE@euro \ + de_LU \ + de_LU.iso88591 \ + de_LU.iso885915@euro \ + de_LU.utf8 \ + de_LU@euro \ + el_GR \ + el_GR.ISO8859-7 \ + el_GR.ISO8859-7@euro \ + el_GR.iso88597 \ + el_GR.utf8 \ + en_AU \ + en_AU.ISO8859-1 \ + en_AU.iso88591 \ + en_AU.utf8 \ + en_BW \ + en_BW.iso88591 \ + en_DK \ + en_DK.iso88591 \ + en_GB \ + en_GB.ISO8859-1 \ + en_GB.ISO8859-15 \ + en_GB.iso88591 \ + en_GB.iso885915 \ + en_GB.utf8 \ + en_HK \ + en_HK.iso88591 \ + en_IE \ + en_IE.ISO8859-1 \ + en_IE.ISO8859-15 \ + en_IE.iso88591 \ + en_IE.iso885915@euro \ + en_IE.utf8 \ + en_IE@euro \ + en_IN \ + en_IN.utf8 \ + en_NZ \ + en_NZ.ISO8859-1 \ + en_NZ.iso88591 \ + en_NZ.utf8 \ + en_PH \ + en_PH.iso88591 \ + en_SG \ + en_SG.iso88591 \ + en_ZA \ + en_ZA.iso88591 \ + en_ZA.utf8 \ + en_ZW \ + en_ZW.iso88591 \ + es_AR \ + es_AR.ISO8859-1 \ + es_AR.iso88591 \ + es_AR.utf8 \ + es_BO \ + es_BO.ISO8859-1 \ + es_BO.iso88591 \ + es_BO.utf8 \ + es_CL \ + es_CL.ISO8859-1 \ + es_CL.iso88591 \ + es_CL.utf8 \ + es_CO \ + es_CO.ISO8859-1 \ + es_CO.iso88591 \ + es_CO.utf8 \ + es_CR \ + es_CR.ISO8859-1 \ + es_CR.iso88591 \ + es_CR.utf8 \ + es_DO \ + es_DO.iso88591 \ + es_DO.utf8 \ + es_EC \ + es_EC.ISO8859-1 \ + es_EC.iso88591 \ + es_EC.utf8 \ + es_ES \ + es_ES.ISO8859-1 \ + es_ES.ISO8859-15 \ + es_ES.UTF-8 \ + es_ES.iso88591 \ + es_ES.iso885915@euro \ + es_ES.utf8 \ + es_ES@euro \ + es_GT \ + es_GT.ISO8859-1 \ + es_GT.iso88591 \ + es_GT.utf8 \ + es_HN \ + es_HN.iso88591 \ + es_HN.utf8 \ + es_MX \ + es_MX.ISO8859-1 \ + es_MX.iso88591 \ + es_MX.utf8 \ + es_NI \ + es_NI.ISO8859-1 \ + es_NI.iso88591 \ + es_NI.utf8 \ + es_PA \ + es_PA.ISO8859-1 \ + es_PA.iso88591 \ + es_PA.utf8 \ + es_PE \ + es_PE.ISO8859-1 \ + es_PE.iso88591 \ + es_PE.utf8 \ + es_PY \ + es_PY.ISO8859-1 \ + es_PY.iso88591 \ + es_PY.utf8 \ + es_SV \ + es_SV.ISO8859-1 \ + es_SV.iso88591 \ + es_SV.utf8 \ + es_UY \ + es_UY.ISO8859-1 \ + es_UY.iso88591 \ + es_UY.utf8 \ + es_VE \ + es_VE.ISO8859-1 \ + es_VE.iso88591 \ + es_VE.utf8 \ + et_EE \ + et_EE.ISO8859-15 \ + et_EE.iso88591 \ + et_EE.utf8 \ + eu_ES \ + eu_ES.iso88591 \ + eu_ES.iso885915@euro \ + eu_ES@euro \ + fa_IR.utf8 \ + fi_FI \ + fi_FI.ISO8859-1 \ + fi_FI.ISO8859-15 \ + fi_FI.UTF-8 \ + fi_FI.iso88591 \ + fi_FI.iso885915@euro \ + fi_FI.utf8 \ + fi_FI@euro \ + fo_FO \ + fo_FO.iso88591 \ + fo_FO.utf8 \ + fr_BE \ + fr_BE.ISO8859-1 \ + fr_BE.ISO8859-15 \ + fr_BE.UTF-8 \ + fr_BE.iso88591 \ + fr_BE.iso885915@euro \ + fr_BE.utf8 \ + fr_BE@euro \ + fr_CH \ + fr_CH.ISO8859-1 \ + fr_CH.iso88591 \ + fr_CH.utf8 \ + fr_FR \ + fr_FR.ISO8859-1 \ + fr_FR.ISO8859-15 \ + fr_FR.UTF-8 \ + fr_FR.iso88591 \ + fr_FR.iso885915@euro \ + fr_FR.utf8 \ + fr_FR@euro \ + fr_LU \ + fr_LU.iso88591 \ + fr_LU.iso885915@euro \ + fr_LU.utf8 \ + fr_LU@euro \ + ga_IE \ + ga_IE.iso88591 \ + ga_IE.iso885915@euro \ + ga_IE.utf8 \ + ga_IE@euro \ + gl_ES \ + gl_ES.iso88591 \ + gl_ES.iso885915@euro \ + gl_ES.utf8 \ + gl_ES@euro \ + gv_GB \ + gv_GB.iso88591 \ + hebrew \ + he \ + he_IL \ + he_IL.ISO8859-8 \ + he_IL.UTF-8 \ + he_IL.iso88598 \ + he_IL.utf8 \ + hi_IN.UTF-8 \ + hi_IN.utf8 \ + hr_HR \ + hr_HR.ISO8859-2 \ + hr_HR.iso88592 \ + hr_HR.utf8 \ + hu_HU \ + hu_HU.ISO8859-2 \ + hu_HU.iso88592 \ + hu_HU.utf8 \ + id_ID \ + id_ID.iso88591 \ + id_ID.utf8 \ + is_IS \ + is_IS.ISO8859-1 \ + is_IS.iso88591 \ + is_IS.utf8 \ + it \ + it.ISO8859-1 \ + it.ISO8859-15 \ + it.UTF-8 \ + italian \ + it_CH \ + it_CH.iso88591 \ + it_CH.utf8 \ + it_IT \ + it_IT.ISO8859-1 \ + it_IT.ISO8859-15 \ + it_IT.UTF-8 \ + it_IT.iso88591 \ + it_IT.iso885915@euro \ + it_IT.utf8 \ + it_IT@euro \ + iw_IL \ + iw_IL.iso88598 \ + ja \ + japan \ + japanese \ + japanese.euc \ + japanese.sjis \ + ja_JP \ + ja_JP.EUC \ + ja_JP.PCK \ + ja_JP.UTF-8 \ + ja_JP.eucJP \ + ja_JP.eucjp \ + ja_JP.sjis \ + ja_JP.ujis \ + ja_JP.utf8 \ + ka_GE \ + ka_GE.georgianps \ + kl_GL \ + kl_GL.iso88591 \ + kl_GL.utf8 \ + ko \ + ko.UTF-8 \ + korean \ + korean.euc \ + ko_KR \ + ko_KR.EUC \ + ko_KR.EUC@dict \ + ko_KR.UTF-8 \ + ko_KR.UTF-8@dict \ + ko_KR.euckr \ + ko_KR.utf8 \ + kw_GB \ + kw_GB.iso88591 \ + lt_LT \ + lt_LT.ISO8859-13 \ + lt_LT.iso885913 \ + lt_LT.utf8 \ + lithuanian \ + lt \ + lt.ISO8859-13 \ + lv \ + lv.ISO8859-13 \ + lv_LV \ + lv_LV.ISO8859-13 \ + lv_LV.iso885913 \ + lv_LV.utf8 \ + mi_NZ \ + mi_NZ.iso885913 \ + mk_MK \ + mk_MK.ISO8859-5 \ + mk_MK.iso88595 \ + mk_MK.utf8 \ + mr_IN.utf8 \ + ms_MY \ + ms_MY.iso88591 \ + mt_MT \ + mt_MT.iso88593 \ + nb_NO \ + nb_NO.ISO-8859-1 \ + nl \ + nl.ISO8859-1 \ + nl.ISO8859-15 \ + nl_BE \ + nl_BE.ISO8859-1 \ + nl_BE.ISO8859-15 \ + nl_BE.iso88591 \ + nl_BE.iso885915@euro \ + nl_BE.utf8 \ + nl_BE@euro \ + nl_NL \ + nl_NL.ISO8859-1 \ + nl_NL.ISO8859-15 \ + nl_NL.iso88591 \ + nl_NL.iso885915@euro \ + nl_NL.utf8 \ + nl_NL@euro \ + nn_NO \ + nn_NO.iso88591 \ + no \ + no.ISO8859-1 \ + no_NO \ + no_NO.ISO8859-1@bokmal \ + no_NO.ISO8859-1@nynorsk \ + no_NO.iso88591 \ + no_NO.utf8 \ + norwegian \ + oc_FR \ + oc_FR.iso88591 \ + polish \ + pl_PL \ + pl_PL.ISO8859-2 \ + pl_PL.UTF-8 \ + pl_PL.iso88592 \ + pl_PL.utf8 \ + portuguese \ + pt \ + pt.ISO8859-1 \ + pt.ISO8859-15 \ + pt_BR \ + pt_BR.ISO8859-1 \ + pt_BR.UTF-8 \ + pt_BR.iso88591 \ + pt_BR.utf8 \ + pt_PT \ + pt_PT.ISO8859-1 \ + pt_PT.ISO8859-15 \ + pt_PT.iso88591 \ + pt_PT.iso885915@euro \ + pt_PT.utf8 \ + pt_PT@euro \ + ro_RO \ + ro_RO.ISO8859-2 \ + ro_RO.iso88592 \ + ro_RO.utf8 \ + ru \ + ru.ISO8859-5 \ + ru.UTF-8 \ + ru.ansi1251 \ + ru.koi8-r \ + ru_SU \ + russian \ + ru_RU \ + ru_RU.ANSI1251 \ + ru_RU.ISO8859-5 \ + ru_RU.KOI8-R \ + ru_RU.UTF-8 \ + ru_RU.iso88595 \ + ru_RU.koi8r \ + ru_RU.utf8 \ + ru_UA \ + ru_UA.koi8u \ + romanian \ + se_NO \ + se_NO.utf8 \ + sk \ + sk.ISO8859-2 \ + slovak \ + slovene \ + slovenian \ + spanish \ + sk_SK \ + sk_SK.ISO8859-2 \ + sk_SK.iso88592 \ + sk_SK.utf8 \ + sh \ + sh.ISO8859-2 \ + sh_BA.ISO8859-2@bosnia \ + sh_YU \ + sh_YU.iso88592 \ + sh_YU.utf8 \ + sl_SI \ + sl_SI.ISO8859-2 \ + sl_SI.iso88592 \ + sl_SI.utf8 \ + su \ + su.ISO8859-1 \ + sq_AL \ + sq_AL.ISO8859-2 \ + sq_AL.iso88591 \ + sq_AL.utf8 \ + sr_SP \ + sr_SP.ISO8859-5 \ + sr_YU \ + sr_YU.ISO8859-5 \ + sr_YU.iso88592 \ + sr_YU.iso88595@cyrillic \ + sr_YU.utf8 \ + sr_YU@cyrillic \ + sv \ + sv.ISO8859-1 \ + sv.ISO8859-15 \ + sv.UTF-8 \ + sv_FI \ + sv_FI.iso88591 \ + sv_FI.iso885915@euro \ + sv_FI.utf8 \ + sv_FI@euro \ + sv_SE \ + sv_SE.ISO8859-1 \ + sv_SE.ISO8859-15 \ + sv_SE.UTF-8 \ + sv_SE.iso88591 \ + sv_SE.iso885915 \ + sv_SE.utf8 \ + swedish \ + ta_IN \ + ta_IN.utf8 \ + te_IN \ + te_IN.utf8 \ + tg_TJ \ + tg_TJ.koi8t \ + th \ + thai \ + th_TH \ + th_TH.ISO8859-11 \ + th_TH.TIS620 \ + th_TH.UTF-8 \ + th_TH.tis620 \ + th_TH.utf8 \ + tl_PH \ + tl_PH.iso88591 \ + tr \ + tr.ISO8859-9 \ + turkish \ + tr_TR \ + tr_TR.ISO8859-9 \ + tr_TR.UTF-8 \ + tr_TR.iso88599 \ + tr_TR.utf8 \ + uk_UA \ + uk_UA.koi8u \ + uk_UA.utf8 \ + ur_PK \ + ur_PK.utf8 \ + uz_UZ \ + uz_UZ.iso88591 \ + vi_VN \ + vi_VN.tcvn \ + vi_VN.utf8 \ + wa_BE \ + wa_BE.iso88591 \ + wa_BE.iso885915@euro \ + wa_BE@euro \ + zh \ + zh.GBK \ + zh.UTF-8 \ + zh_CN \ + zh_CN.EUC \ + zh_CN.EUC@pinyin \ + zh_CN.EUC@radical \ + zh_CN.EUC@stroke \ + zh_CN.GB18030 \ + zh_CN.GB18030@pinyin \ + zh_CN.GB18030@radical \ + zh_CN.GB18030@stroke \ + zh_CN.GBK \ + zh_CN.GBK@pinyin \ + zh_CN.GBK@radical \ + zh_CN.GBK@stroke \ + zh_CN.UTF-8 \ + zh_CN.UTF-8@pinyin \ + zh_CN.UTF-8@radical \ + zh_CN.UTF-8@stroke \ + zh_CN.gb18030 \ + zh_CN.gb2312 \ + zh_CN.gbk \ + zh_CN.utf8 \ + zh_HK \ + zh_HK.BIG5HK \ + zh_HK.BIG5HK@radical \ + zh_HK.BIG5HK@stroke \ + zh_HK.UTF-8 \ + zh_HK.UTF-8@radical \ + zh_HK.UTF-8@stroke \ + zh_HK.big5hkscs \ + zh_HK.utf8 \ + zh_TW \ + zh_TW.BIG5 \ + zh_TW.BIG5@pinyin \ + zh_TW.BIG5@radical \ + zh_TW.BIG5@stroke \ + zh_TW.BIG5@zhuyin \ + zh_TW.EUC \ + zh_TW.EUC@pinyin \ + zh_TW.EUC@radical \ + zh_TW.EUC@stroke \ + zh_TW.EUC@zhuyin \ + zh_TW.UTF-8 \ + zh_TW.UTF-8@pinyin \ + zh_TW.UTF-8@radical \ + zh_TW.UTF-8@stroke \ + zh_TW.UTF-8@zhuyin \ + zh_TW.big5 \ + zh_TW.euctw \ + zh_TW.utf8 + + +# List of locales which should be linked to the "en_US" locale, +# e.g. these locales should get the defaults (for example that +# US-Letter is used as default papersize) mainly used in the USA +US_LOCALES= \ + en_CA \ + en_CA.ISO8859-1 \ + en_CA.iso88591 \ + en_CA.utf8 \ + en_US.ISO8859-1 \ + en_US.ISO8859-15 \ + en_US.UTF-8 \ + en_US.iso88591 \ + en_US.iso885915 \ + en_US.utf8 \ + es_PR \ + es_PR.iso88591 \ + es_PR.utf8 \ + es_US \ + es_US.iso88591 \ + fr_CA \ + fr_CA.ISO8859-1 \ + fr_CA.iso88591 \ + fr_CA.utf8 \ + yi_US \ + yi_US.cp1255 + +install:: + ( \ + cd $(DESTDIR)$(XPRINTDIR) ; \ + for i in $(C_LOCALES) \ + ; do \ + $(RM) $$i ; \ + $(LN) C $$i ; \ + done \ + ) ; \ + ( \ + cd $(DESTDIR)$(XPRINTDIR) ; \ + for i in $(US_LOCALES) \ + ; do \ + $(RM) $$i ; \ + $(LN) en_US $$i ; \ + done \ + ) + Index: xc/programs/Xserver/XpConfig/C/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/Imakefile diff -N xc/programs/Xserver/XpConfig/C/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,8 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = print + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,23 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/11/20 04:22:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = attributes ddx-config models + +#if HasGhostScript +all:: Xprinters.ghostscript + +# Enable the "xp_pdf_spooldir_tmp_Xprintjobs" printer if we have GS +Xprinters.ghostscript: Xprinters + sed Xprinters.ghostscript + +clean:: + $(RM) Xprinters.ghostscript + +InstallNamedNonExec(Xprinters.ghostscript,Xprinters,$(XPRINTDIR)/C/print) +#else +InstallNamedNonExec(Xprinters,Xprinters,$(XPRINTDIR)/C/print) +#endif /* HasGhostScript */ + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/Xprinters =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/Xprinters,v retrieving revision 1.1 diff -u -r1.1 Xprinters --- a/xc/programs/Xserver/XpConfig/C/print/Xprinters 14 Nov 2003 15:54:43 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/Xprinters 21 Apr 2004 09:35:03 -0000 @@ -29,6 +29,13 @@ #Augment_Printer_List %none% ######################################################################## +# Preconfigured entry for the PSspooldir model +# (which sends jobs to /tmp/Xprintjobs instead to a physical printer) +######################################################################## +#Printer xp_pdf_spooldir_tmp_Xprintjobs +Printer xp_ps_spooldir_tmp_Xprintjobs + +######################################################################## # Add individual printers to the list of printers managed by the # server. These are aliases, determined by driver name. ######################################################################## @@ -40,4 +47,3 @@ # Printer xppclpr # Printer xppclmonopr # Printer xprasterpr - Index: xc/programs/Xserver/XpConfig/C/print/attributes/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/attributes/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/attributes/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/attributes/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,8 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPATTRIBUTEDIR = $(XPRINTDIR)/C/print/attributes + +InstallNonExecFile(document,$(XPATTRIBUTEDIR)) +InstallNonExecFile(job,$(XPATTRIBUTEDIR)) +InstallNonExecFile(printer,$(XPATTRIBUTEDIR)) + Index: xc/programs/Xserver/XpConfig/C/print/attributes/document =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/attributes/document,v retrieving revision 1.1 diff -u -r1.1 document --- a/xc/programs/Xserver/XpConfig/C/print/attributes/document 14 Nov 2003 15:54:43 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/attributes/document 21 Apr 2004 09:35:03 -0000 @@ -21,9 +21,17 @@ *copy-count: 1 *default-medium: iso-a4 *default-printer-resolution: 300 -*document-format: {Postscript 2} -*plex: duplex +# "PSspooldir" jobs should always be 300 DPI +# (to be compatible to DPS-based PostScript viewers such as sdtimage) +PSspooldir.default-printer-resolution: 300 + +# "PS2PDFspooldir-GS" jobs should always be 600 DPI +PS2PDFspooldir-GS.default-printer-resolution: 600 + +# Some resolution defaults to make applications happy which are too lazy +# to pick an own default in absence of "default-printer-resolution" +HPLJ4050-PS.default-printer-resolution: 600 # EXAMPLES # Index: xc/programs/Xserver/XpConfig/C/print/attributes/printer =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/attributes/printer,v retrieving revision 1.1 diff -u -r1.1 printer --- a/xc/programs/Xserver/XpConfig/C/print/attributes/printer 14 Nov 2003 15:54:43 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/attributes/printer 21 Apr 2004 09:35:03 -0000 @@ -16,8 +16,24 @@ # Set this attribute for all printers. # Example: "*.document-formats-ready: {pcl 5}" - -*xp-ddx-identifier: XP-POSTSCRIPT +# Remove this line and replace them with per printer settings +# if you want to use more than one DDX!! +*xp-model-identifier: PSdefault + + +# Sample entry for the "PSspooldir" model +# Just add a printer called "xp_ps_spooldir_tmp_Xprintjobs" to "Xprinters" +# and you will get an extra printer which files the PostScript jobs +# in the "/tmp/Xprintjobs/" directory. +xp_ps_spooldir_tmp_Xprintjobs.xp-model-identifier: PSspooldir + +# Sample entry for the "PS2PDFspooldir-GS" model +# Just add a printer called "xp_pdf_spooldir_tmp_Xprintjobs" to "Xprinters" +# and you will get an extra printer which convertes the PostScript jobs +# to PDF using "ps2pdf" and files them into the "/tmp/Xprintjobs/" directory. +# NOTE: Future versions of Xprint will use the PDF DDX instead directly +# instead of relying on GhostScript/ps2pdf... +xp_pdf_spooldir_tmp_Xprintjobs.xp-model-identifier: PS2PDFspooldir-GS # IMPORTANT EXAMPLES Index: xc/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,8 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = raster + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,6 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPDDXCONFIGRASTERDIR = $(XPRINTDIR)/C/print/ddx-config/raster + +InstallNonExecFile(pcl,$(XPDDXCONFIGRASTERDIR)) +InstallNonExecFile(postscript,$(XPDDXCONFIGRASTERDIR)) Index: xc/programs/Xserver/XpConfig/C/print/models/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,44 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +#if XpPostScriptDDX +PS_MODELDIRS = \ + PSdefault \ + SPSPARC2 \ + HPLJ4050-PS \ + PSspooldir + +#if HasGhostScript +XCOMM Models for printers which need GhostScript for post-processing +GS_MODELDIRS = \ + GSdefault \ + CANONBJ10E-GS \ + PS2PDFspooldir-GS +#endif /* HasGhostScript */ +#endif /* XpPostScriptDDX */ + +#if XpColorPclDDX +PCL_COLOR_MODELDIRS = \ + HPDJ1600C +#endif + +#if XpMonoPclDDX +PCL_MONO_MODELDIRS = \ + HPLJ4family +#endif + +#if XpRasterDDX +RASTER_MODELDIRS = +#endif + +SUBDIRS = \ + $(PS_MODELDIRS) \ + $(GS_MODELDIRS) \ + $(PCL_COLOR_MODELDIRS) \ + $(PCL_MONO_MODELDIRS) \ + $(RASTER_MODELDIRS) + + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,15 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/02/10 05:42:52 gisburn Exp $ + +XPMODELNAME = CANONBJ10E-GS + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +# All GhostScript-printer models should use the printer-builtin fonts from the +# "GSdefault" printer model (unless they employ more or other builtin fonts) +# (native PostScript printers should use the fonts from the "PSdefault" model) +install:: + $(RM) $(DESTDIR)$(MODELDIR)/fonts + $(LN) ../GSdefault/fonts $(DESTDIR)$(MODELDIR) + Index: xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,23 @@ +# $Xprint.org: CANONBJ10E-GS model-config,v 1.4 2003/02/10 14:48:04 gisburn Exp $ + +*content-orientations-supported: portrait landscape +*descriptor: Canon BJ-10e (GhostScript) +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ +} + +*plexes-supported: simplex +*printer-model: "Canon BJ-10e (GhostScript)" +*printer-resolutions-supported: 360 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,14 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPMODELNAME = GSdefault + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +# All PostScript-printer models should use the printer-builtin fonts from the +# "PSdefault" printer model (unless they employ more or other builtin fonts) +install:: + $(RM) $(DESTDIR)$(MODELDIR)/fonts + $(LN) ../PSdefault/fonts $(DESTDIR)$(MODELDIR) + Index: xc/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,137 @@ +# $Xprint.org: GSdefault model-config,v 1.1 2003/02/10 14:48:04 gisburn Exp $ +# Generic default model-config for the PostScript DDX when using GhostScript +# as printer driver +# +# DO NOT MODIFY THIS FILE!! +# +# If you want to make customisations for your printer create a copy +# of this printer model. +# Example (for creating a model config "MYCOMPANYlaserxx"): +# 1. Create model config dir: +# % mkdir MYCOMPANYlaserxx +# 2. Link (or copy) the PMF (printer font metrics) for the +# printer buildin fonts: +# % ln -s GSdefault/fonts MYCOMPANYlaserxx/. +# 3. Copy the model config file: +# % cp GSdefault/model-config MYCOMPANYlaserxx/. +# 4. Customize MYCOMPANYlaserxx/model-config to match your needs. +# + +# Attributes supported for this printer model +# You may want to cut the lists here down to the attributes supported +# by your printer. +*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape +*descriptor: GhostScript default model +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ + {executive FALSE {6.35 177.80 6.35 260.35}}\ + {folio FALSE {6.35 204.47 6.35 323.85}}\ + {invoice FALSE {6.35 133.35 6.35 209.55}}\ + {ledger FALSE {6.35 273.05 6.35 425.45}}\ + {quarto FALSE {6.35 209.55 6.35 268.732}}\ + {a FALSE {6.35 209.55 6.35 273.05}}\ + {b FALSE {6.35 273.05 6.35 425.45}}\ + {c FALSE {6.35 425.45 6.35 552.45}}\ + {d FALSE {6.35 552.45 6.35 857.25}}\ + {e FALSE {6.35 857.25 6.35 1111.25}}\ + {na-6x9-envelope FALSE {6.35 146.05 6.35 222.25}}\ + {na-10x15-envelope FALSE {6.35 247.65 6.35 374.65}}\ + {monarch-envelope FALSE {6.35 91.948 6.35 184.15}}\ + {na-10x13-envelope FALSE {6.35 247.65 6.35 323.85}}\ + {na-9x12-envelope FALSE {6.35 222.25 6.35 298.45}}\ + {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}}\ + {na-7x9-envelope FALSE {6.35 171.45 6.35 222.25}}\ + {na-9x11-envelope FALSE {6.35 222.25 6.35 273.05}}\ + {na-10x14-envelope FALSE {6.35 247.65 6.35 349.25}}\ + {na-number-9-envelope FALSE {6.35 92.075 6.35 219.075}}\ + {iso-a0 FALSE {6.35 834.65 6.35 1182.65}}\ + {iso-a1 FALSE {6.35 587.65 6.35 834.65}}\ + {iso-a2 FALSE {6.35 413.65 6.35 587.65}}\ + {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\ + {iso-a6 FALSE {6.35 98.65 6.35 141.65}}\ + {iso-a7 FALSE {6.35 67.65 6.35 98.65}}\ + {iso-a8 FALSE {6.35 45.65 6.35 67.65}}\ + {iso-a9 FALSE {6.35 30.65 6.35 45.65}}\ + {iso-a10 FALSE {6.35 19.65 6.35 30.65}}\ + {iso-b1 FALSE {6.35 700.65 6.35 993.65}}\ + {iso-b2 FALSE {6.35 493.65 6.35 700.65}}\ + {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\ + {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {iso-b6 FALSE {6.35 118.65 6.35 169.65}}\ + {iso-b7 FALSE {6.35 81.65 6.35 118.65}}\ + {iso-b8 FALSE {6.35 55.65 6.35 81.65}}\ + {iso-b9 FALSE {6.35 37.65 6.35 55.65}}\ + {iso-b10 FALSE {6.35 24.65 6.35 37.65}}\ + {jis-b1 FALSE {6.35 721.65 6.35 1023.65}}\ + {jis-b2 FALSE {6.35 508.65 6.35 721.65}}\ + {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\ + {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\ + {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\ + {jis-b6 FALSE {6.35 121.65 6.35 175.65}}\ + {jis-b7 FALSE {6.35 84.65 6.35 121.65}}\ + {jis-b8 FALSE {6.35 57.65 6.35 84.65}}\ + {jis-b9 FALSE {6.35 38.65 6.35 57.65}}\ + {jis-b10 FALSE {6.35 25.65 6.35 38.65}}\ + {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\ + {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\ + {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\ + {iso-c6 FALSE {6.35 107.65 6.35 155.65}}\ + {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\ + {hp-2x-postcard FALSE {6.35 141.65 6.35 193.65}}\ + {hp-european-edp FALSE {6.35 298.45 6.35 349.25}}\ + {hp-mini FALSE {6.35 133.35 6.35 209.55}}\ + {hp-postcard FALSE {6.35 93.65 6.35 141.65}}\ + {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\ + {hp-us-edp FALSE {6.35 273.05 6.35 349.25}}\ + {hp-us-government-legal FALSE {6.35 196.85 6.35 323.85}}\ + {hp-us-government-letter FALSE {6.35 196.85 6.35 247.65}}\ +} +# If you have more than one tray use the following example: +# 1. List the supported trays +#*input-trays-supported: main manual +# 2. Define each tray and it's paper sizes +#*medium-source-sizes-supported: \ +#{ main \ +# {na-letter FALSE {6.35 209.55 6.35 273.05}} \ +# {na-legal FALSE {6.35 209.55 6.35 349.25}} \ +# {iso-a4 FALSE {6.35 203.65 6.35 290.65}} \ +#} \ +#{ manual \ +# {iso-a5 FALSE {6.35 141.65 6.35 203.65}} \ +# {iso-c5 FALSE {6.35 155.65 6.35 222.65}} \ +# {iso-designated-long FALSE {6.35 103.65 6.35 213.65}} \ +# {jis-b5 FALSE {6.35 175.65 6.35 250.65}} \ +# {monarch-envelope FALSE {6.35 91.948 6.35 184.15}} \ +# {na-legal FALSE {6.35 209.55 6.35 349.25}} \ +# {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}} \ +# {executive FALSE {6.35 177.8 6.35 260.35}} \ +# {iso-a3 FALSE {6.35 290.65 6.35 413.65}} \ +# {iso-a0 FALSE {6.35 834.65 6.35 1182.65}} \ +#} +*plexes-supported: simplex duplex tumble +*printer-model: "GhostScript default model" +# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720, +# 940, 1200 and 2440 are supported DPI values, we limit it here +# to some common values: +*printer-resolutions-supported: 300 360 400 600 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional + +# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now. +# xp-psddx-download-fonts defines which fonts should be downloaded as outlines +# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc") +*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc +# xp-psddx-download-font-type defines which font type is used to download outlines +# (valid values are "bitmap", "pstype1" and "pstype3") +*xp-psddx-download-font-type: pstype1 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,14 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = fonts + +XPMODELNAME = HPDJ1600C + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config,v retrieving revision 1.1 diff -u -r1.1 model-config --- a/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config 14 Nov 2003 15:54:43 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config 21 Apr 2004 09:35:03 -0000 @@ -1,28 +1,16 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ +# $Xprint.org: HPDJ1600C model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ # This is the configuration file for the HP DeskJet 1600C printer. # # The CDEnext SI supports two 1600C drivers XP-PCL-MONO and # XP-PCL-COLOR, which work with this configuration file. # -# Attribute IDs must be qualified using either the printer-model -# identifier or an asterisk ('*'). For example, if "HPDJ1600C" is the -# printer-model, then to initialize the 'plexes-supported' attribute -# to 'simplex', use: "HPDJ1600C.plexes-supported: simplex". For the -# asterisk, use: "*.plexes-supported: simplex". If the same attribute -# is specified using each method, the printer-model qualified entry -# takes precedence. - -HPDJ1600C.printer-model: "Hewlett-Packard DeskJet 1600C" -HPDJ1600C.printer-resolutions-supported: 300 -HPDJ1600C.content-orientations-supported: portrait landscape -HPDJ1600C.document-formats-supported: {PCL 5} {PostScript 2} -HPDJ1600C.plexes-supported: simplex duplex -HPDJ1600C.xp-ddx-identifier: XP-PCL-COLOR -HPDJ1600C.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } -HPDJ1600C.xp-setup-proviso: setup-optional +*content-orientations-supported: portrait landscape +*descriptor: Hewlett-Packard DeskJet 1600C +*document-formats-supported: {PCL 5} {PostScript 2} +*input-trays-supported: # 1/4" unprintable margins -HPDJ1600C.medium-source-sizes-supported:\ +*medium-source-sizes-supported:\ { '' \ {na-letter FALSE {6.35 209.55 6.35 273.05}}\ {executive FALSE {6.35 177.75 6.35 260.35}}\ @@ -41,4 +29,12 @@ {hp-japanese-postcard FALSE {6 94 6 142 }}\ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\ } - +*plexes-supported: simplex duplex +*printer-model: "Hewlett-Packard DeskJet 1600C" +*printer-resolutions-supported: 300 +*xp-ddx-identifier: XP-PCL-COLOR +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } +*xp-raw-formats-supported: { PCL 5 } +*xp-setup-proviso: setup-optional +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,57 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPFONTS = \ + 9nb00051.pmf \ + 9nb00052.pmf \ + 9nb00053.pmf \ + 9nb00054.pmf \ + 9nb00055.pmf \ + 9nb00056.pmf \ + 9nb00057.pmf \ + 9nb00058.pmf \ + 9nb00059.pmf \ + 9nb00060.pmf \ + 9nb00061.pmf \ + 9nb00062.pmf \ + 9nb00063.pmf \ + 9nb00064.pmf \ + 9nb00065.pmf \ + 9nb00066.pmf \ + 9nb00067.pmf \ + 9nb00068.pmf \ + 9nb00069.pmf \ + 9nb00070.pmf \ + 9nb00071.pmf \ + 9nb00072.pmf \ + 9nb00073.pmf \ + 9nb00074.pmf \ + 9nb00075.pmf \ + 9nb00076.pmf \ + 9nb00077.pmf \ + 9nb00079.pmf \ + 9nb00080.pmf \ + 9nb00081.pmf \ + 9nb00082.pmf \ + 9nb00083.pmf \ + 9nb00084.pmf \ + 9nb00085.pmf \ + 9nb00086.pmf \ + 9nb00087.pmf \ + 9nb00088.pmf \ + 9nb00089.pmf \ + 9nb00090.pmf \ + 9nb00091.pmf \ + 9nb00092.pmf \ + 9nb00093.pmf \ + 9nb00094.pmf \ + lpr0ye1a.pmf \ + fonts.alias \ + fonts.dir \ + README + +XPMODELNAME = HPDJ1600C + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) +MODELFONTDIR = $(MODELDIR)/fonts +InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR)) + Index: xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias,v retrieving revision 1.1.4.1 diff -u -r1.1.4.1 fonts.alias --- a/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias 17 Nov 2003 19:03:43 -0000 1.1.4.1 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias 21 Apr 2004 09:35:03 -0000 @@ -1 +0,0 @@ -! So the file isn't empty Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,15 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/12/16 00:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = fonts + +XPMODELNAME = HPLJ4050-PS + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) + Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,36 @@ +# $Xprint.org: HPLJ4050-PS model-config,v 1.1 2003/12/16 00:48:04 gisburn Exp $ +# model-config for the HP LaserJet 4050 PostScript printer series +# +*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape +*descriptor: Hewlett-Packard LaserJet 4050 PostScript printer +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ + {executive FALSE {6.35 177.80 6.35 260.35}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\ +} + +# Duplex unit is optional for HPLJ4050 series +*plexes-supported: simplex +*printer-model: "Hewlett-Packard LaserJet 4050 PostScript printer" +*printer-resolutions-supported: 600 1200 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional + +# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now. +# xp-psddx-download-fonts defines which fonts should be downloaded as outlines +# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc") +*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc +# xp-psddx-download-font-type defines which font type is used to download outlines +# (valid values are "bitmap", "pstype1" and "pstype3") +*xp-psddx-download-font-type: pstype1 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,45 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/12/16 00:42:52 gisburn Exp $ + +XPFONTS = \ + AvantGarde-Book.pmf \ + AvantGarde-BookOblique.pmf \ + AvantGarde-Demi.pmf \ + AvantGarde-DemiOblique.pmf \ + Courier-Bold.pmf \ + Courier-BoldOblique.pmf \ + Courier-Oblique.pmf \ + Courier.pmf \ + Helvetica-Bold.pmf \ + Helvetica-BoldOblique.pmf \ + Helvetica-Oblique.pmf \ + Helvetica.pmf \ + LubalinGraph-Book.pmf \ + LubalinGraph-BookOblique.pmf \ + LubalinGraph-Demi.pmf \ + LubalinGraph-DemiOblique.pmf \ + NewCenturySchlbk-Bold.pmf \ + NewCenturySchlbk-BoldItalic.pmf \ + NewCenturySchlbk-Italic.pmf \ + NewCenturySchlbk-Roman.pmf \ + Souvenir-Demi.pmf \ + Souvenir-DemiItalic.pmf \ + Souvenir-Light.pmf \ + Souvenir-LightItalic.pmf \ + Symbol.pmf \ + Times-Bold.pmf \ + Times-BoldItalic.pmf \ + Times-Italic.pmf \ + Times-Roman.pmf \ + ZapfDingbats.pmf + +XPMODELNAME = HPLJ4050-PS + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) +MODELFONTDIR = $(MODELDIR)/fonts + +# We reuse some of the PSdefault fonts +PARENTMODELFONTDIR=../../PSdefault/fonts + +InstallXpMultiplePMFLinks($(XPFONTS),$(PARENTMODELFONTDIR),$(MODELFONTDIR)) +InstallXpPMFFontsDir($(MODELFONTDIR)) + Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,14 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = fonts + +XPMODELNAME = HPLJ4family + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config,v retrieving revision 1.1 diff -u -r1.1 model-config --- a/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config 14 Nov 2003 15:54:44 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config 21 Apr 2004 09:35:03 -0000 @@ -1,28 +1,15 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ +# $Xprint.org: HPLJ4family model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ # This is the configuration file for the HP LaserJet 4 Printers. # # Though not a deliverable for the CDEnext SI, the XP-PCL-MONO # driver should be able to support the LaserJet 4 printers. # -# Attribute IDs must be qualified using either the printer-model -# identifier or an asterisk ('*'). For example, if "HPLJ4family" is the -# printer-model, then to initialize the 'plexes-supported' attribute -# to 'simplex', use: "HPLJ4family.plexes-supported: simplex". For the -# asterisk, use: "*.plexes-supported: simplex". If the same attribute -# is specified using each method, the printer-model qualified entry -# takes precedence. - -HPLJ4family.printer-model: "Hewlett-Packard LaserJet 4 Series" -HPLJ4family.printer-resolutions-supported: 300 600 -HPLJ4family.content-orientations-supported: portrait landscape -HPLJ4family.document-formats-supported: {PCL 5} {PostScript 2} -HPLJ4family.plexes-supported: simplex duplex -HPLJ4family.xp-ddx-identifier: XP-PCL-MONO -HPLJ4family.xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } -HPLJ4family.xp-setup-proviso: setup-optional - +*content-orientations-supported: portrait landscape +*descriptor: Hewlett-Packard LaserJet 4 Series +*document-formats-supported: {PCL 5} {PostScript 2} +*input-trays-supported: # 1/4" unprintable margins -HPLJ4family.medium-source-sizes-supported:\ +*medium-source-sizes-supported:\ { '' \ {na-letter FALSE {6.35 209.55 6.35 273.05}}\ {executive FALSE {6.35 177.75 6.35 260.35}}\ @@ -41,4 +28,12 @@ {hp-japanese-postcard FALSE {6 94 6 142 }}\ {hp-japanese-doublepostcard FALSE {6 142 6 194 }}\ } - +*plexes-supported: simplex duplex +*printer-model: "Hewlett-Packard LaserJet 4 Series" +*printer-resolutions-supported: 300 600 +*xp-ddx-identifier: XP-PCL-MONO +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: { PCL 5 } { PostScript 2 } +*xp-raw-formats-supported: { PCL 5 } +*xp-setup-proviso: setup-optional +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,56 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPFONTS = \ + 9nb00051.pmf \ + 9nb00052.pmf \ + 9nb00053.pmf \ + 9nb00054.pmf \ + 9nb00055.pmf \ + 9nb00056.pmf \ + 9nb00057.pmf \ + 9nb00058.pmf \ + 9nb00059.pmf \ + 9nb00060.pmf \ + 9nb00061.pmf \ + 9nb00062.pmf \ + 9nb00063.pmf \ + 9nb00064.pmf \ + 9nb00065.pmf \ + 9nb00066.pmf \ + 9nb00067.pmf \ + 9nb00068.pmf \ + 9nb00069.pmf \ + 9nb00070.pmf \ + 9nb00071.pmf \ + 9nb00072.pmf \ + 9nb00073.pmf \ + 9nb00074.pmf \ + 9nb00075.pmf \ + 9nb00076.pmf \ + 9nb00077.pmf \ + 9nb00079.pmf \ + 9nb00080.pmf \ + 9nb00081.pmf \ + 9nb00082.pmf \ + 9nb00083.pmf \ + 9nb00084.pmf \ + 9nb00085.pmf \ + 9nb00086.pmf \ + 9nb00087.pmf \ + 9nb00088.pmf \ + 9nb00089.pmf \ + 9nb00090.pmf \ + 9nb00091.pmf \ + 9nb00092.pmf \ + 9nb00093.pmf \ + 9nb00094.pmf \ + fonts.alias \ + fonts.dir \ + lpr0ye1a.pmf \ + README + +XPMODELNAME = HPLJ4family + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) +MODELFONTDIR = $(MODELDIR)/fonts +InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR)) Index: xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias,v retrieving revision 1.1.4.1 diff -u -r1.1.4.1 fonts.alias --- a/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias 17 Nov 2003 19:03:43 -0000 1.1.4.1 +++ b/xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias 21 Apr 2004 09:35:03 -0000 @@ -1 +0,0 @@ -! So the file isn't empty Index: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,35 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/11/20 03:42:52 gisburn Exp $ + +XPMODELNAME = PS2PDFspooldir-GS + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +#if BuildGISWxprintglue || BuildGISWxprint +XCOMM Hack for Solaris's native /usr/openwin/bin/Xprt which does not +XCOMM understand the new %xpconfigdir% modelconfig variable +XCOMM (this is only used for the GISWxprintglue package build; +XCOMM the GISWxprint does not need it but using it avoids confusion +XCOMM if someone uses GISWxprint to run both Solaris native Xprt and +XCOMM our own binary side-by-side using the same config) +all:: model-config.SolarisXprt + +model-config.SolarisXprt: model-config + nawk model-config.SolarisXprt + +clean:: + $(RM) model-config.SolarisXprt + +InstallNamedNonExec(model-config.SolarisXprt,model-config,$(MODELDIR)) +#else +InstallNonExecFile(model-config,$(MODELDIR)) +#endif /* BuildGISWxprintglue || BuildGISWxprint */ + +InstallNamedProg(ps2pdf_spooltodir.sh,ps2pdf_spooltodir.sh,$(MODELDIR)) + +# All printer models which use GhostScript for filtering should use the +# printer-builtin fonts from the "GSdefault" printer model +# (unless they employ more or other builtin fonts) +install:: + $(RM) $(DESTDIR)$(MODELDIR)/fonts + $(LN) ../GSdefault/fonts $(DESTDIR)$(MODELDIR) + Index: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,72 @@ +# $Xprint.org: PS2PDFspooldir-GS model-config,v 1.1 2003/11/20 03:48:04 gisburn Exp $ +# PostScript DDX model-config which converts jobs to PDF via GhostScript's "ps2pdf" +# and then sends them to a spool dir instead to a print queue +# +# This model is basically a cut-down GSdefault model with a custom *xp-spooler-command +# +# DO NOT MODIFY THIS FILE!! +# +# If you want to make customisations for your printer create a copy +# of this printer model. +# Example (for creating a model config "MYCOMPANYlaserxx"): +# 1. Create model config dir: +# % mkdir MYCOMPANYlaserxx +# 2. Link (or copy) the PMF (printer font metrics) for the +# printer buildin fonts: +# % ln -s PS2PDFspooldir-GS/fonts MYCOMPANYlaserxx/. +# 3. Copy the model config file: +# % cp PS2PDFspooldir-GS/model-config MYCOMPANYlaserxx/. +# 4. Customize MYCOMPANYlaserxx/model-config to match your needs. +# +# Attributes supported for this printer model +*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape +*descriptor: PDF job spool dir /tmp/Xprintjobs +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ + {executive FALSE {6.35 177.80 6.35 260.35}}\ + {ledger FALSE {6.35 273.05 6.35 425.45}}\ + {quarto FALSE {6.35 209.55 6.35 268.732}}\ + {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\ + {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\ + {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\ + {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\ + {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\ + {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\ + {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\ + {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\ +} + +*plexes-supported: simplex duplex tumble +*printer-model: "PDF job spool dir /tmp/Xprintjobs" +# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720, +# 940, 1200 and 2440 are supported DPI values, we limit it here +# to some common values: +*printer-resolutions-supported: 300 360 400 600 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional + +# Use custom spooler script which sends the output to a dir instead to a printer queue +# Note that "%xpconfigdir%" is currently only supported in Xprt servers build +# from xprint.mozdev.org sources, other platforms have replace it with the +# absolute path name to the script +*xp-spooler-command: %xpconfigdir%/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh -d /tmp/Xprintjobs -s .pdf -u 077 -p %printer-name% -c %copy-count% -t %job-name% -o "%options%" + +# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now. +# xp-psddx-download-fonts defines which fonts should be downloaded as outlines +# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc") +*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc +# xp-psddx-download-font-type defines which font type is used to download outlines +# (valid values are "bitmap", "pstype1" and "pstype3") +*xp-psddx-download-font-type: pstype1 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh diff -N xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,130 @@ +#!/bin/sh +PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin +export PATH + +verbose_msgs="false" +DEFAULT_SPOOLDIR=/tmp/Xprintjobs + +usage() +{ + printf "Usage: ${0}: [options]\n" + printf "-v\tbe verbose\n" + printf "-d dirname\tdefine spool dir\n" + printf "-p string\tname of printer selected by user\n" + printf "-c integer\tnumber of copies\n" + printf "-t string\tjob title\n" + printf "-s string\tfile name suffix\n" + printf "-o string\tspooler options\n" + printf "-u mask\tpermission mask for new files (see umask)\n" + exit 2 +} + +verbose() +{ + if ${verbose_msgs} ; then + echo "$1" + fi +} + +spooldir="${DEFAULT_SPOOLDIR}" +printername= +num_job_copies= +job_title= +filename_suffix= +spooler_options= +permmask= +while getopts va:b:d:p:c:t:s:o:u: i +do + case $i in + v) + verbose_msgs="true" + ;; + d) + spooldir="$OPTARG" + ;; + p) + printername="$OPTARG" + ;; + c) + num_job_copies="$OPTARG" + ;; + t) + job_title="$OPTARG" + ;; + s) + filename_suffix="$OPTARG" + ;; + o) + spooler_options="$OPTARG" + ;; + u) + permmask="$OPTARG" + ;; + ?) usage + ;; + esac +done + +verbose "# spooldir=\"$spooldir\"" +verbose "# printername=\"$printername\"" +verbose "# num_job_copies=\"$num_job_copies\"" +verbose "# job_title=\"$job_title\"" +verbose "# spooler_options=\"$spooler_options\"" +verbose "# umask=\"$permmask\"" + +if [ ! -d "${DEFAULT_SPOOLDIR}" ] ; then + mkdir "${DEFAULT_SPOOLDIR}" + chmod a+rwxt "${DEFAULT_SPOOLDIR}" +fi + +if [ "${permmask}" != "" ] ; then + umask ${permmask} +fi + +if [ ! -d "$spooldir" ] ; then + echo "$0: spooldir \"$spooldir\" does not exits." >&2 + exit 1 +fi +if [ ! -w "$spooldir" ] ; then + echo "$0: Cannot write to spooldir \"$spooldir\"." >&2 + exit 1 +fi + +# Create first part of the output file name (prefix and an "unique" +# id(=date and time))... +filename="Xpjob_`date +%Y%m%d%H%M%S`" + +# ... then add options ... +if [ "${printername}" != "" ] ; then + filename="${filename}_${printername}" +fi +if [ "${num_job_copies}" != "" -a "${num_job_copies}" != "1" ] ; then + filename="${filename}_copies_${num_job_copies}" +fi +if [ "${job_title}" != "" ] ; then + filename="${filename}_title_${job_title}" +fi + +# ... mangle output file name and filter chars (like whitespaces) +# which may screw-up further processing by other shell scripts ... +filename="`echo \"${filename}\" | tr '[:blank:]' '_' | tr -c -d '[:alnum:]_.-'`" + +# ... add path and suffix ... +filename="${spooldir}/${filename}${filename_suffix}" + +verbose "# File name is \"$filename\"." + +# ... and finally capture stdin to the file (we are using "gs" directly to +# avoid the problem that "ps2pdf" is not available in all Linux +# distributions by default). +#ps2pdf - - | cat >"${filename}" +gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=-" -dCompatibilityLevel=1.2 -c .setpdfwrite -f - | cat >"${filename}" + +if ${verbose_msgs} ; then + printf "# File is " ; ls -l "${filename}" +fi + +verbose "# Done." + +exit 0 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,14 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = fonts + +XPMODELNAME = PSdefault + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config 21 Apr 2004 09:35:03 -0000 @@ -0,0 +1,136 @@ +# $Xprint.org: PSdefault model-config,v 1.2 2002/11/07 19:48:04 gisburn Exp $ +# Generic default model-config for the PostScript DDX +# +# DO NOT MODIFY THIS FILE!! +# +# If you want to make customisations for your printer create a copy +# of this printer model. +# Example (for creating a model config "MYCOMPANYlaserxx"): +# 1. Create model config dir: +# % mkdir MYCOMPANYlaserxx +# 2. Link (or copy) the PMF (printer font metrics) for the +# printer buildin fonts: +# % ln -s PSdefault/fonts MYCOMPANYlaserxx/. +# 3. Copy the model config file: +# % cp PSdefault/model-config MYCOMPANYlaserxx/. +# 4. Customize MYCOMPANYlaserxx/model-config to match your needs. +# + +# Attributes supported for this printer model +# You may want to cut the lists here down to the attributes supported +# by your printer. +*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape +*descriptor: PostScript default model +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ + {executive FALSE {6.35 177.80 6.35 260.35}}\ + {folio FALSE {6.35 204.47 6.35 323.85}}\ + {invoice FALSE {6.35 133.35 6.35 209.55}}\ + {ledger FALSE {6.35 273.05 6.35 425.45}}\ + {quarto FALSE {6.35 209.55 6.35 268.732}}\ + {a FALSE {6.35 209.55 6.35 273.05}}\ + {b FALSE {6.35 273.05 6.35 425.45}}\ + {c FALSE {6.35 425.45 6.35 552.45}}\ + {d FALSE {6.35 552.45 6.35 857.25}}\ + {e FALSE {6.35 857.25 6.35 1111.25}}\ + {na-6x9-envelope FALSE {6.35 146.05 6.35 222.25}}\ + {na-10x15-envelope FALSE {6.35 247.65 6.35 374.65}}\ + {monarch-envelope FALSE {6.35 91.948 6.35 184.15}}\ + {na-10x13-envelope FALSE {6.35 247.65 6.35 323.85}}\ + {na-9x12-envelope FALSE {6.35 222.25 6.35 298.45}}\ + {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}}\ + {na-7x9-envelope FALSE {6.35 171.45 6.35 222.25}}\ + {na-9x11-envelope FALSE {6.35 222.25 6.35 273.05}}\ + {na-10x14-envelope FALSE {6.35 247.65 6.35 349.25}}\ + {na-number-9-envelope FALSE {6.35 92.075 6.35 219.075}}\ + {iso-a0 FALSE {6.35 834.65 6.35 1182.65}}\ + {iso-a1 FALSE {6.35 587.65 6.35 834.65}}\ + {iso-a2 FALSE {6.35 413.65 6.35 587.65}}\ + {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\ + {iso-a6 FALSE {6.35 98.65 6.35 141.65}}\ + {iso-a7 FALSE {6.35 67.65 6.35 98.65}}\ + {iso-a8 FALSE {6.35 45.65 6.35 67.65}}\ + {iso-a9 FALSE {6.35 30.65 6.35 45.65}}\ + {iso-a10 FALSE {6.35 19.65 6.35 30.65}}\ + {iso-b1 FALSE {6.35 700.65 6.35 993.65}}\ + {iso-b2 FALSE {6.35 493.65 6.35 700.65}}\ + {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\ + {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {iso-b6 FALSE {6.35 118.65 6.35 169.65}}\ + {iso-b7 FALSE {6.35 81.65 6.35 118.65}}\ + {iso-b8 FALSE {6.35 55.65 6.35 81.65}}\ + {iso-b9 FALSE {6.35 37.65 6.35 55.65}}\ + {iso-b10 FALSE {6.35 24.65 6.35 37.65}}\ + {jis-b1 FALSE {6.35 721.65 6.35 1023.65}}\ + {jis-b2 FALSE {6.35 508.65 6.35 721.65}}\ + {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\ + {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\ + {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\ + {jis-b6 FALSE {6.35 121.65 6.35 175.65}}\ + {jis-b7 FALSE {6.35 84.65 6.35 121.65}}\ + {jis-b8 FALSE {6.35 57.65 6.35 84.65}}\ + {jis-b9 FALSE {6.35 38.65 6.35 57.65}}\ + {jis-b10 FALSE {6.35 25.65 6.35 38.65}}\ + {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\ + {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\ + {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\ + {iso-c6 FALSE {6.35 107.65 6.35 155.65}}\ + {iso-designated-long FALSE {6.35 103.65 6.35 213.65}}\ + {hp-2x-postcard FALSE {6.35 141.65 6.35 193.65}}\ + {hp-european-edp FALSE {6.35 298.45 6.35 349.25}}\ + {hp-mini FALSE {6.35 133.35 6.35 209.55}}\ + {hp-postcard FALSE {6.35 93.65 6.35 141.65}}\ + {hp-tabloid FALSE {6.35 273.05 6.35 425.45}}\ + {hp-us-edp FALSE {6.35 273.05 6.35 349.25}}\ + {hp-us-government-legal FALSE {6.35 196.85 6.35 323.85}}\ + {hp-us-government-letter FALSE {6.35 196.85 6.35 247.65}}\ +} +# If you have more than one tray use the following example: +# 1. List the supported trays +#*input-trays-supported: main manual +# 2. Define each tray and it's paper sizes +#*medium-source-sizes-supported: \ +#{ main \ +# {na-letter FALSE {6.35 209.55 6.35 273.05}} \ +# {na-legal FALSE {6.35 209.55 6.35 349.25}} \ +# {iso-a4 FALSE {6.35 203.65 6.35 290.65}} \ +#} \ +#{ manual \ +# {iso-a5 FALSE {6.35 141.65 6.35 203.65}} \ +# {iso-c5 FALSE {6.35 155.65 6.35 222.65}} \ +# {iso-designated-long FALSE {6.35 103.65 6.35 213.65}} \ +# {jis-b5 FALSE {6.35 175.65 6.35 250.65}} \ +# {monarch-envelope FALSE {6.35 91.948 6.35 184.15}} \ +# {na-legal FALSE {6.35 209.55 6.35 349.25}} \ +# {na-number-10-envelope FALSE {6.35 98.425 6.35 234.95}} \ +# {executive FALSE {6.35 177.8 6.35 260.35}} \ +# {iso-a3 FALSE {6.35 290.65 6.35 413.65}} \ +# {iso-a0 FALSE {6.35 834.65 6.35 1182.65}} \ +#} +*plexes-supported: simplex duplex tumble +*printer-model: "PostScript default model" +# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720, +# 940, 1200 and 2440 are supported DPI values, we limit it here +# to some common values: +*printer-resolutions-supported: 300 360 400 600 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional + +# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now. +# xp-psddx-download-fonts defines which fonts should be downloaded as outlines +# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc") +*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc +# xp-psddx-download-font-type defines which font type is used to download outlines +# (valid values are "bitmap", "pstype1" and "pstype3") +*xp-psddx-download-font-type: pstype1 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Book.pmf Binary files /dev/null and AvantGarde-Book.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-BookOblique.pmf Binary files /dev/null and AvantGarde-BookOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-Demi.pmf Binary files /dev/null and AvantGarde-Demi.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/AvantGarde-DemiOblique.pmf Binary files /dev/null and AvantGarde-DemiOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Bold.pmf Binary files /dev/null and Courier-Bold.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-BoldOblique.pmf Binary files /dev/null and Courier-BoldOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier-Oblique.pmf Binary files /dev/null and Courier-Oblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Courier.pmf Binary files /dev/null and Courier.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Bold.pmf Binary files /dev/null and Helvetica-Bold.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-BoldOblique.pmf Binary files /dev/null and Helvetica-BoldOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica-Oblique.pmf Binary files /dev/null and Helvetica-Oblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Helvetica.pmf Binary files /dev/null and Helvetica.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile 21 Apr 2004 09:35:04 -0000 @@ -0,0 +1,41 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPFONTS = \ + AvantGarde-Book.pmf \ + AvantGarde-BookOblique.pmf \ + AvantGarde-Demi.pmf \ + AvantGarde-DemiOblique.pmf \ + Courier-Bold.pmf \ + Courier-BoldOblique.pmf \ + Courier-Oblique.pmf \ + Courier.pmf \ + Helvetica-Bold.pmf \ + Helvetica-BoldOblique.pmf \ + Helvetica-Oblique.pmf \ + Helvetica.pmf \ + LubalinGraph-Book.pmf \ + LubalinGraph-BookOblique.pmf \ + LubalinGraph-Demi.pmf \ + LubalinGraph-DemiOblique.pmf \ + NewCenturySchlbk-Bold.pmf \ + NewCenturySchlbk-BoldItalic.pmf \ + NewCenturySchlbk-Italic.pmf \ + NewCenturySchlbk-Roman.pmf \ + Souvenir-Demi.pmf \ + Souvenir-DemiItalic.pmf \ + Souvenir-Light.pmf \ + Souvenir-LightItalic.pmf \ + Symbol.pmf \ + Times-Bold.pmf \ + Times-BoldItalic.pmf \ + Times-Italic.pmf \ + Times-Roman.pmf \ + ZapfDingbats.pmf + +XPMODELNAME = PSdefault + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) +MODELFONTDIR = $(MODELDIR)/fonts +InstallMultipleDest(install,$(XPFONTS),$(MODELFONTDIR)) +InstallXpPMFFontsDir($(MODELFONTDIR)) + Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Book.pmf Binary files /dev/null and LubalinGraph-Book.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-BookOblique.pmf Binary files /dev/null and LubalinGraph-BookOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-Demi.pmf Binary files /dev/null and LubalinGraph-Demi.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/LubalinGraph-DemiOblique.pmf Binary files /dev/null and LubalinGraph-DemiOblique.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Bold.pmf Binary files /dev/null and NewCenturySchlbk-Bold.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-BoldItalic.pmf Binary files /dev/null and NewCenturySchlbk-BoldItalic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Italic.pmf Binary files /dev/null and NewCenturySchlbk-Italic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/NewCenturySchlbk-Roman.pmf Binary files /dev/null and NewCenturySchlbk-Roman.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Demi.pmf Binary files /dev/null and Souvenir-Demi.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-DemiItalic.pmf Binary files /dev/null and Souvenir-DemiItalic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-Light.pmf Binary files /dev/null and Souvenir-Light.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Souvenir-LightItalic.pmf Binary files /dev/null and Souvenir-LightItalic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Symbol.pmf Binary files /dev/null and Symbol.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Bold.pmf Binary files /dev/null and Times-Bold.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-BoldItalic.pmf Binary files /dev/null and Times-BoldItalic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Italic.pmf Binary files /dev/null and Times-Italic.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Times-Roman.pmf Binary files /dev/null and Times-Roman.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/ZapfDingbats.pmf Binary files /dev/null and ZapfDingbats.pmf differ Index: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,34 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ + +XPMODELNAME = PSspooldir + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +#if BuildGISWxprintglue || BuildGISWxprint +XCOMM Hack for Solaris's native /usr/openwin/bin/Xprt which does not +XCOMM understand the new %xpconfigdir% modelconfig variable +XCOMM (this is only used for the GISWxprintglue package build; +XCOMM the GISWxprint does not need it but using it avoids confusion +XCOMM if someone uses GISWxprint to run both Solaris native Xprt and +XCOMM our own binary side-by-side using the same config) +all:: model-config.SolarisXprt + +model-config.SolarisXprt: model-config + nawk model-config.SolarisXprt + +clean:: + $(RM) model-config.SolarisXprt + +InstallNamedNonExec(model-config.SolarisXprt,model-config,$(MODELDIR)) +#else +InstallNonExecFile(model-config,$(MODELDIR)) +#endif /* BuildGISWxprintglue || BuildGISWxprint */ + +InstallNamedProg(spooltodir.sh,spooltodir.sh,$(MODELDIR)) + +# All PostScript-printer models should use the printer-builtin fonts from the +# "PSdefault" printer model (unless they employ more or other builtin fonts) +install:: + $(RM) $(DESTDIR)$(MODELDIR)/fonts + $(LN) ../PSdefault/fonts $(DESTDIR)$(MODELDIR) + Index: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config diff -N xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,71 @@ +# $Xprint.org: PSspooldir model-config,v 1.1 2002/11/25 19:48:04 gisburn Exp $ +# PostScript DDX model-config which sends jobs to a spool dir instead to a print queue +# +# This model is basically a cut-down PSdefault model with a custom *xp-spooler-command +# +# DO NOT MODIFY THIS FILE!! +# +# If you want to make customisations for your printer create a copy +# of this printer model. +# Example (for creating a model config "MYCOMPANYlaserxx"): +# 1. Create model config dir: +# % mkdir MYCOMPANYlaserxx +# 2. Link (or copy) the PMF (printer font metrics) for the +# printer buildin fonts: +# % ln -s PSspooldir/fonts MYCOMPANYlaserxx/. +# 3. Copy the model config file: +# % cp PSspooldir/model-config MYCOMPANYlaserxx/. +# 4. Customize MYCOMPANYlaserxx/model-config to match your needs. +# +# Attributes supported for this printer model +*content-orientations-supported: portrait landscape reverse-portrait reverse-landscape +*descriptor: PostScript job spool dir /tmp/Xprintjobs +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ +{ '' \ + {na-letter FALSE {6.35 209.55 6.35 273.05}}\ + {na-legal FALSE {6.35 209.55 6.35 349.25}}\ + {executive FALSE {6.35 177.80 6.35 260.35}}\ + {ledger FALSE {6.35 273.05 6.35 425.45}}\ + {quarto FALSE {6.35 209.55 6.35 268.732}}\ + {iso-a3 FALSE {6.35 290.65 6.35 413.65}}\ + {iso-a4 FALSE {6.35 203.65 6.35 290.65}}\ + {iso-a5 FALSE {6.35 141.65 6.35 203.65}}\ + {iso-b3 FALSE {6.35 346.65 6.35 493.65}}\ + {iso-b4 FALSE {6.35 243.65 6.35 346.65}}\ + {iso-b5 FALSE {6.35 169.65 6.35 243.65}}\ + {jis-b3 FALSE {6.35 357.65 6.35 508.65}}\ + {jis-b4 FALSE {6.35 250.65 6.35 357.65}}\ + {jis-b5 FALSE {6.35 175.65 6.35 250.65}}\ + {iso-c3 FALSE {6.35 317.65 6.35 451.65}}\ + {iso-c4 FALSE {6.35 222.65 6.35 317.65}}\ + {iso-c5 FALSE {6.35 155.65 6.35 222.65}}\ +} + +*plexes-supported: simplex duplex tumble +*printer-model: "PostScript job spool dir /tmp/Xprintjobs" +# 75, 100, 120, 150, 180, 200, 240, 300, 360, 400, 600, 720, +# 940, 1200 and 2440 are supported DPI values, we limit it here +# to some common values: +*printer-resolutions-supported: 300 360 400 600 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional + +# Use custom spooler script which sends the output to a dir instead to a printer queue +# Note that "%xpconfigdir%" is currently only supported in Xprt servers build +# from xprint.mozdev.org sources, other platforms have replace it with the +# absolute path name to the script +*xp-spooler-command: %xpconfigdir%/C/print/models/PSspooldir/spooltodir.sh -d /tmp/Xprintjobs -s .ps -u 077 -p %printer-name% -c %copy-count% -t %job-name% -o "%options%" + +# NOTE: xp-psddx-* attributes are EXPERIMENTAL for now. +# xp-psddx-download-fonts defines which fonts should be downloaded as outlines +# (valid types are "pfa", "pfb", "ttf", "ttc", "otf", "otc") +*xp-psddx-download-fonts: pfa pfb ttf ttc otf otc +# xp-psddx-download-font-type defines which font type is used to download outlines +# (valid values are "bitmap", "pstype1" and "pstype3") +*xp-psddx-download-font-type: pstype1 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh diff -N xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,127 @@ +#!/bin/sh +PATH=/usr/bin:/usr/sbin:/bin:/sbin +export PATH + +verbose_msgs="false" +DEFAULT_SPOOLDIR=/tmp/Xprintjobs + +usage() +{ + printf "Usage: ${0}: [options]\n" + printf "-v\tbe verbose\n" + printf "-d dirname\tdefine spool dir\n" + printf "-p string\tname of printer selected by user\n" + printf "-c integer\tnumber of copies\n" + printf "-t string\tjob title\n" + printf "-s string\tfile name suffix\n" + printf "-o string\tspooler options\n" + printf "-u mask\tpermission mask for new files (see umask)\n" + exit 2 +} + +verbose() +{ + if ${verbose_msgs} ; then + echo "$1" + fi +} + +spooldir="${DEFAULT_SPOOLDIR}" +printername= +num_job_copies= +job_title= +filename_suffix= +spooler_options= +permmask= +while getopts va:b:d:p:c:t:s:o:u: i +do + case $i in + v) + verbose_msgs="true" + ;; + d) + spooldir="$OPTARG" + ;; + p) + printername="$OPTARG" + ;; + c) + num_job_copies="$OPTARG" + ;; + t) + job_title="$OPTARG" + ;; + s) + filename_suffix="$OPTARG" + ;; + o) + spooler_options="$OPTARG" + ;; + u) + permmask="$OPTARG" + ;; + ?) usage + ;; + esac +done + +verbose "# spooldir=\"$spooldir\"" +verbose "# printername=\"$printername\"" +verbose "# num_job_copies=\"$num_job_copies\"" +verbose "# job_title=\"$job_title\"" +verbose "# spooler_options=\"$spooler_options\"" +verbose "# umask=\"$permmask\"" + +if [ ! -d "${DEFAULT_SPOOLDIR}" ] ; then + mkdir "${DEFAULT_SPOOLDIR}" + chmod a+rwxt "${DEFAULT_SPOOLDIR}" +fi + +if [ "${permmask}" != "" ] ; then + umask ${permmask} +fi + +if [ ! -d "$spooldir" ] ; then + echo "$0: spooldir \"$spooldir\" does not exits." >&2 + exit 1 +fi +if [ ! -w "$spooldir" ] ; then + echo "$0: Cannot write to spooldir \"$spooldir\"." >&2 + exit 1 +fi + +# Create first part of the output file name (prefix and an "unique" +# id(=date and time))... +filename="Xpjob_`date +%Y%m%d%H%M%S`" + +# ... then add options ... +if [ "${printername}" != "" ] ; then + filename="${filename}_${printername}" +fi +if [ "${num_job_copies}" != "" -a "${num_job_copies}" != "1" ] ; then + filename="${filename}_copies_${num_job_copies}" +fi +if [ "${job_title}" != "" ] ; then + filename="${filename}_title_${job_title}" +fi + +# ... mangle output file name and filter chars (like whitespaces) +# which may screw-up further processing by other shell scripts ... +filename="`echo \"${filename}\" | tr '[:blank:]' '_' | tr -c -d '[:alnum:]_.-'`" + +# ... add path and suffix ... +filename="${spooldir}/${filename}${filename_suffix}" + +verbose "# File name is \"$filename\"." + +# ... and finally capture stdin to the file. +cat >"${filename}" + +if ${verbose_msgs} ; then + printf "# File is " ; ls -l "${filename}" +fi + +verbose "# Done." + +exit 0 +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,15 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = fonts + +XPMODELNAME = SPSPARC2 + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) + +InstallNonExecFile(model-config,$(MODELDIR)) + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) + Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config,v retrieving revision 1.1 diff -u -r1.1 model-config --- a/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config 14 Nov 2003 15:54:44 -0000 1.1 +++ b/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config 21 Apr 2004 09:35:06 -0000 @@ -1,13 +1,18 @@ -# $Xorg: model-config,v 1.3 2000/08/17 19:48:04 cpqbld Exp $ -SPSPARC2.printer-model: "SunPics SPARCprinter II" -SPSPARC2.printer-resolutions-supported: 300 -SPSPARC2.content-orientations-supported: portrait landscape -SPSPARC2.document-formats-supported: {PostScript 2} -SPSPARC2.plexes-supported: simplex -SPSPARC2.xp-ddx-identifier: XP-POSTSCRIPT -SPSPARC2.xp-embedded-formats-supported: { PostScript 2 } -*xp-setup-proviso: setup-optional -SPSPARC2.medium-source-sizes-supported: \ +# $Xprint.org: SPSPARC2 model-config,v 1.4 2002/11/07 19:48:04 gisburn Exp $ +*content-orientations-supported: portrait landscape +*descriptor: SunPics SPARCprinter II +*document-formats-supported: {POSTSCRIPT 2} +*input-trays-supported: +*medium-source-sizes-supported: \ { '' {na-letter FALSE {6.35 209.55 6.35 273.05}} \ {na-legal FALSE {6.35 209.55 6.35 349.25}} \ {iso-a4 FALSE {6.35 203.65 6.35 290.65}}} +*plexes-supported: simplex +*printer-model: "SunPics SPARCprinter II" +*printer-resolutions-supported: 300 +*xp-ddx-identifier: XP-POSTSCRIPT +*xp-listfonts-modes-supported: xp-list-internal-printer-fonts xp-list-glyph-fonts +*xp-embedded-formats-supported: {POSTSCRIPT 2} +*xp-raw-formats-supported: {POSTSCRIPT 2} +*xp-setup-proviso: setup-optional +# EOF. Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Book.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Book.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Book.pmf Binary files /tmp/cvsHJrHVU and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-BookOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-BookOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-BookOblique.pmf Binary files /tmp/cvsdQYyOO and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-Demi.pmf Binary files /tmp/cvsjtXoNG and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-DemiOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-DemiOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/AvantGarde-DemiOblique.pmf Binary files /tmp/cvs13Kacz and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Bold.pmf Binary files /tmp/cvsZavE1r and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-BoldOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-BoldOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-BoldOblique.pmf Binary files /tmp/cvsfV42yn and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Oblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Oblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier-Oblique.pmf Binary files /tmp/cvslY88rj and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Courier.pmf Binary files /tmp/cvsxO2NHf and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Bold.pmf Binary files /tmp/cvsZ4t5ic and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-BoldOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-BoldOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-BoldOblique.pmf Binary files /tmp/cvsrlH1Y6 and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Oblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Oblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica-Oblique.pmf Binary files /tmp/cvsVoBB61 and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Helvetica.pmf Binary files /tmp/cvsR0JT1Z and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,28 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/10/22 02:42:52 gisburn Exp $ + +XPFONTS = \ + Courier-Bold.pmf \ + Courier-BoldOblique.pmf \ + Courier-Oblique.pmf \ + Courier.pmf \ + Helvetica-Bold.pmf \ + Helvetica-BoldOblique.pmf \ + Helvetica-Oblique.pmf \ + Helvetica.pmf \ + Symbol.pmf \ + Times-Bold.pmf \ + Times-BoldItalic.pmf \ + Times-Italic.pmf \ + Times-Roman.pmf + +XPMODELNAME = SPSPARC2 + +MODELDIR = $(XPRINTDIR)/C/print/models/$(XPMODELNAME) +MODELFONTDIR = $(MODELDIR)/fonts + +# We reuse some of the PSdefault fonts +PARENTMODELFONTDIR=../../PSdefault/fonts + +InstallXpMultiplePMFLinks($(XPFONTS),$(PARENTMODELFONTDIR),$(MODELFONTDIR)) +InstallXpPMFFontsDir($(MODELFONTDIR)) + Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Book.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Book.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Book.pmf Binary files /tmp/cvsJcEgoY and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-BookOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-BookOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-BookOblique.pmf Binary files /tmp/cvsHjQycX and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-Demi.pmf Binary files /tmp/cvsB8d77T and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-DemiOblique.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-DemiOblique.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/LubalinGraph-DemiOblique.pmf Binary files /tmp/cvst013tR and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Bold.pmf Binary files /tmp/cvsHxDUFR and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-BoldItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-BoldItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-BoldItalic.pmf Binary files /tmp/cvsBStLjS and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Italic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Italic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Italic.pmf Binary files /tmp/cvsJqRnqT and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Roman.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Roman.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/NewCenturySchlbk-Roman.pmf Binary files /tmp/cvs5lZXBS and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Demi.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Demi.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Demi.pmf Binary files /tmp/cvsztL8cS and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-DemiItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-DemiItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-DemiItalic.pmf Binary files /tmp/cvshY3beS and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Light.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Light.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-Light.pmf Binary files /tmp/cvsTlag4U and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-LightItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-LightItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Souvenir-LightItalic.pmf Binary files /tmp/cvsrpVXhY and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Symbol.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Symbol.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Symbol.pmf Binary files /tmp/cvsBWfPAZ and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Bold.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Bold.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Bold.pmf Binary files /tmp/cvsdgSSf1 and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-BoldItalic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-BoldItalic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-BoldItalic.pmf Binary files /tmp/cvsTtiSi3 and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Italic.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Italic.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Italic.pmf Binary files /tmp/cvs70pnL5 and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Roman.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Roman.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Times-Roman.pmf Binary files /tmp/cvsZGlzVa and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/ZapfDingbats.pmf =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/ZapfDingbats.pmf diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/ZapfDingbats.pmf Binary files /tmp/cvsdudOrg and /dev/null differ Index: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/fonts.dir =================================================================== RCS file: xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/fonts.dir diff -N xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/fonts.dir --- a/xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/fonts.dir 14 Nov 2003 15:54:45 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ -13 -Courier-Bold.pmf -adobe-courier-bold-r-normal--199-120-1200-1200-p-1190-iso8859-1 -Courier-BoldOblique.pmf -adobe-courier-bold-i-normal--199-120-1200-1200-p-1190-iso8859-1 -Courier-Oblique.pmf -adobe-courier-medium-i-normal--199-120-1200-1200-p-1190-iso8859-1 -Courier.pmf -adobe-courier-medium-r-normal--199-120-1200-1200-p-1190-iso8859-1 -Helvetica-Bold.pmf -adobe-helvetica-bold-r-normal--199-120-1200-1200-p-1123-iso8859-1 -Helvetica-BoldOblique.pmf -adobe-helvetica-bold-i-normal--199-120-1200-1200-p-1123-iso8859-1 -Helvetica-Oblique.pmf -adobe-helvetica-medium-i-normal--199-120-1200-1200-p-1085-iso8859-1 -Helvetica.pmf -adobe-helvetica-medium-r-normal--199-120-1200-1200-p-1085-iso8859-1 -Symbol.pmf -adobe-symbol-medium-r-normal--199-120-1200-1200-p-1166-adobe-fontspecific -Times-Bold.pmf -adobe-times-bold-r-normal--199-120-1200-1200-p-1076-iso8859-1 -Times-BoldItalic.pmf -adobe-times-bold-i-normal--199-120-1200-1200-p-1044-iso8859-1 -Times-Italic.pmf -adobe-times-medium-i-normal--199-120-1200-1200-p-1025-iso8859-1 -Times-Roman.pmf -adobe-times-medium-r-normal--199-120-1200-1200-p-1030-iso8859-1 Index: xc/programs/Xserver/XpConfig/en_US/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/en_US/Imakefile diff -N xc/programs/Xserver/XpConfig/en_US/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/en_US/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,8 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/11/23 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = print + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/XpConfig/en_US/print/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/en_US/print/Imakefile diff -N xc/programs/Xserver/XpConfig/en_US/print/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/en_US/print/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,26 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/06/09 05:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = attributes + +XPLOCALEPRINTDIR=$(XPRINTDIR)/en_US/print + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) + +MakeDirectories(install,$(XPLOCALEPRINTDIR)) + +# We only have different values in "attributes", so link all other files +# to the "defaults" in the C locale +LINK_TO_C_LOCALE=Xprinters ddx-config models + +install:: + ( \ + cd $(DESTDIR)$(XPLOCALEPRINTDIR) ; \ + for i in $(LINK_TO_C_LOCALE) \ + ; do \ + $(RM) $$i ; \ + $(LN) ../../C/print/$$i $$i ; \ + done \ + ) Index: xc/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile =================================================================== RCS file: xc/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile diff -N xc/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,18 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/11/23 05:42:52 gisburn Exp $ + +XPATTRIBUTEDIR = $(XPRINTDIR)/en_US/print/attributes + +# Install the "en_US"-specific "document" attribute resources... +InstallNonExecFile(document,$(XPATTRIBUTEDIR)) + +# ... and reuse "job" and "printer" pools from the C locale +install:: + ( \ + cd $(DESTDIR)$(XPATTRIBUTEDIR) ; \ + for i in job printer \ + ; do \ + $(RM) $$i ; \ + $(LN) ../../../C/print/attributes/$$i $$i ; \ + done \ + ) + Index: xc/programs/Xserver/XpConfig/en_US/print/attributes/document =================================================================== RCS file: xc/programs/Xserver/XpConfig/en_US/print/attributes/document diff -N xc/programs/Xserver/XpConfig/en_US/print/attributes/document --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/XpConfig/en_US/print/attributes/document 21 Apr 2004 09:35:06 -0000 @@ -0,0 +1,13 @@ +# $Xorg: document,v 1.2 2002/11/30 22:10:03 gisburn Exp $ +# Document DPA-Object initial attribute values for en_US(-like) locales +# +# Note that the defaults (for all locales) are set in +# ${XPCONFIGDIR}/C/print/attributes/document +# Values in ${XPCONFIGDIR}/${LANG}/print/attributes/document are used to +# set/override these defaults for a specific locale on demand + +# US and some other countries use US-Letter as default paper size +# ("C"-locale default is "ISO-A4") +*default-medium: na-letter + +# EOF. Index: xc/programs/Xserver/Xprint/AttrValid.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/AttrValid.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 AttrValid.c --- a/xc/programs/Xserver/Xprint/AttrValid.c 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/AttrValid.c 21 Apr 2004 09:35:06 -0000 @@ -30,8 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.c,v 1.4 2001/01/17 22:36:27 dawes Exp $ */ - #include #include "attributes.h" @@ -46,7 +44,7 @@ &DefaultMediumSize, 1 }; static XpOidMediumSourceSize DefaultMediumSourceSize = { - xpoid_unspecified, XpOidMediumSS_DISCRETE, { &DefaultMediumSizeList } + xpoid_unspecified, XpOidMediumSS_DISCRETE, &DefaultMediumSizeList }; static XpOidMediumSS DefaultMediumSS = { &DefaultMediumSourceSize, 1 @@ -298,7 +296,7 @@ } const XpOidMediumSS* -XpGetDefaultMediumSS(void) +XpGetDefaultMediumSS() { return &DefaultMediumSS; } Index: xc/programs/Xserver/Xprint/AttrValid.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/AttrValid.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 AttrValid.h --- a/xc/programs/Xserver/Xprint/AttrValid.h 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/AttrValid.h 21 Apr 2004 09:35:06 -0000 @@ -30,7 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/AttrValid.h,v 1.6 2001/10/31 22:50:27 tsi Exp $ */ #ifndef _Xp_AttrValid_h #define _Xp_AttrValid_h @@ -85,7 +84,7 @@ #define XpPutStringAttr(pContext, pool, oid, value) \ XpPutOneAttribute(pContext, pool, XpOidString(oid), value) -#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */ +#ifdef _XP_PRINT_SERVER_ /* needed for XpContextPtr in Printstr.h */ /* * XpOid-valued attribute access @@ -179,7 +178,7 @@ XPAttributes pool, XpOid oid, const XpOidMediumSS* msss); -const XpOidMediumSS* XpGetDefaultMediumSS(void); +const XpOidMediumSS* XpGetDefaultMediumSS(); /* * XpOidTrayMediumList-valued attribute access @@ -193,15 +192,12 @@ XPAttributes pool, XpOid oid, const XpOidTrayMediumList* tm); -BOOL XpOidTrayMediumListHasTray(const XpOidTrayMediumList* list, XpOid tray); - /* * Attribute pool validation */ void XpValidateAttributePool(XpContextPtr pContext, XPAttributes pool, const XpValidatePoolsRec* vpr); -void XpValidateNotificationProfile(XpContextPtr pContext); void XpValidatePrinterPool(XpContextPtr pContext, const XpValidatePoolsRec* vpr); void XpValidateJobPool(XpContextPtr pContext, @@ -210,9 +206,6 @@ const XpValidatePoolsRec* vpr); void XpValidatePagePool(XpContextPtr pContext, const XpValidatePoolsRec* vpr); -void XpValidatePrinterMediaAttrs(XpContextPtr pContext, - const XpOidList* valid_trays, - const XpOidList* valid_sizes); #endif /* _XP_PRINT_SERVER_ */ Index: xc/programs/Xserver/Xprint/DiPrint.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/DiPrint.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 DiPrint.h --- a/xc/programs/Xserver/Xprint/DiPrint.h 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/DiPrint.h 21 Apr 2004 09:35:06 -0000 @@ -30,8 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/DiPrint.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */ - /* * The XpDiListEntry struct is the type of each element of the array * handed back to the extension code to handle a GetPrinterList request. Index: xc/programs/Xserver/Xprint/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Imakefile,v retrieving revision 1.1.4.5 diff -u -r1.1.4.5 Imakefile --- a/xc/programs/Xserver/Xprint/Imakefile 26 Mar 2004 01:12:54 -0000 1.1.4.5 +++ b/xc/programs/Xserver/Xprint/Imakefile 21 Apr 2004 09:35:07 -0000 @@ -1,10 +1,4 @@ XCOMM $Xorg: Imakefile,v 1.4 2001/03/14 18:44:11 pookie Exp $ - - - - -XCOMM $XFree86: xc/programs/Xserver/Xprint/Imakefile,v 1.19 2002/11/11 17:55:01 alanh Exp $ - #include #ifndef XpRasterDDX @@ -20,10 +14,10 @@ #define XpPostScriptDDX YES #endif -SRCS1 = Init.c Quarks.c attributes.c Util.c mediaSizes.c \ +SRCS1 = Init.c Quarks.c spooler.c attributes.c Util.c mediaSizes.c \ Oid.c AttrValid.c -OBJS1 = Init.o Quarks.o attributes.o Util.o mediaSizes.o \ +OBJS1 = Init.o Quarks.o spooler.o attributes.o Util.o mediaSizes.o \ Oid.o AttrValid.o #ifdef OS2Architecture @@ -34,7 +28,7 @@ #if XprtServer #if PrintOnlyServer || defined(PrintServerExtensions) #if PrintOnlyServer -PO_DEFINES = -DPRINT_ONLY_SERVER +PO_DEFINES = -DPRINT_ONLY_SERVER #endif #ifdef PrintServerExtensions XPEXT_DEFINES = PrintServerExtensions @@ -48,7 +42,7 @@ OBJS2 = ddxInit.o #endif -SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS_OS2) +SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS_OS2) OBJS = $(OBJS1) $(OBJS_OS2) @@ -75,15 +69,15 @@ #if XpRasterDDX || XpColorPclDDX || XpMonoPclDDX || XpPostScriptDDX -SUBDIRS = $(RASTDIR) $(PCLDIR) $(MPCLDIR) $(PSDIR) - +SUBDIRS = $(RASTDIR) $(PCLDIR) $(MPCLDIR) $(PSDIR) etc #define IHaveSubdirs #endif INCLUDES = -I$(XINCLUDESRC) -I. -I../mfb -I../mi -I../cfb \ - -I../include -I$(TOP)/include -I$(LIBSRC) \ - -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(XLIBSRC) + -I../include -I$(TOP)/include -I$(LIBSRC) \ + -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(XLIBSRC) + LINTLIBS = $(TOP)/server/dix/llib-ldix.ln $(TOP)/server/os/llib-los.ln \ $(TOP)/server/ddx/mfb/llib-lmfb.ln \ @@ -91,7 +85,7 @@ $(TOP)/server/ddx/cfb/llib-lcfb.ln DEFINES = -DXPRINTDIR=\"$(XPRINTDIR)\" $(RASTDEF) $(PCLDEF) $(MPCLDEF) \ - $(PSDEF) $(MKTMP_DEFINES) -UXFree86LOADER -D_XP_PRINT_SERVER_ + $(PSDEF) $(MKTMP_DEFINES) -UXFree86LOADER -D_XP_PRINT_SERVER_ /* Go ahead: Call me paranoid ... */ Makefiles:: @@ -131,3 +125,14 @@ #endif DependTarget() + +MANDIR = $(MISCMANDIR) +MANSUFFIX = $(MISCMANSUFFIX) +InstallManPage(Xprint,$(MANDIR)) + +#ifdef HasDocBookTools +all:: Xprint.man Xprint.html + +ConvertDocBookToManPage(Xprint.sgml, Xprint.man) +ConvertDocBookToHTML(Xprint.sgml, Xprint.html) +#endif /* HasDocBookTools */ Index: xc/programs/Xserver/Xprint/Init.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Init.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 Init.c --- a/xc/programs/Xserver/Xprint/Init.c 5 Mar 2004 13:39:53 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/Init.c 21 Apr 2004 09:35:07 -0000 @@ -50,7 +50,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/Init.c,v 1.14tsi Exp $ */ #include #include @@ -91,6 +90,7 @@ #include "attributes.h" #include "os.h" +#include "spooler.h" static void GenericScreenInit( int index, @@ -116,57 +116,6 @@ #define MODELDIRNAME "/models" #define FONTDIRNAME "/fonts" -/* - * The string LIST_QUEUES is fed to a shell to generate an ordered - * list of available printers on the system. These string definitions - * are taken from the file PrintSubSys.C within the code for the - * dtprintinfo program. - */ -#ifdef AIXV4 -const char *LIST_QUEUES = "lsallq | grep -v '^bsh$' | sort"; -#else -#ifdef hpux -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "awk '" - " $2 == \"for\" " - " { " - " x = match($3, /:/); " - " print substr($3, 1, x-1)" - " }' | sort"; -#else -#ifdef __osf__ - const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $2 == \"for\" " - " { print $4 }' " - " | sort"; -#else -#ifdef __uxp__ -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $4 == \"for\" " - " { " - " x = match($5, /:/); " - " print substr($5, 1, x-1)" - " }' | sort"; -#else -#if defined(CSRG_BASED) || defined(linux) || defined(ISC) || defined(__GNUC__) -const char *LIST_QUEUES = "LANG=C lpc status | grep -v '^\t' | " - "sed -e /:/s/// | sort"; -#else -const char *LIST_QUEUES = "LANG=C lpstat -v | " - "nawk '" - " $2 == \"for\" " - " { " - " x = match($3, /:/); " - " print substr($3, 1, x-1)" - " }' | sort"; -#endif -#endif -#endif -#endif -#endif - #ifdef XPRASTERDDX static @@ -183,9 +132,9 @@ static PixmapFormatRec ColorPclPixmapFormats[] = { - { 1, 1, BITMAP_SCANLINE_PAD }, - { 8, 8, BITMAP_SCANLINE_PAD }, - { 24,32, BITMAP_SCANLINE_PAD } + { 1, 1, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD } }; #define NUMCPCLFORMATS (sizeof ColorPclPixmapFormats)/(sizeof ColorPclPixmapFormats[0]) @@ -211,9 +160,9 @@ static PixmapFormatRec PSPixmapFormats[] = { - { 1, 1, BITMAP_SCANLINE_PAD }, - { 8, 8, BITMAP_SCANLINE_PAD }, - { 24,32, BITMAP_SCANLINE_PAD } + { 1, 1, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD } }; #define NUMPSFORMATS (sizeof PSPixmapFormats)/(sizeof PSPixmapFormats[0]) @@ -325,10 +274,64 @@ int screenNum; } DriverMapEntry, *DriverMapPtr; +static const char configFilePath[] = +"/etc/dt/config/print:/usr/dt/config/print"; + +static const char printServerConfigDir[] = "XPSERVERCONFIGDIR"; + +static int printScreenPrivIndex, + printWindowPrivIndex, + printGCPrivIndex; +static unsigned long printGeneration = 0; static char *configFileName = (char *)NULL; static Bool freeDefaultFontPath = FALSE; static char *origFontPath = (char *)NULL; +static Bool xprintInitGlobalsCalled = FALSE; +/* + * This function is responsible for doing initalisation of any global + * variables at an very early point of server startup (even before + * |ProcessCommandLine()|. + */ +void XprintInitGlobals(void) +{ + xprintInitGlobalsCalled = TRUE; + +#ifdef SMART_SCHEDULE + /* Somehow the XF86 "smart scheduler" completely kills the Xprint DDX + * (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=467 + * ("Xfree86's "smart scheduler" breaks Xprt") */ + SmartScheduleDisable = TRUE; +#endif /* SMART_SCHEDULE */ +} + +/* + * XprintUseMsg() prints usage for the Xprint-specific options + */ +void XprintUseMsg() +{ + XpSpoolerTypePtr curr = xpstm; + + /* Option '-XpFile' */ + ErrorF("-XpFile file specifies an alternate `Xprinters' file, rather\n"); + ErrorF(" than the default one (e.g.\n"); + ErrorF(" `${XPCONFIGDIR}/${LANG}/print/Xprinters') or\n"); + ErrorF(" `${XPCONFIGDIR}/C/print/Xprinters'.\n"); + + /* Option '-XpSpoolerType' */ + ErrorF("-XpSpoolerType string specifies a spooler type.\n"); + ErrorF(" Supported values are:\n"); + + while( curr->name != NULL ) + { + ErrorF(" - '%s'\n", curr->name); + curr++; + } + ErrorF(" (multiple values can be specified, seperated by ':',\n"); + ErrorF(" the first active spooler will be chosen).\n"); + ErrorF(" default is '%s'.\n", XPDEFAULTSPOOLERNAMELIST); +} + /* * XprintOptions checks argv[i] to see if it is our command line * option specifying a configuration file name. It returns the index @@ -340,6 +343,7 @@ char **argv, int i) { + extern void ddxUseMsg(); if(strcmp(argv[i], "-XpFile") == 0) { if ((i + 1) >= argc) { @@ -349,8 +353,19 @@ configFileName = argv[i + 1]; return i + 2; } + else if(strcmp(argv[i], "-XpSpoolerType") == 0) + { + if ((i + 1) >= argc) { + ddxUseMsg (); + return i + 2; + } + XpSetSpoolerTypeNameList(argv[i + 1]); + return i + 2; + } else + { return i; + } } /************************************************************ @@ -417,7 +432,7 @@ { PrinterDbPtr pCurEntry, pNextEntry; - for(pCurEntry = printerDb, pNextEntry = 0; + for(pCurEntry = printerDb, pNextEntry = (PrinterDbPtr)NULL; pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pNextEntry) { pNextEntry = pCurEntry->next; @@ -429,7 +444,7 @@ */ xfree(pCurEntry); } - printerDb = 0; + printerDb = (PrinterDbPtr)NULL; } /* @@ -460,11 +475,12 @@ return TRUE; } -static void +static int AugmentPrinterDb(const char *command) { FILE *fp; char name[256]; + int num_printers = 0; /* Number of printers we found */ fp = popen(command, "r"); /* XXX is a 256 character limit overly restrictive for printer names? */ @@ -472,8 +488,10 @@ { name[strlen(name) - 1] = (char)'\0'; /* strip the \n */ AddPrinterDbName(name); + num_printers++; } pclose(fp); + return num_printers; } /* @@ -592,7 +610,7 @@ "xp-ddx-identifier"); if(pEntry->driverName == (char *)NULL || strlen(pEntry->driverName) == 0 || - GetInitFunc(pEntry->driverName) == 0) + GetInitFunc(pEntry->driverName) == (Bool(*)())NULL) { if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) { ErrorF("Xp Extension: Can't load driver %s\n", @@ -650,7 +668,7 @@ /* * Check for a LANG-specific file. */ - if ((dirName = XpGetConfigDir(TRUE)) != 0) + if(dirName = XpGetConfigDir(TRUE)) { filePath = (char *)xalloc(strlen(dirName) + strlen(XPRINTERSFILENAME) + 2); @@ -669,7 +687,7 @@ xfree(filePath); } - if ((dirName = XpGetConfigDir(FALSE)) != 0) + if(dirName = XpGetConfigDir(FALSE)) { filePath = (char *)xalloc(strlen(dirName) + strlen(XPRINTERSFILENAME) + 2); @@ -701,6 +719,7 @@ static PrinterDbPtr BuildPrinterDb(void) { + char *printerList, *augmentCmd = (char *)NULL; Bool defaultAugment = TRUE, freeConfigFileName; if(configFileName && access(configFileName, R_OK) != 0) @@ -727,7 +746,7 @@ { while((tok = strtok((char *)NULL, " \t")) != (char *)NULL) { - if ((ptr = MbStrchr(tok, '\012')) != 0) + if(ptr = MbStrchr(tok, '\012')) *ptr = (char)'\0'; AddPrinterDbName(tok); } @@ -768,7 +787,43 @@ if(defaultAugment == TRUE) { - AugmentPrinterDb(LIST_QUEUES); + XpSpoolerTypePtr curr_spooler_type; /* spooler we are currently probing for queues */ + int num_printers_found; /* number of printers found by |AugmentPrinterDb()| */ + char *tok_lasts; /* strtok_r() position token */ + char *spnamelist; /* list of spooler names, seperated by ":" */ + char *spname; /* spooler name */ + + spnamelist = strdup(XpGetSpoolerTypeNameList()); /* strtok_r() modifies string so dup' it first */ + + for( spname = strtok_r(spnamelist, ":", &tok_lasts) ; + spname != NULL ; + spname = strtok_r(NULL, ":", &tok_lasts) ) + { + curr_spooler_type = XpSpoolerNameToXpSpoolerType(spname); + if(!curr_spooler_type) + { + FatalError("BuildPrinterDb: No spooler type entry found for '%s'.\n", spname); + } + + if(curr_spooler_type->list_queues_command == NULL || + strlen(curr_spooler_type->list_queues_command) == 0) + { + continue; + } + + num_printers_found = AugmentPrinterDb(curr_spooler_type->list_queues_command); + /* Did we found a spooler which works ? */ + if(num_printers_found > 0) + { + spooler_type = curr_spooler_type; +#ifdef DEBUG_gisburn + fprintf(stderr, "BuildPrinterDb: using '%s'.\n", spooler_type->name); +#endif /* DEBUG_gisburn */ + break; + } + } + + free(spnamelist); } MergeNameMap(); @@ -951,7 +1006,7 @@ return (char *)NULL; configDir = XpGetConfigDir(TRUE); - if ((fontDir = ValidateFontDir(configDir, modelName)) != 0) + if(fontDir = ValidateFontDir(configDir, modelName)) { xfree(configDir); return fontDir; @@ -1013,8 +1068,8 @@ static void AugmentFontPath(void) { - char *modelID, **allIDs = (char **)NULL; - PrinterDbPtr pDbEntry; + char *newPath, *modelID, **allIDs = (char **)NULL; + PrinterDbPtr pDb, pDbEntry; int numModels, i; if(!origFontPath) @@ -1072,7 +1127,7 @@ for(i = 0; allIDs != (char **)NULL && allIDs[i] != (char *)NULL; i ++) { char *fontDir; - if ((fontDir = FindFontDir(allIDs[i])) != 0) + if(fontDir = FindFontDir(allIDs[i])) { AddToFontPath(fontDir); xfree(fontDir); @@ -1162,7 +1217,7 @@ * fpe->name. */ if(fpe->name_length < PATH_PREFIX_LEN || - (strlen(fontDir) != (unsigned)(fpe->name_length - PATH_PREFIX_LEN)) || + (strlen(fontDir) != (fpe->name_length - PATH_PREFIX_LEN)) || strncmp(fontDir, fpe->name + PATH_PREFIX_LEN, fpe->name_length - PATH_PREFIX_LEN)) { @@ -1235,6 +1290,18 @@ char **driverNames; char *configDir; + /* This should NEVER happen, but... */ + if( !xprintInitGlobalsCalled ) + { + FatalError("Internal error: XprintInitGlobals() not called."); + } +#ifdef SMART_SCHEDULE + if( SmartScheduleDisable != TRUE ) + { + FatalError("Internal error: XF86 smart scheduler incompatible to Xprint DDX."); + } +#endif /* SMART_SCHEDULE */ + /* * this little test is just a warning at startup to make sure * that the config directory exists. @@ -1254,10 +1321,9 @@ xfree(configDir); } else { - ErrorF("Xp Extension: could not find config dir %s\n", - configDir ? configDir : XPRINTDIR); - - if (configDir) xfree(configDir); + /* Refuse to start when we do not have our config dir... */ + FatalError("Xp Extension: could not find config dir %s\n", + configDir ? configDir : XPRINTDIR); } if(printerDb != (PrinterDbPtr)NULL) @@ -1414,7 +1480,7 @@ } if(callInit == TRUE) { - pBFunc initFunc; + Bool (*initFunc)(); initFunc = GetInitFunc(pDb->driverName); if(initFunc(index, pScreen, argc, argv) == FALSE) { @@ -1451,9 +1517,10 @@ int argc, char **argv) { + int i; float fWidth, fHeight, maxWidth, maxHeight; unsigned short width, height; - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; int res, maxRes; /* @@ -1477,6 +1544,7 @@ { if(pDb->screenNum == index) { + XpValidatePoolsRec *pValRec; pVFunc dimensionsFunc; @@ -1506,6 +1574,57 @@ } /* + * QualifyName - takes an unqualified file name such as X6printers and + * a colon-separated list of directory path names such as + * /etc/opt/dt:/opt/dt/config. + * + * Returns a fully qualified file path name such as /etc/opt/dt/X6printers. + * The returned value is malloc'd, and the caller is responsible for + * freeing the associated memory. + */ +static char * +QualifyName(fileName, searchPath) + char *fileName; + char *searchPath; +{ + char * curPath = searchPath; + char * nextPath; + char * chance; + FILE *pFile; + + if (fileName == NULL || searchPath == NULL) + return NULL; + + while (1) { + if ((nextPath = strchr(curPath, ':')) != NULL) + *nextPath = 0; + + chance = (char *)xalloc(strlen(curPath) + strlen(fileName) + 2); + sprintf(chance,"%s/%s",curPath,fileName); + + /* see if we can read from the file */ + if((pFile = fopen(chance, "r")) != (FILE *)NULL) + { + fclose(pFile); + /* ... restore the colon, .... */ + if (nextPath) + *nextPath = ':'; + + return chance; + } + + xfree(chance); + + if (nextPath == NULL) /* End of path list? */ + break; + + /* try the next path */ + curPath = nextPath + 1; + } + return NULL; +} + +/* * FillPrinterListEntry fills in a single XpDiListEntry element with data * derived from the supplied PrinterDbPtr element. * @@ -1548,12 +1667,11 @@ int localeLen, char *locale) { - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; for(pDb = printerDb; pDb != (PrinterDbPtr)NULL; pDb = pDb->next) { - if (strlen(pDb->name) == (unsigned)nameLen - && !strncmp(pDb->name, name, nameLen)) + if(strlen(pDb->name) == nameLen && !strncmp(pDb->name, name, nameLen)) { FillPrinterListEntry(pEntry, pDb, localeLen, locale); return TRUE; @@ -1598,7 +1716,7 @@ if(!nameLen || name == (char *)NULL) { int i; - PrinterDbPtr pDb; + PrinterDbPtr pDb, pDb2; for(pDb = printerDb, i = 0; pDb != (PrinterDbPtr)NULL; pDb = pDb->next, i++) @@ -1648,11 +1766,12 @@ XpDiValidatePrinter(char *printerName, int printerNameLen) { PrinterDbPtr pCurEntry; + WindowPtr pWin; for(pCurEntry = printerDb; pCurEntry != (PrinterDbPtr)NULL; pCurEntry = pCurEntry->next) { - if(strlen(pCurEntry->name) == (unsigned)printerNameLen && + if(strlen(pCurEntry->name) == printerNameLen && !strncmp(pCurEntry->name, printerName, printerNameLen)) return WindowTable[pCurEntry->screenNum]; } @@ -1680,3 +1799,4 @@ return (char *)NULL; /* XXX Should we supply a default driverName? */ } + Index: xc/programs/Xserver/Xprint/Oid.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Oid.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 Oid.c --- a/xc/programs/Xserver/Xprint/Oid.c 5 Mar 2004 13:39:53 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/Oid.c 21 Apr 2004 09:35:08 -0000 @@ -30,7 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/Oid.c,v 1.5tsi Exp $ */ #include "attributes.h" @@ -274,7 +273,7 @@ */ if(ptr_return != (const char**)NULL) *ptr_return = ptr+length; - return (XpOid)i; + return i; } /* @@ -751,7 +750,7 @@ XpOid XpOidLinkedListNextOid(XpOidLinkedList* me) { - if(me->current ? (me->current = me->current->next) != 0 : xFalse) + if(me->current ? me->current = me->current->next : xFalse) return me->current->oid; else return xpoid_none; @@ -1652,6 +1651,8 @@ const XpOidMediumSS* msss) { int i_mss, i_ds, i_itm; + XpOidMediumDiscreteSizeList* ds_list; + int tray_count; XpOid current_tray, current_medium; XpOidMediumDiscreteSizeList* unspecified_tray_ds; XpOidMediumDiscreteSizeList* tray_ds; @@ -1711,7 +1712,6 @@ * list */ if(tray_ds == (XpOidMediumDiscreteSizeList*)NULL) - { if(unspecified_tray_ds == (XpOidMediumDiscreteSizeList*)NULL) { /* @@ -1722,10 +1722,7 @@ continue; } else - { tray_ds = unspecified_tray_ds; - } - } /* * loop through the discrete sizes list, looking for a size that * matches the medium for the current input tray @@ -2107,13 +2104,15 @@ { switch(notify) { - default: case XPOID_NOTIFY_UNSUPPORTED: return (const char*)NULL; + break; case XPOID_NOTIFY_NONE: return NOTIFY_NONE_STR; + break; case XPOID_NOTIFY_EMAIL: return NOTIFY_EMAIL_STR; + break; } } @@ -2238,7 +2237,7 @@ const char* first_nonws_ptr; const char* format; const char* variant; - const char* version = 0; + const char* version; int format_len; int variant_len; int version_len; @@ -2551,12 +2550,10 @@ * variants must both be NULL or match */ if(fmt->variant == (char*)NULL) - { if(list->list[i].variant == (char*)NULL) return xTrue; else continue; - } if(list->list[i].variant == (char*)NULL) continue; if(strcmp(fmt->variant, list->list[i].variant) != 0) @@ -2565,12 +2562,10 @@ * versions must both be NULL or match */ if(fmt->version == (char*)NULL) - { if(list->list[i].version == (char*)NULL) return xTrue; else continue; - } if(list->list[i].version == (char*)NULL) continue; if(strcmp(fmt->version, list->list[i].version) == 0) Index: xc/programs/Xserver/Xprint/Oid.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Oid.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Oid.h --- a/xc/programs/Xserver/Xprint/Oid.h 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/Oid.h 21 Apr 2004 09:35:08 -0000 @@ -30,7 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/Oid.h,v 1.3 1999/12/16 02:26:24 robin Exp $ */ #ifndef _Xp_Oid_h #define _Xp_Oid_h @@ -206,7 +205,7 @@ /* * XpOidLinkedList public methods */ -XpOidLinkedList* XpOidLinkedListNew(void); +XpOidLinkedList* XpOidLinkedListNew(); void XpOidLinkedListDelete(XpOidLinkedList*); #define XpOidLinkedListCount(l) ((l) ? (l)->count : 0) XpOid XpOidLinkedListGetOid(XpOidLinkedList* list, int i); Index: xc/programs/Xserver/Xprint/OidDefs.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/OidDefs.h,v retrieving revision 1.1 diff -u -r1.1 OidDefs.h --- a/xc/programs/Xserver/Xprint/OidDefs.h 14 Nov 2003 15:54:45 -0000 1.1 +++ b/xc/programs/Xserver/Xprint/OidDefs.h 21 Apr 2004 09:35:08 -0000 @@ -133,6 +133,14 @@ xpoid_val_medium_size_jis_b8, xpoid_val_medium_size_jis_b9, xpoid_val_medium_size_jis_b10, + xpoid_val_medium_size_hp_2x_postcard, + xpoid_val_medium_size_hp_european_edp, + xpoid_val_medium_size_hp_mini, + xpoid_val_medium_size_hp_postcard, + xpoid_val_medium_size_hp_tabloid, + xpoid_val_medium_size_hp_us_edp, + xpoid_val_medium_size_hp_us_government_legal, + xpoid_val_medium_size_hp_us_government_letter, xpoid_val_plex_simplex, xpoid_val_plex_duplex, xpoid_val_plex_tumble, Index: xc/programs/Xserver/Xprint/OidStrs.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/OidStrs.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 OidStrs.h --- a/xc/programs/Xserver/Xprint/OidStrs.h 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/OidStrs.h 21 Apr 2004 09:35:08 -0000 @@ -30,140 +30,144 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/OidStrs.h,v 1.4 2001/01/17 22:36:28 dawes Exp $ */ +/* This is an automatically-generated file. Do not edit. */ static int XpOidStringMapCount = 127; -#define OIDATA(name) { name, sizeof(name)-1, 0, 0, 0 } - static const XpOidStringMapEntry XpOidStringMap[] = { - OIDATA(""), - OIDATA(""), - OIDATA("descriptor"), - OIDATA("content-orientation"), - OIDATA("copy-count"), - OIDATA("default-printer-resolution"), - OIDATA("default-input-tray"), - OIDATA("default-medium"), - OIDATA("document-format"), - OIDATA("plex"), - OIDATA("xp-listfonts-modes"), - OIDATA("job-name"), - OIDATA("job-owner"), - OIDATA("notification-profile"), - OIDATA("xp-setup-state"), - OIDATA("xp-spooler-command-options"), - OIDATA("content-orientations-supported"), - OIDATA("document-formats-supported"), - OIDATA("dt-pdm-command"), - OIDATA("input-trays-medium"), - OIDATA("medium-source-sizes-supported"), - OIDATA("plexes-supported"), - OIDATA("printer-model"), - OIDATA("printer-name"), - OIDATA("printer-resolutions-supported"), - OIDATA("xp-embedded-formats-supported"), - OIDATA("xp-listfonts-modes-supported"), - OIDATA("xp-page-attributes-supported"), - OIDATA("xp-raw-formats-supported"), - OIDATA("xp-setup-proviso"), - OIDATA("document-attributes-supported"), - OIDATA("job-attributes-supported"), - OIDATA("locale"), - OIDATA("multiple-documents-supported"), - OIDATA("available-compression"), - OIDATA("available-compressions-supported"), - OIDATA("portrait"), - OIDATA("landscape"), - OIDATA("reverse-portrait"), - OIDATA("reverse-landscape"), - OIDATA("iso-a0"), - OIDATA("iso-a1"), - OIDATA("iso-a2"), - OIDATA("iso-a3"), - OIDATA("iso-a4"), - OIDATA("iso-a5"), - OIDATA("iso-a6"), - OIDATA("iso-a7"), - OIDATA("iso-a8"), - OIDATA("iso-a9"), - OIDATA("iso-a10"), - OIDATA("iso-b0"), - OIDATA("iso-b1"), - OIDATA("iso-b2"), - OIDATA("iso-b3"), - OIDATA("iso-b4"), - OIDATA("iso-b5"), - OIDATA("iso-b6"), - OIDATA("iso-b7"), - OIDATA("iso-b8"), - OIDATA("iso-b9"), - OIDATA("iso-b10"), - OIDATA("na-letter"), - OIDATA("na-legal"), - OIDATA("executive"), - OIDATA("folio"), - OIDATA("invoice"), - OIDATA("ledger"), - OIDATA("quarto"), - OIDATA("iso-c3"), - OIDATA("iso-c4"), - OIDATA("iso-c5"), - OIDATA("iso-c6"), - OIDATA("iso-designated-long"), - OIDATA("na-10x13-envelope"), - OIDATA("na-9x12-envelope"), - OIDATA("na-number-10-envelope"), - OIDATA("na-7x9-envelope"), - OIDATA("na-9x11-envelope"), - OIDATA("na-10x14-envelope"), - OIDATA("na-number-9-envelope"), - OIDATA("na-6x9-envelope"), - OIDATA("na-10x15-envelope"), - OIDATA("monarch-envelope"), - OIDATA("a"), - OIDATA("b"), - OIDATA("c"), - OIDATA("d"), - OIDATA("e"), - OIDATA("jis-b0"), - OIDATA("jis-b1"), - OIDATA("jis-b2"), - OIDATA("jis-b3"), - OIDATA("jis-b4"), - OIDATA("jis-b5"), - OIDATA("jis-b6"), - OIDATA("jis-b7"), - OIDATA("jis-b8"), - OIDATA("jis-b9"), - OIDATA("jis-b10"), - OIDATA("simplex"), - OIDATA("duplex"), - OIDATA("tumble"), - OIDATA("top"), - OIDATA("middle"), - OIDATA("bottom"), - OIDATA("envelope"), - OIDATA("manual"), - OIDATA("large-capacity"), - OIDATA("main"), - OIDATA("side"), - OIDATA("event-report-job-completed"), - OIDATA("electronic-mail"), - OIDATA("xp-setup-mandatory"), - OIDATA("xp-setup-optional"), - OIDATA("xp-setup-ok"), - OIDATA("xp-setup-incomplete"), - OIDATA("xp-list-glyph-fonts"), - OIDATA("xp-list-internal-printer-fonts"), - OIDATA("0"), - OIDATA("01"), - OIDATA("02"), - OIDATA("03"), - OIDATA("012"), - OIDATA("013"), - OIDATA("023"), - OIDATA("0123") + { "", 0 }, + { "", 0 }, + { "descriptor", 10 }, + { "content-orientation", 19 }, + { "copy-count", 10 }, + { "default-printer-resolution", 26 }, + { "default-input-tray", 18 }, + { "default-medium", 14 }, + { "document-format", 15 }, + { "plex", 4 }, + { "xp-listfonts-modes", 18 }, + { "job-name", 8 }, + { "job-owner", 9 }, + { "notification-profile", 20 }, + { "xp-setup-state", 14 }, + { "xp-spooler-command-options", 26 }, + { "content-orientations-supported", 30 }, + { "document-formats-supported", 26 }, + { "dt-pdm-command", 14 }, + { "input-trays-medium", 18 }, + { "medium-source-sizes-supported", 29 }, + { "plexes-supported", 16 }, + { "printer-model", 13 }, + { "printer-name", 12 }, + { "printer-resolutions-supported", 29 }, + { "xp-embedded-formats-supported", 29 }, + { "xp-listfonts-modes-supported", 28 }, + { "xp-page-attributes-supported", 28 }, + { "xp-raw-formats-supported", 24 }, + { "xp-setup-proviso", 16 }, + { "document-attributes-supported", 29 }, + { "job-attributes-supported", 24 }, + { "locale", 6 }, + { "multiple-documents-supported", 28 }, + { "available-compression", 21 }, + { "available-compressions-supported", 32 }, + { "portrait", 8 }, + { "landscape", 9 }, + { "reverse-portrait", 16 }, + { "reverse-landscape", 17 }, + { "iso-a0", 6 }, + { "iso-a1", 6 }, + { "iso-a2", 6 }, + { "iso-a3", 6 }, + { "iso-a4", 6 }, + { "iso-a5", 6 }, + { "iso-a6", 6 }, + { "iso-a7", 6 }, + { "iso-a8", 6 }, + { "iso-a9", 6 }, + { "iso-a10", 7 }, + { "iso-b0", 6 }, + { "iso-b1", 6 }, + { "iso-b2", 6 }, + { "iso-b3", 6 }, + { "iso-b4", 6 }, + { "iso-b5", 6 }, + { "iso-b6", 6 }, + { "iso-b7", 6 }, + { "iso-b8", 6 }, + { "iso-b9", 6 }, + { "iso-b10", 7 }, + { "na-letter", 9 }, + { "na-legal", 8 }, + { "executive", 9 }, + { "folio", 5 }, + { "invoice", 7 }, + { "ledger", 6 }, + { "quarto", 6 }, + { "iso-c3", 6 }, + { "iso-c4", 6 }, + { "iso-c5", 6 }, + { "iso-c6", 6 }, + { "iso-designated-long", 19 }, + { "na-10x13-envelope", 17 }, + { "na-9x12-envelope", 16 }, + { "na-number-10-envelope", 21 }, + { "na-7x9-envelope", 15 }, + { "na-9x11-envelope", 16 }, + { "na-10x14-envelope", 17 }, + { "na-number-9-envelope", 20 }, + { "na-6x9-envelope", 15 }, + { "na-10x15-envelope", 17 }, + { "monarch-envelope", 16 }, + { "a", 1 }, + { "b", 1 }, + { "c", 1 }, + { "d", 1 }, + { "e", 1 }, + { "jis-b0", 6 }, + { "jis-b1", 6 }, + { "jis-b2", 6 }, + { "jis-b3", 6 }, + { "jis-b4", 6 }, + { "jis-b5", 6 }, + { "jis-b6", 6 }, + { "jis-b7", 6 }, + { "jis-b8", 6 }, + { "jis-b9", 6 }, + { "jis-b10", 7 }, + { "hp-2x-postcard", 14 }, + { "hp-european-edp", 15 }, + { "hp-mini", 7 }, + { "hp-postcard", 11 }, + { "hp-tabloid", 10 }, + { "hp-us-edp", 9 }, + { "hp-us-government-legal", 22 }, + { "hp-us-government-letter", 23 }, + { "simplex", 7 }, + { "duplex", 6 }, + { "tumble", 6 }, + { "top", 3 }, + { "middle", 6 }, + { "bottom", 6 }, + { "envelope", 8 }, + { "manual", 6 }, + { "large-capacity", 14 }, + { "main", 4 }, + { "side", 4 }, + { "event-report-job-completed", 26 }, + { "electronic-mail", 15 }, + { "xp-setup-mandatory", 18 }, + { "xp-setup-optional", 17 }, + { "xp-setup-ok", 11 }, + { "xp-setup-incomplete", 19 }, + { "xp-list-glyph-fonts", 19 }, + { "xp-list-internal-printer-fonts", 30 }, + { "0", 1 }, + { "01", 2 }, + { "02", 2 }, + { "03", 2 }, + { "012", 3 }, + { "013", 3 }, + { "023", 3 }, + { "0123", 4 } }; - -#undef OIDATA Index: xc/programs/Xserver/Xprint/Xprint.html =================================================================== RCS file: xc/programs/Xserver/Xprint/Xprint.html diff -N xc/programs/Xserver/Xprint/Xprint.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/Xprint.html 21 Apr 2004 09:35:09 -0000 @@ -0,0 +1,296 @@ +Xprint

Name

Xprint — The "X print service" - a portable, network-transparent printing system based on the X11 protocol

Synopsis

Xprint is a very flexible, extensible, scaleable, client/server + print system based on ISO 10175 (and some other specs) and the X11 + rendering protocol. + Using Xprint an application can search, query and use devices like + printers, FAX machines or create documents in formats like PDF. + In particular, an application can seek a printer, query supported + attributes (like paper size, trays, fonts etc.), configure the printer + device to match it’s needs and print on it like on any other X device + reusing parts of the code which is used for the video card Xserver. +

OVERVIEW

+ The "X Print Service" technology allows X rendering to devices such as + printers and fax. Most of the service is available in the X11 + technology stack as Xp, with the remainder in single toolkit stacks (e.g. DtPrint for CDE). + Modifications have also been made to the LessTif/Motif/Qt technology + stacks to support Xprint. +

+ The Xp portion consists of: +

  • Xp Extension for the X-Server (included in the X-Server Xprt)

  • Xp Extension API for the client side (libXp/libXprintUtils)

  • PCL ddx driver that converts core X to native PCL

  • PDF ddx driver that converts core X to native PDF

  • PostScript ddx driver that converts core X to native PostScript

  • Raster ddx driver that generates xwd rasters which can be converted to PCL, PDF or PostScript rasters

+ From an X clients perspective, it can attach to one of two nearly + identical X-Servers, a "Video" X-Server, and a "Print" X-Server + which has the additional Xp capability but otherwise looks and + behaves the same. +

HOW THE X PRINT SERVICE WORKS

+ The X Print Service expands on the traditional X-Server and Xlib world + in four ways. + +

  1. + Most obvious is the use of "print ddx drivers" instead of + "video ddx drivers". While a video ddx driver modifies pixels + in a video frame buffer, a print ddx driver generates "page + description language (PDL)" output (such as PCL, PDF or PostScript) + or sends the print rendering instructions to a platform-specific + print API (like Win32/GDI). +

    + Once a print ddx driver generates PDL output, it can be sent to + a spooler such as lp(1) + or retrieved by the client (to implement functionality like "print-to-file"). +

    + Though not currently done, a single X-Server can support both + print and video ddx drivers. +

  2. + Since printers support "paged" output, unlike video, a portion + of the Xp Extension supports APIs to delineate printed output. + For example, XpStartPage and XpEndPage tell the X-Server where + a physical page starts and ends in an otherwise continuous + stream of X rendering primitives. Likewise, XpStartJob and + XpEndJob determine when a collection of pages starts and ends. + XpEndJob typically causes the generated PDL to be submitted to + a spooler, such as lp(1). +

  3. + Since printers have extensive capabilities, another portion of + the Xp Extension supports APIs to manipulate "print contexts". +

    + Once a printer is selected using the Xp Extension API, a print + context to represent it can be created. A print context + embodies the printer selected - it contains the printer's + default capabilities, selectable range of capabilities, + printer state, and generated output. Some "attributes" within + the print context can be modified by the user, and the + X-Server and print ddx driver will react accordingly. For + example, the attribute "content-orientation" can be set to + "landscape" or "portrait" (if the printer supports these + values - which can be queried using the Xprint API as well). +

  4. + Since printers can have "built in" fonts, the Xp Extension in + the X-Server works with the print ddx drivers to make + available (for printing only) additional fonts on a per print + context basis. +

    + When a print context is created and set for a given printer, + the X font calls may be able to access additional printer + fonts. To do this (typically), the X-Server must have access + to "printer metric files" (.pmf) that describe at minimum the + metrics of the built in fonts. +

USAGE

+ There are three tasks to start the X Print Service: +

  1. configuring the X Print Server,

  2. starting the X Print Service

  3. configuring the user session so that clients can find the running X Print Service

+ The tasks are described in detail below. +

SERVER CONFIGURATION

+ The X Print Server (Xprt) can read a number of configuration files which + control its behavior and support for printers. Each vendor platform has + a default location for this information. Xprt can also read the + environment variable XPCONFIGDIR to locate alternate configuration + directories. Common settings include: + +

export XPCONFIGDIR=/X11/lib/X11/XpConfig/
export XPCONFIGDIR=/proj/x11/xc/programs/Xserver/XpConfig/

+ Xprt has many built-in defaults, and lacking any configuration files, + will immediately try to support all printers visible via lpstat(1). +

+ In order of importance for configuration by a system administrator, the + configuration files for a "C" locale are as follows (see Xprt(1x) for more + details (including support for non-"C" locales)): +

${XPCONFIGDIR}/C/print/Xprinters

+ 'Xprinters' is the top most configuration file. It tells + Xprt which specific printer names (e.g. mylaser) should + be supported, and whether lpstat(1) or other commands + should be used to automatically supplement the list of + printers. +

${XPCONFIGDIR}/C/print/attributes/printer

+ The 'printer' file maps printer names to model + configurations (see 'model-config' below). For example, + "mylaser" could be mapped to a "HPDJ1600C", and all other + arbitrary printers could be mapped to a default, such as + "HPLJ4SI". When depending on lpstat(1) in the Xprinters + file, setting up defaults in 'printer' becomes all the + more important. +

${XPCONFIGDIR}/C/print/attributes/document

+ The 'document' file specifies the initial document values + for any print jobs. For example, which paper tray to + use, what default resolution, etc. +

${XPCONFIGDIR}/C/print/attributes/job

+ The 'job' file specifies the initial job values for any + print jobs. For example, "notification-profile" can be + set so that when a print job is successfully sent to a + printer, e-mail is sent to the user. +

${XPCONFIGDIR}/C/print/models/PSdefault/model-config, ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir, ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf, ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf

+ The 'model-config' file has attributes that describe the + printer model’s capabilities and default settings. + Printer model fonts may also be present. The model-config + file also identifies the print ddx driver to be used. + + For each printer model supported, a complete hierarchy of + files should exist. In most cases, these files do not + need to be modified. +

${XPCONFIGDIR}/C/print/ddx-config/raster/pcl, ${XPCONFIGDIR}/C/print/ddx-config/raster/pdf, ${XPCONFIGDIR}/C/print/ddx-config/raster/postscript

+ The print ddx drivers can have highly specific + configuration files to control their behavior. In most + cases, these files do not need to be modified. +

+ + More information in how to configure and customize the X print server can be found in the + Xprt(1x) + manual page. +

STARTING UP

+ The summary checklist for starting the X Print Service is as follows: + +

  1. + Choose an execution model for the X Print Service. The X + Print Service can be run on a per-user session basis, per + machine basis, or can be run on a few machines globally + available to a number of users. +

  2. + If print jobs are to be submitted to a spooler (almost always + the case), make sure all needed printers are available to the + spooler subsystem (most often lp(1)) + on the same machine running the X Print Service. +

  3. + Configure the X Print Server. See ``X Print Server + Configuration''. +

  4. + Depending on #1, start the X Print Server process "Xprt", and + then the toolkit-specific Print Dialog Manager Daemon process + (such as CDEnext's "dtpdmd") at the appropriate times. + Note that libXprintUtils-based applications/toolkits do not need + a Print Dialog Manager Daemon process to use Xprint. +

+ The details are described below. +

+ Because the X Print Service is based on X, it can be easily distributed. + The most significant factors in which execution model to choose will be + driven by: +

  • + how many printers will be accessable through the printer + subsystem on any given machine. A system administrator may + choose to cluster printers on a few given machines, or + scatter them across an organization and possibly make + extensive use of remote spoolers to make them globally + available. +

  • + how many machines will need a copy of the X Print Server + configuration files. The files have been architected so + that one super-set version of them can be maintained and + distributed (e.g. via NFS), and a per-machine or per-user + version of the `Xprinters' is all that is needed to have the + appropriate information in them utilized or ignored. +

  • + how many users can demand services from a given X Print + Service. +

+ + With the above in mind, some obvious execution models include: +

  • + Global - in this model, the system administrator is choosing + to run the X Print Service on a *few* select machines with + appropriate printers configured, and allow clients access to + the global resource. This can centralize the administration + of printers and configuration files, but may have to be + monitored for performance loading. +

    + Startup would likely be done by boot-up scripts (such as /etc/init.d/xprint). +

  • + Per-machine - every machine with potential X Print Service + users would run the service. Printer and configuration file + administration is decentralized, and usage would be limited + to the users on the machine. +

    + Startup would likely be done by boot-up scripts (such as /etc/init.d/xprint). +

  • + Per-user session - every user would run an entire X Print + Service for themselves. In the future, the Video X Server + normally started may contain Print X Server capability, so + this model becomes very natural. +

    + Startup would likely be done at session login or by + launching actions or processes manually once the user + logs in. Note: Deamons like "dtpdmd" must be started after Xprt. +

+ Starting of the processes is straight forward. In strict order (example is for manually starting the X print server for CDEnext usage): +

  1. [machineA] % Xprt [-XpFile Xprinters file] [:dispNum] 

    + Note that Xprt will look for configuration files in either + a default location or where XPCONFIGDIR points. +

    -XpFile specifies an alternate `Xprinters' file, rather + than the default one or `${XPCONFIGDIR}/C/print/Xprinters'. +

  2. [machineA] % dtpdmd -d machineA[:dispNum] [-l /tmp/dtpdmd.log] 

    + The dtpdmd will maintain an X-Selection on the X-Server, + and will start dtpdm's as required to service requests. +

+ In all but the per-user session model, the machine running the dtpdmd + (thus dtpdm's) will need display authorization to the users video + display. +

CLIENT CONFIGURATION

+ Once a X Print Server and dtpdmd have been started -- many of them + in some cases -- clients will need to find and use them. There are + two mechanisms that allow clients to discover X Print Servers and + printers. + +

  • + "X Print Specifier" - assuming usage of the DtPrint/XprintUtils-based print + applications, the following notation is understood: +

    printer_name@machine[:dispNum]

    + For example: +

    colorlj7@printhub:2

    + In the above example, the X Print Server running at `printhub:2' + is assumed to support the printer named `colorlj7'. +

  • ${XPSERVERLIST} - assuming usage of the DtPrint print dialogs, + the environment variable ${XPSERVERLIST} can contain a list + of X Print Servers. For example: +

    XPSERVERLIST="printhub:2 printhub:3 otherdept:0"

    + Then in the dialogs, only a printer name needs to be entered. + The dialog will then search the X Print Servers in ${XPSERVERLIST} + for a server than supports the printer, and then establish + contact. +

END-USER SEQUENCE

+ From most CDEnext applications, printing is accomplished by bringing + down the File menu and selecting Print.... This will result in + the DtPrintSetupBox dialog, which will request the name of a printer, + and offer limited capability to configure print options (e.g. number + of copies). If the user wishes, they can select Setup..., which + will start a dtpdm capable of modifying additional print options. + Finally, the user should select Print. +

ENVIRONMENT

${XPCONFIGDIR}

This environment variable points to the root + of the Xprint server configuration directory hierarchy. + If the variable is not defined, the default + path is be assumed. The default path may be + /usr/X11R6/lib/X11/xserver/, + /usr/lib/X11/xserver/, + /usr/share/Xprint/xserver/ or + /usr/openwin/server/etc/XpConfig, depending on the + system, and may be configured in /etc/init.d/xprint.

${LANG}

+ This environment variable selects the locale settings used by the Xprint server. + Xprt allows language-specific settings (stored in ${XPCONFIGDIR}/${LANG}/print/) + which will override the default settings (stored in ${XPCONFIGDIR}/C/print/). + If ${LANG} is not set "C" is assumed. +

${XPSERVERLIST}

The environment variable ${XPSERVERLIST} contains a list + of display identifiers (separated by whitespace) which tell an + application where it can find the Xprint servers. Usually + ${XPSERVERLIST} is set by the profile startup scripts (e.g. + /etc/profile or /etc/profile.d/xprint.sh) using the output of + /etc/init.d/xprint get_xpserverlist.

Example: +

+		export XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`"

Alternatively ${XPSERVERLIST} can be set + manually. Example:

+		export XPSERVERLIST="littlecat:80 bitdog:72"

+ instructs an application to find an Xprint server at display + 80 on the machine "littlecat" and at display 72 on the + machine bigdog. +

${XPRINTER}

The environment variable ${XPRINTER} + defines the default printer used by print + applications. The syntax is either + printername or + printername@display.

Examples: +

XPRINTER=ps003

+ tells an application to look for the + first printer named "ps003" on all Xprint + servers.

XPRINTER=hplaser19@littlecat:80

+ tells an application to use the printer "hplaser19" + on the Xprint server at display + "littlecat:80".

If ${XPRINTER} is not set the applications + will examine the values of the ${PDPRINTER}, + ${LPDEST}, and + ${PRINTER} environment variables (in that order). +

SEE ALSO

X11(7), xplsprinters(1x), xphelloworld(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/)

AUTHORS

+ This manual page was written by + Roland Mainz based on the original X11R6.6 + xc/programs/Xserver/XpConfig/README. +

Index: xc/programs/Xserver/Xprint/Xprint.man =================================================================== RCS file: xc/programs/Xserver/Xprint/Xprint.man diff -N xc/programs/Xserver/Xprint/Xprint.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/Xprint.man 21 Apr 2004 09:35:09 -0000 @@ -0,0 +1,415 @@ +.\" 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 "Xprint" "__miscmansuffix__" "13 February 2004" "" "" +.SH NAME +Xprint \- The \&"X print service\&" - a portable, network-transparent printing system based on the X11 protocol +.SH SYNOPSIS +.PP +Xprint is a very flexible, extensible, scaleable, client/server +print system based on ISO 10175 (and some other specs) and the X11 +rendering protocol. +Using Xprint an application can search, query and use devices like +printers, FAX machines or create documents in formats like PDF. +In particular, an application can seek a printer, query supported +attributes (like paper size, trays, fonts etc.), configure the printer +device to match its needs and print on it like on any other X device +reusing parts of the code which is used for the video card Xserver. +.SH "OVERVIEW" +.PP +The "X Print Service" technology allows X rendering to devices such as +printers and fax. Most of the service is available in the X11 +technology stack as Xp, with the remainder in single toolkit stacks (e.g. DtPrint for CDE). +Modifications have also been made to the LessTif/Motif/Qt technology +stacks to support Xprint. +.PP +The Xp portion consists of: +.TP 0.2i +\(bu +Xp Extension for the X-Server (included in the X-Server Xprt) +.TP 0.2i +\(bu +Xp Extension API for the client side (libXp/libXprintUtils) +.TP 0.2i +\(bu +PCL ddx driver that converts core X to native PCL +.TP 0.2i +\(bu +PDF ddx driver that converts core X to native PDF +.TP 0.2i +\(bu +PostScript ddx driver that converts core X to native PostScript +.TP 0.2i +\(bu +Raster ddx driver that generates xwd rasters which can be converted to PCL, PDF or PostScript rasters +.PP +From an X clients perspective, it can attach to one of two nearly +identical X-Servers, a "Video" X-Server, and a "Print" X-Server +which has the additional Xp capability but otherwise looks and +behaves the same. +.SH "HOW THE X PRINT SERVICE WORKS" +.PP +The X Print Service expands on the traditional X-Server and Xlib world +in four ways. +.TP 1. +Most obvious is the use of "print ddx drivers" instead of +"video ddx drivers". While a video ddx driver modifies pixels +in a video frame buffer, a print ddx driver generates "page +description language (PDL)" output (such as PCL, PDF or PostScript) +or sends the print rendering instructions to a platform-specific +print API (like Win32/GDI). + +Once a print ddx driver generates PDL output, it can be sent to +a spooler such as \fBlp\fR(1) +or retrieved by the client (to implement functionality like "print-to-file"). + +Though not currently done, a single X-Server can support both +print and video ddx drivers. +.TP 2. +Since printers support "paged" output, unlike video, a portion +of the Xp Extension supports APIs to delineate printed output. +For example, \fBXpStartPage\fR and \fBXpEndPage\fR tell the X-Server where +a physical page starts and ends in an otherwise continuous +stream of X rendering primitives. Likewise, \fBXpStartJob\fR and +\fBXpEndJob\fR determine when a collection of pages starts and ends. +\fBXpEndJob\fR typically causes the generated PDL to be submitted to +a spooler, such as \fBlp\fR(1). +.TP 3. +Since printers have extensive capabilities, another portion of +the Xp Extension supports APIs to manipulate "print contexts". + +Once a printer is selected using the Xp Extension API, a print +context to represent it can be created. A print context +embodies the printer selected - it contains the printer's +default capabilities, selectable range of capabilities, +printer state, and generated output. Some "attributes" within +the print context can be modified by the user, and the +X-Server and print ddx driver will react accordingly. For +example, the attribute "content-orientation" can be set to +"landscape" or "portrait" (if the printer supports these +values - which can be queried using the Xprint API as well). +.TP 4. +Since printers can have "built in" fonts, the Xp Extension in +the X-Server works with the print ddx drivers to make +available (for printing only) additional fonts on a per print +context basis. + +When a print context is created and set for a given printer, +the X font calls may be able to access additional printer +fonts. To do this (typically), the X-Server must have access +to "printer metric files" (.pmf) that describe at minimum the +metrics of the built in fonts. +.SH "USAGE" +.PP +There are three tasks to start the X Print Service: +.TP 1. +configuring the X Print Server, +.TP 2. +starting the X Print Service +.TP 3. +configuring the user session so that clients can find the running X Print Service +.PP +The tasks are described in detail below. +.SH "SERVER CONFIGURATION" +.PP +The X Print Server (Xprt) can read a number of configuration files which +control its behavior and support for printers. Each vendor platform has +a default location for this information. Xprt can also read the +environment variable \fBXPCONFIGDIR\fR to locate alternate configuration +directories. Common settings include: + +export XPCONFIGDIR=/X11/lib/X11/XpConfig/ + +export XPCONFIGDIR=/proj/x11/xc/programs/Xserver/XpConfig/ +.PP +Xprt has many built-in defaults, and lacking any configuration files, +will immediately try to support all printers visible via \fBlpstat\fR(1). +.PP +In order of importance for configuration by a system administrator, the +configuration files for a "C" locale are as follows (see \fBXprt\fR(__mansuffix__) for more +details (including support for non-"C" locales)): +.TP +\fB\fI${XPCONFIGDIR}/C/print/Xprinters\fB\fR +\&'Xprinters' is the top most configuration file. It tells +Xprt which specific printer names (e.g. mylaser) should +be supported, and whether \fBlpstat\fR(1) or other commands +should be used to automatically supplement the list of +printers. +.TP +\fB\fI${XPCONFIGDIR}/C/print/attributes/printer\fB\fR +The 'printer' file maps printer names to model +configurations (see 'model-config' below). For example, +"mylaser" could be mapped to a "HPDJ1600C", and all other +arbitrary printers could be mapped to a default, such as +"HPLJ4SI". When depending on \fBlpstat\fR(1) in the Xprinters +file, setting up defaults in 'printer' becomes all the +more important. +.TP +\fB\fI${XPCONFIGDIR}/C/print/attributes/document\fB\fR +The 'document' file specifies the initial document values +for any print jobs. For example, which paper tray to +use, what default resolution, etc. +.TP +\fB\fI${XPCONFIGDIR}/C/print/attributes/job\fB\fR +The 'job' file specifies the initial job values for any +print jobs. For example, "notification-profile" can be +set so that when a print job is successfully sent to a +printer, e-mail is sent to the user. +.TP +\fB\fI${XPCONFIGDIR}/C/print/models/PSdefault/model-config\fB\fR +.TP +\fB\fI${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir\fB\fR +.TP +\fB\fI${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf\fB\fR +.TP +\fB\fI${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf\fB\fR +The 'model-config' file has attributes that describe the +printer models capabilities and default settings. +Printer model fonts may also be present. The model-config +file also identifies the print ddx driver to be used. +For each printer model supported, a complete hierarchy of +files should exist. In most cases, these files do not +need to be modified. +.TP +\fB\fI${XPCONFIGDIR}/C/print/ddx-config/raster/pcl\fB\fR +.TP +\fB\fI${XPCONFIGDIR}/C/print/ddx-config/raster/pdf\fB\fR +.TP +\fB\fI${XPCONFIGDIR}/C/print/ddx-config/raster/postscript\fB\fR +The print ddx drivers can have highly specific +configuration files to control their behavior. In most +cases, these files do not need to be modified. +More information in how to configure and customize the X print server can be found in the +\fBXprt\fR(__mansuffix__) +manual page. +.SH "STARTING UP" +.PP +The summary checklist for starting the X Print Service is as follows: +.TP 1. +Choose an execution model for the X Print Service. The X +Print Service can be run on a per-user session basis, per +machine basis, or can be run on a few machines globally +available to a number of users. +.TP 2. +If print jobs are to be submitted to a spooler (almost always +the case), make sure all needed printers are available to the +spooler subsystem (most often \fBlp\fR(1)) +on the same machine running the X Print Service. +.TP 3. +Configure the X Print Server. See ``X Print Server +Configuration''. +.TP 4. +Depending on #1, start the X Print Server process "Xprt", and +then the toolkit-specific Print Dialog Manager Daemon process +(such as CDEnext's "dtpdmd") at the appropriate times. +Note that libXprintUtils-based applications/toolkits do not need +a Print Dialog Manager Daemon process to use Xprint. +The details are described below. +.PP +Because the X Print Service is based on X, it can be easily distributed. +The most significant factors in which execution model to choose will be +driven by: +.TP 0.2i +\(bu +how many printers will be accessable through the printer +subsystem on any given machine. A system administrator may +choose to cluster printers on a few given machines, or +scatter them across an organization and possibly make +extensive use of remote spoolers to make them globally +available. +.TP 0.2i +\(bu +how many machines will need a copy of the X Print Server +configuration files. The files have been architected so +that one super-set version of them can be maintained and +distributed (e.g. via NFS), and a per-machine or per-user +version of the `Xprinters' is all that is needed to have the +appropriate information in them utilized or ignored. +.TP 0.2i +\(bu +how many users can demand services from a given X Print +Service. +With the above in mind, some obvious execution models include: +.TP 0.2i +\(bu +Global - in this model, the system administrator is choosing +to run the X Print Service on a *few* select machines with +appropriate printers configured, and allow clients access to +the global resource. This can centralize the administration +of printers and configuration files, but may have to be +monitored for performance loading. + +Startup would likely be done by boot-up scripts (such as \fI/etc/init.d/xprint\fR). +.TP 0.2i +\(bu +Per-machine - every machine with potential X Print Service +users would run the service. Printer and configuration file +administration is decentralized, and usage would be limited +to the users on the machine. + +Startup would likely be done by boot-up scripts (such as \fI/etc/init.d/xprint\fR). +.TP 0.2i +\(bu +Per-user session - every user would run an entire X Print +Service for themselves. In the future, the Video X Server +normally started may contain Print X Server capability, so +this model becomes very natural. + +Startup would likely be done at session login or by +launching actions or processes manually once the user +logs in. Note: Deamons like "dtpdmd" must be started after Xprt. +.PP +Starting of the processes is straight forward. In strict order (example is for manually starting the X print server for CDEnext usage): +.TP 1. + +.nf +[machineA] % Xprt [-XpFile Xprinters file] [:dispNum] +.fi + +Note that Xprt will look for configuration files in either +a default location or where \fBXPCONFIGDIR\fR points. + +\fB-XpFile\fR specifies an alternate `Xprinters' file, rather +than the default one or `\fI${XPCONFIGDIR}/C/print/Xprinters\fR'. +.TP 2. + +.nf +[machineA] % dtpdmd -d machineA[:dispNum] [-l /tmp/dtpdmd.log] +.fi + +The dtpdmd will maintain an X-Selection on the X-Server, +and will start dtpdm's as required to service requests. +.PP +In all but the per-user session model, the machine running the dtpdmd +(thus dtpdm's) will need display authorization to the users video +display. +.SH "CLIENT CONFIGURATION" +.PP +Once a X Print Server and dtpdmd have been started -- many of them +in some cases -- clients will need to find and use them. There are +two mechanisms that allow clients to discover X Print Servers and +printers. +.TP 0.2i +\(bu +"X Print Specifier" - assuming usage of the DtPrint/XprintUtils-based print +applications, the following notation is understood: + + +.nf +printer_name@machine[:dispNum] +.fi + +For example: + + +.nf +colorlj7@printhub:2 +.fi + +In the above example, the X Print Server running at `printhub:2' +is assumed to support the printer named `colorlj7'. +.TP 0.2i +\(bu +\fB${XPSERVERLIST}\fR - assuming usage of the DtPrint print dialogs, +the environment variable \fB${XPSERVERLIST}\fR can contain a list +of X Print Servers. For example: + + +.nf +XPSERVERLIST="printhub:2 printhub:3 otherdept:0" +.fi + +Then in the dialogs, only a printer name needs to be entered. +The dialog will then search the X Print Servers in \fB${XPSERVERLIST}\fR +for a server than supports the printer, and then establish +contact. +.SH "END-USER SEQUENCE" +.PP +From most CDEnext applications, printing is accomplished by bringing +down the File menu and selecting Print.... This will result in +the DtPrintSetupBox dialog, which will request the name of a printer, +and offer limited capability to configure print options (e.g. number +of copies). If the user wishes, they can select Setup..., which +will start a dtpdm capable of modifying additional print options. +Finally, the user should select Print. +.SH "ENVIRONMENT" +.TP +\fB${XPCONFIGDIR}\fR +This environment variable points to the root +of the Xprint server configuration directory hierarchy. +If the variable is not defined, the default +path is be assumed. The default path may be +\fI/usr/X11R6/lib/X11/xserver/\fR, +\fI/usr/lib/X11/xserver/\fR, +\fI/usr/share/Xprint/xserver/\fR or +\fI/usr/openwin/server/etc/XpConfig\fR, depending on the +system, and may be configured in \fI/etc/init.d/xprint\fR. +.TP +\fB${LANG}\fR +This environment variable selects the locale settings used by the Xprint server. +Xprt allows language-specific settings (stored in \fI${XPCONFIGDIR}/${LANG}/print/\fR) +which will override the default settings (stored in \fI${XPCONFIGDIR}/C/print/\fR). +If \fB${LANG}\fR is not set "C" is assumed. +.TP +\fB${XPSERVERLIST}\fR +The environment variable \fB${XPSERVERLIST}\fR contains a list +of display identifiers (separated by whitespace) which tell an +application where it can find the Xprint servers. Usually +\fB${XPSERVERLIST}\fR is set by the profile startup scripts (e.g. +\fI/etc/profile\fR or \fI/etc/profile.d/xprint.sh\fR) using the output of +\fB/etc/init.d/xprint get_xpserverlist\fR. + +Example: +.PP + +.nf + export XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`" +.fi + +Alternatively \fB${XPSERVERLIST}\fR can be set +manually. Example: + + +.nf + export XPSERVERLIST="littlecat:80 bitdog:72" +.fi + +instructs an application to find an Xprint server at display +80 on the machine "littlecat" and at display 72 on the +machine bigdog. +.TP +\fB${XPRINTER} \fR +The environment variable \fB${XPRINTER}\fR +defines the default printer used by print +applications. The syntax is either +\fIprintername\fR or +\fIprintername\fR@\fIdisplay\fR. + +Examples: +.RS +.TP +\fBXPRINTER=ps003\fR +tells an application to look for the +first printer named "ps003" on all Xprint +servers. +.TP +\fBXPRINTER=hplaser19@littlecat:80\fR +tells an application to use the printer "hplaser19" +on the Xprint server at display +"littlecat:80". +.RE + +If \fB${XPRINTER}\fR is not set the applications +will examine the values of the \fB${PDPRINTER}\fR, +\fB${LPDEST}\fR, and +\fB${PRINTER}\fR environment variables (in that order). +.SH "SEE ALSO" +.PP +\fBX11\fR(__miscmansuffix__), \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 ), Xprint main site (http://xprint.mozdev.org/ ) +.SH "AUTHORS" +.PP +This manual page was written by +Roland Mainz based on the original X11R6.6 +\fIxc/programs/Xserver/XpConfig/README\fR. Index: xc/programs/Xserver/Xprint/Xprint.sgml =================================================================== RCS file: xc/programs/Xserver/Xprint/Xprint.sgml diff -N xc/programs/Xserver/Xprint/Xprint.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/Xprint.sgml 21 Apr 2004 09:35:09 -0000 @@ -0,0 +1,626 @@ + + + + + + + Xprint + __miscmansuffix__ + + + Xprint + + The "X print service" - a portable, network-transparent printing system based on the X11 protocol + + + Xprint is a very flexible, extensible, scaleable, client/server + print system based on ISO 10175 (and some other specs) and the X11 + rendering protocol. + Using Xprint an application can search, query and use devices like + printers, FAX machines or create documents in formats like PDF. + In particular, an application can seek a printer, query supported + attributes (like paper size, trays, fonts etc.), configure the printer + device to match it’s needs and print on it like on any other X device + reusing parts of the code which is used for the video card Xserver. + + + + + OVERVIEW + + The "X Print Service" technology allows X rendering to devices such as + printers and fax. Most of the service is available in the X11 + technology stack as Xp, with the remainder in single toolkit stacks (e.g. DtPrint for CDE). + Modifications have also been made to the LessTif/Motif/Qt technology + stacks to support Xprint. + + + The Xp portion consists of: + + Xp Extension for the X-Server (included in the X-Server Xprt) + Xp Extension API for the client side (libXp/libXprintUtils) + PCL ddx driver that converts core X to native PCL + PDF ddx driver that converts core X to native PDF + PostScript ddx driver that converts core X to native PostScript + Raster ddx driver that generates xwd rasters which can be converted to PCL, PDF or PostScript rasters + + + + From an X clients perspective, it can attach to one of two nearly + identical X-Servers, a "Video" X-Server, and a "Print" X-Server + which has the additional Xp capability but otherwise looks and + behaves the same. + + + + + HOW THE X PRINT SERVICE WORKS + + The X Print Service expands on the traditional X-Server and Xlib world + in four ways. + + + + + Most obvious is the use of "print ddx drivers" instead of + "video ddx drivers". While a video ddx driver modifies pixels + in a video frame buffer, a print ddx driver generates "page + description language (PDL)" output (such as PCL, PDF or PostScript) + or sends the print rendering instructions to a platform-specific + print API (like Win32/GDI). + + + Once a print ddx driver generates PDL output, it can be sent to + a spooler such as lp1 + or retrieved by the client (to implement functionality like "print-to-file"). + + + Though not currently done, a single X-Server can support both + print and video ddx drivers. + + + + + + Since printers support "paged" output, unlike video, a portion + of the Xp Extension supports APIs to delineate printed output. + For example, XpStartPage and XpEndPage tell the X-Server where + a physical page starts and ends in an otherwise continuous + stream of X rendering primitives. Likewise, XpStartJob and + XpEndJob determine when a collection of pages starts and ends. + XpEndJob typically causes the generated PDL to be submitted to + a spooler, such as lp1. + + + + + Since printers have extensive capabilities, another portion of + the Xp Extension supports APIs to manipulate "print contexts". + + + Once a printer is selected using the Xp Extension API, a print + context to represent it can be created. A print context + embodies the printer selected - it contains the printer's + default capabilities, selectable range of capabilities, + printer state, and generated output. Some "attributes" within + the print context can be modified by the user, and the + X-Server and print ddx driver will react accordingly. For + example, the attribute "content-orientation" can be set to + "landscape" or "portrait" (if the printer supports these + values - which can be queried using the Xprint API as well). + + + + + Since printers can have "built in" fonts, the Xp Extension in + the X-Server works with the print ddx drivers to make + available (for printing only) additional fonts on a per print + context basis. + + + When a print context is created and set for a given printer, + the X font calls may be able to access additional printer + fonts. To do this (typically), the X-Server must have access + to "printer metric files" (.pmf) that describe at minimum the + metrics of the built in fonts. + + + + + + + + USAGE + + There are three tasks to start the X Print Service: + + configuring the X Print Server, + starting the X Print Service + configuring the user session so that clients can find the running X Print Service + + + + The tasks are described in detail below. + + + + + SERVER CONFIGURATION + + The X Print Server (Xprt) can read a number of configuration files which + control its behavior and support for printers. Each vendor platform has + a default location for this information. Xprt can also read the + environment variable XPCONFIGDIR to locate alternate configuration + directories. Common settings include: + + + export XPCONFIGDIR=/X11/lib/X11/XpConfig/ + export XPCONFIGDIR=/proj/x11/xc/programs/Xserver/XpConfig/ + + + + Xprt has many built-in defaults, and lacking any configuration files, + will immediately try to support all printers visible via lpstat1. + + + In order of importance for configuration by a system administrator, the + configuration files for a "C" locale are as follows (see Xprt__mansuffix__ for more + details (including support for non-"C" locales)): + + + ${XPCONFIGDIR}/C/print/Xprinters + + + 'Xprinters' is the top most configuration file. It tells + Xprt which specific printer names (e.g. mylaser) should + be supported, and whether lpstat1 or other commands + should be used to automatically supplement the list of + printers. + + + + + + ${XPCONFIGDIR}/C/print/attributes/printer + + + The 'printer' file maps printer names to model + configurations (see 'model-config' below). For example, + "mylaser" could be mapped to a "HPDJ1600C", and all other + arbitrary printers could be mapped to a default, such as + "HPLJ4SI". When depending on lpstat1 in the Xprinters + file, setting up defaults in 'printer' becomes all the + more important. + + + + + + ${XPCONFIGDIR}/C/print/attributes/document + + + The 'document' file specifies the initial document values + for any print jobs. For example, which paper tray to + use, what default resolution, etc. + + + + + + ${XPCONFIGDIR}/C/print/attributes/job + + + The 'job' file specifies the initial job values for any + print jobs. For example, "notification-profile" can be + set so that when a print job is successfully sent to a + printer, e-mail is sent to the user. + + + + + + ${XPCONFIGDIR}/C/print/models/PSdefault/model-config + ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/fonts.dir + ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00051.pmf + ${XPCONFIGDIR}/C/print/models/PSdefault/fonts/9nb00093.pmf + + + + The 'model-config' file has attributes that describe the + printer model’s capabilities and default settings. + Printer model fonts may also be present. The model-config + file also identifies the print ddx driver to be used. + + For each printer model supported, a complete hierarchy of + files should exist. In most cases, these files do not + need to be modified. + + + + + + ${XPCONFIGDIR}/C/print/ddx-config/raster/pcl + ${XPCONFIGDIR}/C/print/ddx-config/raster/pdf + ${XPCONFIGDIR}/C/print/ddx-config/raster/postscript + + + + The print ddx drivers can have highly specific + configuration files to control their behavior. In most + cases, these files do not need to be modified. + + + + + + More information in how to configure and customize the X print server can be found in the + Xprt__mansuffix__ + manual page. + + + + + STARTING UP + + The summary checklist for starting the X Print Service is as follows: + + + + + Choose an execution model for the X Print Service. The X + Print Service can be run on a per-user session basis, per + machine basis, or can be run on a few machines globally + available to a number of users. + + + + + If print jobs are to be submitted to a spooler (almost always + the case), make sure all needed printers are available to the + spooler subsystem (most often lp1) + on the same machine running the X Print Service. + + + + + Configure the X Print Server. See ``X Print Server + Configuration''. + + + + + Depending on #1, start the X Print Server process "Xprt", and + then the toolkit-specific Print Dialog Manager Daemon process + (such as CDEnext's "dtpdmd") at the appropriate times. + Note that libXprintUtils-based applications/toolkits do not need + a Print Dialog Manager Daemon process to use Xprint. + + + + The details are described below. + + + Because the X Print Service is based on X, it can be easily distributed. + The most significant factors in which execution model to choose will be + driven by: + + + + how many printers will be accessable through the printer + subsystem on any given machine. A system administrator may + choose to cluster printers on a few given machines, or + scatter them across an organization and possibly make + extensive use of remote spoolers to make them globally + available. + + + + + how many machines will need a copy of the X Print Server + configuration files. The files have been architected so + that one super-set version of them can be maintained and + distributed (e.g. via NFS), and a per-machine or per-user + version of the `Xprinters' is all that is needed to have the + appropriate information in them utilized or ignored. + + + + + how many users can demand services from a given X Print + Service. + + + + + With the above in mind, some obvious execution models include: + + + + Global - in this model, the system administrator is choosing + to run the X Print Service on a *few* select machines with + appropriate printers configured, and allow clients access to + the global resource. This can centralize the administration + of printers and configuration files, but may have to be + monitored for performance loading. + + + Startup would likely be done by boot-up scripts (such as /etc/init.d/xprint). + + + + + + Per-machine - every machine with potential X Print Service + users would run the service. Printer and configuration file + administration is decentralized, and usage would be limited + to the users on the machine. + + + Startup would likely be done by boot-up scripts (such as /etc/init.d/xprint). + + + + + + Per-user session - every user would run an entire X Print + Service for themselves. In the future, the Video X Server + normally started may contain Print X Server capability, so + this model becomes very natural. + + + Startup would likely be done at session login or by + launching actions or processes manually once the user + logs in. Note: Deamons like "dtpdmd" must be started after Xprt. + + + + + + Starting of the processes is straight forward. In strict order (example is for manually starting the X print server for CDEnext usage): + + + + [machineA] % Xprt [-XpFile <Xprinters file>] [:dispNum] & + + + Note that Xprt will look for configuration files in either + a default location or where XPCONFIGDIR points. + + + specifies an alternate `Xprinters' file, rather + than the default one or `${XPCONFIGDIR}/C/print/Xprinters'. + + + + + [machineA] % dtpdmd -d machineA[:dispNum] [-l /tmp/dtpdmd.log] & + + + The dtpdmd will maintain an X-Selection on the X-Server, + and will start dtpdm's as required to service requests. + + + + + + In all but the per-user session model, the machine running the dtpdmd + (thus dtpdm's) will need display authorization to the users video + display. + + + + + CLIENT CONFIGURATION + + Once a X Print Server and dtpdmd have been started -- many of them + in some cases -- clients will need to find and use them. There are + two mechanisms that allow clients to discover X Print Servers and + printers. + + + + + "X Print Specifier" - assuming usage of the DtPrint/XprintUtils-based print + applications, the following notation is understood: + + + printer_name@machine[:dispNum] + + + For example: + + + colorlj7@printhub:2 + + + In the above example, the X Print Server running at `printhub:2' + is assumed to support the printer named `colorlj7'. + + + + + ${XPSERVERLIST} - assuming usage of the DtPrint print dialogs, + the environment variable ${XPSERVERLIST} can contain a list + of X Print Servers. For example: + + + XPSERVERLIST="printhub:2 printhub:3 otherdept:0" + + + Then in the dialogs, only a printer name needs to be entered. + The dialog will then search the X Print Servers in ${XPSERVERLIST} + for a server than supports the printer, and then establish + contact. + + + + + + + + END-USER SEQUENCE + + From most CDEnext applications, printing is accomplished by bringing + down the <File> menu and selecting <Print...>. This will result in + the DtPrintSetupBox dialog, which will request the name of a printer, + and offer limited capability to configure print options (e.g. number + of copies). If the user wishes, they can select <Setup...>, which + will start a dtpdm capable of modifying additional print options. + Finally, the user should select <Print>. + + + + + ENVIRONMENT + + + ${XPCONFIGDIR} + + This environment variable points to the root + of the Xprint server configuration directory hierarchy. + If the variable is not defined, the default + path is be assumed. The default path may be + /usr/X11R6/lib/X11/xserver/, + /usr/lib/X11/xserver/, + /usr/share/Xprint/xserver/ or + /usr/openwin/server/etc/XpConfig, depending on the + system, and may be configured in /etc/init.d/xprint. + + + + + ${LANG} + + + This environment variable selects the locale settings used by the Xprint server. + Xprt allows language-specific settings (stored in ${XPCONFIGDIR}/${LANG}/print/) + which will override the default settings (stored in ${XPCONFIGDIR}/C/print/). + If ${LANG} is not set "C" is assumed. + + + + + + ${XPSERVERLIST} + + The environment variable ${XPSERVERLIST} contains a list + of display identifiers (separated by whitespace) which tell an + application where it can find the Xprint servers. Usually + ${XPSERVERLIST} is set by the profile startup scripts (e.g. + /etc/profile or /etc/profile.d/xprint.sh) using the output of + /etc/init.d/xprint get_xpserverlist. + Example: + + + export XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`" + + + Alternatively ${XPSERVERLIST} can be set + manually. Example: + + + export XPSERVERLIST="littlecat:80 bitdog:72" + + + instructs an application to find an Xprint server at display + 80 on the machine "littlecat" and at display 72 on the + machine bigdog. + + + + + + ${XPRINTER} + + + The environment variable ${XPRINTER} + defines the default printer used by print + applications. The syntax is either + printername or + printername@display. + Examples: + + + XPRINTER=ps003 + + tells an application to look for the + first printer named "ps003" on all Xprint + servers. + + + + + + XPRINTER=hplaser19@littlecat:80 + + tells an application to use the printer "hplaser19" + on the Xprint server at display + "littlecat:80". + + + + + + If ${XPRINTER} is not set the applications + will examine the values of the ${PDPRINTER}, + ${LPDEST}, and + ${PRINTER} environment variables (in that order). + + + + + + + + SEE ALSO + + + + + + + + X11__miscmansuffix__ + xplsprinters__mansuffix__ + xphelloworld__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/) + + + + + + AUTHORS + + This manual page was written by + Roland Mainz roland.mainz@nrubsig.org based on the original X11R6.6 + xc/programs/Xserver/XpConfig/README. + + + + Index: xc/programs/Xserver/Xprint/attributes.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/attributes.c,v retrieving revision 1.1.4.4 diff -u -r1.1.4.4 attributes.c --- a/xc/programs/Xserver/Xprint/attributes.c 5 Mar 2004 13:39:53 -0000 1.1.4.4 +++ b/xc/programs/Xserver/Xprint/attributes.c 21 Apr 2004 09:35:10 -0000 @@ -1,4 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/Xprint/attributes.c,v 1.1.4.4 2004/03/05 13:39:53 eich Exp $ */ /* $Xorg: attributes.c,v 1.3 2000/08/17 19:48:07 cpqbld Exp $ */ /* (c) Copyright 1996 Hewlett-Packard Company @@ -45,18 +44,15 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/attributes.c,v 1.20 2003/10/29 22:11:54 tsi Exp $ */ -#include +#include #include #include -#include #include #include #if (defined(sun) && defined(SVR4)) || (defined(SCO)) #include #endif - #include "scrnintstr.h" #include @@ -67,11 +63,13 @@ #include "Xresource.h" #include "Xrm.c" +#include "spooler.h" + static XrmDatabase CopyDb(XrmDatabase inDb); extern XrmDatabase XpSpoolerGetServerAttributes(void); -static unsigned long attrGeneration = 0; +static int attrGeneration = 0; typedef struct { XrmDatabase *pDb; @@ -138,6 +136,26 @@ static char NULL_STRING[] = "\0"; /* + * XpGetConfigDirBase returns a string containing the path name of the base + * where the print server configuration directory is localed. + */ +static +char *XpGetConfigDirBase() +{ + char **configDir; + + /* + * If the XPCONFIGDIR environment variable is not set, then use the + * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the + * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl. + */ + if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL) + configDir = XPRINTDIR; + + return configDir; +} + +/* * XpGetConfigDir returns a string containing the path name of the print * server configuration directory. If the useLocale parameter is False * the it returns the path to the "/C" directory. If the useLocale @@ -165,13 +183,7 @@ } } - /* - * If the XPCONFIGDIR environment variable is not set, then use the - * compile-time constant XPRINTDIR. XPRINTDIR is passed in on the - * compile command line, and is defined in $(TOP)/config/cf/Project.tmpl. - */ - if((configDir = getenv("XPCONFIGDIR")) == (char *)NULL) - configDir = XPRINTDIR; + configDir = XpGetConfigDirBase(); dirName = (char *)xalloc(strlen(configDir) + strlen(XPDIR) + strlen(langDir) + 1); @@ -307,7 +319,7 @@ if(systemAttributes.printers != (XrmDatabase)NULL) { - char *fileName; + char *dirName, *fileName; XrmDatabase modelDB = (XrmDatabase)NULL; XrmName xrm_name[5], xrm_class[2]; XrmRepresentation rep_type; @@ -607,6 +619,7 @@ { ContextAttrPtr pCtxtAttrs; XrmDatabase db = (XrmDatabase)NULL; + char *retVal; XrmName xrm_name[3]; XrmRepresentation rep_type; XrmValue value; @@ -670,10 +683,10 @@ */ void XpPutOneAttribute( - XpContextPtr pContext, - XPAttributes class, - const char* attributeName, - const char* value) + XpContextPtr pContext, + XPAttributes class, + const char* attributeName, + const char* value) { ContextAttrPtr pCtxtAttrs; XrmDatabase db; @@ -798,7 +811,7 @@ char *s, c; if (*type != XrmQString) - return False; + return; for (firstNameSeen = False; *quarks; bindings++, quarks++) { if (*bindings == XrmBindLoosely) { @@ -857,6 +870,7 @@ { ContextAttrPtr pCtxtAttrs; XrmDatabase db = (XrmDatabase)NULL; + char *retVal; StringDbStruct enumStruct; XrmQuark empty = NULLQUARK; @@ -1065,6 +1079,34 @@ } /* + * ExecuteCommand takes two pointers - the command to execute, + * and the "argv" style NULL-terminated vector of arguments for the command. + * We wait for the command to terminate before continuing to ensure that + * we don't delete the job file before the spooler has made a copy. + */ +static void +ExecCommand(pCommand, argVector) + char *pCommand; + char **argVector; +{ + pid_t childPid; + int status; + + if((childPid = fork()) == 0) + { + /* return BadAlloc? */ + if (execv(pCommand, argVector) == -1) { + FatalError("unable to exec '%s'", pCommand); + } + } + else + { + (void) waitpid(childPid, &status, 0); + } + return; +} + +/* * SendFileToCommand takes three character pointers - the file name, * the command to execute, * and the "argv" style NULL-terminated vector of arguments for the command. @@ -1120,7 +1162,9 @@ */ if(userName) { - if(geteuid() == (uid_t)0) + uid_t myUid; + + if((myUid = geteuid()) == (uid_t)0) { struct passwd *pPasswd; @@ -1137,6 +1181,8 @@ } else { + int res; + (void) close(pipefd[0]); outPipe = fdopen(pipefd[1], "w"); @@ -1156,6 +1202,7 @@ * store for the supplied print context. The ReplaceAnyString utility * routine is used to perform the actual replacements. */ +extern char *ReplaceAnyString(char *, char *, char *); static char * ReplaceAllKeywords( @@ -1197,6 +1244,10 @@ else command = ReplaceAnyString(command, "%options%", ""); + /* New in xprint.mozdev.org release 007 - replace "%xpconfigdir%" with + * location of $XPCONFIGDIR */ + command = ReplaceAnyString(command, "%xpconfigdir%", XpGetConfigDirBase()); + return command; } @@ -1367,43 +1418,58 @@ char ***pVector, XpContextPtr pContext) { - char *cmdName; + char *cmdName, *curTok; + int i, numChars; if(command == (char *)NULL) return (char *)NULL; - (void) GetToken(command, &cmdName); + numChars = GetToken(command, &cmdName); if(cmdName == (char *)NULL) return (char *)NULL; - *pVector = BuildArgVector(command, pContext); + /* Mangle the command name, too... */ + cmdName = ReplaceAllKeywords(pContext, cmdName); + if(cmdName == (char *)NULL) + return (char *)NULL; + + *pVector = BuildArgVector(command, pContext); + return cmdName; } -#ifdef hpux -static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -o raw -n %copy-count% -t %job-name% %options%"; -#else -static char DEFAULT_SPOOL_COMMAND[] = "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%"; -#endif - int -XpSubmitJob( - char *fileName, - XpContextPtr pContext) +XpSubmitJob(fileName, pContext) + char *fileName; + XpContextPtr pContext; { - char **vector, *cmdNam, *command, *userName; + char **vector, *cmdNam, *cmdOpt, *command, *userName; int i; command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command"); if(command == (char *)NULL || strlen(command) == 0) - command = strdup(DEFAULT_SPOOL_COMMAND); + { + if( spooler_type ) + { + command = strdup(spooler_type->spool_command); + } + else + { + ErrorF("XpSubmitJob: No default spool command defined.\n"); + } + } else + { command = strdup(command); + } if(command == (char *)NULL) + { + ErrorF("XpSubmitJob: No spooler command found, cannot submit job.\n"); return BadAlloc; - + } + cmdNam = VectorizeCommand(command, &vector, pContext); xfree(command); @@ -1431,7 +1497,6 @@ FreeVector(vector); xfree(cmdNam); - return Success; } /* @@ -1504,6 +1569,7 @@ { char *defMedium, *defTray; char *t, *m; + char *pS, *pE, *pLast; defMedium = XpGetOneAttribute( pCon, XPPageAttr, "default-medium" ); Index: xc/programs/Xserver/Xprint/attributes.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/attributes.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 attributes.h --- a/xc/programs/Xserver/Xprint/attributes.h 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/attributes.h 21 Apr 2004 09:35:10 -0000 @@ -30,7 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/attributes.h,v 1.5 2001/08/01 00:44:45 tsi Exp $ */ #ifndef _Xp_attributes_h #define _Xp_attributes_h 1 @@ -49,11 +48,11 @@ */ void XpInitAttributes(XpContextPtr pContext); void XpBuildAttributeStore(char *printerName, - char *qualifierName); + char *qualifierName); void XpAddPrinterAttribute(char *printerName, - char *printerQualifier, - char *attributeName, - char *attributeValue); + char *printerQualifier, + char *attributeName, + char *attributeValue); void XpDestroyAttributes(XpContextPtr pContext); char *XpGetConfigDir(Bool useLocale); char *XpGetOneAttribute(XpContextPtr pContext, @@ -98,33 +97,33 @@ void XpGetReproductionArea(XpContextPtr pContext, xRectangle *pRect); void XpGetMaxWidthHeightRes(const char *printer_name, - const XpValidatePoolsRec* vpr, - float *width, - float *height, - int* resolution); + const XpValidatePoolsRec* vpr, + float *width, + float *height, + int* resolution); /* Util.c */ -char * ReplaceAnyString(char *string, - char *target, - char *replacement); -char * ReplaceFileString(char *string, - char *inFileName, - char *outFileName); +char *ReplaceAnyString(char *string, + char *target, + char *replacement); +char *ReplaceFileString(char *string, + char *inFileName, + char *outFileName); void ExecCommand(char *pCommand, - char **argVector); + char **argVector); int TransferBytes(FILE *pSrcFile, - FILE *pDstFile, - int numBytes); + FILE *pDstFile, + int numBytes); Bool CopyContentsAndDelete(FILE **ppSrcFile, - char **pSrcFileName, - FILE *pDstFile); + char **pSrcFileName, + FILE *pDstFile); int XpSendDocumentData(ClientPtr client, - FILE *fp, - int fileLen, - int maxBufSize); + FILE *fp, + int fileLen, + int maxBufSize); int XpFinishDocData(ClientPtr client); Bool XpOpenTmpFile(char *mode, - char **fname, - FILE **stream); + char **fname, + FILE **stream); #endif /* _Xp_attributes_h */ Index: xc/programs/Xserver/Xprint/ddxInit.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ddxInit.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 ddxInit.c --- a/xc/programs/Xserver/Xprint/ddxInit.c 5 Mar 2004 13:39:53 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ddxInit.c 21 Apr 2004 09:35:10 -0000 @@ -30,13 +30,12 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ddxInit.c,v 1.13 2001/06/11 16:59:02 dawes Exp $ */ #include "X.h" +#include "Xos.h" #include "Xproto.h" #include "windowstr.h" #include "servermd.h" -#include "Xos.h" #include "DiPrint.h" /*- @@ -68,10 +67,13 @@ void InitOutput( - ScreenInfo *pScreenInfo, - int argc, - char **argv) + ScreenInfo *pScreenInfo, + int argc, + char **argv) + { + int i; + pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; @@ -168,10 +170,10 @@ void InitInput( - int argc, + int argc, char **argv) { - DeviceIntPtr ptr, kbd; + DevicePtr ptr, kbd; ptr = AddInputDevice((DeviceProc)PointerProc, TRUE); kbd = AddInputDevice((DeviceProc)KeyboardProc, TRUE); @@ -215,6 +217,7 @@ } #endif + #ifdef DDXTIME CARD32 GetTimeInMillis(void) @@ -226,6 +229,12 @@ } #endif +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ + XprintInitGlobals(); +} + /**************************************** * ddxUseMsg() * @@ -235,7 +244,11 @@ void ddxUseMsg(void) { - /* Right now, let's just do nothing */ +/* Enable |XprintUseMsg()| only if |XprintOptions()| is called + * by |ddxProcessArgument|, too (see below...) */ +#ifdef PRINT_ONLY_SERVER + XprintUseMsg(); +#endif /* PRINT_ONLY_SERVER */ } void AbortDDX (void) @@ -269,12 +282,12 @@ int ChangePointerDevice ( - DeviceIntPtr old_dev, - DeviceIntPtr new_dev, - unsigned char x, - unsigned char y) + DeviceIntPtr old_dev, + DeviceIntPtr new_dev, + unsigned char x, + unsigned char y) { - return (BadDevice); + return (BadDevice); } int Index: xc/programs/Xserver/Xprint/mediaSizes.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/mediaSizes.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 mediaSizes.c --- a/xc/programs/Xserver/Xprint/mediaSizes.c 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/mediaSizes.c 21 Apr 2004 09:35:10 -0000 @@ -30,8 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/mediaSizes.c,v 1.4 2001/01/17 22:36:28 dawes Exp $ */ - /******************************************************************* ** ** ********************************************************* @@ -130,6 +128,14 @@ {xpoid_val_medium_size_jis_b8, 64, 91}, {xpoid_val_medium_size_jis_b9, 45, 64}, {xpoid_val_medium_size_jis_b10, 32, 45}, + {xpoid_val_medium_size_hp_2x_postcard, 148, 200}, + {xpoid_val_medium_size_hp_european_edp, 304.8, 355.6}, + {xpoid_val_medium_size_hp_mini, 139.7, 215.9}, + {xpoid_val_medium_size_hp_postcard, 100, 148}, + {xpoid_val_medium_size_hp_tabloid, 279.4, 431.8}, + {xpoid_val_medium_size_hp_us_edp, 279.4, 355.6}, + {xpoid_val_medium_size_hp_us_government_legal, 203.2, 330.2}, + {xpoid_val_medium_size_hp_us_government_letter, 203.2, 254}, {xpoid_val_medium_size_iso_c3, 324, 458}, {xpoid_val_medium_size_iso_c4, 229, 324}, {xpoid_val_medium_size_iso_c5, 162, 229}, @@ -145,7 +151,8 @@ * attributes pools have been validated. */ int -XpGetResolution(XpContextPtr pContext) +XpGetResolution( + XpContextPtr pContext) { unsigned long resolution; @@ -185,7 +192,8 @@ * attributes pools have been validated. */ XpOid -XpGetContentOrientation(XpContextPtr pContext) +XpGetContentOrientation( + XpContextPtr pContext) { XpOid orientation; @@ -415,7 +423,7 @@ float *width, /* return */ float *height) /* return */ { - unsigned i; + int i; *width = *height = 0; for(i = 0; i < XpNumber(PageDimensions); i++) @@ -739,7 +747,9 @@ } FontResolutionPtr -XpGetClientResolutions(ClientPtr client, int *num) +XpGetClientResolutions(client, num) + ClientPtr client; + int *num; { static struct _FontResolution res; int resolution = XpGetResolution(XpContextOfClient(client)); @@ -755,13 +765,15 @@ } -void XpSetFontResFunc(ClientPtr client) +void XpSetFontResFunc(client) + ClientPtr client; { client->fontResFunc = XpGetClientResolutions; } -void XpUnsetFontResFunc(ClientPtr client) +void XpUnsetFontResFunc(client) + ClientPtr client; { client->fontResFunc = NULL; } Index: xc/programs/Xserver/Xprint/spooler.c =================================================================== RCS file: xc/programs/Xserver/Xprint/spooler.c diff -N xc/programs/Xserver/Xprint/spooler.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/spooler.c 21 Apr 2004 09:35:10 -0000 @@ -0,0 +1,190 @@ + +/* $Xorg: spooler.c,v 1.1 2003/09/14 1:19:56 gisburn Exp $ */ +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +COPYRIGHT HOLDERS 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 names of the copyright holders shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from said +copyright holders. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __hpux +#include +#endif + +#include "spooler.h" + +/* + * The string LIST_QUEUES_* is fed to a shell to generate an ordered + * list of available printers on the system. These string definitions + * are taken from the file PrintSubSys.C within the code for the + * dtprintinfo program. + */ +#define LIST_QUEUES_AIX4 \ + "lsallq | grep -v '^bsh$' | sort | uniq" + +#define LIST_QUEUES_HPUX \ + "LANG=C lpstat -v | " \ + "awk '" \ + " $2 == \"for\" " \ + " { " \ + " x = match($3, /:/); " \ + " print substr($3, 1, x-1)" \ + " }' | sort | uniq" + +#define LIST_QUEUES_OSF \ + "LANG=C lpstat -v | " \ + "nawk '" \ + " $2 == \"for\" " \ + " { print $4 }' " \ + " | sort | uniq" + +#define LIST_QUEUES_UXP \ + "LANG=C lpstat -v |" \ + "nawk '" \ + " $4 == \"for\" " \ + " { " \ + " x = match($5, /:/); " \ + " print substr($5, 1, x-1)" \ + " }' | sort | uniq" + +/* Support both normal and LPRng output of "lpc status" */ +#define LIST_QUEUES_BSD \ + "PATH=\"${PATH}:/usr/bin:/usr/sbin:/bin:/sbin\"\n" \ + "export PATH\n" \ + \ + "which_tool()\n" \ + "{\n" \ + " echo \"${PATH}\" | tr \":\" \"\n\" | while read i ; do ls -1ad \"${i}/${1}\" 2>/dev/null ; done\n" \ + "}\n" \ + \ + "(\n" \ + "WHICH_LPC=\"`which_tool lpc`\"\n" \ + \ + "if [ \"`which_tool nawk`\" != \"\" ] ; then\n" \ + " NAWK=\"nawk\"\n" \ + "else\n" \ + " NAWK=\"awk\"\n" \ + "fi\n" \ + \ + "[ \"${WHICH_LPC}\" != \"\" ] && (LANG=C lpc status | ${NAWK} '/^[^ ]*:$/ && !/@/ && !/ / { print $1 }' | sed -e /:/s///)\n" \ + "[ \"${WHICH_LPC}\" != \"\" ] && (LANG=C lpc -a status | ${NAWK} '/^[^ ]*@[^ ]/ && !/:$/ { split( $1, name, \"@\" ); print name[1]; }')\n" \ + ") | egrep -v -i \" |^all$\" | sort | uniq" + +#define LIST_QUEUES_SYSV \ + "PATH=\"${PATH}:/usr/bin:/usr/sbin:/bin:/sbin\"\n" \ + "export PATH\n" \ + \ + "which_tool()\n" \ + "{\n" \ + " echo \"${PATH}\" | tr \":\" \"\n\" | while read i ; do ls -1ad \"${i}/${1}\" 2>/dev/null ; done\n" \ + "}\n" \ + \ + "(\n" \ + "WHICH_LPSTAT=\"`which_tool lpstat`\"\n" \ + \ + "if [ \"`which_tool nawk`\" != \"\" ] ; then\n" \ + " NAWK=\"nawk\"\n" \ + "else\n" \ + " NAWK=\"awk\"\n" \ + "fi\n" \ + \ + "[ \"${WHICH_LPSTAT}\" != \"\" ] && (LANG=C lpstat -v | ${NAWK} ' $2 == \"for\" { x = match($3, /:/); print substr($3, 1, x-1) }')\n" \ + ") | egrep -v -i \" |^all$\" | sort | uniq" + +#define LIST_QUEUES_OTHER \ + "LANG=C lpstat -v | " \ + "nawk '" \ + " $2 == \"for\" " \ + " { " \ + " x = match($3, /:/); " \ + " print substr($3, 1, x-1)" \ + " }' | sort | uniq" + +#define DEFAULT_SPOOL_COMMAND_HPUX "/usr/bin/lp -d %printer-name% -o raw -n %copy-count% -t %job-name% %options%" +#define DEFAULT_SPOOL_COMMAND_BSD "/usr/bin/lpr -P %printer-name% -#%copy-count% -T %job-name% %options%" +#define DEFAULT_SPOOL_COMMAND_SYSV "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%" +#define DEFAULT_SPOOL_COMMAND_OTHER "/usr/bin/lp -d %printer-name% -n %copy-count% -t %job-name% %options%" + + +/* List of spooler types and the commands used to enumerate + * print queues and submit print jobs */ +XpSpoolerType xpstm[] = +{ + /* OS-specific spoolers */ + { "aix", LIST_QUEUES_AIX4, DEFAULT_SPOOL_COMMAND_OTHER }, + { "aix4", LIST_QUEUES_AIX4, DEFAULT_SPOOL_COMMAND_OTHER }, + { "bsd", LIST_QUEUES_BSD, DEFAULT_SPOOL_COMMAND_BSD }, + { "osf", LIST_QUEUES_OSF, DEFAULT_SPOOL_COMMAND_OTHER }, + { "solaris", LIST_QUEUES_SYSV, DEFAULT_SPOOL_COMMAND_SYSV }, + { "sysv", LIST_QUEUES_SYSV, DEFAULT_SPOOL_COMMAND_SYSV }, + { "uxp", LIST_QUEUES_UXP, DEFAULT_SPOOL_COMMAND_OTHER }, + /* crossplatform spoolers */ + { "cups", LIST_QUEUES_SYSV, DEFAULT_SPOOL_COMMAND_SYSV }, + { "lprng", LIST_QUEUES_BSD, DEFAULT_SPOOL_COMMAND_BSD }, + /* misc */ + { "other", LIST_QUEUES_OTHER, DEFAULT_SPOOL_COMMAND_OTHER }, + { "none", NULL, NULL }, + { NULL, NULL, NULL } +}; + +/* Used by Init.c and attributes.c */ +XpSpoolerTypePtr spooler_type = NULL; + +XpSpoolerTypePtr XpSpoolerNameToXpSpoolerType(char *name) +{ + XpSpoolerTypePtr curr = xpstm; + + while( curr->name != NULL ) + { + if( !strcasecmp(name, curr->name) ) + return curr; + + curr++; + } + + return NULL; +} + +static char *spooler_namelist = NULL; + +char *XpGetSpoolerTypeNameList(void) +{ + if( spooler_namelist ) + return spooler_namelist; + + return XPDEFAULTSPOOLERNAMELIST; +} + +void XpSetSpoolerTypeNameList(char *namelist) +{ + spooler_namelist = namelist; +} + + Index: xc/programs/Xserver/Xprint/spooler.h =================================================================== RCS file: xc/programs/Xserver/Xprint/spooler.h diff -N xc/programs/Xserver/Xprint/spooler.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/spooler.h 21 Apr 2004 09:35:10 -0000 @@ -0,0 +1,72 @@ + +#ifndef SPOOLER_H +#define SPOOLER_H 1 + +/* $Xorg: spooler.h,v 1.1 2003/09/14 1:19:56 gisburn Exp $ */ +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +COPYRIGHT HOLDERS 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 names of the copyright holders shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from said +copyright holders. +*/ + +/* + * Define platform-specific default spooler type + */ +#if defined(sun) +#define XPDEFAULTSPOOLERNAMELIST "solaris" +#elif defined(AIXV4) +#define XPDEFAULTSPOOLERNAMELIST "aix4" +#elif defined(hpux) +#define XPDEFAULTSPOOLERNAMELIST "hpux" +#elif defined(__osf__) +#define XPDEFAULTSPOOLERNAMELIST "osf" +#elif defined(__uxp__) +#define XPDEFAULTSPOOLERNAMELIST "uxp" +#elif defined(CSRG_BASED) || defined(linux) +/* ToDo: This should be "cups:bsd" in the future, but for now + * the search order first-bsd-then-cups is better for backwards + * compatibility. + */ +#define XPDEFAULTSPOOLERNAMELIST "bsd:cups" +#else +#define XPDEFAULTSPOOLERNAMELIST "other" +#endif + +typedef struct +{ + const char *name; + const char *list_queues_command; + const char *spool_command; +} XpSpoolerType, *XpSpoolerTypePtr; + +/* prototypes */ +extern XpSpoolerTypePtr XpSpoolerNameToXpSpoolerType(char *name); +extern void XpSetSpoolerTypeNameList(char *namelist); +extern char *XpGetSpoolerTypeNameList(void); + +/* global vars */ +extern XpSpoolerTypePtr spooler_type; +extern XpSpoolerType xpstm[]; + +#endif /* !SPOOLER_H */ + Index: xc/programs/Xserver/Xprint/etc/Imakefile =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/Imakefile diff -N xc/programs/Xserver/Xprint/etc/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/Imakefile 21 Apr 2004 09:35:10 -0000 @@ -0,0 +1,24 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/10/31 14:42:52 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +XCOMM Check if OS has /etc/profile.d/ +XCOMM Note that Debian Linux does not have /etc/profile.d/ +#ifndef HasEtcProfileDir +# ifdef LinuxArchitecture +# if (LinuxDistribution != LinuxDebian) || BuildFullXprintDistrib +# define HasEtcProfileDir YES +# endif +# else +# define HasEtcProfileDir NO +# endif +#endif + +#if HasEtcProfileDir +SUBDIRS = init.d profile.d Xsession.d +#else +SUBDIRS = init.d Xsession.d +#endif + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/programs/Xserver/Xprint/etc/Xsession.d/Imakefile =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/Xsession.d/Imakefile diff -N xc/programs/Xserver/Xprint/etc/Xsession.d/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/Xsession.d/Imakefile 21 Apr 2004 09:35:10 -0000 @@ -0,0 +1,17 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/01/25 14:42:52 gisburn Exp $ + +all:: + +XCOMM Install glue for Xprint on Solaris/CDE1.x and CDE on AIX +#if (defined(SunArchitecture) && (OSMajorVersion > 4)) || defined(IBMArchitecture) +InstallNamedProg(cde_xsessiond_xprint.sh,0018.xprint,/usr/dt/config/Xsession.d) +#endif + +XCOMM Install xdm startup glue for Xprint on Linux. Note that not all Linux +XCOMM platforms have /etc/X11/Xsession.d/ and/or /etc/X11/xinit/xinitrc.d +XCOMM (see http://xprint.freedesktop.org/cgi-bin/bugzilla/show_bug.cgi?id=182) +#if defined(LinuxArchitecture) +InstallNamedProg(cde_xsessiond_xprint.sh,92xprint-xpserverlist,/etc/X11/Xsession.d) +InstallNamedProg(cde_xsessiond_xprint.sh,92xprint-xpserverlist,/etc/X11/xinit/xinitrc.d) +#endif + Index: xc/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh diff -N xc/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh 21 Apr 2004 09:35:10 -0000 @@ -0,0 +1,30 @@ +#!/bin/sh +##################################################################### +### File: 0018.xprint +### +### Default Location: /usr/dt/config/Xsession.d/ +### +### Purpose: Setup Xprint env vars +### +### Description: This script is invoked by means of the Xsession file +### at user login. +### +### Invoked by: /usr/dt/bin/Xsession +### +### (c) Copyright 2003-2004 Roland Mainz +### +### please send bugfixes or comments to http://xprint.mozdev.org/ +### +##################################################################### + + +# +# Obtain list of Xprint servers +# + +if [ -f "/etc/init.d/xprint" ] ; then + XPSERVERLIST="`/bin/sh /etc/init.d/xprint get_xpserverlist`" + export XPSERVERLIST +fi + +########################## eof ##################### Index: xc/programs/Xserver/Xprint/etc/init.d/Imakefile =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/init.d/Imakefile diff -N xc/programs/Xserver/Xprint/etc/init.d/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/init.d/Imakefile 21 Apr 2004 09:35:11 -0000 @@ -0,0 +1,56 @@ +XCOMM $Xorg: Imakefile,v 1.2 2003/01/20 17:02:01 gisburn Exp $ + +all:: + +#if BuildGISWxprintglue +XCOMM Hack for GISWxprintglue package build +all:: xprint.GISWxprintglue + +xprint.GISWxprintglue: xprint + nawk xprint.GISWxprintglue + +clean:: + $(RM) xprint.GISWxprintglue + +InstallNamedProg(xprint.GISWxprintglue,xprint,/etc/init.d) + +#elif BuildGISWxprint +XCOMM Hack for GISWxprint package build +all:: xprint.GISWxprint + +xprint.GISWxprint: xprint + nawk xprint.GISWxprint + +clean:: + $(RM) xprint.GISWxprint + +InstallNamedProg(xprint.GISWxprint,xprint,/etc/init.d) + +#elif BuildDebianXprintPackage +XCOMM Hack for Debian Xprint server package build +all:: xprint.DebianXprt + +xprint.DebianXprt: xprint + nawk xprint.DebianXprt + +clean:: + $(RM) xprint.DebianXprt + +InstallNamedProg(xprint.DebianXprt,xprint,/etc/init.d) +#else +#if defined(FreeBSDArchitecture) +InstallNamedProg(xprint,xprint,/usr/X11R6/etc/rc.d) +#else +InstallNamedProg(xprint,xprint,/etc/init.d) +#endif +#endif /* BuildDebianXprintPackage */ + +XCOMM Create startup/shutdown links in /etc/rc.d/ for Solaris +#if defined(SunArchitecture) && (OSMajorVersion > 4) +install:: + MakeDir($(DESTDIR)/etc/rc0.d) ; RemoveFile($(DESTDIR)/etc/rc0.d/K38xprint) ; ln -s /etc/init.d/xprint $(DESTDIR)/etc/rc0.d/K38xprint + MakeDir($(DESTDIR)/etc/rc1.d) ; RemoveFile($(DESTDIR)/etc/rc1.d/K38xprint) ; ln -s /etc/init.d/xprint $(DESTDIR)/etc/rc1.d/K38xprint + MakeDir($(DESTDIR)/etc/rc2.d) ; RemoveFile($(DESTDIR)/etc/rc2.d/S81xprint) ; ln -s /etc/init.d/xprint $(DESTDIR)/etc/rc2.d/S81xprint + MakeDir($(DESTDIR)/etc/rcS.d) ; RemoveFile($(DESTDIR)/etc/rcS.d/K38xprint) ; ln -s /etc/init.d/xprint $(DESTDIR)/etc/rcS.d/K38xprint +#endif /* defined(SunArchitecture) && (OSMajorVersion > 4) */ + Index: xc/programs/Xserver/Xprint/etc/init.d/xprint =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/init.d/xprint diff -N xc/programs/Xserver/Xprint/etc/init.d/xprint --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/init.d/xprint 21 Apr 2004 09:35:11 -0000 @@ -0,0 +1,1163 @@ +#!/bin/sh +# +# Copyright (c) 2002-2004 by Roland Mainz +# All rights reserved. +# +#ident "@(#)xprint 0.5 2003/02/14 gisburn" +# +# Basic support for the Linux Standard Base Specification 1.0.0 +# (Note: The Should-Start/Stop lines are there so that this works in the +# future, when the LSB adopts these. The X-UnitedLinux lines are there +# so that it works right now.) +### BEGIN INIT INFO +# Provides: xprint +# Required-Start: $local_fs $remote_fs $syslog $network +# Required-Stop: $local_fs $remote_fs $syslog +# Should-Start: cups lpd xfs +# Should-Stop: cups lpd xfs +# X-UnitedLinux-Should-Start: cups lpd xfs +# X-UnitedLinux-Should-Stop: cups lpd xfs +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Description: Startup/shutdown script for Xprint server(s) +### END INIT INFO +# +# Basic support for IRIX-style "chkconfig" +# chkconfig: 2345 61 61 +# description: Startup/shutdown script for Xprint server(s) +# +############################################################################ +# +# This script has three main tasks: +# 1. Start Xprint servers ("Xprt") at boot time. +# 2. Shutdown Xprint servers when the machine is being shut down. +# 3. Query the list of available printers. +# +# Additional tasks are: +# 4. Restart ('restart'|'force-reload') and conditional restart +# ('condrestart'/'try-restart') for Linux support +# 5. Wrapping of application call with setting XPSERVERLIST ('wrapper') +# +# Usage: +# - Start Xprint server(s) manually: +# % /etc/init.d/xprint start +# +# - Stop Xprint server(s) manually: +# % /etc/init.d/xprint stop +# +# - Populate $XPSERVERLIST env var (for example as part of a global +# login script like /etc/profile or per-user login scripts like +# $HOME/.profile (sh/ksh/bash)) +# % XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`" +# % export XPSERVERLIST +# +# Installation: +# Copy this script to /etc/init.d/xprint and make sure that it is +# executable. If your installation is LSB-compliant, then run +# % /usr/lib/lsb/install_initd /etc/init.d/xprint +# to start the service on startup. Otherwise, manually create links +# to the matching run levels. +# Examples: +# - Solaris 2.7/2.8/2.9: +# % cp xprint /etc/init.d/xprint +# % chmod a+rx /etc/init.d/xprint +# % ln /etc/init.d/xprint /etc/rc0.d/K38xprint +# % ln /etc/init.d/xprint /etc/rc1.d/K38xprint +# % ln /etc/init.d/xprint /etc/rc2.d/S81xprint +# % ln /etc/init.d/xprint /etc/rcS.d/K38xprint +# +# - SuSE Linux 7.3 +# % cp xprint /etc/init.d/xprint +# % chmod a+rx /etc/init.d/xprint +# % ln -s ../xprint /etc/init.d/rc3.d/K13xprint +# % ln -s ../xprint /etc/init.d/rc3.d/S12xprint +# % ln -s ../xprint /etc/init.d/rc5.d/K13xprint +# % ln -s ../xprint /etc/init.d/rc5.d/S12xprint +# % ln -s ../xprint /etc/init.d/rc2.d/K13xprint +# % ln -s ../xprint /etc/init.d/rc2.d/S12xprint +# +# - SuSE Linux 6.4: +# % cp xprint /sbin/init.d/xprint +# % chmod a+rx /sbin/init.d/xprint +# % ln -s ../xprint /sbin/init.d/rc2.d/K20xprint +# % ln -s ../xprint /sbin/init.d/rc2.d/S20xprint +# % ln -s ../xprint /sbin/init.d/rc3.d/K20xprint +# % ln -s ../xprint /sbin/init.d/rc3.d/S20xprint +# +# Notes: +# - The Xprint servers must be started _after_ the print +# spooler or the server(s) may refuse to start +# - The script should be readable by all users to ensure that they +# can use the "get_xpserverlist"-option +# +# Custom configuration: +# - Edit the function setup_config() in this script to match your needs +# +# Known bugs/ToDo/Notes: +# - The shell script assumes that a Xserver can be reached via +# "hostname:displaynum" where "hostname" is obtained from +# "/usr/bin/hostname". It may happen that a kernel firewall +# blocks an X connection on the same host (e.g. client && Xserver +# are running on the same host). +# Suggested fix: Fix the firewall config. +# Suggested workaround: Edit this script and replace the use of +# /usr/bin/hostname with "echo 'localhost'". +# +############################################################################ +# + + +############################################################################ + +fatal_error() +{ + echo "${0}: ## FATAL ERROR: ${1}" 1>&2 + exit 1 +} + +error_echo() +{ + echo "${0}: ## ERROR: ${1}" 1>&2 +} + +warning_echo() +{ + echo "${0}: ## WARNING: ${1}" 1>&2 +} + +verbose_echo() +{ + echo "${0}: ${1}" +} + +msg() +{ + echo "${1}" +} + +############################################################################ + +# Force use of a POSIX conformant sh +# (Solaris /sbin/sh is plain Bourne shell) +[ "$1" != "posix_sh_forced" -a -x /bin/ksh ] && exec /bin/ksh "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /bin/bash ] && exec /bin/bash "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/ksh ] && exec /usr/local/bin/ksh "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /usr/local/bin/bash ] && exec /usr/local/bin/bash "$0" posix_sh_forced "$@" +if [ "$1" != "posix_sh_forced" ] ; then + echo "${0}: ## FATAL ERROR: No POSIX-shell found." 1>&2 + exit 1 +fi + +shift # Drop "posix_sh_forced" + +# debug +#set -x + +# Set search path for commands +export PATH=/usr/bin:/bin:/usr/sbin:/sbin +if [ "$(uname -s)" = "SunOS" ] ; then + export PATH=/usr/xpg4/bin:${PATH} +fi + +## Try to figure-out where X11 was installed +case "$(uname -s)" in + 'SunOS') + XPROJECTROOT=/usr/openwin + export OPENWINHOME=/usr/openwin + ;; + 'AIX') + XPROJECTROOT=/usr/lpp/X11 + ;; + *) + [ -d /usr/X11/bin ] && XPROJECTROOT=/usr/X11 + [ -d /usr/X11R6/bin ] && XPROJECTROOT=/usr/X11R6 + ;; +esac +XPCUSTOMGLUE=default # This is used for customizing this script +export XPROJECTROOT XPCUSTOMGLUE + +if [ -z "${XPROJECTROOT}" ] ; then + fatal_error "Unknown XProjectRoot." +fi + +# Set the location of the Xprt binary we want to use. +XPRT_BIN="${XPROJECTROOT}/bin/Xprt" + +# Set the location of the global file where we store the locations +# of the system-wide servers +if [ -d /var/run ] ; then + XP_GLOBAL_SERVERS=/var/run/Xprint_servers +else + XP_GLOBAL_SERVERS=/tmp/.Xprint_servers +fi + +# ${LOGNAME} will not work if user su'ed into another account +export CURRLOGNAME="$(id -u -n)" + +# Set location where we want to store the list of Xprint servers managed +# by this user +# - If we start as "root" use the global file +# - If we start as normal user use a per-user file + +if [ "${CURRLOGNAME}" != "root" -a "${CURRLOGNAME}" != "" ] ; then + XP_PER_USER_SERVERS="/tmp/.Xprint_servers_${CURRLOGNAME}" + XP_SERVERS="${XP_PER_USER_SERVERS}" +else + XP_SERVERS="${XP_GLOBAL_SERVERS}" +fi + +# Set umask that owner can r/w all files and everyone else can read them +umask 022 + +# Bump limit for per-process open files to ensure that Xprt can open many many fonts +ulimit -n 1024 + +############################################################################ + +# Get list of fonts for a given display +get_fontlist_from_display() +{ + ${XPROJECTROOT}/bin/xset -display "${1}" q | + awk "/Font Path:/ { i=1 ; next } i==1 { print \$0 ; i=0 }" | + fontpath2fontlist +} + +# Get list from a fontserver config +get_fontlist_from_xfs_config() +{ + if [ ! -r "${1}" ] ; then + return 0 + fi + + ( + cat "${1}" | + while read -r i ; do + for val in $i; do + case $val in + \#*) break ;; + ?*=*) key="${val%%=*}" ;; + =*) key="${tok}" ;; + *) [ "${key}" = "catalogue" -a "${tok}" != "" ] && echo "${tok}" ;; + esac + tok="${val#*=}" + done + done + ) | tr "," "[\n]" | fontpath2fontlist +} + +get_fontlist_from_all_xfs_configs() +{ + get_fontlist_from_xfs_config "/etc/openwin/fs/fontserver.cfg" + get_fontlist_from_xfs_config "/usr/openwin/lib/X11/fontserver.cfg" + get_fontlist_from_xfs_config "/etc/X11/fs-xtt/config" + get_fontlist_from_xfs_config "/etc/X11/fs/config" + get_fontlist_from_xfs_config "${XPROJECTROOT}/lib/X11/fs/config" +} + +get_fontlist_from_xf86config() +{ + srcxf86configfile="" + [ -f "/etc/X11/XF86Config-4" ] && srcxf86configfile="/etc/X11/XF86Config-4" + [ -f "/etc/X11/XF86Config" ] && srcxf86configfile="/etc/X11/XF86Config" + + + if [ "${srcxf86configfile}" = "" ] ; then + return 0 + fi + + currsection="" + cat "${srcxf86configfile}" | + while read i1 i2 i3 i4 ; do + # Strip "\"" from I2 + i2="${i2#\"}" ; i2="${i2%\"}" + + case "${i1}" in + \#*) + continue + ;; + 'Section') + currsection="${i2}" + ;; + 'EndSection') + currsection="" + ;; + 'FontPath') + [ "$currsection" = "Files" ] && echo "${i2%:unscaled}" + ;; + esac + done | egrep -v -i "tcp/|tcp4/|tcp6/|unix/" + + return 0 +} + +get_fontlist_from_defoma() +{ + # Include Debian defoma font directory where relevant + if [ -d "/var/lib/defoma/x-ttcidfont-conf.d/dirs" ] ; then + find "/var/lib/defoma/x-ttcidfont-conf.d/dirs" -name fonts.dir | + while read i ; do echo "${i%/fonts.dir}" ; done + fi +} + +# Get list of system fonts +get_system_fontlist() +{ + case "$(uname -s)" in + 'SunOS') + ## List the standard X11 fonts + # echo "${XPROJECTROOT}/lib/X11/fonts/F3/" + # echo "${XPROJECTROOT}/lib/X11/fonts/F3bitmaps/" + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/" + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/outline/" + # We cannot use /usr/openwin/lib/X11/fonts/Type1/sun/ - see + # http://xprint.mozdev.org/bugs/show_bug.cgi?id=5726 + # ("Xprint doesn't start under Solaris 2.9 due *.ps files in /usr/openwin/lib/X11/fonts/Type1/sun/fonts.dir") + #echo "${XPROJECTROOT}/lib/X11/fonts/Type1/sun/" + echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/" + echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/" + echo "${XPROJECTROOT}/lib/X11/fonts/misc/" + echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/" + + ## List all fonts in all locales installed on this machine + cat /usr/openwin/lib/locale/*/OWfontpath | tr "," "\n" | sort -u + ;; + 'Linux') + ( + get_fontlist_from_defoma + + get_fontlist_from_xf86config + + # Getting font paths from XFS is mainly required for compatibilty to RedHat + get_fontlist_from_all_xfs_configs + + ## List all fonts in all locales installed on this machine + find /usr/share/fonts "${XPROJECTROOT}/lib/X11/fonts" -name fonts.dir | + while read i ; do echo "${i%/fonts.dir}" ; done + ) | sort -u + ;; + * | 'AIX') + ## List the standard X11 fonts + # (AIX should be handled like Solaris but I did not found a way to + # enumerate all fonts in all installed locales without scanning the + # dirs manually) + echo "${XPROJECTROOT}/lib/X11/fonts/Type1/" + echo "${XPROJECTROOT}/lib/X11/fonts/TrueType/" + echo "${XPROJECTROOT}/lib/X11/fonts/TTF/" + echo "${XPROJECTROOT}/lib/X11/fonts/Speedo/" + echo "${XPROJECTROOT}/lib/X11/fonts/misc/" + echo "${XPROJECTROOT}/lib/X11/fonts/75dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/100dpi/" + echo "${XPROJECTROOT}/lib/X11/fonts/" + ;; + esac +} + +# Filter fonts per given extended regular expressions +# (and make sure we filter any model-config fonts - they are managed by Xprt internally) +filter_fontlist() +{ + egrep -- "${1}" | fgrep -v "/models/" | egrep -v -- "${2}" +} + +# Filter font paths with unsupported font types +# (such as CID fonts) +filter_unsupported_fonts() +{ + egrep -v -i "/cid(/$|$)|/csl(/$|$)" +} + +# Validate fontpath +# Only return valid font path entries (note that these entries may +# include non-file stuff like font server references) +validate_fontlist() +{ + while read i ; do + case "${i}" in + # Check if font path entry is a font server... + tcp/*|tcp4/*|tcp6/*|unix/*) + echo "${i}" + ;; + # ... if not check if the path is accessible + # and has a valid "fonts.dir" index + *) + [ -f "${i}/fonts.dir" ] && echo "${i}" + ;; + esac + done +} + +# Build a comma-seperated list of fonts (font path) from a list of fonts +fontlist2fontpath() +{ + fp="" + read fp; + while read i ; do + fp="${fp},${i}" + done + + echo "$fp" +} + +# Build a list (one item per line) of fonts from a font path +fontpath2fontlist() +{ + while read i ; do + echo "${i}" | tr "," "\n" + done +} + +# Sort scaleable fonts (PS Type1 and TrueType) first in a font list +sort_scaleable_fonts_first() +{ + i="$(fontlist2fontpath)" + # First list PS Type1 fonts... + echo "${i}" | fontpath2fontlist | fgrep "/Type1" + # ... then TrueType fonts ... + echo "${i}" | fontpath2fontlist | egrep -i "/TrueType|/TT(/$|$)|/TTF(/$|$)" + # ... then all others + echo "${i}" | fontpath2fontlist | egrep -v -i "/Type1|/TrueType|/TT(/$|$)|/TTF(/$|$)" +} + +# Check if a X display is used by a Xserver or not +# Known bugs: +# - there is no way in plain bourne shell or bash (see comment about ksh93 +# below) to test if a Xserver sits only on a socket and not on a pipe +# - some Xserver's don't cleanup their stuff in /tmp on exit which may end +# in the problem that we don't detect possible free display numbers +# (one problem is that only ksh93 can do stuff like +# "cat "${lastdisplaynumreturned_store}" + return 0 + fi + done + + # Using "magic" value of 189 here due lack of a better solution + echo "189" + echo "189" >"${lastdisplaynumreturned_store}" + return 0 +} + +# Check if a process exists or not +pexists() +{ + [ "$1" = "" ] && return 1; + + # Use of /proc would be better but not all platforms (like AIX) have procfs + [ "$(ps -p $1 | fgrep $1)" != "" ] && return 0; + return 1 +} + +# Check if there is a spooler running... +is_spooler_running() +{ + # This covers Linux lpd, CUPS, Solaris and AIX 4.x - but what about + # AIX 5.x, HP-UX and IRIX ? + + [ "$(ps -A | egrep 'lpd|lpsched|cupsd|qdaemon' | fgrep -v 'grep')" != "" ] && return 0; + return 1 +} + +# Wait until the spooler system has been started (but not more than 30secs) +wait_for_print_spooler() +{ + for i in 1 2 3 4 5 6 7 8 9 10 ; do + is_spooler_running && return 0; + sleep 3 + done + + return 0 +} + +lock_server_registry() +{ + lock_counter=0 # counts in 1/100s + waiting_for_lock_msg_send="false" + while ! mkdir "${XP_SERVERS}.lock" 2>/dev/null ; do + # print notice after 2 seconds + if [ ${lock_counter} -gt 200 -a "${waiting_for_lock_msg_send}" != "true" ] ; then + echo "${0}: waiting for lock(=${XP_SERVERS}.lock)..." + waiting_for_lock_msg_send="true" + fi + + # tread the lock as "broken" after 20 seconds + if [ ${lock_counter} -gt 2000 ] ; then + echo "${0}: WARNING: lock timeout for lock(=${XP_SERVERS}.lock)." + return 0 + fi + + if [ -x /bin/usleep ] ; then + /bin/usleep 200000 + lock_counter=$((${lock_counter} + 20)) # 20/100s + else + sleep 1 + lock_counter=$((${lock_counter} + 100)) # 100/100s + fi + done +} + +unlock_server_registry() +{ + rmdir "${XP_SERVERS}.lock" +} + +# Kill dead registry locks (silently!) +kill_dead_registry_locks() +{ + rm -Rf "${XP_SERVERS}.lock" +} + +# Start Xprint servers +start_servers() +{ + # Write registry "intro" ... + lock_server_registry + echo "# Xprint server list" >>"${XP_SERVERS}" + echo "# File is for private use for ${0}." >>"${XP_SERVERS}" + echo "# Do not edit, rely on the content or file format." >>"${XP_SERVERS}" + unlock_server_registry + + hostname="$(hostname)" + + default_fontpath="$(get_system_fontlist | fontlist2fontpath)" + default_fontpath_acceptpattern=".*"; + default_fontpath_rejectpattern="_No_Match_"; # Match nothing + + curr=0 + while [ $curr -lt $num_xpstart ] ; do + if [ "${xpstart_remote_server[$curr]}" != "" ] ; then + # Remote Xprt, just put the entry into the registry + lock_server_registry + echo "display=${xpstart_remote_server[$curr]}" >>"${XP_SERVERS}" + unlock_server_registry + else + # Run block in seperate process to avoid that changes to the + # xpstart_* variables affect the next cycle + ( + # Use defaults if there are no special options + [ "${xpstart_fontpath[$curr]}" = "" ] && xpstart_fontpath[$curr]="${default_fontpath}"; + [ "${xpstart_fontpath_acceptpattern[$curr]}" = "" ] && xpstart_fontpath_acceptpattern[$curr]="$default_fontpath_acceptpattern"; + [ "${xpstart_fontpath_rejectpattern[$curr]}" = "" ] && xpstart_fontpath_rejectpattern[$curr]="$default_fontpath_rejectpattern"; + [ "${xpstart_displayid[$curr]}" = "" ] && xpstart_displayid[$curr]="$(FindFreeXDisplayNum)" + [ "${xpstart_logger[$curr]}" = "" ] && xpstart_logger[$curr]="logger -p lpr.notice -t Xprt_${xpstart_displayid[$curr]}"; + [ "${xpstart_logfile[$curr]}" = "" ] && xpstart_logfile[$curr]="/dev/null"; + [ "${xpstart_xprt_binary[$curr]}" = "" ] && xpstart_xprt_binary[$curr]="${XPRT_BIN}"; + if [ "${xpstart_xprt_binary[$curr]}" = "/usr/openwin/bin/Xprt" -o "$(uname -s)" = "SunOS" ] ; then + # Solaris /usr/openwin/bin/Xprt does not support "-nolisten tcp" + # yet nor is it possible to run a Xserver on a unix socket only + # in Solaris since access to the unix domain sockets in + # /tmp/.X11-pipe and /tmp/.X11-unix is restricted to applications + # with group-id "root" (e.g. the Xprt server would need to be + # setgid "root" that plain users can start it listening on a unix + # socket only) + [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn" + else + [ "${xpstart_options[$curr]}" = "" ] && xpstart_options[$curr]="-ac -pn -nolisten tcp" + fi + + # Check if the Xprt binary is available + if [ ! -x "${xpstart_xprt_binary[$curr]}" ] ; then + error_echo "Can't find \"${xpstart_xprt_binary[$curr]}\"." + exit 1 # exit block + fi + + # Verify and set location of font encodings directory file + if [ "${xpstart_font_encodings_dir[$curr]}" = "" ] ; then + if [ -f "${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" ] ; then + xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/xf86encodings/encodings.dir" + else + xpstart_font_encodings_dir[$curr]="${XPROJECTROOT}/lib/X11/fonts/encodings/encodings.dir"; + fi + fi + + unset FONT_ENCODINGS_DIRECTORY + if [ ! -f "${xpstart_font_encodings_dir[$curr]}" ] ; then + warning_echo "Can't find \"${xpstart_font_encodings_dir[$curr]}\", TrueType font support may not work." + fi + + export FONT_ENCODINGS_DIRECTORY="${xpstart_font_encodings_dir[$curr]}" + + # Generate font path (containing only valid font path elements) + # from input font path and filter expressions + curr_fp=$(echo "${xpstart_fontpath[$curr]}" | + fontpath2fontlist | + filter_fontlist "${xpstart_fontpath_acceptpattern[$curr]}" "${xpstart_fontpath_rejectpattern[$curr]}" | + filter_unsupported_fonts | + sort_scaleable_fonts_first | + validate_fontlist | + fontlist2fontpath) + + # Set Xserver auditing level option + unset curr_audit + if [ "${xpstart_auditlevel[$curr]}" != "" ] ; then + curr_audit="-audit ${xpstart_auditlevel[$curr]}" + fi + + # Set Xprt -XpFile option + unset curr_xpfile + if [ "${xpstart_xpfile[$curr]}" != "" ] ; then + curr_xpfile="-XpFile ${xpstart_xpfile[$curr]}" + fi + + # Set custom XPCONFIGDIR (if there is one) + unset XPCONFIGDIR + if [ "${xpstart_xpconfigdir[$curr]}" != "" ] ; then + export XPCONFIGDIR="${xpstart_xpconfigdir[$curr]}" + fi + + # If someone uses "-nolisten tcp" make sure we do not add a hostname to force local transport + if [ "$(echo "${xpstart_options[$curr]}" | egrep "nolisten.*tcp")" != "" ] ; then + xp_display=":${xpstart_displayid[$curr]}" + else + xp_display="${hostname}:${xpstart_displayid[$curr]}" + fi + + ( + ( + "${xpstart_xprt_binary[$curr]}" \ + ${xpstart_options[$curr]} \ + ${curr_xpfile} ${curr_audit} \ + -fp ${curr_fp} \ + :${xpstart_displayid[$curr]} & + server_pid="$!" + + # Append the new server to the registry + lock_server_registry + echo "display=${xp_display} display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >>"${XP_SERVERS}" + unlock_server_registry + + wait + echo "Xprint server pid=${server_pid} done, exitcode=$?." + + # Remove the dead server from the registry + # (only if the registry still exists - if /etc/init.d/xprint stop" gets called the registry + # will be removed - and we should not re-create it afterwards...) + lock_server_registry + if [ -f "${XP_SERVERS}" ] ; then + x="$(cat "${XP_SERVERS}")" # Store content of file "${XP_SERVERS}" in var "x" + echo "${x}" | fgrep -v "display_id=${xpstart_displayid[$curr]} pid=${server_pid}" >"${XP_SERVERS}" + fi + unlock_server_registry + ) 2>&1 | while read i ; do echo "$i" | tee -a "${xpstart_logfile[$curr]}" | ${xpstart_logger[$curr]} ; done + ) & + ) + fi + + curr=$(($curr + 1)) + done + + # Remove tmp. file created by |FindFreeXDisplayNum()| + rm -f "${lastdisplaynumreturned_store}" + + # Done. + lock_server_registry + echo "# EOF." >>"${XP_SERVERS}" + unlock_server_registry + return 0 +} + + +# Convenience function to check setup and start Xprt server(s) +do_start() +{ + if [ -f "${XP_SERVERS}" ] ; then + numservers="$(do_get_xpserverlist | wc -l)" + if [ ${numservers} -gt 0 ] ; then + verbose_echo "Xprint servers are already running." + return 0 + else + verbose_echo "Old server registry found, cleaning-up..." + do_stop + fi + fi + + # Check if we can write the registry file + touch "${XP_SERVERS}" 2>/dev/null + if [ ! -f "${XP_SERVERS}" ] ; then + error_echo "Cannot create \"${XP_SERVERS}\"." + # exit code 4 = user had insufficient privilege (LSB) + exit 4 + fi + + if ! setup_config ; then + error_echo "setup_config failed." + exit 1 + fi + + # Provide two paths here - one which simply starts the Xprt servers, + # assuming that there is a print spooler already running (or that + # ${XPCONFIG}/C/print/Xprinters provides static print queue entries + # (like for the PSspooldir print model)) and a 2nd path which + # explicitly checks if the print queue daemons are running + if true ; then + msg "Starting Xprint servers: Xprt." + start_servers + else + # Continue in the background if there is no spooler running yet (that + # we don't hold off the boot process nor run in a possible race-condition + # when /etc/init.d/lpd was not called yet but the runlevel script waits + # for us to finish first ... + if is_spooler_running ; then + msg "Starting Xprint servers: Xprt." + start_servers + else + msg "Starting Xprint servers (in the background): Xprt." + (wait_for_print_spooler ; start_servers) & + sleep 5 + fi + fi + + if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then + touch /var/lock/subsys/xprint + fi +} + +# Convenience function to stop Xprt server(s) +do_stop() +{ + msg "Stopping Xprint servers: Xprt." + + lock_server_registry + if [ -f "${XP_SERVERS}" ] ; then + reglist="$(cat "${XP_SERVERS}")" + rm -f "${XP_SERVERS}" + fi + unlock_server_registry + + if [ "${reglist}" != "" ] ; then + echo "${reglist}" | + grep "^display=.*:.* pid=[0-9]*$" | + while read i ; do + ( + eval ${i} + if pexists ${pid} ; then + kill ${pid} + fi + + # Remove the X sockets/pipes which are not in use anymore + # (It would be better if the Xservers would cleanup this + # automatically, but most Xservers do not do that... ;-( + # Note that this will not work on Solaris where applications + # must run with groupid="root" if they want to write into + # /tmp/.X11-unix/ and/or /tmp/.X11-pipe/) + if [ "${display_id}" != "" ] ; then + rm -f "/tmp/.X${display_id}-lock" 2>/dev/null + rm -f "/tmp/.X11-unix/X${display_id}" 2>/dev/null + rm -f "/tmp/.X11-pipe/X${display_id}" 2>/dev/null + fi + ) + done + fi + + if [ "${CURRLOGNAME}" = "root" -a -d /var/lock/subsys/ ] ; then + rm -f /var/lock/subsys/xprint + fi + + # Remove any outstanding (dead) locks and cleanup + rm -f "${XP_SERVERS}" + kill_dead_registry_locks +} + +# Convenience function to obtain a list of available Xprint servers +do_get_xpserverlist() +{ + if [ -f "${XP_PER_USER_SERVERS}" -o -f "${XP_GLOBAL_SERVERS}" ] ; then + xpserverlist=$( + # Enumerate both per-user and global servers (in that order) + ( + [ -f "${XP_PER_USER_SERVERS}" ] && cat "${XP_PER_USER_SERVERS}" + [ -f "${XP_GLOBAL_SERVERS}" ] && cat "${XP_GLOBAL_SERVERS}" + ) | + egrep "^display=.*:.* pid=[0-9]*$|^display=.*:[0-9]*$" | + while read i ; do + ( + pid="none" + eval ${i} + # Check if the Xprt process exists (if possible) + if [ "$pid" != "none" ] ; then + if pexists ${pid} ; then + echo ${display} + fi + else + echo ${display} + fi + ) + done | tr "[\n]" " " + ) + # Only produce output if we have some entries... + [ "${xpserverlist}" != "" ] && echo "${xpserverlist}" + fi +} + +do_restart() +{ + msg "Restarting Xprint server(s): Xprt." + do_stop + sleep 1 + do_start +} + +# Set platform-defaults for setup_config() +setup_config_defaults() +{ + curr_num_xpstart="${1}" + + #### Defaults for Linux/Solaris + # Start Xprt using builtin XPCONFIGDIR at a free display numer + # (Solaris(=SunOS5.x)'s /usr/openwin/bin/Xprt supports TrueType fonts, + # therefore we don't need to filter them) + xpstart_fontpath[${curr_num_xpstart}]=""; + xpstart_fontpath_acceptpattern[${curr_num_xpstart}]=".*"; + xpstart_fontpath_rejectpattern[${curr_num_xpstart}]="/Speedo|/F3bitmaps|/F3"; + xpstart_displayid[${curr_num_xpstart}]=""; + xpstart_xpconfigdir[${curr_num_xpstart}]=""; + xpstart_xpfile[${curr_num_xpstart}]=""; + xpstart_auditlevel[${curr_num_xpstart}]="4"; + xpstart_options[${curr_num_xpstart}]=""; + xpstart_logger[${curr_num_xpstart}]=""; + # Check whether we have /dev/stderr (needed for old AIX + old Debian) + if [ -w "/dev/stderr" ] ; then + xpstart_logfile[${curr_num_xpstart}]="/dev/stderr"; + else + xpstart_logfile[${curr_num_xpstart}]="/dev/tty"; + fi + xpstart_xprt_binary[${curr_num_xpstart}]=""; + + # Custom rules for the GISWxprintglue package on Solaris + # (which uses Solaris's /usr/openwin/bin/Xprt but a custom config) + if [ "${XPCUSTOMGLUE}" = "GISWxprintglue" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprintglue/server/etc/XpConfig" + xpstart_xprt_binary[${curr_num_xpstart}]="/usr/openwin/bin/Xprt" + fi + # Custom rules for the GISWxprint package on Solaris + # (which uses both it's own Xprt and a custom config) + if [ "${XPCUSTOMGLUE}" = "GISWxprint" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="/opt/GISWxprint/server/etc/XpConfig" + xpstart_xprt_binary[${curr_num_xpstart}]="/opt/GISWxprint/bin/Xprt" + xpstart_font_encodings_dir[${curr_num_xpstart}]="/opt/GISWxprint/lib/X11/fonts/encodings/encodings.dir" + fi + + ####################################################### + ### + ### Debian Xprint package default configuration + ### + if [ "${XPCUSTOMGLUE}" = "DebianGlue" ] ; then + # Set XPCONFIGDIR=/usr/share/Xprint/xserver + xpstart_xpconfigdir[${curr_num_xpstart}]="/usr/share/Xprint/xserver"; + + # Use fixed display ID (":64"), or else all client programs will have to be + # restarted simply to update XPSERVERLIST to the latest ID when upgrading, + # which would be a nightmare. + xpstart_displayid[${curr_num_xpstart}]=64; + + # Do not send any messages to console + xpstart_logfile[${curr_num_xpstart}]="/dev/null"; + + # By default use binary provided by Debian's "xprt-xprintorg" package + # (=/usr/bin/Xprt), otherwise leave blank (e.g. use script's default + # (=/usr/X11R6/bin/Xprt)) + if [ -x "/usr/bin/Xprt" ] ; then + xpstart_xprt_binary[${curr_num_xpstart}]="/usr/bin/Xprt"; + fi + fi + ### + ### End Debian default configuration + ### + ####################################################### +} + +fetch_etc_initd_xprint_envvars() +{ + curr_num_xpstart="${1}" + + ## Process some $ETC_INITD_XPRINT_* vars after all which may be used by + # a user to override the hardcoded values here when starting Xprt per-user + # (a more flexible way is to provide an own setup config script in + # "~./Xprint_per_user_startup" - see above) + if [ "${ETC_INITD_XPRINT_XPRT_PATH}" != "" ] ; then + xpstart_xprt_binary[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_PATH}" + fi + if [ "${ETC_INITD_XPRINT_XPCONFIGDIR}" != "" ] ; then + xpstart_xpconfigdir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPCONFIGDIR}" + fi + if [ "${ETC_INITD_XPRINT_XPFILE}" != "" ] ; then + xpstart_xpfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPFILE}" + fi + if [ "${ETC_INITD_XPRINT_LOGFILE}" != "" ] ; then + xpstart_logfile[${curr_num_xpstart}]="${ETC_INITD_XPRINT_LOGFILE}" + fi + if [ "${ETC_INITD_XPRINT_DISPLAYID}" != "" ] ; then + xpstart_displayid[${curr_num_xpstart}]="${ETC_INITD_XPRINT_DISPLAYID}" + fi + if [ "${ETC_INITD_XPRINT_FONTPATH}" != "" ] ; then + xpstart_fontpath[${curr_num_xpstart}]="${ETC_INITD_XPRINT_FONTPATH}" + fi + if [ "${ETC_INITD_XPRINT_XPRT_OPTIONS}" != "" ] ; then + xpstart_options[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XPRT_OPTIONS}" + fi + if [ "${ETC_INITD_XPRINT_AUDITLEVEL}" != "" ] ; then + xpstart_auditlevel[${curr_num_xpstart}]="${ETC_INITD_XPRINT_AUDITLEVEL}" + fi + if [ "${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" != "" ] ; then + xpstart_font_encodings_dir[${curr_num_xpstart}]="${ETC_INITD_XPRINT_XF86ENCODINGSDIR}" + fi +} + +############################################################################ +# setup_config() sets the configuration parameters used to start one +# or more Xprint servers ("Xprt"). +# The following variables are used: +# - "num_xpstart" - number of servers to start +# - "xpstart_fontpath[index]" - custom font path. Leave blank if you want +# the platform-specific default +# - "xpstart_fontpath_acceptpattern[index]" - extended regular expression +# (see egrep(1)) used to filter the font path - items only pass this +# filter if they match the pattern (leave blank if you want to filter +# nothing) +# - "xpstart_fontpath_rejectpattern[index]" - extended regular expression +# (see egrep(1)) used to filter the font path - items only pass this +# filter if they do not match the pattern (leave blank if you want to +# filter nothing) +# - "xpstart_font_encodings_dir[index]" - location of "encodings.dir". +# Leave blank to use the default. +# - "xpstart_displayid[index]" - display id to use for the Xprint server +# (leave blank to choose the next available free display id) +# - "xpstart_xpconfigdir[index]" - value for custom XPCONFIGDIR (leave blank +# if you don not want that that XPCONFIGDIR is set at Xprt startup) +# - "xpstart_xpfile[index]" - value used for Xprt's "-XpFile" option (leave +# blank if you do not want to set this option) +# - "xpstart_auditlevel[index]" - set Xserver auditing level (leave blank to +# use no auditing) +# - "xpstart_options[index]" - set further Xprt options (leave blank to set +# no further options) +# - "xpstart_logger[index]" - utility which gets stderr/stdout messages from +# Xprt and sends them to a logging daemon. Leave blank to use /usr/bin/logger +# to send such messages to the lpr.notice syslog) +# - "xpstart_logfile[index]" - log file to append stderr/stdout messages from +# Xprt to. Leave blank to send messages to /dev/null +# - "xpstart_xprt_binary[index]" - set custom Xprt binary (leave blank to use +# the platform-specifc default) +setup_config() +{ + num_xpstart=0; + + if [ "${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" != "" ] ; then + user_cfg="${ETC_INITD_XPRINT_CUSTOM_SETUP_CONFIG}" + else + user_cfg="${HOME}/.Xprint_per_user_startup" + fi + + # Source per-user ~/.Xprint_per_user_startup file if there is one + # (and do not use the script's defaults below) + if [ -r "${user_cfg}" ] ; then + # Define API version which should be checked by ${HOME}/.Xprint_per_user_startup + # ${HOME}/.Xprint_per_user_startup should bail-out if the version differ + etc_initd_xprint_api_version=2 + + # Source per-user settings script + . "${user_cfg}" + + # done with setting the config for per-user Xprt instances + return 0; + else + # Use /etc/init.d/xprint's builtin config + # Each entry should start with |setup_config_defaults| to pull the + # platform defaults and finish with |num_xpstart=$(($num_xpstart + 1))| + # to end the entry + + # Set platform-defaults + setup_config_defaults "${num_xpstart}" + + ## -- snip -- + + # Admins can put their stuff "in" here... + + ## -- snip -- + + # Override script's builtin values with those a user may set via the + # $ETC_INIITD_XPRINT_* env vars + fetch_etc_initd_xprint_envvars "${num_xpstart}" + + num_xpstart=$((${num_xpstart} + 1)) + + return 0; + fi + + #### Sample 1: + # # Start Xprt on a free display ID with custom XPCONFIGDIR and without + # # Speedo and TrueType fonts + # xpstart_fontpath_rejectpattern[$num_xpstart]="/Speedo|/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig"; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + + #### Sample 2: + # # Start Xprt without TrueType fonts on a display 55 with custom + # # XPCONFIGDIR + # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_displayid[$num_xpstart]=55; + # xpstart_xpconfigdir[$num_xpstart]="/home/gisburn/cwork/Xprint/Xprt_config/XpConfig"; + # xpstart_auditlevel[$num_xpstart]=4; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 3: + # # Start Xprt without TrueType fonts on a display 56 with custom + # # XPCONFIGDIR and alternate "Xprinters" file + # xpstart_fontpath_rejectpattern[$num_xpstart]="/TrueType|/TT(/$|$)|/TTF(/$|$)"; + # xpstart_displayid[$num_xpstart]=56; + # xpstart_xpconfigdir[$num_xpstart]="/etc/XpConfig/default"; + # xpstart_xpfile[$num_xpstart]="/etc/XpConfig/default/Xprinters_test2" + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + # xpstart_xprt_binary[$num_xpstart]=""; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 4: + # # Start Xprt with Solaris ISO-8859-7 (greek(="el") locale) fonts on + # # display 57 + # xpstart_fontpath[$num_xpstart]="/usr/openwin/lib/locale/iso_8859_7/X11/fonts/75dpi,/usr/openwin/lib/locale/iso_8859_7/X11/fonts/Type1,/usr/openwin/lib/X11/fonts/misc/"; + # xpstart_fontpath_acceptpattern[$num_xpstart]=""; + # xpstart_fontpath_rejectpattern[$num_xpstart]="_No_Match_"; + # xpstart_displayid[$num_xpstart]="57"; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 5: + # # Start Xprt with the font list of an existing Xserver (excluding Speedo fonts) on + # # display 58 + # # Note that this only works within a X session. At system boot time + # # there will be no $DISPLAY to fetch the information from!! + # xpstart_fontpath[$num_xpstart]="$(get_fontlist_from_display ${DISPLAY} | fontlist2fontpath)"; + # xpstart_fontpath_acceptpattern[$num_xpstart]=""; + # xpstart_fontpath_rejectpattern[$num_xpstart]=""; + # xpstart_displayid[$num_xpstart]="58"; + # xpstart_xpconfigdir[$num_xpstart]=""; + # xpstart_auditlevel[$num_xpstart]="4"; + # xpstart_options[$num_xpstart]="-ac -pn"; + # xpstart_xprt_binary[$num_xpstart]=""; + #num_xpstart=$(($num_xpstart + 1)) + + #### Sample 6: + # # List remote Xprt's here + # # (note that there is no test to check whether these DISPLAYs are valid!) + # xpstart_remote_server[$num_xpstart]="sera:12" ; num_xpstart=$(($num_xpstart + 1)) + # xpstart_remote_server[$num_xpstart]="gandalf:19" ; num_xpstart=$(($num_xpstart + 1)) +} + +############################################################################ + +# Main +case "$1" in + ## Start Xprint servers + 'start') + do_start + ;; + + ## Stop Xprint servers + # Note that this does _not_ kill Xprt instances started using this script + # by non-root users + 'stop') + do_stop + ;; + + ## Restart Xprint servers + 'restart'|'force-reload') + do_restart + ;; + + ## Reload configuration without stopping and restarting + 'reload') + # not supported + msg "reload not supported, use 'restart' or 'force-reload'" + exit 3 + ;; + + ## Restart Xprint only if it is already running + 'condrestart'|'try-restart') + # only restart if it is already running + [ -f /var/lock/subsys/xprint ] && do_restart || : + ;; + + ## Get list of all Xprint servers for this user + # (incl. per-user and system-wide instances) + 'get_xpserverlist') + do_get_xpserverlist + ;; + + ## Get status of Xprint servers, RedHat-style + 'status') + x="$(do_get_xpserverlist)" + if [ "${x}" != "" ] ; then + msg "Xprint (${x}) is running..." + exit 0 + else + msg "Xprint is stopped" + exit 3 + fi + ;; + + ## Wrapper + 'wrapper') + cmd="${2}" + [ "${cmd}" = "" ] && fatal_error "No command given." + shift ; shift + export XPSERVERLIST="$(do_get_xpserverlist)" + [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found." + exec "${cmd}" "$@" + ;; + + ## Wrapper for "xplsprinters" + 'lsprinters') + [ "${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" != "" ] && cmd="${ETC_INITD_XPRINT_XPLSPRINTERS_PATH}" + [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprintglue" ] && cmd="/opt/GISWxprintglue/bin/xplsprinters" + [ "${cmd}" = "" -a "${XPCUSTOMGLUE}" = "GISWxprint" ] && cmd="/opt/GISWxprint/bin/xplsprinters" + [ "${cmd}" = "" -a "${XPROJECTROOT}" != "" ] && cmd="${XPROJECTROOT}/bin/xplsprinters" + [ "${cmd}" = "" ] && cmd="xplsprinters" + + shift + export XPSERVERLIST="$(do_get_xpserverlist)" + [ "${XPSERVERLIST}" = "" ] && fatal_error "No Xprint servers found." + exec "${cmd}" "$@" + ;; + + ## Print usage + *) + msg "Usage: $0 { start | stop | restart | reload | force-reload | status | condrestart | try-restart | wrapper | lsprinters | get_xpserverlist }" + exit 2 +esac +exit 0 + +# EOF. Index: xc/programs/Xserver/Xprint/etc/profile.d/Imakefile =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/profile.d/Imakefile diff -N xc/programs/Xserver/Xprint/etc/profile.d/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/profile.d/Imakefile 21 Apr 2004 09:35:11 -0000 @@ -0,0 +1,6 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/10/31 14:42:52 gisburn Exp $ + +all:: + +InstallNamedProg(xprint.csh,xprint.csh,/etc/profile.d) +InstallNamedProg(xprint.sh,xprint.sh,/etc/profile.d) Index: xc/programs/Xserver/Xprint/etc/profile.d/xprint.csh =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/profile.d/xprint.csh diff -N xc/programs/Xserver/Xprint/etc/profile.d/xprint.csh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/profile.d/xprint.csh 21 Apr 2004 09:35:11 -0000 @@ -0,0 +1,16 @@ +# +# /etc/profile.d/xprint.csh +# +# Copyright (c) 2002-2004 by Roland Mainz +# please send bugfixes or comments to http://xprint.mozdev.org/ + + +# +# Obtain list of Xprint servers +# + +if ( -f /etc/init.d/xprint ) then + setenv XPSERVERLIST "`/bin/sh /etc/init.d/xprint get_xpserverlist`" +endif + +# /etc/profile.d/xprint.csh ends here. Index: xc/programs/Xserver/Xprint/etc/profile.d/xprint.sh =================================================================== RCS file: xc/programs/Xserver/Xprint/etc/profile.d/xprint.sh diff -N xc/programs/Xserver/Xprint/etc/profile.d/xprint.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/etc/profile.d/xprint.sh 21 Apr 2004 09:35:11 -0000 @@ -0,0 +1,16 @@ +# +# /etc/profile.d/xprint.sh +# +# Copyright (c) 2002-2004 by Roland Mainz +# please send bugfixes or comments to http://xprint.mozdev.org/ + +# +# Obtain list of Xprint servers +# + +if [ -f "/etc/init.d/xprint" ] ; then + XPSERVERLIST="`/bin/sh /etc/init.d/xprint get_xpserverlist`" + export XPSERVERLIST +fi + +# /etc/profile.d/xprint.sh ends here. Index: xc/programs/Xserver/Xprint/pdf/README =================================================================== RCS file: xc/programs/Xserver/Xprint/pdf/README diff -N xc/programs/Xserver/Xprint/pdf/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/pdf/README 21 Apr 2004 09:35:14 -0000 @@ -0,0 +1 @@ +Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=3529 Index: xc/programs/Xserver/Xprint/ps/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/Imakefile,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Imakefile --- a/xc/programs/Xserver/Xprint/ps/Imakefile 5 Mar 2004 13:39:53 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/Imakefile 21 Apr 2004 09:35:14 -0000 @@ -1,12 +1,22 @@ -XCOMM $Xorg: Imakefile,v 1.4 2000/08/17 19:48:09 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/programs/Xserver/Xprint/ps/Imakefile,v 1.8 2001/12/21 21:02:05 dawes Exp $ +XCOMM $Xorg: Imakefile,v 1.5 2001/03/14 18:26:56 pookie Exp $ #include +#if BuildFreeType +FT2SOURCEDIR = $(TOP)/extras/freetype2/src +FT2INCDIR = $(TOP)/extras/freetype2/include +FT2INCS = -I$(FT2INCDIR) \ + -I$(FT2SOURCEDIR)/type42 +TTF2PT1OURCEDIR = $(TOP)/extras/ttf2pt1 +FT_DEFINES = -DXP_USE_FREETYPE +FTSRCS = psout_ft.c psout_ftpstype1.c psout_ftpstype3.c PsFTFonts.c +FTOBJS = psout_ft.o psout_ftpstype1.o psout_ftpstype3.o PsFTFonts.o + +TTF2PT1SRCS = ft.c pt1.c runt1asm.c ttf2pt1.c +TTF2PT1OBJS = ft.o pt1.o runt1asm.o ttf2pt1.o +TTF2PT1_DEFINES = -DUSE_FREETYPE -DXP_ONLY_BLOCKS +#endif /* BuildFreeType */ + SRCS1 = PsInit.c PsPrint.c PsGC.c PsMisc.c PsSpans.c PsArea.c PsPixel.c \ PsLine.c PsPolygon.c PsArc.c PsText.c PsWindow.c PsFonts.c \ PsAttr.c PsAttVal.c PsColor.c PsPixmap.c psout.c PsCache.c @@ -15,15 +25,45 @@ PsLine.o PsPolygon.o PsArc.o PsText.o PsWindow.o PsFonts.o \ PsAttr.o PsAttVal.o PsColor.o PsPixmap.o psout.o PsCache.o -SRCS = $(SRCS1) +SRCS = $(SRCS1) $(TTF2PT1SRCS) $(FTSRCS) -OBJS = $(OBJS1) +OBJS = $(OBJS1) $(TTF2PT1OBJS) $(FTOBJS) - DEFINES = -UXFree86LOADER -DXP_PSTEXT -D_XP_PRINT_SERVER_ -DBM_CACHE +#if BuildFreeType +LinkSourceFile(ttf2pt1.c,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(pt1.c,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(pt1.h,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(ft.c,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(runt1asm.c,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(t1asm.c,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(ttf.h,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(global.h,$(TTF2PT1OURCEDIR)/) +LinkSourceFile(version.h,$(TTF2PT1OURCEDIR)/) +#endif /* BuildFreeType */ + +#ifdef XVendorString +VENDORSTRING = XVendorString + VENDOR_STRING = -DVENDOR_STRING=\"$(VENDORSTRING)\" +#endif + +#ifdef XVendorRelease +VENDORRELEASE = XVendorRelease + VENDOR_RELEASE = -DVENDOR_RELEASE="$(VENDORRELEASE)" +#endif + +VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) + +XCOMM DEFINES = -DPIXPRIV + +XCOMM BM_CACHE disabled because it causes PostScript errors +XCOMM (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1489) +XCOMM DEFINES = -DXP_PSTEXT -DBM_CACHE $(VENDOR_DEFINES) $(TTF2PT1_DEFINES) $(FT_DEFINES) + DEFINES = -UXFree86LOADER -DXP_PSTEXT -D_XP_PRINT_SERVER_ $(VENDOR_DEFINES) $(TTF2PT1_DEFINES) $(FT_DEFINES) INCLUDES = -I. -I../../cfb -I../../mi -I../../mfb -I$(LIBSRC) \ - -I$(XINCLUDESRC) -I../../include -I.. -I$(TOP)/include \ - -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(FONTLIBSRC)/include + -I$(XINCLUDESRC) -I../../include -I.. -I$(TOP)/include \ + -I$(EXTINCSRC) -I$(FONTINCSRC) -I$(FONTLIBSRC)/include \ + $(FT2INCS) -I../../../../lib/font/FreeType LINTLIBS = $(TOP)/server/dix/llib-ldix.ln $(TOP)/server/os/llib-los.ln \ $(TOP)/server/ddx/mfb/llib-lmfb.ln \ Index: xc/programs/Xserver/Xprint/ps/Ps.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/Ps.h,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 Ps.h --- a/xc/programs/Xserver/Xprint/ps/Ps.h 5 Mar 2004 13:39:54 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ps/Ps.h 21 Apr 2004 09:35:14 -0000 @@ -7,6 +7,7 @@ documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting +documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. @@ -73,7 +74,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/Ps.h,v 1.13 2001/12/21 21:02:05 dawes Exp $ */ #ifndef _PS_H_ #define _PS_H_ @@ -113,6 +113,7 @@ #include #include "attributes.h" + /* * Public index variables from PsInit.c */ @@ -249,6 +250,63 @@ Bool (*DestroyWindow)(WindowPtr); } PsScreenPrivRec, *PsScreenPrivPtr; +typedef struct PsFontTypeInfoRec PsFontTypeInfoRec; + +/* Structure to hold information about one font on disk + * Notes: + * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if + * they all use the same font on the disk) + * - the FreeType font download code uses multiple |PsFontTypeInfoRec| + * records for one font on disk if they differ in the encoding being + * used (this is an exception from the + * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better + * to rework that in a later step and add a new per-encoding structure). + */ +struct PsFontTypeInfoRec +{ + PsFontTypeInfoRec *next; /* Next record in list... */ + char *adobe_ps_name; /* PostScript font name (from the + * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */ + char *download_ps_name; /* PostScript font name used for font download */ + char *filename; /* File name of font */ +#ifdef XP_USE_FREETYPE + char *ft_download_encoding; /* encoding used for download */ + PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */ +#endif /* XP_USE_FREETYPE */ + int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */ + int font_type; /* See PSFTI_FONT_TYPE_* below... */ + Bool downloadableFont; /* Font can be downloaded */ + Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */ +}; + +#define PSFTI_FONT_TYPE_OTHER (0) +#define PSFTI_FONT_TYPE_PMF (1) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2) +#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3) +#define PSFTI_FONT_TYPE_TRUETYPE (4) +/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */ +#define PSFTI_FONT_TYPE_FREETYPE (5) + +typedef struct PsFontInfoRec PsFontInfoRec; + +/* Structure which represents our context info for a single XLFD font + * Note that multiple |PsFontInfoRec| records can share the same + * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent + * different appearances of the same font on disk(=|PsFontTypeInfoRec|)). + */ +struct PsFontInfoRec +{ + PsFontInfoRec *next; /* Next record in list... */ + /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to + * identify a font */ + FontPtr font; /* The font this record is for */ + pointer font_fontPrivate; + PsFontTypeInfoRec *ftir; /* Record about the font file on disk */ + const char *dfl_name; /* XLFD for this font */ + int size; /* Font size. Use |mtx| if |size==0| */ + float mtx[4]; /* Transformation matrix (see |size|) */ +}; + typedef struct { char *jobFileName; @@ -259,6 +317,8 @@ ClientPtr getDocClient; int getDocBufSize; PsOutPtr pPsOut; + PsFontTypeInfoRec *fontTypeInfoRecords; + PsFontInfoRec *fontInfoRecords; } PsContextPrivRec, *PsContextPrivPtr; typedef struct @@ -291,6 +351,7 @@ extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc, char **argv); +static Bool PsDestroyContext(XpContextPtr pCon); extern XpContextPtr PsGetContextFromWindow(WindowPtr win); /* @@ -314,6 +375,10 @@ */ extern Bool PsCreateGC(GCPtr pGC); +static int PsGetDrawablePrivateStuff(DrawablePtr pDrawable, GC *gc, + unsigned long *valid, PsOutPtr *psOut, + ColormapPtr *cMap); +extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable ); extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable, PsOutPtr *psOut, ColormapPtr *cMap); extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable); @@ -366,9 +431,8 @@ extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, char *pImage); -extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, int format, - char *pImage); +extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pImage); extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty); @@ -456,7 +520,19 @@ extern char *PsGetFontName(FontPtr pFont); extern int PsGetFontSize(FontPtr pFont, float *mtx); extern char *PsGetPSFontName(FontPtr pFont); +extern char *PsGetPSFaceOrFontName(FontPtr pFont); extern int PsIsISOLatin1Encoding(FontPtr pFont); +extern char *PsGetEncodingName(FontPtr pFont); +extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont); +extern void PsFreeFontInfoRecords(PsContextPrivPtr priv); +extern PsFTDownloadFontType PsGetFTDownloadFontType(void); + +/* + * Functions in PsFTFonts.c + */ + +extern char *PsGetFTFontFileName(FontPtr pFont); +extern Bool PsIsFreeTypeFont(FontPtr pFont); /* * Functions in PsAttr.c @@ -503,14 +579,4 @@ extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); -/* - * Functions in PsCache.c - */ - -#ifdef BM_CACHE -extern int PsBmIsImageCached(int gWidth, int gHeight, char *pBuffer); -extern int PsBmPutImageInCache(int gWidth, int gHeight, char *pBuffer); -extern void PsBmClearImageCache(void); -#endif - #endif /* _PS_H_ */ Index: xc/programs/Xserver/Xprint/ps/PsArea.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsArea.c,v retrieving revision 1.1.4.1 diff -u -r1.1.4.1 PsArea.c --- a/xc/programs/Xserver/Xprint/ps/PsArea.c 17 Nov 2003 19:03:44 -0000 1.1.4.1 +++ b/xc/programs/Xserver/Xprint/ps/PsArea.c 21 Apr 2004 09:35:14 -0000 @@ -228,7 +228,7 @@ return; } -static void +void PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y, int w, int h, int leftPad, int format, int imageRes, char *pImage) { @@ -269,9 +269,9 @@ ColormapPtr cMap; int pageRes, sw, sh; #ifdef BM_CACHE - long cache_id = 0; + long cache_id = 0; #endif - + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; if (!imageRes) { sw = w; @@ -296,100 +296,100 @@ PsOut_BeginImageCache(psOut, cache_id); #endif - if( depth==24 ) - { - PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3); - if( format==XYPixmap ) + if( depth==24 ) { - int rowsiz = PixmapBytePad(w, depth); - char *planes[3]; - planes[0] = pImage; - planes[1] = &pImage[rowsiz*h]; - planes[2] = &pImage[rowsiz*h*2]; - for( r=0 ; rbgPixel), - PsGetPixelColor(cMap, pGC->fgPixel), - x, y, w, h, sw, sh, 1); - for( r=0 ; rbgPixel), + PsGetPixelColor(cMap, pGC->fgPixel), + x, y, w, h, sw, sh, 1); + for( r=0 ; r>j)&1)<<(7-j)); } - else - iv_ = iv; - c = iv_; - PsOut_OutImageBytes(psOut, 1, &c); + char *pt = &pImage[rowsiz*r]; + for( i=0 ; i>j)&1)<<(7-j)); } + else + iv_ = iv; + c = iv_; + PsOut_OutImageBytes(psOut, 1, &c); + } } + PsOut_EndImage(psOut); } - PsOut_EndImage(psOut); } - } #ifdef BM_CACHE - PsOut_EndImageCache(psOut); + PsOut_EndImageCache(psOut); } PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel), PsGetPixelColor(cMap, pGC->fgPixel)); Index: xc/programs/Xserver/Xprint/ps/PsAttVal.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsAttVal.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsAttVal.c --- a/xc/programs/Xserver/Xprint/ps/PsAttVal.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsAttVal.c 21 Apr 2004 09:35:14 -0000 @@ -32,7 +32,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttVal.c,v 1.4 2001/01/17 22:36:31 dawes Exp $ */ #include "Ps.h" #include "AttrValid.h" @@ -73,7 +72,16 @@ }; static unsigned long ValidPrinterResolutionsCards[] = { + 75, + 100, + 120, + 150, + 180, + 200, + 240, 300, + 360, + 400, 600, 720, 940, @@ -86,7 +94,20 @@ }; static unsigned long DefaultPrinterResolutionsCards[] = { - 300 + 75, + 100, + 120, + 150, + 180, + 200, + 240, + 300, + 360, + 400, + 600, + 720, + 940, + 1200 }; static XpOidCardList DefaultPrinterResolutions = { DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards) @@ -143,13 +164,6 @@ DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts) }; -/* -** So filtered printers that accept other raw formats can be -** used with this driver. -** -** Noah Roberts (jik-) -*/ -#if 0 static XpOidDocFmt ValidRawFormatsSupportedFmts[] = { { "Postscript", "2", NULL } @@ -157,7 +171,6 @@ static XpOidDocFmtList ValidRawFormatsSupported = { ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts) }; -#endif static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = { { "Postscript", "2", NULL } @@ -178,12 +191,74 @@ }; static XpOid ValidMediumSizesOids[] = { + xpoid_val_medium_size_iso_a0, + xpoid_val_medium_size_iso_a1, + xpoid_val_medium_size_iso_a2, + xpoid_val_medium_size_iso_a3, xpoid_val_medium_size_iso_a4, + xpoid_val_medium_size_iso_a5, + xpoid_val_medium_size_iso_a6, + xpoid_val_medium_size_iso_a7, + xpoid_val_medium_size_iso_a8, + xpoid_val_medium_size_iso_a9, + xpoid_val_medium_size_iso_a10, + xpoid_val_medium_size_iso_b0, + xpoid_val_medium_size_iso_b1, + xpoid_val_medium_size_iso_b2, + xpoid_val_medium_size_iso_b3, + xpoid_val_medium_size_iso_b4, + xpoid_val_medium_size_iso_b5, + xpoid_val_medium_size_iso_b6, + xpoid_val_medium_size_iso_b7, + xpoid_val_medium_size_iso_b8, + xpoid_val_medium_size_iso_b9, + xpoid_val_medium_size_iso_b10, xpoid_val_medium_size_na_letter, xpoid_val_medium_size_na_legal, xpoid_val_medium_size_executive, + xpoid_val_medium_size_folio, + xpoid_val_medium_size_invoice, + xpoid_val_medium_size_ledger, + xpoid_val_medium_size_quarto, + xpoid_val_medium_size_iso_c3, + xpoid_val_medium_size_iso_c4, + xpoid_val_medium_size_iso_c5, + xpoid_val_medium_size_iso_c6, xpoid_val_medium_size_iso_designated_long, - xpoid_val_medium_size_na_number_10_envelope + xpoid_val_medium_size_na_10x13_envelope, + xpoid_val_medium_size_na_9x12_envelope, + xpoid_val_medium_size_na_number_10_envelope, + xpoid_val_medium_size_na_7x9_envelope, + xpoid_val_medium_size_na_9x11_envelope, + xpoid_val_medium_size_na_10x14_envelope, + xpoid_val_medium_size_na_number_9_envelope, + xpoid_val_medium_size_na_6x9_envelope, + xpoid_val_medium_size_na_10x15_envelope, + xpoid_val_medium_size_monarch_envelope, + xpoid_val_medium_size_a, + xpoid_val_medium_size_b, + xpoid_val_medium_size_c, + xpoid_val_medium_size_d, + xpoid_val_medium_size_e, + xpoid_val_medium_size_jis_b0, + xpoid_val_medium_size_jis_b1, + xpoid_val_medium_size_jis_b2, + xpoid_val_medium_size_jis_b3, + xpoid_val_medium_size_jis_b4, + xpoid_val_medium_size_jis_b5, + xpoid_val_medium_size_jis_b6, + xpoid_val_medium_size_jis_b7, + xpoid_val_medium_size_jis_b8, + xpoid_val_medium_size_jis_b9, + xpoid_val_medium_size_jis_b10, + xpoid_val_medium_size_hp_2x_postcard, + xpoid_val_medium_size_hp_european_edp, + xpoid_val_medium_size_hp_mini, + xpoid_val_medium_size_hp_postcard, + xpoid_val_medium_size_hp_tabloid, + xpoid_val_medium_size_hp_us_edp, + xpoid_val_medium_size_hp_us_government_legal, + xpoid_val_medium_size_hp_us_government_letter, }; static XpOidList ValidMediumSizes = { ValidMediumSizesOids, XpNumber(ValidMediumSizesOids) @@ -205,7 +280,7 @@ &ValidPrinterResolutions, &DefaultPrinterResolutions, &ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported, &ValidListfontsModes, &DefaultListfontsModes, - NULL /* Any raw format specified (NR)*/, &DefaultRawFormatsSupported, + &ValidRawFormatsSupported, &DefaultRawFormatsSupported, &ValidSetupProviso, &DefaultDocumentFormat }; Index: xc/programs/Xserver/Xprint/ps/PsAttr.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsAttr.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsAttr.c --- a/xc/programs/Xserver/Xprint/ps/PsAttr.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsAttr.c 21 Apr 2004 09:35:14 -0000 @@ -57,7 +57,6 @@ * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttr.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */ /******************************************************************* ** @@ -76,6 +75,7 @@ ********************************************************************/ #include "Ps.h" +#include "attributes.h" char * PsGetAttributes( Index: xc/programs/Xserver/Xprint/ps/PsCache.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsCache.c,v retrieving revision 1.1.4.1 diff -u -r1.1.4.1 PsCache.c --- a/xc/programs/Xserver/Xprint/ps/PsCache.c 17 Nov 2003 19:03:44 -0000 1.1.4.1 +++ b/xc/programs/Xserver/Xprint/ps/PsCache.c 21 Apr 2004 09:35:14 -0000 @@ -79,21 +79,21 @@ #include "fntfil.h" #include "fntfilst.h" -#define GET 0 -#define RESET 1 +#define GET 0 +#define RESET 1 struct bm_cache_list { - struct bm_cache_list *next; - struct bm_cache_list *prev; + struct bm_cache_list *next; + struct bm_cache_list *prev; int height; - long id; + long id; char *pBuffer; }; struct bm_cache_head { - struct bm_cache_list *head; - int width; - struct bm_cache_head *next; + struct bm_cache_list *head; + int width; + struct bm_cache_head *next; struct bm_cache_head *prev; }; @@ -106,14 +106,14 @@ if(func == RESET) { - unique_id = 0; - return 0; + unique_id = 0; + return 0; } else - return ++unique_id; + return ++unique_id; } -int +int PsBmIsImageCached( int gWidth, int gHeight, @@ -126,28 +126,28 @@ { if(pList->width == gWidth) { - struct bm_cache_list *pItem = pList->head; + struct bm_cache_list *pItem = pList->head; - while(pItem != NULL) - { - if(pItem->height == gHeight) - { - int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; - - if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length)) - { - return_val = pItem->id; - break; - } - } - else if(pItem->height > gHeight) - break; + while(pItem != NULL) + { + if(pItem->height == gHeight) + { + int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight; + + if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length)) + { + return_val = pItem->id; + break; + } + } + else if(pItem->height > gHeight) + break; - pItem = pItem->next; - } + pItem = pItem->next; + } } - else if(pList->width > gWidth) - break; + else if(pList->width > gWidth) + break; pList = pList->next; } @@ -180,39 +180,39 @@ while(pList != NULL) { if(pList->width == gWidth) - { - struct bm_cache_list *pItem = pList->head; + { + struct bm_cache_list *pItem = pList->head; - while(pItem != NULL) - { - if(pItem->height >= gHeight) - { - pNew->next = pItem; - pNew->prev = pItem->prev; - if(pItem->prev != NULL) - pItem->prev->next = pNew; + while(pItem != NULL) + { + if(pItem->height >= gHeight) + { + pNew->next = pItem; + pNew->prev = pItem->prev; + if(pItem->prev != NULL) + pItem->prev->next = pNew; else - pList->head = pNew; + pList->head = pNew; pItem->prev = pNew; - return_val = pNew->id; + return_val = pNew->id; - break; - } - else if(pItem->next == NULL) - { - pNew->prev = pItem; - pItem->next = pNew; + break; + } + else if(pItem->next == NULL) + { + pNew->prev = pItem; + pItem->next = pNew; - return_val = pNew->id; + return_val = pNew->id; - break; - } + break; + } - pItem = pItem->next; - } + pItem = pItem->next; + } - break; + break; } pList = pList->next; @@ -223,50 +223,50 @@ struct bm_cache_head *pNewList; pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head)); - + pNewList->next = NULL; pNewList->prev = NULL; pNewList->width = gWidth; pNewList->head = pNew; - + if(bm_cache == NULL) { - bm_cache = pNewList; - return_val = pNew->id; + bm_cache = pNewList; + return_val = pNew->id; } else { - pList = bm_cache; + pList = bm_cache; - while(pList != NULL) - { - if(pList->width > gWidth) - { - pNewList->next = pList; - pNewList->prev = pList->prev; + while(pList != NULL) + { + if(pList->width > gWidth) + { + pNewList->next = pList; + pNewList->prev = pList->prev; - if(pList->prev != NULL) - pList->prev->next = pNewList; + if(pList->prev != NULL) + pList->prev->next = pNewList; else - bm_cache = pNewList; - pList->prev = pNewList; + bm_cache = pNewList; + pList->prev = pNewList; - return_val = pNew->id; + return_val = pNew->id; - break; - } - else if(pList->next == NULL) + break; + } + else if(pList->next == NULL) { - pNewList->prev = pList; - pList->next = pNewList; + pNewList->prev = pList; + pList->next = pNewList; - return_val = pNew->id; + return_val = pNew->id; - break; - } + break; + } - pList = pList->next; - } + pList = pList->next; + } } } @@ -280,35 +280,35 @@ { if(pItem != NULL) { - if(pItem->pBuffer != NULL) - free(pItem->pBuffer); + if(pItem->pBuffer != NULL) + free(pItem->pBuffer); pItem->pBuffer = NULL; - if(pItem->next) - PsBmClearImageCacheItem(pItem->next); + if(pItem->next) + PsBmClearImageCacheItem(pItem->next); pItem->next = NULL; - free(pItem); - pItem = NULL; + free(pItem); + pItem = NULL; } } -static void +static void PsBmClearImageCacheList( struct bm_cache_head *pList) { if(pList != NULL) { - if(pList->head) - PsBmClearImageCacheItem(pList->head); + if(pList->head) + PsBmClearImageCacheItem(pList->head); pList->head = NULL; - if(pList->next) - PsBmClearImageCacheList(pList->next); + if(pList->next) + PsBmClearImageCacheList(pList->next); pList->next = NULL; - free(pList); - pList = NULL; + free(pList); + pList = NULL; } } Index: xc/programs/Xserver/Xprint/ps/PsColor.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsColor.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsColor.c --- a/xc/programs/Xserver/Xprint/ps/PsColor.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsColor.c 21 Apr 2004 09:35:15 -0000 @@ -73,7 +73,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsColor.c,v 1.2 2001/10/28 03:32:56 tsi Exp $ */ #include "Ps.h" #include "gcstruct.h" @@ -86,6 +85,7 @@ int i; unsigned short rgb; VisualPtr pVisual = pColor->pVisual; + Pixel pix; if( pVisual->class==TrueColor ) { Index: xc/programs/Xserver/Xprint/ps/PsFTFonts.c =================================================================== RCS file: xc/programs/Xserver/Xprint/ps/PsFTFonts.c diff -N xc/programs/Xserver/Xprint/ps/PsFTFonts.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/ps/PsFTFonts.c 21 Apr 2004 09:35:15 -0000 @@ -0,0 +1,80 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + +#include +#include +#include + +#include "regionstr.h" +#include "fontstruct.h" +#include "dixfontstr.h" +#include "scrnintstr.h" +#include "fontxlfd.h" +#include "fntfil.h" +#include "fntfilst.h" + +#include "Ps.h" + +#include +#include FT_FREETYPE_H + +#include "ft.h" +#include "ftfuncs.h" + +char * +PsGetFTFontFileName(FontPtr pFont) +{ + FTFontPtr tf = (FTFontPtr)pFont->fontPrivate; + return tf->instance->face->filename; +} + +Bool +PsIsFreeTypeFont(FontPtr pFont) +{ + int i; + int nprops = pFont->info.nprops; + FontPropPtr props = pFont->info.props; + /* "RASTERIZER_NAME" must match the rasterizer name set in + * xc/lib/font/FreeType/ftfuncs.c */ + Atom name = MakeAtom("RASTERIZER_NAME", 15, True); + Atom value = (Atom)0; + char *rv; + + for( i=0 ; i +#include +#include + Bool PsRealizeFont( ScreenPtr pscr, @@ -110,7 +115,7 @@ for( i=0 ; iinfo.nprops; FontPropPtr props = pFont->info.props; - Atom name = MakeAtom("PRINTER_RESIDENT_FONT", 21, True); + /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute + * name - changing the name will break printer-builtin fonts. */ + Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True); Atom value = (Atom)0; for( i=0 ; iinfo.nprops; + FontPropPtr props = pFont->info.props; + Atom fnt = MakeAtom("FONT", 4, True); + Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True); + Atom enc = MakeAtom("CHARSET_ENCODING", 16, True); + Atom fv = 0, rv = 0, ev = 0; + char *fp = 0; + char *rp = 0; + char *ep = 0; + char *encname; + + for( i=0 ; ifpe->name == "tcp/:7100")) + */ +static +Bool IsFPEaReadableDir(FontPtr pFont) +{ + const char *fpe_name = pFont->fpe->name; + if (!fpe_name) + return False; + +#define MODEL_FONTPATH_PREFIX "PRINTER:" +#define MODEL_FONTPATH_PREFIX_LEN 8 + /* Strip model-specific font path prefix if there is one... */ + if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN)) + fpe_name += MODEL_FONTPATH_PREFIX_LEN; + + if (access(fpe_name, F_OK) == 0) + { + return True; + } + + return False; +} + +static +char *getFontFilename(FontPtr pFont) +{ + FontDirectoryPtr dir; + const char *dlfnam; + FILE *file; + struct stat statb; + int count, i, status; + char buf[512]; + char *front, *end, *fn; + char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */ + font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */ + +#ifdef XP_USE_FREETYPE + if( PsIsFreeTypeFont(pFont) ) + { + const char *fontname = PsGetFTFontFileName(pFont); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:""); +#endif /* DEBUG_gisburn */ + + if( !fontname ) + return NULL; + + return strdup(fontname); + } +#endif /* XP_USE_FREETYPE */ + + if (!IsFPEaReadableDir(pFont)) + { +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name); +#endif /* DEBUG_gisburn */ + return NULL; + } + + dir = pFont->fpe->private; + sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir"); + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + file = fopen(font_dir_fname, "r"); + if (file) + { + if (fstat (fileno(file), &statb) == -1) + return NULL; + + while( fgets(buf, sizeof(buf)-1, file) ) + { + if ((fn = strstr(buf, " -"))) + { + strcpy(font_file_fname, buf); + font_file_fname[fn - buf] = '\0'; + fn++; + if ((front = str_case_str(fn, "normal-"))) + { + fn[front - fn] = '\0'; + if (str_case_str(dlfnam, fn)) + { + char full_font_file_path[PATH_MAX]; + + fclose(file); + + sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname); + +#ifdef xDEBUG_gisburn + fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path); +#endif /* DEBUG_gisburn */ + return strdup(full_font_file_path); + } + } + } + } + } + font_file_fname[0] = '\0'; + fclose(file); + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFilename: returning NULL\n"); +#endif /* DEBUG_gisburn */ + + return NULL; +} + +static +PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontTypeInfoRec *rec; + const char *psname; + char *font_filename; + char *encname; +#ifdef XP_USE_FREETYPE + Bool is_freetypefont; +#endif /* XP_USE_FREETYPE */ + +#ifdef XP_USE_FREETYPE + is_freetypefont = PsIsFreeTypeFont(pFont); +#endif /* XP_USE_FREETYPE */ + encname = PsGetEncodingName(pFont); + + /* First try: Search by PostScript font name */ + psname = PsGetPSFontName(pFont); + if (psname) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if (rec->adobe_ps_name) + { + if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname)) && + (!strcmp(rec->ft_download_encoding, encname))) + { + return rec; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if (rec->adobe_ps_name) + { + if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcmp(rec->adobe_ps_name, psname))) + { + return rec; + } + } + } + } + } + + /* Last attempt: Search by filename */ + font_filename = getFontFilename(pFont); + if (font_filename) + { + for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next ) + { + if (rec->filename) + { +#ifdef XP_USE_FREETYPE + if (is_freetypefont) + { + if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) && + (!strcasecmp(rec->ft_download_encoding, encname)) ) + { + free(font_filename); + return rec; + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) && + (!strcasecmp(rec->filename, font_filename)) ) + { + free(font_filename); + return rec; + } + } + } + } + + free(font_filename); + } + + return NULL; +} + +static +void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontTypeInfoRecords; + cPriv->fontTypeInfoRecords = add_rec; +} + +static +Bool strcaseendswith(const char *str, const char *suffix) +{ + const char *s; + + s = str + strlen(str) - strlen(suffix); + + if (!strcasecmp(s, suffix)) + return True; + + return False; +} + + +static +int getFontFileType( const char *filename ) +{ + int type; + + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( strcaseendswith(filename, ".pfb") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if( strcaseendswith(filename, ".pfa") ) + { + type = PSFTI_FONT_TYPE_PS_TYPE1_PFA; + } + /* Is this a PMF(=Printer Metrics File) ? */ + else if( strcaseendswith(filename, ".pmf") ) + { + type = PSFTI_FONT_TYPE_PMF; + } + /* Is this a TrueType font file ? */ + else if( strcaseendswith(filename, ".ttf") || + strcaseendswith(filename, ".ttc") || + strcaseendswith(filename, ".otf") || + strcaseendswith(filename, ".otc") ) + { + type = PSFTI_FONT_TYPE_TRUETYPE; + } + else + { + type = PSFTI_FONT_TYPE_OTHER; + } + +#ifdef XP_USE_FREETYPE + { + XpContextPtr pCon; + char *downloadfonts; + pCon = XpGetPrintContext(requestingClient); + downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts"); + if( downloadfonts ) + { + /* Should we download PS Type1 fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) && + (strstr(downloadfonts, "pfa") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) && + (strstr(downloadfonts, "pfb") != NULL) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + + /* Should we download TrueType fonts as PS Type1||Type3 ? */ + if( (type == PSFTI_FONT_TYPE_TRUETYPE) && + ((strstr(downloadfonts, "ttf") != NULL) || + (strstr(downloadfonts, "ttc") != NULL) || + (strstr(downloadfonts, "otf") != NULL) || + (strstr(downloadfonts, "otc") != NULL)) ) + { + type = PSFTI_FONT_TYPE_FREETYPE; + } + } + } +#endif /* XP_USE_FREETYPE */ + +#ifdef DEBUG_gisburn + fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type); +#endif /* DEBUG_gisburn */ + return type; +} + +PsFTDownloadFontType PsGetFTDownloadFontType(void) +{ + PsFTDownloadFontType downloadfonttype; + XpContextPtr pCon; + char *psfonttype; + + pCon = XpGetPrintContext(requestingClient); + psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type"); + + if( !psfonttype || !strlen(psfonttype) ) + { + return PsFontType1; /* Default download font type is PS Type1 */ + } + + if( !strcmp(psfonttype, "bitmap") ) + { + downloadfonttype = PsFontBitmap; + } + else if( !strcmp(psfonttype, "pstype3") ) + { + downloadfonttype = PsFontType3; + } + else if( !strcmp(psfonttype, "pstype1") ) + { + downloadfonttype = PsFontType1; + } + else + { + FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype); + return 0; /* NO-OP, FatalError() will call |exit()| */ + } + + return downloadfonttype; +} + +static +PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + char *dlfnam; + PsFontTypeInfoRec *rec; + char *psname; + + if (!(dlfnam = PsGetFontName(pFont))) + return NULL; + + if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontTypeInfoRec)); + + rec->next = NULL; + + if (rec->filename = getFontFilename(pFont)) + { + rec->font_type = getFontFileType(rec->filename); + } + else + { + rec->filename = NULL; + rec->font_type = PSFTI_FONT_TYPE_OTHER; + } + + rec->adobe_ps_name = PsGetPSFontName(pFont); + rec->ft_download_encoding = PsGetEncodingName(pFont); + rec->ft_download_font_type = PsGetFTDownloadFontType(); + rec->download_ps_name = NULL; + +#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } } + + /* Set some flags based on the font type */ + switch( rec->font_type ) + { + case PSFTI_FONT_TYPE_PS_TYPE1_PFA: + case PSFTI_FONT_TYPE_PS_TYPE1_PFB: + rec->downloadableFont = True; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_PMF: + rec->downloadableFont = True; /* This font is in printer's ROM */ + SET_FONT_DOWNLOAD_STATUS(rec, True); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + + case PSFTI_FONT_TYPE_TRUETYPE: + /* Note: TrueType font download not implemented */ + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + +#ifdef XP_USE_FREETYPE + case PSFTI_FONT_TYPE_FREETYPE: + if( rec->ft_download_font_type == PsFontType1 || + rec->ft_download_font_type == PsFontType3 ) + { + rec->downloadableFont = True; + } + else + { + rec->downloadableFont = False; + } + + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */ + break; +#endif /* XP_USE_FREETYPE */ + + case PSFTI_FONT_TYPE_OTHER: + default: + rec->downloadableFont = False; + SET_FONT_DOWNLOAD_STATUS(rec, False); + rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont); + break; + } + +#ifdef XP_USE_FREETYPE + if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) ) + { + char *s; + register int c; + + if( rec->adobe_ps_name ) + { + rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding); + } + else + { + /* Unfortunately not all TTF fonts have a PostScript font name (like + * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType, + * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we + * have to generate a font name + */ + char ftfontname[64]; + static long myfontindex = 0L; + sprintf(ftfontname, "psfont_%lx", myfontindex++); + + rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2); + sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding); + + fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name); + } + + /* Make sure the font name we use for download is a valid PS font name */ + for( s = rec->download_ps_name ; *s != '\0'; s++ ) + { + c = *s; + + /* Check for allowed chars, invalid ones are replaced with a '_' + * (and check that the first char is not a digit) */ + if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) ) + { + *s = '_'; + } + } + } + else +#endif /* XP_USE_FREETYPE */ + { + if( rec->adobe_ps_name ) + { + rec->download_ps_name = strdup(rec->adobe_ps_name); + } + else + { + rec->download_ps_name = NULL; + } + } + + /* Safeguard - only treat font as downloadable when we have a PS font name!! */ + if (!rec->download_ps_name && rec->downloadableFont) + { + /* XXX: Log this message to the log when the logging service has been hook'ed up */ + fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam); + rec->downloadableFont = False; + } + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n", + ((rec->filename) ?(rec->filename) :("")), + ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("")), + ((rec->download_ps_name)?(rec->download_ps_name):(""))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +static +PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontTypeInfoRec *rec; + char *dlfnam; + + if(!(dlfnam = PsGetFontName(pFont))) + return NULL; + + rec = PsFindFontTypeInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontTypeInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontTypeInfoRec(pDrawable, rec); + + return rec; +} + +static +void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv ) +{ + PsFontTypeInfoRec *curr, *next; + curr = priv->fontTypeInfoRecords; + while( curr != NULL ) + { + if (curr->filename) + free(curr->filename); /* Free memory allocated by |strdup()| */ + + if (curr->download_ps_name) + free(curr->download_ps_name); + + next = curr->next; + xfree(curr); + curr = next; + } +} + +static +PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + PsFontInfoRec *rec; + + if (!pFont) + return NULL; + + for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next ) + { + if ((rec->font == pFont) && + (rec->font_fontPrivate == pFont->fontPrivate)) + return rec; + } + + return NULL; +} + +static +void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec) +{ + PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable); + + /* ToDO: Always move the last used entry to the top that the list get's + * sorted in an efficient order... :-) */ + add_rec->next = cPriv->fontInfoRecords; + cPriv->fontInfoRecords = add_rec; +} + +static +PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + PsFontTypeInfoRec *ftir; + + if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont))) + return NULL; + + if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec)))) + return NULL; + memset(rec, 0, sizeof(PsFontInfoRec)); + + rec->font = pFont; + rec->font_fontPrivate = pFont->fontPrivate; + rec->ftir = ftir; + rec->next = NULL; + rec->dfl_name = PsGetFontName(pFont); + rec->size = PsGetFontSize(pFont, rec->mtx); + +#ifdef DEBUG_gisburn + fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n", + ((rec->dfl_name)?(rec->dfl_name):(""))); +#endif /* DEBUG_gisburn */ + + return rec; +} + +PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont) +{ + PsFontInfoRec *rec; + + rec = PsFindFontInfoRec(pDrawable, pFont); + if (rec) + return rec; + + rec = PsCreateFontInfoRec(pDrawable, pFont); + if (!rec) + return NULL; + + PsAddFontInfoRec(pDrawable, rec); + + return rec; +} + +void PsFreeFontInfoRecords( PsContextPrivPtr priv ) +{ + PsFontInfoRec *curr, *next; + curr = priv->fontInfoRecords; + while( curr != NULL ) + { + next = curr->next; + xfree(curr); + curr = next; + } + + PsFreeFontTypeInfoRecords(priv); + + priv->fontTypeInfoRecords = NULL; + priv->fontInfoRecords = NULL; +} Index: xc/programs/Xserver/Xprint/ps/PsGC.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsGC.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 PsGC.c --- a/xc/programs/Xserver/Xprint/ps/PsGC.c 5 Mar 2004 13:39:54 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ps/PsGC.c 21 Apr 2004 09:35:15 -0000 @@ -57,7 +57,6 @@ * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsGC.c,v 1.6tsi Exp $ */ /******************************************************************* ** @@ -171,6 +170,26 @@ } } +PsContextPrivPtr +PsGetPsContextPriv( DrawablePtr pDrawable ) +{ + XpContextPtr pCon; + PsContextPrivPtr cPriv; + + switch(pDrawable->type) + { + case DRAWABLE_PIXMAP: + return FALSE; + case DRAWABLE_WINDOW: + pCon = PsGetContextFromWindow((WindowPtr)pDrawable); + if (pCon != NULL) + { + return pCon->devPrivates[PsContextPrivateIndex].ptr; + } + } + return NULL; +} + int PsUpdateDrawableGC( GCPtr pGC, @@ -181,6 +200,7 @@ GC dGC; unsigned long valid; int i; + PsContextPrivPtr cPriv; BoxPtr boxes; if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap)) @@ -232,6 +252,8 @@ PsOut_Offset(*psOut, pDrawable->x, pDrawable->y); PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip); } + cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) ) + ->devPrivates[PsContextPrivateIndex].ptr; break; } return TRUE; Index: xc/programs/Xserver/Xprint/ps/PsInit.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsInit.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 PsInit.c --- a/xc/programs/Xserver/Xprint/ps/PsInit.c 5 Mar 2004 13:39:54 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ps/PsInit.c 21 Apr 2004 09:35:15 -0000 @@ -71,9 +71,8 @@ ** * Copyright: Copyright 1996 The Open Group, Inc. ** * ** ********************************************************* -** +** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsInit.c,v 1.13tsi Exp $ */ #include #include @@ -109,8 +108,12 @@ char **argv; { #if 0 + int maxXres, maxYres, maxWidth, maxHeight; + int maxRes, maxDim, numBytes; PsScreenPrivPtr pPriv; #endif + char **printerNames; + int numPrinters; int nVisuals; int nDepths; VisualPtr visuals; @@ -188,7 +191,7 @@ visuals[1].vid = FakeClientID(0); visuals[1].class = PseudoColor; - visuals[1].bitsPerRGBValue = 0; + visuals[1].bitsPerRGBValue = 8; visuals[1].ColormapEntries = 256; visuals[1].nplanes = 8; visuals[1].redMask = 0x0; @@ -209,7 +212,7 @@ /* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 24 BIT */ /* miScreenInit(pScreen, (pointer)0, pScreen->width, pScreen->height, - pScreen->width / (pScreen->mmWidth / 25.40), + pScreen->width / (pScreen->mmWidth / 25.40), pScreen->height / (pScreen->mmHeight / 25.40), 0, 24, nDepths, depths, visuals[1].vid, nVisuals, visuals); */ @@ -217,7 +220,7 @@ /* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 8 BIT */ miScreenInit(pScreen, (pointer)0, pScreen->width, pScreen->height, - (int) (pScreen->width / (pScreen->mmWidth / 25.40)), + (int) (pScreen->width / (pScreen->mmWidth / 25.40)), (int) (pScreen->height / (pScreen->mmHeight / 25.40)), 0, 8, nDepths, depths, visuals[1].vid, nVisuals, visuals); @@ -243,7 +246,7 @@ sizeof(PsWindowPrivRec)); PsContextPrivateIndex = XpAllocateContextPrivateIndex(); - XpAllocateContextPrivate(PsContextPrivateIndex, + XpAllocateContextPrivate(PsContextPrivateIndex, sizeof(PsContextPrivRec)); PsPixmapPrivateIndex = AllocatePixmapPrivateIndex(); @@ -278,7 +281,7 @@ XpDriverFuncsPtr pFuncs; PsContextPrivPtr pConPriv; char *server, *attrStr; - + /* * Initialize the attribute store for this printer. */ @@ -304,18 +307,23 @@ pFuncs->GetMediumDimensions = PsGetMediumDimensions; pFuncs->GetReproducibleArea = PsGetReproducibleArea; pFuncs->SetImageResolution = PsSetImageResolution; - + /* * Set up the context privates */ pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - pConPriv->jobFileName = (char *)NULL; - pConPriv->pJobFile = (FILE *)NULL; - - pConPriv->getDocClient = (ClientPtr)NULL; - pConPriv->getDocBufSize = 0; + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + pConPriv->jobFileName = (char *)NULL; + pConPriv->pJobFile = (FILE *)NULL; + pConPriv->dash = (unsigned char *)NULL; + pConPriv->validGC = 0; + pConPriv->getDocClient = (ClientPtr)NULL; + pConPriv->getDocBufSize = 0; + pConPriv->pPsOut = NULL; + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; /* * document-attributes-supported @@ -323,15 +331,15 @@ server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP ); if ((attrStr = (char *) xalloc(strlen(server) + strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL) - + strlen(PAGE_ATT_VAL) + 6)) == NULL) + + strlen(PAGE_ATT_VAL) + 6)) == NULL) { return BadAlloc; } - sprintf(attrStr, "*%s:\t%s %s %s", + sprintf(attrStr, "*%s:\t%s %s %s", DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL); XpAugmentAttributes( pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * job-attributes-supported */ @@ -344,7 +352,7 @@ sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL); XpAugmentAttributes(pCon, XPPrinterAttr, attrStr); xfree(attrStr); - + /* * xp-page-attributes-supported */ @@ -375,7 +383,7 @@ { PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; - + if( pConPriv->pJobFile!=(FILE *)NULL ) { fclose(pConPriv->pJobFile); @@ -388,6 +396,11 @@ pConPriv->jobFileName = (char *)NULL; } + PsFreeFontInfoRecords(pConPriv); + + /* Reset context to make sure we do not use any stale/invalid/obsolete data */ + memset(pConPriv, 0, sizeof(PsContextPrivRec)); + /*### free up visuals/depths ###*/ return Success; Index: xc/programs/Xserver/Xprint/ps/PsLine.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsLine.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsLine.c --- a/xc/programs/Xserver/Xprint/ps/PsLine.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsLine.c 21 Apr 2004 09:35:15 -0000 @@ -73,7 +73,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsLine.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include "Ps.h" #include "gcstruct.h" Index: xc/programs/Xserver/Xprint/ps/PsMisc.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsMisc.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsMisc.c --- a/xc/programs/Xserver/Xprint/ps/PsMisc.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsMisc.c 21 Apr 2004 09:35:15 -0000 @@ -73,7 +73,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsMisc.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include "Xos.h" /* for SIGCLD on pre-POSIX systems */ #include Index: xc/programs/Xserver/Xprint/ps/PsPixel.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsPixel.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsPixel.c --- a/xc/programs/Xserver/Xprint/ps/PsPixel.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsPixel.c 21 Apr 2004 09:35:15 -0000 @@ -73,7 +73,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixel.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */ #include Index: xc/programs/Xserver/Xprint/ps/PsPixmap.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsPixmap.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsPixmap.c --- a/xc/programs/Xserver/Xprint/ps/PsPixmap.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsPixmap.c 21 Apr 2004 09:35:15 -0000 @@ -57,7 +57,7 @@ * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixmap.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */ + /******************************************************************* ** ** ********************************************************* @@ -79,6 +79,10 @@ #include "Ps.h" +#define BitsPerPixel(d) (\ + (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ + (PixmapWidthPaddingInfo[d].padRoundUp+1)) + PixmapPtr PsCreatePixmap( ScreenPtr pScreen, @@ -199,7 +203,7 @@ return(disp); } -static void +void PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable) { switch(elm->type) @@ -488,8 +492,6 @@ case PolyFillArcCmd: *nElms += elm->c.arcs.nArcs; break; - default: - break; } } } @@ -552,8 +554,6 @@ *nElms += 1; } break; - default: - break; } } } Index: xc/programs/Xserver/Xprint/ps/PsPolygon.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsPolygon.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 PsPolygon.c --- a/xc/programs/Xserver/Xprint/ps/PsPolygon.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/PsPolygon.c 21 Apr 2004 09:35:15 -0000 @@ -73,7 +73,6 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPolygon.c,v 1.6 2001/01/17 22:36:32 dawes Exp $ */ #include "Ps.h" #include "gcstruct.h" @@ -176,7 +175,8 @@ } else { - pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y; + i = 0; + pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y; for( i=1 ; i #include @@ -91,6 +90,7 @@ #include "Ps.h" #include "windowstr.h" +#include "attributes.h" #include "Oid.h" /* static utility function to get document/page attributes */ @@ -206,6 +206,8 @@ unlink(priv->jobFileName); xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + + PsFreeFontInfoRecords(priv); return Success; } @@ -214,6 +216,7 @@ * Append any trailing information here */ PsOut_EndFile(priv->pPsOut, 0); + priv->pPsOut = NULL; /* this is where we find out if we're out of space */ error = (fclose(priv->pJobFile) == EOF); @@ -233,6 +236,8 @@ xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + PsFreeFontInfoRecords(priv); + return BadAlloc; } @@ -265,10 +270,12 @@ xfree(priv->jobFileName); priv->jobFileName = (char *)NULL; + PsFreeFontInfoRecords(priv); + #ifdef BM_CACHE PsBmClearImageCache(); #endif - + return r; } @@ -281,10 +288,13 @@ { int iorient, iplex, icount, ires; unsigned short iwd, iht; + register WindowPtr pChild; PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr; + char s[80]; + xEvent event; /* * Put a pointer to the context in the window private structure @@ -298,9 +308,16 @@ * Start the page */ if (pConPriv->pPsOut == NULL) { - pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, - iorient, icount, iplex, ires, - (int)iwd, (int)iht, False); + char *title; + + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + + pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, False); + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; } PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires, (int)iwd, (int)iht); @@ -348,15 +365,22 @@ { int iorient, iplex, icount, ires; unsigned short iwd, iht; + char *title; PsContextPrivPtr pConPriv = (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr; + /* get job level attributes */ + title = XpGetOneAttribute(pCon, XPJobAttr, "job-name"); + /* get document level attributes */ S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht); pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile, - iorient, icount, iplex, ires, - (int)iwd, (int)iht, (type == XPDocRaw)); + title, iorient, icount, iplex, ires, + (int)iwd, (int)iht, (Bool)(type == XPDocRaw)); + + pConPriv->fontInfoRecords = NULL; + pConPriv->fontTypeInfoRecords = NULL; return Success; } @@ -391,8 +415,11 @@ PsContextPrivPtr cPriv; PsOutPtr psOut; - if (len_fmt != 12 || !strcmp(pFmt, "PostScript 2") || len_opt) + if (len_fmt != 12 || + strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 || + len_opt) return BadValue; + cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr; psOut = cPriv->pPsOut; Index: xc/programs/Xserver/Xprint/ps/PsText.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsText.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 PsText.c --- a/xc/programs/Xserver/Xprint/ps/PsText.c 5 Mar 2004 13:39:54 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ps/PsText.c 21 Apr 2004 09:35:16 -0000 @@ -73,49 +73,13 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsText.c,v 1.12tsi Exp $ */ #include "Ps.h" #include "gcstruct.h" #include "windowstr.h" +#include "fntfil.h" #include "fntfilst.h" -#include - -static int readFontName(char *fileName, char *file_name, char *dlfnam) -{ - FILE *file; - struct stat statb; - char buf[256]; - char *front, *fn; - - file = fopen(fileName, "r"); - if(file) - { - if (fstat (fileno(file), &statb) == -1) - return 0; - while(fgets(buf, 255, file)) - { - if((fn = strstr(buf, " -"))) - { - strcpy(file_name, buf); - file_name[fn - buf - 4] = '\0'; - fn++; - if((front = strstr(fn, "normal-"))) - { - fn[front - fn] = '\0'; - if(strstr(dlfnam, fn)) - { - fclose(file); - return 1; - } - } - } - } - } - file_name[0] = '\0'; - fclose(file); - return 0; -} +#include int PsPolyText8( @@ -147,70 +111,97 @@ elm->c.text8.string = (char *)xalloc(count); memcpy(elm->c.text8.string, string, count); disp->nelms += 1; + + return x; } else { - char *fnam, ffname[512], *dlfnam; - FontDirectoryPtr dir; - char file_name[MAXFONTNAMELEN]; - - dir = pGC->font->fpe->private; - sprintf(ffname, "%s%s", dir->directory, "fonts.dir"); - - fnam = PsGetPSFontName(pGC->font); - if(!fnam){ - if(!(dlfnam = PsGetFontName(pGC->font))) - return x; - /* If Type1 font, try to download to printer first */ - if(strstr(ffname, "Type1") && readFontName(ffname, file_name, dlfnam)) - { - int siz; - float mtx[4]; - PsOutPtr psOut; - ColormapPtr cMap; - - if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) - return x; - sprintf(ffname, "%s%s%s", dir->directory, file_name, ".pfa"); - PsOut_DownloadType1(psOut, file_name, ffname); - PsOut_Offset(psOut, pDrawable->x, pDrawable->y); - PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); - siz = PsGetFontSize(pGC->font, mtx); - if( !siz ) PsOut_TextAttrsMtx(psOut, file_name, mtx, 1); - else PsOut_TextAttrs(psOut, file_name, siz, 1); - PsOut_Text(psOut, x, y, string, count, -1); - return x; - } - { - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; - - GetGlyphs(pGC->font, (unsigned long)count, - (unsigned char *)string, Linear8Bit,&n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n != 0) - PsPolyGlyphBlt(pDrawable, pGC, x, y, n, - charinfo, FONTGLYPHS(pGC->font)); - x += w; - } - }else{ - int iso; - int siz; - float mtx[4]; - PsOutPtr psOut; - ColormapPtr cMap; - - if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return x; - PsOut_Offset(psOut, pDrawable->x, pDrawable->y); - PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); - siz = PsGetFontSize(pGC->font, mtx); - iso = PsIsISOLatin1Encoding(pGC->font); - if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso); - else PsOut_TextAttrs(psOut, fnam, siz, iso); - PsOut_Text(psOut, x, y, string, count, -1); + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + firec->ftir->download_ps_name, pGC->font, 0); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count); + + return x; } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + if (firec->ftir->alreadyDownloaded[0] == False) + { + PsOut_DownloadType1(psOut, "PsPolyText8", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[0] = True; + } + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; + + GetGlyphs(pGC->font, (unsigned long)count, + (unsigned char *)string, Linear8Bit, &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, + charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } } return x; } @@ -246,21 +237,136 @@ (unsigned short *)xalloc(count*sizeof(unsigned short)); memcpy(elm->c.text16.string, string, count*sizeof(unsigned short)); disp->nelms += 1; + + return x; } else { - unsigned long n, i; - int w; - CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ - - GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string, - (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, - &n, charinfo); - w = 0; - for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth; - if (n != 0) - PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); - x += w; + PsFontInfoRec *firec; + + /* We need a context for rendering... */ + if (PsGetPsContextPriv(pDrawable) == NULL) + return x; + + firec = PsGetFontInfoRec(pDrawable, pGC->font); + if (!firec) + return x; + +#ifdef XP_USE_FREETYPE + if (firec->ftir->downloadableFont && + (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + int i; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + /* Scan the string we want to render and download all neccesary parts + * of the font (one part(="font page") has 256 glyphs) + */ + for( i = 0 ; i < count ; i++ ) + { + c = string[i]; +#if IMAGE_BYTE_ORDER == LSBFirst + c_hiByte = c & 0x00FF; + c_lowByte = (c >> 8) & 0x00FF; +#elif IMAGE_BYTE_ORDER == MSBFirst + c_hiByte = (c >> 8) & 0x00FF; + c_lowByte = c & 0x00FF; +#else +#error Unsupported byte order +#endif + fontPage = c_hiByte; + + if (firec->ftir->alreadyDownloaded[fontPage] == False) + { + char buffer[256]; + const char *ps_name; + + if (fontPage > 0) + { + sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage); + ps_name = buffer; + } + else + { + ps_name = firec->ftir->download_ps_name; + } + + PsOut_DownloadFreeType(psOut, + firec->ftir->ft_download_font_type, + ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */ + + firec->ftir->alreadyDownloaded[fontPage] = True; + } + } + + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count); + + return x; + } + else +#endif /* XP_USE_FREETYPE */ + if (firec->ftir->downloadableFont && + (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE)) + { + PsOutPtr psOut; + ColormapPtr cMap; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + int i; + + if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) + return x; + + PsOut_DownloadType1(psOut, "PsPolyText16", + firec->ftir->download_ps_name, firec->ftir->filename); + firec->ftir->alreadyDownloaded[fontPage] = True; + + PsOut_Offset(psOut, pDrawable->x, pDrawable->y); + PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); + if (!firec->size) + PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding); + else + PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding); + PsOut_Text16(psOut, x, y, string, count, -1); + + return x; + } + + /* Render glyphs as bitmaps */ + { + unsigned long n, i; + int w; + CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */ + + GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string, + (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit, + &n, charinfo); + w = 0; + for (i=0; i < n; i++) + w += charinfo[i]->metrics.characterWidth; + if (n != 0) + PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); + x += w; + + return x; + } } return x; } @@ -386,7 +492,7 @@ pointer pGlyphBase) { int width, height; - PixmapPtr pPixmap = NullPixmap; + PixmapPtr pPixmap; int nbyLine; /* bytes per line of padded pixmap */ FontPtr pfont; GCPtr pGCtmp; @@ -399,7 +505,7 @@ int gWidth, gHeight; /* width and height of glyph */ register int nbyGlyphWidth; /* bytes per scanline of glyph */ int nbyPadGlyph; /* server padded line of glyph */ - int w; + int w, tmpx; XID gcvals[3]; pfont = pGC->font; @@ -435,6 +541,7 @@ PsDestroyPixmap(pPixmap); return; } + tmpx = 0; while(nGlyphs--) { pci = *pCharInfo++; @@ -466,8 +573,9 @@ 1, x + pci->metrics.leftSideBearing, y - pci->metrics.ascent, gWidth, gHeight, 0, XYBitmap, (char *)pb); - x += pci->metrics.characterWidth; } + + x += pci->metrics.characterWidth; } DEALLOCATE_LOCAL(pbits); FreeScratchGC(pGCtmp); Index: xc/programs/Xserver/Xprint/ps/PsWindow.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/PsWindow.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 PsWindow.c --- a/xc/programs/Xserver/Xprint/ps/PsWindow.c 5 Mar 2004 13:39:54 -0000 1.1.4.3 +++ b/xc/programs/Xserver/Xprint/ps/PsWindow.c 21 Apr 2004 09:35:16 -0000 @@ -73,11 +73,9 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/PsWindow.c,v 1.12tsi Exp $ */ #include #include -#include #include #include "mistruct.h" @@ -87,7 +85,8 @@ #include "Ps.h" -#if 0 +extern WindowPtr *WindowTable; + /* * The following list of strings defines the properties which will be * placed on the screen's root window if the property was defined in @@ -104,7 +103,7 @@ DT_PRINT_PAGE_COMMAND, (char *)NULL }; -#endif + /* * PsCreateWindow - watch for the creation of the root window. @@ -219,6 +218,8 @@ RegionPtr pRegion, int what) { + int status; + WindowPtr pRoot; #define FUNCTION 0 #define FOREGROUND 1 @@ -298,6 +299,7 @@ gcmask |= GCFunction | GCClipMask; i = pScreen->myNum; + pRoot = WindowTable[i]; pBgWin = pWin; if (what == PW_BORDER) @@ -375,14 +377,14 @@ } break; case GCClipMask: - if( (pointer)(long)pGC->clientClipType!=(pointer)CT_NONE ) + if( (pointer)pGC->clientClipType!=(pointer)CT_NONE ) { gcmask |= index; gcval[i++] = (pointer)CT_NONE; } break; case GCSubwindowMode: - if( (pointer)(long)pGC->subWindowMode!=newValues[SUBWINDOW] ) + if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] ) { gcmask |= index; gcval[i++] = newValues[SUBWINDOW]; @@ -396,7 +398,7 @@ } break; case GCFillStyle: - if( (pointer)(long)pGC->fillStyle!=newValues[FILLSTYLE] ) + if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] ) { gcmask |= index; gcval[i++] = newValues[FILLSTYLE]; Index: xc/programs/Xserver/Xprint/ps/psout.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/psout.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 psout.c --- a/xc/programs/Xserver/Xprint/ps/psout.c 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/psout.c 21 Apr 2004 09:35:17 -0000 @@ -73,79 +73,17 @@ ** ********************************************************* ** ********************************************************************/ -/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.c,v 1.11 2001/12/19 21:55:59 dawes Exp $ */ - -/* - * For XFree86 3.3.3: - * - * As a *quick* way of preventing some buffers overflowing onto the stack, - * they have been made static. There are potential problems with - * PsOutRec.Buf overflowing too which should be investigated as part of a - * review of this code, but that is at least always allocated with malloc - * and shouldn't pose an immediate stack trashing problem. - * - */ #include +#include #include "os.h" -#include "Ps.h" +#define USE_PSOUT_PRIVATE 1 #include "psout.h" +/* For VENDOR_STRING and VENDOR_RELEASE */ +#include "site.h" -typedef void *voidPtr; - -typedef struct PsPatRec_ -{ - PsFillEnum type; - voidPtr tag; -} PsPatRec; - -typedef PsPatRec *PsPatPtr; - -typedef struct PsOutRec_ -{ - FILE *Fp; - char Buf[256]; - int CurColor; - int LineWidth; - PsCapEnum LineCap; - PsJoinEnum LineJoin; - int NDashes; - int *Dashes; - int DashOffset; - int LineBClr; - PsRuleEnum FillRule; - char *FontName; - int FontSize; - float FontMtx[4]; - int ImageFormat; - int RevImage; - int NPatterns; - int MxPatterns; - PsPatPtr Patterns; - int ClipType; - PsClipRec Clip; - int InFrame; - int XOff; - int YOff; - - PsFillEnum InTile; - int ImgSkip; - int ImgBClr; - int ImgFClr; - int ImgX; - int ImgY; - int ImgW; - int ImgH; - int SclW; - int SclH; - - int NDownloads; - int MxDownloads; - char **Downloads; - Bool isRaw; - - int start_image; -} PsOutRec; +extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms); +extern void PsDestroyFillElementList(int nElms, PsElmPtr elms); /* * Standard definitions @@ -174,6 +112,7 @@ /ie{ifelse}bd\ /len{length}bd\ /m{moveto}bd\ +/rm{rmoveto}bd\ /l{lineto}bd\ /rl{rlineto}bd\ /a{arc}bd\ @@ -236,7 +175,11 @@ /mp{makepattern}bd\ /spt{setpattern}bd\ /spd{setpagedevice}bd\ -"; +" +#ifdef XP_USE_FREETYPE +"/trmoveto{currentfont /FontMatrix get transform rm}d" +#endif /* XP_USE_FREETYPE */ +; /* * Composite definitions @@ -341,7 +284,6 @@ /mtx{scl t [3 i 0 0 5 i 0 0]}bd \ "; -int pagenum = 0; char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"}; /* * Setup definitions @@ -360,7 +302,7 @@ * PRIVATE FUNCTIONS * *******************************************************************/ -static void +void S_Flush(PsOutPtr self) { if( self->Buf[0] ) @@ -388,7 +330,7 @@ { int i, k=0; S_Flush(self); - memset(self->Buf, 0, 256); + memset(self->Buf, 0, sizeof(self->Buf)); for( i=0 ; defs[i]!='\0' ;) { if( k>70 && (i==0 || (i && defs[i-1]!='/')) && @@ -396,7 +338,7 @@ { S_Flush(self); k = 0; - memset(self->Buf, 0, 256); + memset(self->Buf, 0, sizeof(self->Buf)); } if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; } self->Buf[k] = defs[i]; @@ -405,11 +347,11 @@ S_Flush(self); } -static void +void S_OutNum(PsOutPtr self, float num) { int i; - static char buf[64]; + char buf[64]; sprintf(buf, "%.3f", num); for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0'; if( buf[strlen(buf)-1]=='.' ) buf[strlen(buf)-1] = '\0'; @@ -422,7 +364,7 @@ S_OutStr(PsOutPtr self, char *txt, int txtl) { int i, k; - static char buf[512]; + char buf[1024]; for( i=0,k=0 ; i=' ' && txt[i]<='~') && @@ -430,7 +372,9 @@ { buf[k] = txt[i]; k++; continue; } buf[k] = '\\'; k++; sprintf(&buf[k], "%03o", txt[i]&0xFF); - k += 3; + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; } strcat(self->Buf, "("); i = strlen(self->Buf); @@ -440,7 +384,32 @@ if( strlen(self->Buf)>70 ) S_Flush(self); } +/* Same as S_OutStr() but takes |short *| instead of |char *| */ static void +S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl) +{ + int i, k; + char buf[2048]; + for( i=0,k=0 ; i=' ' && txt[i]<='~') && + txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' ) + { buf[k] = txt[i]; k++; continue; } + buf[k] = '\\'; k++; + sprintf(&buf[k], "%03o", txt[i]&0xFFFF); + /* Skip to the end of the buffer */ + while( buf[k] != '\0' ) + k++; + } + strcat(self->Buf, "("); + i = strlen(self->Buf); + memcpy(&self->Buf[i], buf, k); + self->Buf[i+k] = '\0'; + strcat(self->Buf, ")"); + if( strlen(self->Buf)>70 ) S_Flush(self); +} + +void S_OutTok(PsOutPtr self, char *tok, int cr) { if( self->Buf[0] ) strcat(self->Buf, " "); @@ -471,6 +440,27 @@ float fwd = ((float)wd/(float)res)*72.; float fht = ((float)ht/(float)res)*72.; +#define USE_WORKAROUND_COPY_COUNT_BUG 1 + +#ifdef USE_WORKAROUND_COPY_COUNT_BUG + /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 - + * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies + * instead of n copies. + * The problem is that we use both /NumCopies here but pass the + * %copy-count% to the spooler, too. + * But we only have to use _one_ way... + * + * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 - + * "PS DDX creates n^2 copies of a job instead of n copies") will back this + * workaround out and replace it with a better solution. + * (see mozilla.org bug 140030 + * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number + * of copies causes too many copies to print") for the initial report for + * this issue...) + */ + count = 1; +#endif /* USE_WORKAROUND_COPY_COUNT_BUG */ + S_OutTok(self, "/pWd", 0); S_OutNum(self, fwd); S_OutTok(self, "d /pHt", 0); @@ -577,10 +567,11 @@ } PsOutPtr -PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res, +PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res, int wd, int ht, Bool raw) { int i; + char buffer[256+32]; /* enougth space for a title with 256 chars... */ /* * Get ready to output PostScript header */ @@ -589,15 +580,25 @@ memset(psout, 0, sizeof(PsOutRec)); psout->Fp = fp; psout->isRaw = raw; - pagenum = 0; + psout->pagenum = 0; if (!raw) { /* * Output PostScript header */ - S_Comment(psout, "%!PS-Adobe-3.0 EPSF-3.0"); - S_Comment(psout, "%%Creator: The Open Group PostScript Print Server"); - /*### BoundingBox ###*/ + /* GhostScript will rant about the missing BoundingBox if we use + * "%!PS-Adobe-3.0 EPSF-3.0" here... */ + S_Comment(psout, "%!PS-Adobe-3.0"); + sprintf(buffer, + "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)", + VENDOR_STRING, VENDOR_RELEASE); + S_Comment(psout, buffer); + + if (title) + { + sprintf(buffer, "%%%%Title: %.256s", title); + S_Comment(psout, buffer); + } S_Comment(psout, "%%EndComments"); S_Comment(psout, "%%BeginProlog"); S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions"); @@ -634,10 +635,13 @@ { char coms[50]; int i; + + if (!self) + return; if (!self->isRaw) { S_Comment(self,"%%Trailer"); - sprintf(coms,"%%%%Pages: %d",pagenum); + sprintf(coms,"%%%%Pages: %d", self->pagenum); S_Comment(self, coms); S_Comment(self, "%%EOF"); } @@ -646,9 +650,6 @@ if( self->Patterns ) xfree(self->Patterns); if( self->Clip.rects ) xfree(self->Clip.rects); if( closeFile ) fclose(self->Fp); - for( i=0 ; iNDownloads ; i++ ) xfree(self->Downloads[i]); - if( self->Downloads ) xfree(self->Downloads); - pagenum = 0; /* reset page num back to 0 */ xfree(self); } @@ -661,8 +662,8 @@ /*** comment for pagenumbers *****/ S_Comment(self,"%%PageHeader"); - pagenum++; - sprintf(coms,"%%%%Page: %d %d",pagenum,pagenum); + self->pagenum++; + sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum); S_Comment(self, coms); sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]); S_Comment(self, coms); @@ -959,7 +960,7 @@ PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso) { int i; - static char buf[256]; + char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && siz==self->FontSize ) return; if( self->FontName ) xfree(self->FontName); @@ -979,7 +980,7 @@ PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso) { int i; - static char buf[256]; + char buf[256]; if( self->FontName && strcmp(fnam, self->FontName)==0 && mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; @@ -1171,6 +1172,30 @@ } } +void +PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr) +{ + int xo = self->XOff; + int yo = self->YOff; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + S_OutStr16(self, text, textl); + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + if( bclr<0 ) S_OutTok(self, "T", 1); + else + { + int ir = bclr>>16; + int ig = (bclr>>8)&0xFF; + int ib = bclr&0xFF; + S_OutNum(self, (float)ir/255.); + S_OutNum(self, (float)ig/255.); + S_OutNum(self, (float)ib/255.); + S_OutTok(self, "Tb", 1); + } +} + #ifdef BM_CACHE void /* new */ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr) @@ -1181,7 +1206,7 @@ if( self->InFrame || self->InTile ) xo = yo = 0; x += xo; y += yo; - sprintf(cacheID, "c%ldi", cache_id); + sprintf(cacheID, "c%di", cache_id); S_OutNum(self, (float)x); S_OutNum(self, (float)y); @@ -1214,7 +1239,7 @@ { char cacheID[10]; - sprintf(cacheID, "/c%ldi {", cache_id); + sprintf(cacheID, "/c%di {", cache_id); S_OutTok(self, cacheID, 0); } /* new */ @@ -1225,7 +1250,7 @@ S_OutTok(self, "}bd", 1); } /* new */ #endif - + void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format) @@ -1488,13 +1513,11 @@ } self->Patterns[self->NPatterns].tag = tag; self->Patterns[self->NPatterns].type = type; - sprintf(key, "/ %ld", (long)tag); + sprintf(key, "/ %d", (int)tag); switch(type) { case PsTile: key[1] = 't'; break; case PsStip: key[1] = 's'; break; - case PsOpStip: key[1] = 'o'; break; - default: break; - } + case PsOpStip: key[1] = 'o'; break; } S_OutTok(self, key, 0); S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0); S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0); @@ -1535,13 +1558,11 @@ for( i=0 ; iNPatterns ; i++ ) { if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; } if( i>=self->NPatterns ) return; - sprintf(key, " %ld", (long)tag); + sprintf(key, " %d", (int)tag); switch(type) { case PsTile: key[0] = 't'; break; case PsStip: key[0] = 's'; break; - case PsOpStip: key[0] = 'o'; break; - default: break; - } + case PsOpStip: key[0] = 'o'; break; } S_OutTok(self, key, 0); S_OutTok(self, "spt", 1); self->CurColor = 0xFFFFFFFF; @@ -1556,83 +1577,141 @@ } } -void -PsOut_DownloadType1(PsOutPtr self, char *name, char *fname) +typedef enum PsDownfontFontType_ +{ + PsDFT_Type1PFA=0, + PsDFT_Type1PFB, + PsDFT_TrueType /* not implemented yet */ +} PsDownfontFontType; + +/* Download a PS Type1 font */ +int +PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname) { int i; int stt; - static char buf[256]; + char buf[256]; FILE *fp; + PsDownfontFontType type; + + fp = fopen(fname, "r"); + if( !fp ) + return 0; - for( i=0 ; iNDownloads ; i++ ) - { if( strcmp(name, self->Downloads[i])==0 ) break; } - if( iNDownloads ) return; +#ifdef DEBUG_gisburn + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname); +#endif /* DEBUG_gisburn */ - if( (self->NDownloads+1)>self->MxDownloads ) + fread(buf, 32, 1, fp); + fseek(fp, (long)0, 0); + + /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */ + if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 ) { - if( self->NDownloads ) - { - self->MxDownloads *= 2; - self->Downloads = (char **)xrealloc(self->Downloads, - self->MxDownloads*sizeof(char *)); - } - else - { - self->MxDownloads = 32; - self->Downloads = (char **)xalloc(self->MxDownloads*sizeof(char *)); - } + type = PsDFT_Type1PFB; + } + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (!strncmp(buf, "%!PS-AdobeFont", 14)) + { + type = PsDFT_Type1PFA; } - - self->Downloads[self->NDownloads] = (char *)xalloc(strlen(name)+1); - strcpy(self->Downloads[self->NDownloads], name); - self->NDownloads += 1; + else + { + /* This should be log-able! */ + fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname); + return 0; + } S_Flush(self); sprintf(buf, "%%%%BeginFont: %s", name); S_Comment(self, buf); - fp = fopen(fname, "r"); - if( !fp ) return; - fread(buf, 1, 1, fp); - fseek(fp, (long)0, 0); - if( (buf[0]&0xFF)==0x80 ) - { - int len; - for(;;) - { - stt = fread(buf, 1, 2, fp); - if( stt!=2 || (buf[0]&0xFF)!=0x80 ) break; - if( (int)buf[1]<1 || (int)buf[1]>2 ) break; - stt = fread(buf, 1, 4, fp); - if( stt!=4 ) break; - len = ((buf[3]&0xFF)<<24)|((buf[2]&0xFF)<<16)| - ((buf[1]&0xFF)<<8)|(buf[0]&0xFF); - for(; len ;) + if( type == PsDFT_Type1PFB ) + { + char *buf, + *pt; + int len, + ch, + stype; + + ch = fgetc(fp); + /* Strip out the binary headers and de-binary it */ + while( (ch&0xFF) == 0x80 ) + { + stype = fgetc(fp); + if( stype==3 ) /* eof mark */ + break; + len = fgetc(fp); + len |= fgetc(fp)<<8; + len |= fgetc(fp)<<16; + len |= fgetc(fp)<<24; + buf = (char *)xalloc(len+1); + if( stype==1 ) + { + /* Process ASCII section */ + len = fread(buf, 1, len, fp); + /* convert any lone CRs (ie Mac eol) to LFs */ + for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ ) + { + if ( pt[1]!='\n' ) + *pt = '\n'; + } + fwrite(buf, 1, len, self->Fp); + } + else if( stype==2 ) { - i = len<256 ? len : 256; - stt = fread(buf, 1, i, fp); - if( stt<=0 ) break; - if (!ferror(self->Fp)) { - (void) fwrite(buf, 1, stt, self->Fp); - } - if( stt>4)&0xf) <= 9 ) + fputc('0'+((ch>>4)&0xf), self->Fp); + else + fputc('A'-10+((ch>>4)&0xf), self->Fp); + + if( (ch&0xf) <= 9 ) + fputc('0'+(ch&0xf), self->Fp); + else + fputc('A'-10+(ch&0xf), self->Fp); + + if( (i&0x1f)==0x1f ) + fputc('\n', self->Fp); + } } + xfree(buf); + + /* Next block... */ + ch = fgetc(fp); } } - else + /* Is this a Adobe PostScript ASCII font (PFA) ? */ + else if (type == PsDFT_Type1PFA) { for(;;) { stt = fread(buf, 1, 256, fp); if( stt<=0 ) break; if (!ferror(self->Fp)) { - (void) fwrite(buf, 1, stt, self->Fp); + (void) fwrite(buf, 1, stt, self->Fp); } - if( stt<256 ) break; + if( stt<256 ) + break; } } fclose(fp); S_Flush(self); S_Comment(self, "%%EndFont"); + + /* Success... */ + return 1; } + + + + + + Index: xc/programs/Xserver/Xprint/ps/psout.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ps/psout.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 psout.h --- a/xc/programs/Xserver/Xprint/ps/psout.h 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/ps/psout.h 21 Apr 2004 09:35:17 -0000 @@ -57,7 +57,6 @@ * or other dealings in this Software without prior written authorization * from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.h,v 1.4 2001/12/14 19:59:18 dawes Exp $ */ /******************************************************************* ** @@ -147,10 +146,80 @@ typedef PsClipRec *PsClipPtr; +typedef enum PsFTDownloadFontType_ +{ + PsFontBitmap=0, + PsFontType1, + PsFontType3 +} PsFTDownloadFontType; + +#ifdef USE_PSOUT_PRIVATE +typedef void *voidPtr; + +typedef struct PsPatRec_ +{ + PsFillEnum type; + voidPtr tag; +} PsPatRec; + +typedef PsPatRec *PsPatPtr; + +typedef struct PsOutRec_ +{ + FILE *Fp; + char Buf[16384]; + int CurColor; + int LineWidth; + PsCapEnum LineCap; + PsJoinEnum LineJoin; + int NDashes; + int *Dashes; + int DashOffset; + int LineBClr; + PsRuleEnum FillRule; + char *FontName; + int FontSize; + float FontMtx[4]; + int ImageFormat; + int RevImage; + int NPatterns; + int MxPatterns; + PsPatPtr Patterns; + int ClipType; + PsClipRec Clip; + int InFrame; + int XOff; + int YOff; + + PsFillEnum InTile; + int ImgSkip; + int ImgBClr; + int ImgFClr; + int ImgX; + int ImgY; + int ImgW; + int ImgH; + int SclW; + int SclH; + + Bool isRaw; + + int pagenum; + + int start_image; +} PsOutRec; + typedef struct PsOutRec_ *PsOutPtr; -extern PsOutPtr PsOut_BeginFile(FILE *fp, int orient, int count, int plex, - int res, int wd, int ht, Bool raw); +extern void S_Flush(PsOutPtr self); +extern void S_OutNum(PsOutPtr self, float num); +extern void S_OutTok(PsOutPtr self, char *tok, int cr); +#else +typedef struct PsOutRec_ *PsOutPtr; +#endif /* USE_PSOUT_PRIVATE */ + +extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, + int res, int wd, int ht, Bool raw); extern void PsOut_EndFile(PsOutPtr self, int closeFile); extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res, int wd, int ht); @@ -182,8 +251,9 @@ extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr); +extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr); -extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, +extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format); extern void PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y, int w, int h, int sw, int sh, int format); @@ -200,16 +270,17 @@ extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type); extern void PsOut_RawData(PsOutPtr self, char *data, int len); -extern void PsOut_DownloadType1(PsOutPtr self, char *name, char *fname); -#ifdef BM_CACHE -extern void PsOut_BeginImageCache(PsOutPtr self, long cache_id); -extern void PsOut_EndImageCache(PsOutPtr self); -extern void PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, - int bclr, int fclr); -#endif +extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname); -extern FILE *PsOut_ChangeFile(PsOutPtr self, FILE *fp); +extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); +extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset); +extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset); +extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex); +extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl); +extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl); +extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso); +extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso); #endif Index: xc/programs/Xserver/Xprint/ps/psout_ft.c =================================================================== RCS file: xc/programs/Xserver/Xprint/ps/psout_ft.c diff -N xc/programs/Xserver/Xprint/ps/psout_ft.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/ps/psout_ft.c 21 Apr 2004 09:35:17 -0000 @@ -0,0 +1,330 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + +#include +#include +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H + +#include "Xproto.h" +#include "font.h" +#include "fontstruct.h" +#include "fntfilst.h" +#include "fontutil.h" +#include "fontenc.h" +#include "ft.h" +#include "ftfuncs.h" +#include "servermd.h" /* needed for endian test (IMAGE_BYTE_ORDER) */ + +#define USE_FT_PS_NAMES 1 + +#ifdef USE_FT_PS_NAMES +void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex) +{ + FTFontPtr tf = (FTFontPtr)pFont->fontPrivate; + FT_Face ttface = tf->instance->face->face; + FT_Error error; + char buf[256]; + unsigned long ftindex; + + /* Remap X11 font index to FreeType font index */ + ftindex = FTRemap(ttface, &tf->mapping, x11fontindex); + + if( FT_Has_PS_Glyph_Names(ttface) ) + { + error = FT_Get_Glyph_Name(ttface, ftindex, buf, 64); + } + else + { + error = 1; + } + + if( error ) + { + /* Check for unicode mapping + * See Adobe document "Unicode and Glyph Names" + * (http://partners.adobe.com/asn/tech/type/unicodegn.jsp) + */ + if( (tf->mapping.mapping->type == FONT_ENCODING_UNICODE) && + (ftindex < 0xFFFE) ) + { + sprintf(buf, "uni%04lx", ftindex); + } + else + { + sprintf(buf, "ch%02lx", ftindex); + } + } + + strcpy(destbuf, buf); +} +#endif /* USE_FT_PS_NAMES */ + +int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset) +{ + switch(downloadfonttype) + { + case PsFontType3: + return PsOut_DownloadFreeType3(self, psfontname, pFont, block_offset); + case PsFontType1: + return PsOut_DownloadFreeType1(self, psfontname, pFont, block_offset); + default: + FatalError("PS DDX: PsOut_DownloadFreeType(downloadfonttype='%d' not implemented\n", + (int)downloadfonttype); + return 0; /* NO-OP, FatalError() will call |exit()| */ + } +} + +/* cloned from |PsOut_TextAttrs16| */ +void +PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso) +{ + int i; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + siz==self->FontSize ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + self->FontSize = siz; + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = -1.; +} + +/* cloned from |PsOut_TextAttrsMtx16| */ +void +PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso) +{ + int i; + if( self->FontName && strcmp(fnam, self->FontName)==0 && + mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] && + mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return; + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(fnam)+1); + strcpy(self->FontName, fnam); + for( i=0 ; i<4 ; i++ ) self->FontMtx[i] = mtx[i]; + self->FontSize = -1; +} + +static +int FT_Get_CharcellMetricsCharacterHeight(FontPtr pFont) +{ + FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate; + + return ftfont->instance->charcellMetrics->ascent + + ftfont->instance->charcellMetrics->descent; +} + +static +int FT_Get_CharcellMetricsCharacterWidth(FontPtr pFont) +{ + FTFontPtr ftfont = (FTFontPtr)pFont->fontPrivate; + + if( ftfont->instance->spacing != FT_PROPORTIONAL ) + { + int width = ftfont->instance->charcellMetrics->characterWidth; + + /* If the font uses a matrix make sure we transform the |characterWidth| + * back to it's original value since we download the untransformed font + * and use a PostScript transformation matrix to transform the font when + * rendering the text + */ + if( ftfont->instance->transformation.nonIdentity ) + { + FT_Vector v; + + FT_Matrix m = ftfont->instance->transformation.matrix; + (void)FT_Matrix_Invert(&m); /* FixMe: We should check the return code */ + v.x = width; + v.y = FT_Get_CharcellMetricsCharacterHeight(pFont); + FT_Vector_Transform(&v, &m); + width = v.x; + } + + return width; + } + + return 0; +} + +void +PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl) +{ + int i; + int xo = self->XOff, + yo = self->YOff; + char buf[256]; + int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont); + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutTok(self, "moveto", 1); + + S_OutTok(self, "[ ", 0); + + for( i = 0 ; i < textl ; i++ ) + { +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + unsigned int ch = text[i]&0xFF; + unsigned long block_offset = 0; + PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset); + + sprintf(buf, "/%s ", namebuf); +#else + sprintf(buf, "/ch%02x ", text[i]&0xFF); +#endif /* USE_FT_PS_NAMES */ + S_OutTok(self, buf, 0); + } + + /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */ + if( cwidth != 0 ) + { + /* If the we use a matrix to render the font (instead of using |self->FontSize|) + * we must apply the matrix to the "rmoveto" which is used to force the exact + * character width. The "trmoveto" macro will do that for us... + */ + if( self->FontSize == -1 ) + { + sprintf(buf, "]{gs glyphshow gr %d 0 trmoveto}fa", cwidth); + } + else + { + sprintf(buf, "]{gs glyphshow gr %d 0 rm}fa", cwidth); + } + } + else + { + sprintf(buf, "]{glyphshow}fa"); + } + S_OutTok(self, buf, 0); +} + +/* XXX: |PsOut_FreeType_Text16| should be rewritten - currently it uses lame, + * slow hacks and makes some risky assumtions about how |PsOut_Text16| + * allocates memory */ +void +PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl) +{ + int i; + int xo = self->XOff, + yo = self->YOff; + unsigned short c, + c_hiByte, + c_lowByte, + fontPage; + long lastFontPage = -1; + char baseFontName[256]; + char buf[256]; + + if( self->InFrame || self->InTile ) xo = yo = 0; + x += xo; y += yo; + + strcpy(baseFontName, self->FontName); + + S_OutNum(self, (float)x); + S_OutNum(self, (float)y); + S_OutTok(self, "moveto", 1); + + for( i = 0 ; i < textl ; i++ ) + { + c = text[i]; +#if IMAGE_BYTE_ORDER == LSBFirst + c_hiByte = c & 0x00FF; + c_lowByte = (c >> 8) & 0x00FF; +#elif IMAGE_BYTE_ORDER == MSBFirst + c_hiByte = (c >> 8) & 0x00FF; + c_lowByte = c & 0x00FF; +#else +#error Unsupported byte order +#endif + fontPage = c_hiByte; + + if( fontPage != lastFontPage ) + { + if( fontPage > 0 ) + { + sprintf(buf, "%s_%x", baseFontName, fontPage); + } + else + { + sprintf(buf, "%s", baseFontName); + } + + if( self->FontSize == -1 ) + { + PsOut_TextAttrsMtx(self, buf, self->FontMtx, FALSE); + } + else + { + PsOut_TextAttrs(self, buf, self->FontSize, FALSE); + } + lastFontPage = fontPage; + } + +#ifdef USE_FT_PS_NAMES + { + char namebuf[256]; + unsigned int ch = c_lowByte; + unsigned long block_offset = c_hiByte * 0x100 /* same as c_hiByte << 8 */; + int cwidth = FT_Get_CharcellMetricsCharacterWidth(pFont); + PsOut_Get_FreeType_Glyph_Name(namebuf, pFont, ch+block_offset); + + /* Check whether we have any special spacing requirements (e.g. non-proportional fonts) ... */ + if( cwidth != 0 ) + { + /* If the we use a matrix to render the font (instead of using |self->FontSize|) + * we must apply the matrix to the "rmoveto" which is used to force the exact + * character width. The "trmoveto" macro will do that for us... + */ + if( self->FontSize == -1 ) + { + sprintf(buf, "gs /%s glyphshow gr %d 0 trmoveto", namebuf, cwidth); + } + else + { + sprintf(buf, "gs /%s glyphshow gr %d 0 rm", namebuf, cwidth); + } + } + else + { + sprintf(buf, "/%s glyphshow", namebuf); + } + } +#else + sprintf(buf, "/ch%02x glyphshow", c_lowByte); +#endif /* USE_FT_PS_NAMES */ + S_OutTok(self, buf, 1); + } + + if( self->FontName ) xfree(self->FontName); + self->FontName = (char *)xalloc(strlen(baseFontName)+1); + strcpy(self->FontName, baseFontName); +} + Index: xc/programs/Xserver/Xprint/ps/psout_ftpstype1.c =================================================================== RCS file: xc/programs/Xserver/Xprint/ps/psout_ftpstype1.c diff -N xc/programs/Xserver/Xprint/ps/psout_ftpstype1.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/ps/psout_ftpstype1.c 21 Apr 2004 09:35:17 -0000 @@ -0,0 +1,180 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + + +#include +#include +#include +#include + +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#include FT_FREETYPE_H + +#include "Xproto.h" +#include "font.h" +#include "fontstruct.h" +#include "fntfilst.h" +#include "fontutil.h" +#include "fontenc.h" +#include "ft.h" +#include "ftfuncs.h" + +int do_debug_ft2pt1 = FALSE; +int do_enable_ft2pt1_optimizer = FALSE; + +/* Defined in ttf2pt1.c */ +int ft2pt1_main(int argc, char **argv, + FTFontPtr tf, const char *download_psfontname, unsigned long download_font_block_offset); + +/* Download FreeType outlines as PS Type1 font */ +int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset) +{ + FTFontPtr tf; + FT_Face face; + int ft2pt1_numargs = 0; + char *ft2pt1_args[40]; + char *pstype1filename_prefix; + char pstype1filename[PATH_MAX+1]; + int ft2pt1_main_retval; + pid_t childpid; + + tf = (FTFontPtr)pFont->fontPrivate; + face = tf->instance->face->face; + + /* Set debugging flags */ + do_debug_ft2pt1 = (getenv("XPRT_PSDDX_DO_DEBUG_FT2PT1") != NULL); + do_enable_ft2pt1_optimizer = (getenv("XPRT_PSDDX_DO_ENABLE_FT2PT1_OPTIMIZER") != NULL); + + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "# Converting FT2 font to PS Type1 filename='%s', ttface=%lx\n", tf->instance->face->filename, (long)face); + } + + pstype1filename_prefix = tempnam(NULL, "Xprt_"); + + ft2pt1_args[ft2pt1_numargs] = "ft2pt1"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Ob"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-e"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-a"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Ga"; ft2pt1_numargs++; + if( do_enable_ft2pt1_optimizer ) + { + /* Scale fonts to a 1000x1000 matrix */ + ft2pt1_args[ft2pt1_numargs] = "-Ot"; ft2pt1_numargs++; + } + else + { + /* Disable the ttf2pt1 optimisations */ + ft2pt1_args[ft2pt1_numargs] = "-Ou"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Oo"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Os"; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = "-Oh"; ft2pt1_numargs++; + } + + if( !do_debug_ft2pt1 ) + { + ft2pt1_args[ft2pt1_numargs] = "-W 0"; ft2pt1_numargs++; + } + ft2pt1_args[ft2pt1_numargs] = tf->instance->face->filename; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = pstype1filename_prefix; ft2pt1_numargs++; + ft2pt1_args[ft2pt1_numargs] = NULL; + +/* XXX: ttf2pt1 has lots of leaks and global vars which are not cleaned-up + * As long this problem exists we will simply fork() and call the converter + * from the child process (all resources are free'ed when the child process + * exists) as a workaround. + */ +#define FT2PT1_NEEDS_SEPERATE_PROCESS 1 + +#ifdef FT2PT1_NEEDS_SEPERATE_PROCESS + /* Flush internal buffer and then the stdio stream before fork()! */ + S_Flush(self); + fflush(self->Fp); + + childpid = fork(); + switch(childpid) + { + case -1: + FatalError("PS DDX internal error: Cannot fork() converter child process, errno=%d\n", (int)errno); + break; + case 0: /* child */ + fclose(self->Fp); + self->Fp = NULL; + + ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval); + } + exit(ft2pt1_main_retval); + break; + default: /* parent */ + waitpid(childpid, &ft2pt1_main_retval, 0); + break; + } + + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (parent)\n", ft2pt1_main_retval); + } +#else + S_Flush(self); + + ft2pt1_main_retval = ft2pt1_main(ft2pt1_numargs, ft2pt1_args, tf, psfontname, block_offset); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "## ft2pt1_main returned %d (child)\n", ft2pt1_main_retval); + } +#endif /* FT2PT1_NEEDS_SEPERATE_PROCESS */ + + if( ft2pt1_main_retval != EXIT_SUCCESS ) + { + FatalError("PS DDX internal error while converting FreeType font '%s' to PS Type1, error=%d\n", + tf->instance->face->filename, ft2pt1_main_retval); + } + + sprintf(pstype1filename, "%s.pfa", pstype1filename_prefix); + if( do_debug_ft2pt1 ) + { + fprintf(stderr, "# Downloading converted FT2/PS Type1 filename='%s'\n", pstype1filename); + } + + PsOut_DownloadType1(self, "PsOut_DownloadFreeType1", psfontname, pstype1filename); + + if( !do_debug_ft2pt1 ) + { + unlink(pstype1filename); + } + + free(pstype1filename_prefix); + + S_Flush(self); + + return 0; +} + + Index: xc/programs/Xserver/Xprint/ps/psout_ftpstype3.c =================================================================== RCS file: xc/programs/Xserver/Xprint/ps/psout_ftpstype3.c diff -N xc/programs/Xserver/Xprint/ps/psout_ftpstype3.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/ps/psout_ftpstype3.c 21 Apr 2004 09:35:17 -0000 @@ -0,0 +1,463 @@ + +/* +Copyright (c) 2003-2004 Roland Mainz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +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 +AUTHORS OR COPYRIGHT HOLDERS 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. +*/ + +#include +#include +#include "os.h" +#define USE_PSOUT_PRIVATE 1 +#include "psout.h" + +#include +#include FT_FREETYPE_H +#include FT_TRUETYPE_TABLES_H +#include FT_BBOX_H +#include FT_GLYPH_H + +#include FT_CONFIG_CONFIG_H +#include FT_CONFIG_OPTIONS_H +#include FT_ERRORS_H +#include FT_SYSTEM_H +#include FT_IMAGE_H +#include FT_TYPES_H +#include FT_OUTLINE_H +#include FT_MODULE_H +#include FT_RENDER_H +#include FT_TYPE1_TABLES_H +#include FT_TRUETYPE_IDS_H +#include FT_TRUETYPE_TAGS_H +#include FT_CACHE_H +#include FT_CACHE_IMAGE_H +#include FT_CACHE_SMALL_BITMAPS_H +#include FT_MULTIPLE_MASTERS_H +#include FT_SFNT_NAMES_H + +#define USE_FT_INTERNALS 1 +#ifdef USE_FT_INTERNALS +#include FT_INTERNAL_TYPE1_TYPES_H +#include "t42types.h" +#include FT_INTERNAL_OBJECTS_H +#endif /* USE_FT_INTERNALS */ + +#include "Xproto.h" +#include "font.h" +#include "fontstruct.h" +#include "fntfilst.h" +#include "fontutil.h" +#include "fontenc.h" +#include "ft.h" +#include "ftfuncs.h" + +struct ft2info +{ + FontPtr pFont; + FTFontPtr tf; + FT_Face ttface; + struct + { + char *full_name; + char *copyright; + char *family; + char *subfamily; + char *version; + } nameid; + TT_Postscript *ttpostscript; + TT_Header *ttheader; +}; + +/* Local prototypes */ +static FT_Error PSType3_createOutlineGlyphs(FILE *out, struct ft2info *ti, unsigned long unicode, const char *psglyphname); +static int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset); + +extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */ + +#define USE_FT_PS_NAMES 1 + +static +FT_Error PSType3_createOutlineGlyphs( FILE *out, struct ft2info *ti, unsigned long x11fontindex, const char *psglyphname ) +{ + unsigned long ftindex; + FT_BBox bbox; + FT_Error error; + FT_Outline outline; + + /* Remap X11 font index to FreeType font index */ + ftindex = FTRemap(ti->ttface, &ti->tf->mapping, x11fontindex); + + error = FT_Load_Glyph(ti->ttface, ftindex, (FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING)); + if( error ) + { + fprintf(stderr, "PSType3_createOutlineGlyphs: FT_Load_Glyph() failure, error=%d\n", (int)error); + return error; + } + + outline = ti->ttface->glyph->outline; + + FT_Outline_Get_CBox(&outline, &bbox); + + fprintf(out, "/%s {\n", psglyphname); + fprintf(out, "%ld 0 %ld %ld %ld %ld setcachedevice\n", + (signed long)ti->ttface->glyph->metrics.horiAdvance, + (long)bbox.xMin, + (long)bbox.yMin, + (long)bbox.xMax, + (long)bbox.yMax); + + if( outline.n_contours > 0 ) + { + long i, + j, + k, k1, + cs, ce, + nguide, + contour_start, + contour_end, + last_point; + Bool first; + FT_Vector *vec; + + contour_start = ce = 0; + + vec = outline.points; + last_point = outline.n_points; + + i = j = k = 0; + first = TRUE; + + while( i <= outline.contours[outline.n_contours - 1] ) + { + contour_end = outline.contours[j]; + + if( first ) + { + fprintf(out, "%ld %ld moveto\n", vec[i].x, vec[i].y); + contour_start = i; + first = FALSE; + } + else if( outline.tags[i] & FT_CURVE_TAG_ON ) + { + fprintf(out, "%ld %ld lineto\n", vec[i].x, vec[i].y); + } + else + { + Bool finished = FALSE; + + cs = i-1; + nguide = 0; + while( !finished ) + { + if( i == contour_end+1 ) + { + ce = contour_start; + finished = TRUE; + } + else if( outline.tags[i] & FT_CURVE_TAG_ON ) + { + ce = i; + finished = TRUE; + } + else + { + i++; + nguide++; + } + } + + switch( nguide ) + { + case 0: + fprintf(out, "%ld %ld lineto\n", vec[ce].x, vec[ce].y); + break; + + case 1: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (2*vec[cs+1].x+vec[ce].x)/3, + (2*vec[cs+1].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + case 2: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (-vec[cs].x+4*vec[cs+1].x)/3, + (-vec[cs].y+4*vec[cs+1].y)/3, + (4*vec[cs+2].x-vec[ce].x)/3, + (4*vec[cs+2].y-vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + case 3: + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (5*vec[cs+1].x+vec[cs+2].x)/6, + (5*vec[cs+1].y+vec[cs+2].y)/6, + (vec[cs+1].x+vec[cs+2].x)/2, + (vec[cs+1].y+vec[cs+2].y)/2); + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs+1].x+5*vec[cs+2].x)/6, + (vec[cs+1].y+5*vec[cs+2].y)/6, + (5*vec[cs+2].x+vec[cs+3].x)/6, + (5*vec[cs+2].y+vec[cs+3].y)/6, + (vec[cs+3].x+vec[cs+2].x)/2, + (vec[cs+3].y+vec[cs+2].y)/2); + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs+2].x+5*vec[cs+3].x)/6, + (vec[cs+2].y+5*vec[cs+3].y)/6, + (2*vec[cs+3].x+vec[ce].x)/3, + (2*vec[cs+3].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + + default: /* anything |nguide > 3| */ + k1 = cs + nguide; + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[cs].x+2*vec[cs+1].x)/3, + (vec[cs].y+2*vec[cs+1].y)/3, + (5*vec[cs+1].x+vec[cs+2].x)/6, + (5*vec[cs+1].y+vec[cs+2].y)/6, + (vec[cs+1].x+vec[cs+2].x)/2, + (vec[cs+1].y+vec[cs+2].y)/2); + + for( k = cs+2 ; k <= k1-1 ; k++ ) + { + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[k-1].x+5*vec[k].x)/6, + (vec[k-1].y+5*vec[k].y)/6, + (5*vec[k].x+vec[k+1].x)/6, + (5*vec[k].y+vec[k+1].y)/6, + (vec[k].x+vec[k+1].x)/2, + (vec[k].y+vec[k+1].y)/2); + } + + fprintf(out, "%ld %ld %ld %ld %ld %ld curveto\n", + (vec[k1-1].x+5*vec[k1].x)/6, + (vec[k1-1].y+5*vec[k1].y)/6, + (2*vec[k1].x+vec[ce].x)/3, + (2*vec[k1].y+vec[ce].y)/3, + vec[ce].x, vec[ce].y); + break; + } + } + + if( i >= contour_end ) + { + fprintf(out, "closepath\n"); + first = TRUE; + i = contour_end + 1; + j++; + } + else + { + i++; + } + } + } + + fprintf(out, "fill } bind def\n"); + + return 0; +} + +#ifdef USE_FT_INTERNALS +static FT_BBox * +FT_Get_PS_Font_BBox( FT_Face face ) +{ + const char *driver_name; + FT_BBox *font_bbox = NULL; + + if ( face && face->driver && face->driver->root.clazz ) + { + driver_name = face->driver->root.clazz->module_name; + if ( ft_strcmp( driver_name, "type1" ) == 0 ) + font_bbox = &(((T1_Face)face)->type1.font_bbox); + else if ( ft_strcmp( driver_name, "t1cid" ) == 0 ) + font_bbox = &(((CID_Face)face)->cid.font_bbox); + else if ( ft_strcmp( driver_name, "type42" ) == 0 ) + font_bbox = &(((T42_Face)face)->type1.font_bbox); + } + + return font_bbox; +} +#endif /* USE_FT_INTERNALS */ + +static +int PSType3_generateOutlineFont(FILE *out, const char *psfontname, struct ft2info *ti, long block_offset) +{ + long i; + double scaler; + const int numchars = 256; +#ifdef USE_FT_PS_NAMES + int linewidth = 0; +#endif /* USE_FT_PS_NAMES */ + + fprintf(out, "%%%%BeginFont: %s\n", psfontname); + fprintf(out, "22 dict begin\n"); + fprintf(out, "/FontType 3 def\n"); + fprintf(out, "/StrokeWidth 0 def\n"); + fprintf(out, "/PaintType 0 def\n"); + fprintf(out, "/FontName (%s) def\n", psfontname); + fprintf(out, "/FontInfo 9 dict dup begin\n"); + fprintf(out, " /FullName (%s) def\n", ti->nameid.full_name?ti->nameid.full_name:psfontname); + fprintf(out, " /Notice (%s) def\n", ti->nameid.copyright?ti->nameid.copyright:"nothing here"); + fprintf(out, " /FamilyName (%s) def\n", ti->nameid.family?ti->nameid.family:psfontname); + fprintf(out, " /Weight (%s) def\n", ti->nameid.subfamily?ti->nameid.subfamily:"Regular"); + fprintf(out, " /version (%s) def\n", ti->nameid.version?ti->nameid.version:"0.1"); + + if( ti->ttpostscript ) + { + fprintf(out, " /italicAngle %.9g def\n", (double)ti->ttpostscript->italicAngle); + fprintf(out, " /underlineThickness %d def\n", (int)ti->ttpostscript->underlineThickness); + fprintf(out, " /underlinePosition %d def\n", (int)ti->ttpostscript->underlinePosition); + fprintf(out, " /isFixedPitch %s def\n", ((ti->ttpostscript->isFixedPitch)?("true"):("false"))); + } + else + { + fprintf(out, " /italicAngle %.9g def\n", 0.0); + fprintf(out, " /underlineThickness %d def\n", 100); + fprintf(out, " /underlinePosition %d def\n", 0); + fprintf(out, " /isFixedPitch false def\n"); + } + + fprintf(out, "end def\n"); + + scaler = (1000.0 / (double)ti->ttface->units_per_EM) / 1000.0; + fprintf(out, "/FontMatrix [%.9g 0 0 %.9g 0 0] def\n", scaler, scaler); + + if( ti->ttheader ) + { + fprintf(out, "/FontBBox [%d %d %d %d] def\n", + (int)ti->ttheader->xMin, + (int)ti->ttheader->yMin, + (int)ti->ttheader->xMax, + (int)ti->ttheader->yMax); + } + else + { + FT_BBox *font_bbox = FT_Get_PS_Font_BBox(ti->ttface); + fprintf(out, "/FontBBox [%d %d %d %d] def\n", + (int)font_bbox->xMin, + (int)font_bbox->yMin, + (int)font_bbox->xMax, + (int)font_bbox->yMax); + } + + fprintf(out, "/Encoding [\n"); + for( i = 0 ; i < 256 ; i++ ) + { +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset); + linewidth += strlen(namebuf) + 2; + fprintf(out, "/%s%s", namebuf, (linewidth > 70)?(linewidth = 0, "\n"):(" ")); +#else + fprintf(out, "/ch%02x%s", i, (((i % 10) == 9)?("\n"):(" "))); +#endif /* USE_FT_PS_NAMES */ + } + fprintf(out, "] def\n"); + + fprintf(out, "/CharProcs %d dict def CharProcs begin\n", (int)(numchars + 1)); + fprintf(out, "/.notdef {\n" + "1000 0 0 0 0 0 setcachedevice\n" + "fill } bind def\n"); + for( i = 0 ; i < numchars ; i++ ) + { + char buf[32]; +#ifdef USE_FT_PS_NAMES + char namebuf[256]; + PsOut_Get_FreeType_Glyph_Name(namebuf, ti->pFont, i+block_offset); + sprintf(buf, "%s ", namebuf); +#else + sprintf(buf, "ch%02lx ", i); +#endif /* USE_FT_PS_NAMES */ + PSType3_createOutlineGlyphs(out, ti, i+block_offset, buf); + } + fprintf(out, "end\n" + "/BuildGlyph {\n" + " exch /CharProcs get exch\n" + " 2 copy known not {pop /.notdef} if get exec } bind def\n" + "/BuildChar { 1 index /Encoding get exch get\n" + " 1 index /Encoding get exec } bind def\n"); + fprintf(out, "currentdict end /%s exch definefont pop\n", psfontname); + fprintf(out, "%%EndFont\n"); + + return 0; +} + +static +char *FT_Get_TT_NAME_ID(FT_Face ttface, int index) +{ + FT_SfntName name; + char *s; + + if( index >= FT_Get_Sfnt_Name_Count(ttface) ) + return NULL; + + FT_Get_Sfnt_Name(ttface, index, &name); + s = (char *)malloc(name.string_len+2); + if( !s ) + return NULL; + memcpy(s, (char *)name.string, name.string_len); + s[name.string_len] = '\0'; + return s; +} + +int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset) +{ + struct ft2info cft2info = { 0 }; + struct ft2info *ti = &cft2info; + + S_Flush(self); + + ti->tf = (FTFontPtr)pFont->fontPrivate; + ti->ttface = ti->tf->instance->face->face; + ti->pFont = pFont; +#ifdef DEBUG_gisburn + fprintf(stderr, "# Downloading FT2 font filename='%s', ttface=%lx\n", ti->tf->instance->face->filename, (long)ti->ttface); +#endif /* DEBUG_gisburn */ + + ti->nameid.full_name = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FULL_NAME); + ti->nameid.copyright = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_COPYRIGHT); + ti->nameid.family = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_FAMILY); + ti->nameid.subfamily = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_FONT_SUBFAMILY); + ti->nameid.version = FT_Get_TT_NAME_ID(ti->ttface, TT_NAME_ID_VERSION_STRING); + + ti->ttheader = (TT_Header *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_head); + ti->ttpostscript = (TT_Postscript *)FT_Get_Sfnt_Table(ti->ttface, ft_sfnt_post); + + PSType3_generateOutlineFont(self->Fp, psfontname, ti, block_offset); + + free(ti->nameid.full_name); + free(ti->nameid.copyright); + free(ti->nameid.family); + free(ti->nameid.subfamily); + free(ti->nameid.version); + + S_Flush(self); + + return 0; +} + Index: xc/programs/Xserver/Xprint/raster/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/raster/Imakefile,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Imakefile --- a/xc/programs/Xserver/Xprint/raster/Imakefile 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/raster/Imakefile 21 Apr 2004 09:35:17 -0000 @@ -1,10 +1,5 @@ XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:11 cpqbld Exp $ - - - -XCOMM $XFree86: xc/programs/Xserver/Xprint/raster/Imakefile,v 1.6 2001/08/01 00:44:46 tsi Exp $ - #include SRCS1 = Raster.c RasterAttVal.c @@ -15,8 +10,9 @@ OBJS = $(OBJS1) INCLUDES = -I. -I$(XINCLUDESRC) -I.. -I$(LIBSRC) \ - -I../../cfb -I../../mfb -I../../mi \ - -I../../include -I$(TOP)/include -I$(FONTINCSRC) + -I../../cfb -I../../mfb -I../../mi \ + -I../../include -I$(TOP)/include -I$(FONTINCSRC) + LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \ ../../mfb/llib-lmfb.ln ../../mi/llib-lmi.ln \ Index: xc/programs/Xserver/Xprint/raster/Raster.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/raster/Raster.h,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Raster.h --- a/xc/programs/Xserver/Xprint/raster/Raster.h 5 Mar 2004 13:39:54 -0000 1.1.4.2 +++ b/xc/programs/Xserver/Xprint/raster/Raster.h 21 Apr 2004 09:35:18 -0000 @@ -30,8 +30,6 @@ dealings in this Software without prior written authorization from said copyright holders. */ -/* $XFree86: xc/programs/Xserver/Xprint/raster/Raster.h,v 1.3 2001/10/31 22:50:29 tsi Exp $ */ - /******************************************************************* ** ** ********************************************************* @@ -53,6 +51,7 @@ * Some sleazes to force the XrmDB stuff into the server */ #ifndef HAVE_XPointer +#define HAVE_XPointer 1 typedef char *XPointer; #endif #define Status int @@ -110,6 +109,6 @@ extern XpValidatePoolsRec RasterValidatePoolsRec; extern Bool InitializeRasterDriver(int ndx, ScreenPtr pScreen, int argc, - char **argv); + char **argv); #endif /* _RASTER_H_ */ Index: xc/programs/Xserver/Xprint/svg/README =================================================================== RCS file: xc/programs/Xserver/Xprint/svg/README diff -N xc/programs/Xserver/Xprint/svg/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/svg/README 21 Apr 2004 09:35:18 -0000 @@ -0,0 +1 @@ +Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=5401 Index: xc/programs/Xserver/Xprint/windows/README =================================================================== RCS file: xc/programs/Xserver/Xprint/windows/README diff -N xc/programs/Xserver/Xprint/windows/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/Xserver/Xprint/windows/README 21 Apr 2004 09:35:18 -0000 @@ -0,0 +1 @@ +Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=3530 Index: xc/programs/Xserver/dix/dispatch.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/dispatch.c,v retrieving revision 1.1.4.9 diff -u -r1.1.4.9 dispatch.c --- a/xc/programs/Xserver/dix/dispatch.c 15 Apr 2004 10:15:46 -0000 1.1.4.9 +++ b/xc/programs/Xserver/dix/dispatch.c 21 Apr 2004 09:35:19 -0000 @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.1.4.9 2004/04/15 10:15:46 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/dispatch.c,v 1.1.4.4.2.3.6.2 2004/04/20 03:27:08 gisburn Exp $ */ /* $Xorg: dispatch.c,v 1.5 2001/02/09 02:04:40 xorgcvs Exp $ */ /************************************************************ @@ -253,7 +253,7 @@ #define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */ #define SMART_SCHEDULE_MAX_SLICE 200 /* ms */ -Bool SmartScheduleDisable; +Bool SmartScheduleDisable = FALSE; long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; Index: xc/programs/Xserver/dix/main.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/dix/main.c,v retrieving revision 1.1.4.8 diff -u -r1.1.4.8 main.c --- a/xc/programs/Xserver/dix/main.c 15 Apr 2004 10:15:46 -0000 1.1.4.8 +++ b/xc/programs/Xserver/dix/main.c 21 Apr 2004 09:35:20 -0000 @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.1.4.8 2004/04/15 10:15:46 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/dix/main.c,v 1.1.4.5.2.4.6.1 2004/04/20 03:27:08 gisburn Exp $ */ /* $XFree86: xc/programs/Xserver/dix/main.c,v 3.43 2003/10/30 21:21:02 herrb Exp $ */ /*********************************************************** @@ -251,6 +251,8 @@ display = "0"; + InitGlobals(); + /* Quartz support on Mac OS X requires that the Cocoa event loop be in * the main thread. This allows the X server main to be called again * from another thread. */ Index: xc/programs/Xserver/hw/darwin/darwin.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/darwin/darwin.c,v retrieving revision 1.1.4.4 diff -u -r1.1.4.4 darwin.c --- a/xc/programs/Xserver/hw/darwin/darwin.c 15 Apr 2004 10:15:47 -0000 1.1.4.4 +++ b/xc/programs/Xserver/hw/darwin/darwin.c 21 Apr 2004 09:35:20 -0000 @@ -29,7 +29,7 @@ * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written authorization. */ -/* $XdotOrg: xc/programs/Xserver/hw/darwin/darwin.c,v 1.1.4.4 2004/04/15 10:15:47 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/hw/darwin/darwin.c,v 1.1.4.2.4.1.6.3 2004/04/20 03:27:08 gisburn Exp $ */ /* $XFree86: xc/programs/Xserver/hw/darwin/darwin.c,v 1.55 2003/11/15 00:07:09 torrey Exp $ */ #include "X.h" @@ -448,9 +448,11 @@ } /* +=========================================================================== Utility routines +=========================================================================== */ /* @@ -538,9 +540,11 @@ } /* +=========================================================================== Functions needed to link against device independent X +=========================================================================== */ /* @@ -693,6 +697,10 @@ } } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} /* * ddxProcessArgument -- Index: xc/programs/Xserver/hw/sun/sunIo.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/sun/sunIo.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 sunIo.c --- a/xc/programs/Xserver/hw/sun/sunIo.c 5 Mar 2004 13:40:04 -0000 1.1.4.3 +++ b/xc/programs/Xserver/hw/sun/sunIo.c 21 Apr 2004 09:35:21 -0000 @@ -193,6 +193,11 @@ AbortDDX (); } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument (argc, argv, i) int argc; Index: xc/programs/Xserver/hw/sunLynx/sunLyIo.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/sunLynx/sunLyIo.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 sunLyIo.c --- a/xc/programs/Xserver/hw/sunLynx/sunLyIo.c 5 Mar 2004 13:40:05 -0000 1.1.4.3 +++ b/xc/programs/Xserver/hw/sunLynx/sunLyIo.c 21 Apr 2004 09:35:21 -0000 @@ -295,6 +295,11 @@ AbortDDX (); } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument (argc, argv, i) int argc; Index: xc/programs/Xserver/hw/vfb/InitOutput.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/vfb/InitOutput.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 InitOutput.c --- a/xc/programs/Xserver/hw/vfb/InitOutput.c 5 Mar 2004 13:40:05 -0000 1.1.4.3 +++ b/xc/programs/Xserver/hw/vfb/InitOutput.c 21 Apr 2004 09:35:21 -0000 @@ -273,6 +273,11 @@ #endif } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument(int argc, char *argv[], int i) { Index: xc/programs/Xserver/hw/xfree86/common/xf86Init.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v retrieving revision 1.1.4.6 diff -u -r1.1.4.6 xf86Init.c --- a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c 15 Apr 2004 10:16:09 -0000 1.1.4.6 +++ b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c 21 Apr 2004 09:35:22 -0000 @@ -1641,6 +1641,11 @@ return xf86ProcessArgument(argc, argv, i); } +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + /* * ddxUseMsg -- * Print out correct use of device dependent commandline options. Index: xc/programs/Xserver/hw/xnest/Args.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xnest/Args.c,v retrieving revision 1.1.4.2 diff -u -r1.1.4.2 Args.c --- a/xc/programs/Xserver/hw/xnest/Args.c 5 Mar 2004 13:41:02 -0000 1.1.4.2 +++ b/xc/programs/Xserver/hw/xnest/Args.c 21 Apr 2004 09:35:23 -0000 @@ -47,6 +47,11 @@ Bool xnestDoDirectColormaps = False; Window xnestParentWindow = 0; +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument (int argc, char *argv[], int i) { Index: xc/programs/Xserver/hw/xwin/InitOutput.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/InitOutput.c,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 InitOutput.c --- a/xc/programs/Xserver/hw/xwin/InitOutput.c 15 Apr 2004 10:17:20 -0000 1.1.4.3 +++ b/xc/programs/Xserver/hw/xwin/InitOutput.c 21 Apr 2004 09:35:24 -0000 @@ -394,6 +394,11 @@ /* Compare the current option with the string. */ #define IS_OPTION(name) (strcmp (argv[i], name) == 0) +/* ddxInitGlobals - called by |InitGlobals| from os/util.c */ +void ddxInitGlobals(void) +{ +} + int ddxProcessArgument (int argc, char *argv[], int i) { Index: xc/programs/Xserver/include/os.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/include/os.h,v retrieving revision 1.1.4.5 diff -u -r1.1.4.5 os.h --- a/xc/programs/Xserver/include/os.h 15 Apr 2004 10:17:21 -0000 1.1.4.5 +++ b/xc/programs/Xserver/include/os.h 21 Apr 2004 09:35:24 -0000 @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/include/os.h,v 3.53 2003/10/29 04:17:22 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/include/os.h,v 3.54 2003/10/30 21:21:06 herrb Exp $ */ /*********************************************************** Copyright 1987, 1998 The Open Group @@ -231,6 +231,8 @@ extern void UseMsg(void); +extern void InitGlobals(void); + extern void ProcessCommandLine(int /*argc*/, char* /*argv*/[]); extern int set_font_authorizations( @@ -412,6 +414,8 @@ extern void ExpandCommandLine(int * /*pargc*/, char *** /*pargv*/); #endif +extern void ddxInitGlobals(void); + extern int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/); extern void ddxUseMsg(void); Index: xc/programs/Xserver/os/utils.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/os/utils.c,v retrieving revision 1.1.4.9 diff -u -r1.1.4.9 utils.c --- a/xc/programs/Xserver/os/utils.c 15 Apr 2004 10:17:34 -0000 1.1.4.9 +++ b/xc/programs/Xserver/os/utils.c 21 Apr 2004 09:35:25 -0000 @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.1.4.9 2004/04/15 10:17:34 eich Exp $ */ +/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.1.4.6.2.4.6.3 2004/04/20 03:27:09 gisburn Exp $ */ /* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */ /* @@ -576,6 +576,17 @@ } /* + * This function is responsible for doing initalisation of any global + * variables at an very early point of server startup (even before + * |ProcessCommandLine()|. + */ +void InitGlobals(void) +{ + ddxInitGlobals(); +} + + +/* * This function parses the command line. Handles device-independent fields * and allows ddx to handle additional fields. It is not allowed to modify * argc or any of the strings pointed to by argv. Index: xc/programs/xlogo/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/xlogo/Imakefile,v retrieving revision 1.1.4.3 diff -u -r1.1.4.3 Imakefile --- a/xc/programs/xlogo/Imakefile 5 Mar 2004 13:41:36 -0000 1.1.4.3 +++ b/xc/programs/xlogo/Imakefile 21 Apr 2004 09:35:26 -0000 @@ -13,12 +13,15 @@ XRENDERDEPS = XftClientDepLibs XRENDERLIBS = XftClientLibs XRENDERINCS = $(XFTINCLUDES) $(XRENDERINCLUDES) -I$(XBUILDINCDIR) + + RENDER_SRCS = RenderLogo.c + RENDER_OBJS = RenderLogo.o #endif DEPLIBS = $(XRENDERDEPS) XawClientDepLibs XkbClientDepLibs LOCAL_LIBRARIES = $(XRENDERLIBS) XawClientLibs XkbClientLibs - SRCS = xlogo.c Logo.c RenderLogo.c - OBJS = xlogo.o Logo.o RenderLogo.o + SRCS = xlogo.c Logo.c $(RENDER_SRCS) + OBJS = xlogo.o Logo.o $(RENDER_OBJS) HEADERS = LogoP.h Logo.h RenderLogo.h INCLUDES = $(XRENDERINCS) DEFINES = $(XRENDERDEFS) XkbClientDefines Index: xc/programs/xphelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/Imakefile diff -N xc/programs/xphelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/Imakefile 21 Apr 2004 09:35:26 -0000 @@ -0,0 +1,24 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/02/10 19:44:00 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags + +#if HasMotif2 + XPXMHELLOWORLDDIR = xpxmhelloworld +#endif /* HasMotif2 */ + XPAWHELLOWORLDDIR = xpawhelloworld + 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/xpawhelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/xpawhelloworld/Imakefile diff -N xc/programs/xphelloworld/xpawhelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpawhelloworld/Imakefile 21 Apr 2004 09:35:26 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/05/12 19:54:53 gisburn Exp $ + + DEPLIBS = XawClientDepLibs +LOCAL_LIBRARIES = -L$(PROJECTROOT)/lib -lXm -lXprintUtil XawClientLibs +SYS_LIBRARIES = MathLibrary +INCLUDES = -I/usr/X11R6/include + +DEFINES = + SRCS = xpawhelloworld.c + OBJS = xpawhelloworld.o + +ComplexProgramTarget(xpawhelloworld) + +#ifdef HasDocbookToMan +all:: xpawhelloworld.man + +xpawhelloworld.man: xpawhelloworld.sgml + docbook-to-man xpawhelloworld.sgml >xpawhelloworld.man +#endif Index: xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c diff -N xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.c 21 Apr 2004 09:35:26 -0000 @@ -0,0 +1,425 @@ + +/* + * $Xorg: xpawhelloworld.c,v 1.1 2003/07/30 14:44:31 gisburn Exp $ + * + * xpawhelloworld - Xprint version of hello world using the + * Athena PrintShell widget class + * + * + +Copyright 2003-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 + */ + +/* + * Referencess: + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } + +/* Prototypes */ +static int do_hello_world( int argc, char *argv[], const char *printername, + const char *toFile, const char *sample_string ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool doPrint = False; /* Do we print on a printer ? */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ + +static +void usage( void ) +{ + fprintf(stderr, "usage: %s [options] string\n", ProgramName); + fprintf(stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf(stderr, "-printer printernname\tprinter to use\n"); + fprintf(stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf(stderr, "-v\tverbose output\n"); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + const char *sample_string; + + ProgramName = argv[0]; + + if( argc < 2 ) + { + usage(); + } + + for( i = 1 ; i < (argc-1) ; i++ ) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + } + else + { + usage(); + } + } + + sample_string = argv[argc-1]; + + if( doPrint ) + { + 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(argc, argv, plist[0].name, toFile, sample_string); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL, sample_string); + } + + return retval; +} + +typedef struct +{ + int num_pages; + Widget printshell_content; + int num_visible_rows; + XtAppContext appcontext; /* for XtAppSetExitFlag() */ +} MyPrintCallbackData; + +static +int GetCurrPageNum(Widget printshell) +{ + Cardinal n; + Arg args[2]; + int pagenum = -666; /* bah! */ + + n = 0; + XtSetArg(args[n], XawNcurrPageNumInJob, &pagenum); n++; + XtGetValues(printshell, args, n); + + return pagenum; +} + +static +void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + int curr_page; + + curr_page = GetCurrPageNum(pshell); + Log(("--> PrintOnePageCB, printing page %d of %d\n", curr_page, mpcd->num_pages)); + + /* Get ready for next page + * Scroll widget to display the next page (except for the first page :) + */ + if (!psp->last_page_in_job && curr_page > 1) + { + /* XmText allows two solutions to scroll a page down + * - Either scroll num_rows_per_page down (this is XmText-specific) + * or + * - Call the "next-page" action procedure (this works for all widgets + * which support this action proc) + */ +#define USE_ACTION_TO_SCROLL_DOWN 1 +#ifdef USE_ACTION_TO_SCROLL_DOWN + Log(("Scrolling down one page ...\n")); + XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0); +#else + Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows)); + XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows); +#endif /* USE_ACTION_TO_SCROLL_DOWN */ + } + + if (curr_page == (int)mpcd->num_pages) + { + Log(("Printing last page.\n")); + psp->last_page_in_job = True; + } + + Log(("PrintOnePageCB: done\n")); +} + +static +void PrintStartJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + + Log(("--> PrintStartJobCB\n")); +} + +static +void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XawPrintShellCallbackStruct *psp = (XawPrintShellCallbackStruct *)call_data; + + Log(("--> PrintEndJobCB\n")); + + /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ + XtAppSetExitFlag(mpcd->appcontext); +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) +{ + XtAppContext app; + Widget toplevel, + shell, + print_shell, + hello; + long dpi; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *textFont; + XmFontList textFontList; + Cardinal n; + Arg args[10]; + MyPrintCallbackData mpcd; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XawPrintShell widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi = 0; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = XawOpenApplication(&app, + pdpy, pscreen, + "xpawprintshelldemo", "XpXawPrintShellDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("XawOpenApplication failure.\n")); + + if( doPrint ) + { + n = 0; + XtSetArg(args[n], XawNlayoutMode, XawPrintLAYOUTMODE_DRAWABLEAREA); n++; + print_shell = XtCreatePopupShell("myprintshell", + xawPrintShellWidgetClass, + toplevel, args, n); + + /* we're mapping/unmapping at start/end page time */ + XtSetMappedWhenManaged(print_shell, False); + + shell = print_shell; + } + else + { + shell = toplevel; + } + + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi, dpi); + textFont = XLoadQueryFont(pdpy, fontname); + if( !textFont ) + { + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi, dpi); + textFont = XLoadQueryFont(pdpy, fontname); + } + if( !textFont ) + Error(("XLoadQueryFont failure.\n")); + textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); + + n = 0; + /* Make sure the cursor is off, current Xprt servers do not seem to like + * blinking cursors that much... ;-/ */ + XtSetArg(args[n], XmNcursorPositionVisible, False); n++; + XtSetArg(args[n], XmNvalue, sample_string); n++; + XtSetArg(args[n], XmNfontList, textFontList); n++; + XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; + + hello = XmCreateText(shell, "mytext", args, n); + if( !hello ) + Error(("XmCreateText failure.\n")); + + XtManageChild(hello); + XtRealizeWidget(toplevel); + XtRealizeWidget(shell); + + if( doPrint ) + { + int num_total_rows; + short num_visible_rows; + int num_pages; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get number of rows visible per page and the number of total rows + * in the whole text widget... */ + n = 0; + XtSetArg(args[n], XmNrows, &num_visible_rows); n++ ; + XtSetArg(args[n], XmNtotalLines, &num_total_rows); n++ ; + XtGetValues(hello, args, n); + + /* Take away one row to match the one-line overlapping used by the + * "next-page" action proc */ + num_visible_rows -= 1; + + /* Calculate the number of pages */ + num_pages = (num_total_rows+num_visible_rows-1) / num_visible_rows; + Log(("Printing %d pages (num_total_rows=%d, num_visible_rows=%d)...\n", + num_pages, num_total_rows, num_visible_rows)); + + /* Prepare our own context data for the print shell callbacks */ + mpcd.num_pages = num_pages; + mpcd.printshell_content = hello; + mpcd.num_visible_rows = num_visible_rows; + mpcd.appcontext = app; + + /* Setup the print shell callbacks... */ + XtAddCallback(print_shell, XawNpageSetupCallback, PrintOnePageCB, (XtPointer)&mpcd); + XtAddCallback(print_shell, XawNstartJobCallback, PrintStartJobCB, NULL); + XtAddCallback(print_shell, XawNendJobCallback, PrintEndJobCB, (XtPointer)&mpcd); + + /* ... and finally start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + } + + XtAppMainLoop(app); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} Index: xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.man diff -N xc/programs/xphelloworld/xpawhelloworld/xpawhelloworld.man 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 21 Apr 2004 09:35:26 -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 21 Apr 2004 09:35:26 -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 21 Apr 2004 09:35:26 -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 21 Apr 2004 09:35:26 -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 21 Apr 2004 09:35:26 -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/) + + + + + + + + Index: xc/programs/xphelloworld/xpsimplehelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/xpsimplehelloworld/Imakefile diff -N xc/programs/xphelloworld/xpsimplehelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpsimplehelloworld/Imakefile 21 Apr 2004 09:35:26 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.3 2002/02/10 19:54:53 gisburn Exp $ + +LOCAL_LIBRARIES = $(XLIB) -lXp -lXprintUtil +SYS_LIBRARIES = MathLibrary +DEPLIBS = $(DEPXLIB) + +DEFINES = + SRCS = xpsimplehelloworld.c + OBJS = xpsimplehelloworld.o + +ComplexProgramTarget(xpsimplehelloworld) + +#ifdef HasDocBookTools +all:: xpsimplehelloworld.man xpsimplehelloworld.html + +ConvertDocBookToManPage(xpsimplehelloworld.sgml, xpsimplehelloworld.man) +ConvertDocBookToHTML(xpsimplehelloworld.sgml, xpsimplehelloworld.html) +#endif /* HasDocBookTools */ + Index: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c diff -N xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,374 @@ +/* + * $Xorg: xphelloworld.c,v 1.2 2002/05/10 06:54:^1 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 +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Log(x) { if(verbose) printf x; } + +static const char *ProgramName; /* program name (from argv[0]) */ +static 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, "-printfile file\tprint to file instead of printer\n"); + fprintf (stderr, "-embedpsl2data string\tPostScript level 2 fragment to embed\n" + "\t\t(use 'xppsembeddemo1' to embed demo data)\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +/* strstr(), case-insensitive */ +static +char *str_case_str(const char *s, const char *find) +{ + size_t len; + char c, + sc; + + if ((c = tolower(*find++)) != '\0') + { + len = strlen(find); + do + { + do + { + if ((sc = tolower(*s++)) == '\0') + return NULL; + } while (sc != c); + } while (strncasecmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} + +static +int do_hello_world(const char *printername, const char *printerfile, const char *psembeddata ) +{ + Display *pdpy; /* X connection */ + XPContext pcontext; /* Xprint context */ + void *printtofile_handle; /* "context" when printing to file */ + int xp_event_base, /* XpExtension even base */ + xp_error_base; /* XpExtension error base */ + long dpi; + Screen *pscreen; + int pscreennumber; + Window pwin; + XGCValues gcvalues; + XEvent ev; + GC pgc; + unsigned short dummy; + XRectangle winrect; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *font; + + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + { + fprintf(stderr, "Cannot open printer '%s'\n", printername); + return(EXIT_FAILURE); + } + + if( XpQueryExtension(pdpy, &xp_event_base, &xp_error_base) == False ) + { + fprintf(stderr, "XpQueryExtension() failed.\n"); + XpuClosePrinterDisplay(pdpy, pcontext); + 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(pdpy, pcontext, XPPrintMask); + + /* Set job title */ + XpuSetJobTitle(pdpy, pcontext, "Hello world for Xprint"); + + /* Set print context + * Note that this modifies the available fonts, including builtin printer prints. + * All XListFonts()/XLoadFont() stuff should be done _after_ setting the print + * context to obtain the proper fonts. + */ + XpSetContext(pdpy, pcontext); + + /* Get default printer reolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'.\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + if( printerfile ) + { + Log(("starting job (to file '%s').\n", printerfile)); + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, printerfile); + if( !printtofile_handle ) + { + fprintf(stderr, "%s: Error: %s while trying to print to file.\n", + ProgramName, strerror(errno)); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); + } + else + { + Log(("starting job.\n")); + XpuStartJobToSpooler(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartJobNotify); + } + +#ifdef MULTIPLE_DOCUMENTS_IN_ONE_JOB + /* Start document (one job can contain any number of "documents") + * XpStartDoc() isn't mandatory if job only contains one document - first + * XpStartPage() will generate a "synthetic" XpStartDoc() if one had not + * already been done. + */ + XpStartDoc(pdpy, XPDocNormal); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartDocNotify); +#endif /* MULTIPLE_DOCUMENTS_IN_ONE_JOB */ + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + pscreennumber = XScreenNumberOfScreen(pscreen); + + /* Obtain some info about page geometry */ + XpGetPageDimensions(pdpy, pcontext, &dummy, &dummy, &winrect); + + pwin = XCreateSimpleWindow(pdpy, XRootWindowOfScreen(pscreen), + winrect.x, winrect.y, winrect.width, winrect.height, + 10, + XBlackPixel(pdpy, pscreennumber), + XWhitePixel(pdpy, pscreennumber)); + + gcvalues.background = XWhitePixel(pdpy, pscreennumber); + gcvalues.foreground = XBlackPixel(pdpy, pscreennumber); + + pgc = XCreateGC(pdpy, pwin, GCBackground|GCForeground, &gcvalues); + + Log(("start page.\n")); + XpStartPage(pdpy, pwin); + XpuWaitForPrintNotify(pdpy, xp_event_base, 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(pdpy, pwin); + + /* usual rendering stuff..... */ + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi, dpi); + font = XLoadQueryFont(pdpy, fontname); + XSetFont(pdpy, pgc, font->fid); + XDrawString(pdpy, pwin, pgc, 100, 100, "hello world from X11 print system", 33); + +#define DO_EMBED_TEST 1 + +#ifdef DO_EMBED_TEST + if( psembeddata ) + { + char *embedded_formats_supported; + + embedded_formats_supported = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-embedded-formats-supported"); + + Log(("psembed: xp-embedded-formats-supported='%s'\n", NULLSTR(embedded_formats_supported))); + + /* MAX(XExtendedMaxRequestSize(pdpy), XMaxRequestSize(pdpy)) defines the + * maximum length of emebdded PostScript data which can be send in one + * step using XpPutDocumentData() */ + Log(("psembed: XExtendedMaxRequestSize=%ld\n", (long)XExtendedMaxRequestSize(pdpy))); + Log(("psembed: XMaxRequestSize=%ld\n", (long)XMaxRequestSize(pdpy))); + + /* Should we embed the demo ? */ + if( !strcmp(psembeddata, "xppsembeddemo1") ) + { + Log(("psembed: Using PS embedding demo 1\n")); + psembeddata = "newpath\n270 360 moveto\n 0 72 rlineto\n" + "72 0 rlineto\n 0 -72 rlineto\n closepath\n fill\n"; + } + else + { + Log(("psembed: Using user PS embedding data = '%s'\n", psembeddata)); + } + + /* Check whether "PostScript Level 2" is supported as embedding format + * (The content of the "xp-embedded-formats-supported" attribute needs + * to be searched in a case-insensitive way since the model-configs + * may use the same word with multiple variants of case + * (e.g. "PostScript" vs. "Postscript" or "PCL" vs. "Pcl" etc.") + * To avoid problems we simply use |str_case_str()| (case-insensitive + * strstr()) instead of |strstr()| here...) + */ + if( embedded_formats_supported && + (str_case_str(embedded_formats_supported, "PostScript 2") != NULL) ) + { + /* Note that the emebdded PostScript code uses the same resolution and + * coordinate space as currently be used by the DDX (if you don not + * want that simply reset it yourself :) */ + char *test = (char *)psembeddata; + int test_len = strlen(test); + char *type = "PostScript 2"; /* Format of embedded data + * (older PS DDX may be picky, fixed via + * http://xprint.mozdev.org/bugs/show_bug.cgi?id=4023) + */ + char *option = ""; /* PostScript DDX does not support any options yet + * (in general |BadValue| will be returned for not + * supported options/option values) */ + XpPutDocumentData(pdpy, pwin, test, test_len, type, option); + } + else + { + Log(("psembed: error: cannot embed data, 'PostScript 2' not supported as embedded data format for this printer\n")); + } + } +#endif /* DO_EMBED_TEST */ + + XpEndPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndPageNotify); + Log(("end page.\n")); + +#ifdef DO_SOME_MORE_RENDERING + XpStartPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPStartPageNotify); + + /* some more rendering..... */ + + XpEndPage(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndPageNotify); +#endif /* DO_SOME_MORE_RENDERING */ + +#ifdef MULTIPLE_DOCUMENTS_IN_ONE_JOB + /* End document. Do _not_ use it if you did not explicitly used + * XpStartDoc() above (e.g. if XpStartDoc() was triggered by first + * XpStartPage() - see comment about XpStartDoc() above... + */ + XpEndDoc(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndDocNotify); +#endif /* MULTIPLE_DOCUMENTS_IN_ONE_JOB */ + + /* End the print job - the final results are sent by the X print + * server to the spooler sub system. + */ + XpEndJob(pdpy); + XpuWaitForPrintNotify(pdpy, xp_event_base, XPEndJobNotify); + Log(("end job.\n")); + + if( printerfile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + } + + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_SUCCESS); +} + +int main (int argc, char *argv[]) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + const char *embedpsl2data = NULL; /* PS Level 2 code fragment for embedding in output */ + 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("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + } + else if (!strncmp("-embedpsl2data", arg, len)) + { + if (++i >= argc) + usage(); + embedpsl2data = argv[i]; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + } + else + { + usage(); + } + } + + 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, toFile, embedpsl2data); + + XpuFreePrinterList(plist); + + return(retval); +} + + Index: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.html =================================================================== RCS file: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.html diff -N xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.html 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,16 @@ +xpsimplehelloworld

Name

xpsimplehelloworld — "Hello World"-like Xprint sample utility based on plain X11 rendering calls

Synopsis

xpsimplehelloworld [-printer printernname] [-v] [-h]

DESCRIPTION

xpsimplehelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) using plain X11 + rendering instructions and without using special toolkit support (like one of + the special Xt print shell widget classes + (such as + XmPrintShell(3x) + or + XawPrintShell(3x))). +

OPTIONS

-printer printernname

printer to use

-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

+ 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), xphelloworld(1x), xpxmhelloworld(1x), xpawhelloworld(1x), xpxthelloworld(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/xpsimplehelloworld/xpsimplehelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.man diff -N xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.man 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,46 @@ +.\" 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 "XPSIMPLEHELLOWORLD" "__mansuffix__" "13 February 2004" "" "" +.SH NAME +xpsimplehelloworld \- \&"Hello World\&"-like Xprint sample utility based on plain X11 rendering calls +.SH SYNOPSIS + +\fBxpsimplehelloworld\fR [ \fB-printer \fIprinternname\fB\fR] [ \fB-v\fR] [ \fB-h\fR] + +.SH "DESCRIPTION" +.PP +\fBxpsimplehelloworld\fR is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) using plain X11 +rendering instructions and without using special toolkit support (like one of +the special Xt print shell widget classes +(such as +\fBXmPrintShell\fR(__libmansuffix__) +or +\fBXawPrintShell\fR(__libmansuffix__))). +.SH "OPTIONS" +.TP +\fB-printer \fIprinternname\fB \fR +printer to use +.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 +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__), \fBxphelloworld\fR(__mansuffix__), \fBxpxmhelloworld\fR(__mansuffix__), \fBxpawhelloworld\fR(__mansuffix__), \fBxpxthelloworld\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/xpsimplehelloworld/xpsimplehelloworld.sgml =================================================================== RCS file: xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.sgml diff -N xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.sgml 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,140 @@ + + + + + + + xpsimplehelloworld + __mansuffix__ + + + xpsimplehelloworld + + "Hello World"-like Xprint sample utility based on plain X11 rendering calls + + + + xpsimplehelloworld + + + + + + + + + + + DESCRIPTION + + xpsimplehelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) using plain X11 + rendering instructions and without using special toolkit support (like one of + the special Xt print shell widget classes + (such as + XmPrintShell__libmansuffix__ + or + XawPrintShell__libmansuffix__)). + + + + + + OPTIONS + + + + + + + printer to use + + + + + + + verbose output + + + + + + + print usage + + + + + + + ENVIRONMENT + + + XPSERVERLIST + + + + ${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + KNOWN BUGS + + 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__ + xphelloworld__mansuffix__ + xpxmhelloworld__mansuffix__ + xpawhelloworld__mansuffix__ + xpxthelloworld__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/xpxmhelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/xpxmhelloworld/Imakefile diff -N xc/programs/xphelloworld/xpxmhelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxmhelloworld/Imakefile 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/05/12 19:54:53 gisburn Exp $ + +LOCAL_LIBRARIES = -L$(PROJECTROOT)/lib -lXm -lXt $(XPLIB) -lXprintUtil $(XLIB) +SYS_LIBRARIES = MathLibrary +DEPLIBS = $(DEPXLIB) +INCLUDES = -I/usr/X11R6/include + +DEFINES = + SRCS = xpxmhelloworld.c + OBJS = xpxmhelloworld.o + +ComplexProgramTarget(xpxmhelloworld) + +#ifdef HasDocBookTools +all:: xpxmhelloworld.man xpxmhelloworld.html + +ConvertDocBookToManPage(xpxmhelloworld.sgml, xpxmhelloworld.man) +ConvertDocBookToHTML(xpxmhelloworld.sgml, xpxmhelloworld.html) +#endif /* HasDocBookTools */ Index: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c diff -N xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,449 @@ + +/* + * $Xorg: xpxmhelloworld.c,v 1.2 2003/10/19 00:3:26 gisburn Exp $ + * + * xpxmhelloworld - Xprint version of hello world using Motif widgets + * + * +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 + */ + +/* + * Referencess: + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm + * http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } + +/* Prototypes */ +static int do_hello_world( int argc, char *argv[], const char *printername, + const char *toFile, const char *sample_string ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool doPrint = False; /* Do we print on a printer ? */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ + +static +void usage( void ) +{ + fprintf(stderr, "usage: %s [options] string\n", ProgramName); + fprintf(stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf(stderr, "-printer printernname\tprinter to use\n"); + fprintf(stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf(stderr, "-v\tverbose output\n"); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + XPPrinterList plist; /* list of printers */ + int plist_count; /* number of entries in |plist|-array */ + int i; + int retval; + const char *sample_string; + + ProgramName = argv[0]; + + if( argc < 2 ) + { + usage(); + } + + for( i = 1 ; i < (argc-1) ; i++ ) + { + char *arg = argv[i]; + int len = strlen(arg); + + if (!strncmp("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + } + else + { + usage(); + } + } + + sample_string = argv[argc-1]; + + if( doPrint ) + { + 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(argc, argv, plist[0].name, toFile, sample_string); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL, sample_string); + } + + return retval; +} + +/* xt_xp_openapplication() - mainly identical to XtOpenApplication() but + * takes a |Display *| and |Screen *| as arguments, too... */ +static +Widget xt_xp_openapplication(XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv) +{ + Widget toplevel; + Cardinal n; + Arg args[2]; + + XtToolkitInitialize(); + *app_context_return = XtCreateApplicationContext(); + if( *app_context_return == NULL ) + return NULL; + + XtDisplayInitialize(*app_context_return, dpy, + application_name, application_class, + NULL, 0, + argc, argv); + + n = 0; + XtSetArg(args[n], XtNscreen, screen); n++; + toplevel = XtAppCreateShell(application_name, + application_class, + widget_class, + dpy, + args, n); + + return toplevel; +} + +typedef struct +{ + int num_pages; + int curr_page; + + Widget printshell_content; + int num_visible_rows; + XtAppContext appcontext; /* for XtAppSetExitFlag() */ +} MyPrintCallbackData; + + +static +void PrintOnePageCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintOnePageCB, printing page %d of %d\n", mpcd->curr_page, mpcd->num_pages)); + + mpcd->curr_page++; + + /* Get ready for next page + * Scroll widget to display the next page (except for the first page :) + */ + if (!psp->last_page && mpcd->curr_page > 1) + { + /* XmText allows two solutions to scroll a page down + * - Either scroll num_rows_per_page down (this is XmText-specific) + * or + * - Call the "next-page" action procedure (this works for all widgets + * which support this action proc) + */ +#define USE_ACTION_TO_SCROLL_DOWN 1 +#ifdef USE_ACTION_TO_SCROLL_DOWN + Log(("Scrolling down one page ...\n")); + XtCallActionProc(mpcd->printshell_content, "next-page", NULL, NULL, 0); +#else + Log(("Scrolling down %d rows (=one page) ...\n", mpcd->num_visible_rows)); + XmTextScroll(mpcd->printshell_content, mpcd->num_visible_rows); +#endif /* USE_ACTION_TO_SCROLL_DOWN */ + } + + if (mpcd->curr_page == (int)mpcd->num_pages) + { + Log(("Printing last page.\n")); + psp->last_page = True; + } + + Log(("PrintOnePageCB: done\n")); +} + +static +void PrintStartJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintStartJobCB\n")); +} + +static +void PrintEndJobCB(Widget pshell, XtPointer context, XtPointer call_data) +{ + MyPrintCallbackData *mpcd = (MyPrintCallbackData *)context; + XmPrintShellCallbackStruct *psp = (XmPrintShellCallbackStruct *)call_data; + + Log(("--> PrintEndJobCB\n")); + + /* We're done with printing, tell |XtAppMainLoop()| that it can exit */ + XtAppSetExitFlag(mpcd->appcontext); +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile, const char *sample_string ) +{ + XtAppContext app; + Widget toplevel, + shell, + print_shell, + hello; + long dpi; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *textFont; + XmFontList textFontList; + Cardinal n; + Arg args[10]; + MyPrintCallbackData mpcd; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint XmPrintShell widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi = 0; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = xt_xp_openapplication(&app, + pdpy, pscreen, + "xpxmprintshelldemo", "XpXmPrintShellDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("xt_xp_openapplication failure.\n")); + + if( doPrint ) + { + n = 0; + print_shell = XtCreatePopupShell("myprintshell", + xmPrintShellWidgetClass, + toplevel, args, n); + + /* we're mapping/unmapping at start/end page time */ + XtSetMappedWhenManaged(print_shell, False); + + shell = print_shell; + } + else + { + shell = toplevel; + } + + sprintf(fontname, "-adobe-courier-medium-r-normal--40-*-%ld-%ld-*-*-iso8859-1", dpi, dpi); + textFont = XLoadQueryFont(pdpy, fontname); + if( !textFont ) + { + sprintf(fontname, "-*-*-*-*-*-*-*-160-%ld-%ld-*-*-iso8859-1", dpi, dpi); + textFont = XLoadQueryFont(pdpy, fontname); + } + if( !textFont ) + Error(("XLoadQueryFont failure.\n")); + textFontList = XmFontListCreate(textFont, XmSTRING_DEFAULT_CHARSET); + + n = 0; + /* Make sure the cursor is off, current Xprt servers do not seem to like + * blinking cursors that much... ;-/ */ + XtSetArg(args[n], XmNcursorPositionVisible, False); n++; + XtSetArg(args[n], XmNvalue, sample_string); n++; + XtSetArg(args[n], XmNfontList, textFontList); n++; + XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; + + hello = XmCreateText(shell, "mytext", args, n); + if( !hello ) + Error(("XmCreateText failure.\n")); + + XtManageChild(hello); + XtRealizeWidget(toplevel); + XtRealizeWidget(shell); + + if( doPrint ) + { + int num_total_rows; + short num_visible_rows; + int num_pages; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get number of rows visible per page and the number of total rows + * in the whole text widget... */ + n = 0; + XtSetArg(args[n], XmNrows, &num_visible_rows); n++ ; + XtSetArg(args[n], XmNtotalLines, &num_total_rows); n++ ; + XtGetValues(hello, args, n); + + /* Take away one row to match the one-line overlapping used by the + * "next-page" action proc */ + num_visible_rows -= 1; + + /* Calculate the number of pages */ + num_pages = (num_total_rows+num_visible_rows-1) / num_visible_rows; + Log(("Printing %d pages (num_total_rows=%d, num_visible_rows=%d)...\n", + num_pages, num_total_rows, num_visible_rows)); + + /* Prepare our own context data for the print shell callbacks */ + mpcd.num_pages = num_pages; + mpcd.curr_page = 0; + mpcd.printshell_content = hello; + mpcd.num_visible_rows = num_visible_rows; + mpcd.appcontext = app; + + /* Setup the print shell callbacks... */ + XtAddCallback(print_shell, XmNpageSetupCallback, PrintOnePageCB, (XtPointer)&mpcd); + XtAddCallback(print_shell, XmNstartJobCallback, PrintStartJobCB, NULL); + XtAddCallback(print_shell, XmNendJobCallback, PrintEndJobCB, (XtPointer)&mpcd); + + /* ... and finally start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + } + + XtAppMainLoop(app); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} + Index: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.html =================================================================== RCS file: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.html diff -N xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.html 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,13 @@ +xpxmhelloworld

Name

xpxmhelloworld — "Hello World"-like Xprint sample utility based on the Motif2 toolkit

Synopsis

xpxmhelloworld [-print] [-printer printernname] [-v] [-h] string...

DESCRIPTION

xpxmhelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Motif2 toolkit using the + XmPrintShell(3x) + widget class. +

OPTIONS

-print

Print (default is to display on the video Xserver)

-printer printernname

printer to use

-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

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

SEE ALSO

http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm, http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm, Xprint(7), X11(7), xplsprinters(1x), xphelloworld(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/xpxmhelloworld/xpxmhelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.man diff -N xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.man 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,46 @@ +.\" 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 "XPXMHELLOWORLD" "__mansuffix__" "13 February 2004" "" "" +.SH NAME +xpxmhelloworld \- \&"Hello World\&"-like Xprint sample utility based on the Motif2 toolkit +.SH SYNOPSIS + +\fBxpxmhelloworld\fR [ \fB-print\fR] [ \fB-printer \fIprinternname\fB\fR] [ \fB-v\fR] [ \fB-h\fR] \fB\fIstring\fB\fR\fI ...\fR + +.SH "DESCRIPTION" +.PP +\fBxpxmhelloworld\fR is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) based on +the Motif2 toolkit using the +\fBXmPrintShell\fR(__libmansuffix__) +widget class. +.SH "OPTIONS" +.TP +\fB-print \fR +Print (default is to display on the video Xserver) +.TP +\fB-printer \fIprinternname\fB \fR +printer to use +.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 +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 +http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm , http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm , \fBXprint\fR(__miscmansuffix__), \fBX11\fR(__miscmansuffix__), \fBxplsprinters\fR(__mansuffix__), \fBxphelloworld\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/xpxmhelloworld/xpxmhelloworld.sgml =================================================================== RCS file: xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.sgml diff -N xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.sgml 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,146 @@ + + + + + + + xpxmhelloworld + __mansuffix__ + + + xpxmhelloworld + + "Hello World"-like Xprint sample utility based on the Motif2 toolkit + + + + xpxmhelloworld + + + + + + + + + + string + + + + + DESCRIPTION + + xpxmhelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Motif2 toolkit using the + XmPrintShell__libmansuffix__ + widget class. + + + + + OPTIONS + + + + + + + Print (default is to display on the video Xserver) + + + + + + + printer to use + + + + + + + verbose output + + + + + + + print usage + + + + + + + ENVIRONMENT + + + XPSERVERLIST + + + + ${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + KNOWN BUGS + + A full list of bugs can be obtained from the Xprint.org bug database (http://xprint.mozdev.org/xprint_bugs.html). + + + + + SEE ALSO + + + + http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmPrintShell.htm + http://nscp.upenn.edu/aix4.3html/libs/motiftr/XmText.htm + + + Xprint__miscmansuffix__ + X11__miscmansuffix__ + xplsprinters__mansuffix__ + xphelloworld__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/xpxthelloworld/Imakefile =================================================================== RCS file: xc/programs/xphelloworld/xpxthelloworld/Imakefile diff -N xc/programs/xphelloworld/xpxthelloworld/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxthelloworld/Imakefile 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/07/26 21:32:21 gisburn Exp $ + +LOCAL_LIBRARIES = $(XLIB) XawClientLibs -lXp -lXprintUtil +SYS_LIBRARIES = MathLibrary +DEPLIBS = $(DEPXLIB) XawClientDepLibs + +DEFINES = + SRCS = xpxthelloworld.c + OBJS = xpxthelloworld.o + +ComplexProgramTarget(xpxthelloworld) + +#ifdef HasDocBookTools +all:: xpxthelloworld.man xpxthelloworld.html + +ConvertDocBookToManPage(xpxthelloworld.sgml, xpxthelloworld.man) +ConvertDocBookToHTML(xpxthelloworld.sgml, xpxthelloworld.html) +#endif /* HasDocBookTools */ + Index: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c =================================================================== RCS file: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c diff -N xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,412 @@ + +/* + * $Xorg: xpxthelloworld.c,v 1.1 2002/07/28 08:44:26 gisburn Exp $ + * + * xpxthelloworld - Xprint version of hello world using Athena widgets + * + * +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 +#include + +/* Turn a NULL pointer string into an empty string */ +#define NULLSTR(x) (((x)!=NULL)?(x):("")) + +#define Error(x) { printf x ; exit(EXIT_FAILURE); } +#define Log(x) { if(verbose) printf x; } + +/* Prototypes */ +static void redisplayWidget(Widget widget); +static void MyAppMainLoop(XtAppContext app, Widget printwidget); +static int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile ); + +/* Global vars */ +const char *ProgramName; /* program name (from argv[0]) */ +Bool verbose = False; /* verbose output what the program is doing */ +Bool done = False; /* Done with printing ? */ +Bool doPrint = False; /* Do we print on a printer ? */ +int xp_eventbase, /* XpExtension event base */ + xp_errorbase; /* XpExtension error base */ +Display *pdpy = NULL; /* (Paper) display */ +Screen *pscreen = NULL; /* (Paper) screen (DDX-specific!) */ +XPContext pcontext = None; /* Xprint context */ +void *printtofile_handle = NULL; /* XprintUtil "context" when printing to file */ +Drawable pdrawable = None; /* paper drawable */ +int numpages = 0; /* pages being printed */ + + +static +void MyAppMainLoop(XtAppContext app, Widget printwidget) +{ + XEvent xevent; + + /* process events. */ + while( !done ) + { + XtAppNextEvent(app, &xevent); + + if( XtDispatchEvent(&xevent) == False ) + { + /* XpExtension event ? */ + if( xevent.type == xp_eventbase+XPPrintNotify ) + { + XPPrintEvent *pev = (XPPrintEvent *)&xevent; + + Log(("--> got XPPrintEvent\n")); + + switch( pev->detail ) + { + case XPStartJobNotify: + Log(("Starting page...\n")); + XpStartPage(pdpy, pdrawable); + break; + case XPEndJobNotify: + /* Job done... */ + done = True; + break; + case XPStartPageNotify: + Log(("Rendering page...\n")); + redisplayWidget(printwidget); + + Log(("Page end reached.\n")); + XpEndPage(pdpy); + break; + case XPEndPageNotify: + /* next page or exit */ + numpages++; + + if( numpages >= 1 ) + { + Log(("Finishing job...\n")); + XpEndJob(pdpy); + } + break; + default: + Log(("--> other XPPrintEvent event\n")); + break; + } + } + else + { + Log(("--> other event\n")); + } + } + } +} + +/* Code from the OpenMotif sources (XmRedisplayWidget) */ +static +void redisplayWidget(Widget widget) +{ + XExposeEvent xev ; + Region region ; + + xev.type = Expose ; + /* is this better than 0 ? shouldn't make much difference + * unless the expose method is very tricky... */ + xev.serial = LastKnownRequestProcessed(XtDisplay(widget)) ; + xev.send_event = False ; + xev.display = XtDisplay(widget); + xev.window = XtWindowOfObject(widget); /* work with gadget too */ + xev.x = 0 ; + xev.y = 0 ; + xev.width = widget->core.width ; + xev.height = widget->core.height ; + xev.count = 0 ; + + region = XCreateRegion(); + XtAddExposureToRegion((XEvent*)&xev, region); + + if (widget->core.widget_class->core_class.expose) + (*(widget->core.widget_class->core_class.expose)) + (widget, (XEvent*)&xev, region); + + XDestroyRegion(region); +} + +static +void usage( void ) +{ + fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-print\tPrint via Xprint instead of displaying on the Xserver\n"); + fprintf (stderr, "-printer printernname\tprinter to use\n"); + fprintf (stderr, "-printfile file\tprint to file instead of printer\n"); + fprintf (stderr, "-v\tverbose output\n"); + fprintf (stderr, "\n"); + exit(EXIT_FAILURE); +} + +int main( int argc, char *argv[] ) +{ + const char *printername = NULL; /* printer to query */ + const char *toFile = NULL; /* output file (instead of printer) */ + 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("-print", arg, len)) + { + doPrint = True; + } + else if (!strncmp("-printer", arg, len)) + { + if (++i >= argc) + usage(); + printername = argv[i]; + doPrint = True; + } + else if (!strncmp("-printfile", arg, len)) + { + if (++i >= argc) + usage(); + toFile = argv[i]; + doPrint = True; + } + else if (!strncmp("-v", arg, len)) + { + verbose = True; + } + else + { + usage(); + } + } + + if( doPrint ) + { + 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(argc, argv, plist[0].name, toFile); + + XpuFreePrinterList(plist); + } + else + { + Log(("Displaying on framebuffer Xserver\n")); + + retval = do_hello_world(argc, argv, NULL, NULL); + } + + return(retval); +} + +/* xt_xp_openapplication() - mainly identical to XtOpenApplication() but + * takes a |Display *| and |Screen *| as arguments, too... */ +static +Widget xt_xp_openapplication(XtAppContext *app_context_return, + Display *dpy, + Screen *screen, + String application_name, + String application_class, + WidgetClass widget_class, + int *argc, + String *argv) +{ + Widget toplevel; + Cardinal n; + Arg args[2]; + + XtToolkitInitialize(); + *app_context_return = XtCreateApplicationContext(); + if( *app_context_return == NULL ) + return NULL; + + XtDisplayInitialize(*app_context_return, dpy, + application_name, application_class, + NULL, 0, + argc, argv); + + n = 0; + XtSetArg(args[n], XtNscreen, screen); n++; + toplevel = XtAppCreateShell(application_name, + application_class, + widget_class, + dpy, + args, n); + + return toplevel; +} + +int do_hello_world( int argc, char *argv[], const char *printername, const char *toFile ) +{ + XtAppContext app; + Widget toplevel, + hello; + long dpi; + char fontname[256]; /* BUG: is this really big enougth ? */ + XFontStruct *labelFont; + Cardinal n; + Arg args[10]; + + if( doPrint ) + { + /* Get printer, either by "name" (foobar) or "name@display" (foobar@gaja:5) */ + if( XpuGetPrinter(printername, &pdpy, &pcontext) != 1 ) + Error(("XpuGetPrinter failure.\n")); + + if( XpQueryExtension(pdpy, &xp_eventbase, &xp_errorbase) == False ) + Error(("XpQueryExtension failure.\n")); + + XpSelectInput(pdpy, pcontext, XPPrintMask); + + /* Configure the print context (paper size, title etc.) + * We must do this before creating any Xt widgets - otherwise they will + * make wrong assuptions about fonts, resultions etc. ... + */ + XpuSetJobTitle(pdpy, pcontext, "Simple Xprint Athena widget demo"); + + /* Configuration done, set the context */ + XpSetContext(pdpy, pcontext); + + /* Get default printer resolution */ + if( XpuGetResolution(pdpy, pcontext, &dpi) != 1 ) + { + fprintf(stderr, "No default resolution for printer '%s'\n", printername); + XpuClosePrinterDisplay(pdpy, pcontext); + return(EXIT_FAILURE); + } + + pscreen = XpGetScreenOfContext(pdpy, pcontext); + } + else + { + pdpy = XOpenDisplay(NULL); + if( !pdpy ) + Error(("XOpenDisplay failure.\n")); + + dpi = 0; + + pscreen = XDefaultScreenOfDisplay(pdpy); + } + + toplevel = xt_xp_openapplication(&app, + pdpy, pscreen, + "xpxtawhenademo", "XpXtAthenaDemo", + applicationShellWidgetClass, + &argc, argv); + + if( !toplevel ) + Error(("xt_xp_openapplication failure.\n")); + + sprintf(fontname, "-*-*-*-*-*-*-*-180-%ld-%ld-*-*-iso8859-1", dpi, dpi); + labelFont = XLoadQueryFont(pdpy, fontname); + if( !labelFont ) + Error(("XLoadQueryFont failure.\n")); + + n = 0; + XtSetArg(args[n], XtNlabel, "Hello world\n" + "(Xprint/Athena widget version)"); n++; + XtSetArg(args[n], XtNfont, labelFont); n++; + hello = XtCreateManagedWidget( + "hello", /* arbitrary widget name */ + labelWidgetClass, /* widget class from Label.h */ + toplevel, /* parent widget*/ + args, /* argument list */ + n /* arg list size */ + ); + if( !hello ) + Error(("XtCreateManagedWidget failure.\n")); + + XtRealizeWidget(toplevel); + + if( doPrint ) + { + unsigned short pwidth, pheight; + XRectangle pagerect; + + pdpy = XtDisplay(toplevel); + pdrawable = XtWindow(toplevel); + if( !pdpy || !pdrawable ) + Error(("No display.\n")); + + /* Make sure that the Xt machinery is really using the right screen (assertion) ... */ + if( XpGetScreenOfContext(XtDisplay(toplevel), pcontext) != XtScreen(toplevel) ) + Error(("Widget's screen != print screen. BAD.\n")); + + /* Get the page dimensions and resize the widget based on that info ... */ + XpGetPageDimensions(pdpy, pcontext, &pwidth, &pheight, &pagerect); + XMoveResizeWindow(pdpy, pdrawable, pagerect.x, pagerect.y, pagerect.width, pagerect.height); + + /* ... and then start the print job. */ + if( toFile ) + { + printtofile_handle = XpuStartJobToFile(pdpy, pcontext, toFile); + if( !printtofile_handle ) + { + perror("XpuStartJobToFile failure"); + Error(("XpuStartJobToFile failure.")); + } + } + else + { + XpuStartJobToSpooler(pdpy); + } + + numpages = 0; + } + + MyAppMainLoop(app, toplevel); + + if( doPrint ) + { + if( toFile ) + { + if( XpuWaitForPrintFileChild(printtofile_handle) != XPGetDocFinished ) + { + fprintf(stderr, "%s: Error while printing to file.\n", ProgramName); + } + } + + /* We have to use XpDestroyContext() and XtCloseDisplay() instead + * of XpuClosePrinterDisplay() to make libXt happy... */ + if( pcontext != None ) + XpDestroyContext(pdpy, pcontext); + XtCloseDisplay(pdpy); + } + + return EXIT_SUCCESS; +} + Index: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.html =================================================================== RCS file: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.html diff -N xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.html 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,15 @@ +xpxthelloworld

Name

xpxthelloworld — "Hello World"-like Xprint sample utility based on the Xt toolkit

Synopsis

xpxthelloworld [-print] [-printer printernname] [-v] [-h]

DESCRIPTION

xpxthelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Xt toolkit without using one of the special print shell widget classes + (such as + XmPrintShell(3x) + or + XawPrintShell(3x)). +

OPTIONS

-print

Print (default is to display on the video Xserver)

-printer printernname

printer to use

-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

+ 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), xphelloworld(1x), xpxmhelloworld(1x), xpawhelloworld(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/xpxthelloworld/xpxthelloworld.man =================================================================== RCS file: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.man diff -N xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.man 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,48 @@ +.\" 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 "XPXTHELLOWORLD" "__mansuffix__" "13 February 2004" "" "" +.SH NAME +xpxthelloworld \- \&"Hello World\&"-like Xprint sample utility based on the Xt toolkit +.SH SYNOPSIS + +\fBxpxthelloworld\fR [ \fB-print\fR] [ \fB-printer \fIprinternname\fB\fR] [ \fB-v\fR] [ \fB-h\fR] + +.SH "DESCRIPTION" +.PP +\fBxpxthelloworld\fR is a sample utility for Xprint, the +printing system for the X Window system. It demonstrates how to send a test page to +the specified printer (or the default printer, if none is specified) based on +the Xt toolkit without using one of the special print shell widget classes +(such as +\fBXmPrintShell\fR(__libmansuffix__) +or +\fBXawPrintShell\fR(__libmansuffix__)). +.SH "OPTIONS" +.TP +\fB-print \fR +Print (default is to display on the video Xserver) +.TP +\fB-printer \fIprinternname\fB \fR +printer to use +.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 +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__), \fBxphelloworld\fR(__mansuffix__), \fBxpxmhelloworld\fR(__mansuffix__), \fBxpawhelloworld\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/xpxthelloworld/xpxthelloworld.sgml =================================================================== RCS file: xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.sgml diff -N xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.sgml 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,148 @@ + + + + + + + xpxthelloworld + __mansuffix__ + + + xpxthelloworld + + "Hello World"-like Xprint sample utility based on the Xt toolkit + + + + xpxthelloworld + + + + + + + + + + + + + DESCRIPTION + + xpxthelloworld is a sample utility for Xprint, the + printing system for the X Window system. It demonstrates how to send a test page to + the specified printer (or the default printer, if none is specified) based on + the Xt toolkit without using one of the special print shell widget classes + (such as + XmPrintShell__libmansuffix__ + or + XawPrintShell__libmansuffix__). + + + + + + OPTIONS + + + + + + + Print (default is to display on the video Xserver) + + + + + + + printer to use + + + + + + + verbose output + + + + + + + print usage + + + + + + + ENVIRONMENT + + + XPSERVERLIST + + + + ${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + KNOWN BUGS + + 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__ + xphelloworld__mansuffix__ + xpxmhelloworld__mansuffix__ + xpawhelloworld__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/xplsprinters/Imakefile =================================================================== RCS file: xc/programs/xplsprinters/Imakefile diff -N xc/programs/xplsprinters/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xplsprinters/Imakefile 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.1 2002/02/10 19:54:53 gisburn Exp $ + +LOCAL_LIBRARIES = $(XLIB) -lXp -lXprintUtil +SYS_LIBRARIES = MathLibrary +DEPLIBS = $(DEPXLIB) + +DEFINES = + SRCS = xplsprinters.c + OBJS = xplsprinters.o + +ComplexProgramTarget(xplsprinters) + +#ifdef HasDocBookTools +all:: xplsprinters.man xplsprinters.html + +ConvertDocBookToManPage(xplsprinters.sgml, xplsprinters.man) +ConvertDocBookToHTML(xplsprinters.sgml, xplsprinters.html) +#endif /* HasDocBookTools */ + Index: xc/programs/xplsprinters/xplsprinters.c =================================================================== RCS file: xc/programs/xplsprinters/xplsprinters.c diff -N xc/programs/xplsprinters/xplsprinters.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xplsprinters/xplsprinters.c 21 Apr 2004 09:35:27 -0000 @@ -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 + +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 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); +} + + Index: xc/programs/xplsprinters/xplsprinters.html =================================================================== RCS file: xc/programs/xplsprinters/xplsprinters.html diff -N xc/programs/xplsprinters/xplsprinters.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xplsprinters/xplsprinters.html 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,30 @@ +xplsprinters

Name

xplsprinters — shows a list of Xprint printers and it's attributes

Synopsis

xplsprinters [-l] [-printer printername] [-dump] [-h]

DESCRIPTION

xplsprinters 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. +

OPTIONS

-dump

dump all available printer attributes

-h | -?

print usage

-l

list detailed printer attribute information

-printer printername

printer to use

ENVIRONMENT

XPSERVERLIST

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

EXAMPLES

Example 1. List all available "X Print Specifiers" (printer names)

% xplsprinters

would print: +

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

Example 2. Get information about the supported attributes of printer "ps002":

% xplsprinters -printer ps002 -l

would print: +


+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
+

SEE ALSO

Xprint(7), X11(7), xphelloworld(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/xplsprinters/xplsprinters.man =================================================================== RCS file: xc/programs/xplsprinters/xplsprinters.man diff -N xc/programs/xplsprinters/xplsprinters.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xplsprinters/xplsprinters.man 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,83 @@ +.\" 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 "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 ), Xprint main site (http://xprint.mozdev.org/ ) Index: xc/programs/xplsprinters/xplsprinters.sgml =================================================================== RCS file: xc/programs/xplsprinters/xplsprinters.sgml diff -N xc/programs/xplsprinters/xplsprinters.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ b/xc/programs/xplsprinters/xplsprinters.sgml 21 Apr 2004 09:35:27 -0000 @@ -0,0 +1,177 @@ + + + + + + + xplsprinters + __mansuffix__ + + + + xplsprinters + shows a list of Xprint printers and it's attributes + + + + + xplsprinters + + + + + + + + + + + + + + DESCRIPTION + + + xplsprinters 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. + + + + + OPTIONS + + + + + + + dump all available printer attributes + + + + + + + print usage + + + + + + + list detailed printer attribute information + + + + + + + printer to use + + + + + + + ENVIRONMENT + + + + XPSERVERLIST + + + ${XPSERVERLIST} must be set, + identifying the available Xprint servers. + See Xprint__miscmansuffix__ + for more details. + + + + + + + + EXAMPLES + + + List all available "X Print Specifiers" (printer names) + % xplsprinters + would print: +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 + + + + + Get information about the supported attributes of printer "ps002": + % xplsprinters -printer ps002 -l + would print: + +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 + + + + + + + SEE ALSO + + + + + + + Xprint__miscmansuffix__ + X11__miscmansuffix__ + + xphelloworld__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/) + + + + + +