Index: xc/lib/Imakefile =================================================================== RCS file: /cvs/xorg/xc/lib/Imakefile,v retrieving revision 1.1.4.2.6.2.6.1 diff -u -r1.1.4.2.6.2.6.1 Imakefile --- xc/lib/Imakefile 10 Apr 2004 09:03:55 -0000 1.1.4.2.6.2.6.1 +++ xc/lib/Imakefile 13 Apr 2004 02:45:11 -0000 @@ -153,7 +153,7 @@ #endif #if BuildXprintLib -XPRINTLIBDIR = Xp +XPRINTLIBDIRS = Xp XprintUtil XprintAppUtil #endif #if BuildFontCacheLib @@ -202,7 +202,7 @@ $(XF86RUSHLIBDIR) $(XMULIBDIR) $(XMUULIBDIR) $(XPMLIBDIR) \ $(XAW6LIBDIR) $(XAWLIBDIR) $(XINPUTLIBDIR) \ $(XTSTLIBDIR) $(FSLIBDIR) $(XKBLIBDIR) \ - $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) $(XPRINTLIBDIR) \ + $(XKBUILIBDIR) $(LBXUTILDIR) $(XALIBDIR) $(XPRINTLIBDIRS) \ $(XVLIBDIR) $(GLXLIBDIR) $(GLULIBDIR) $(GLWLIBDIR) \ $(DPSLIBDIR) $(DPSTKLIBDIR) $(PSRESLIBDIR) $(XINERAMADIR) \ $(ZLIBDIR) $(REGEXDIR) $(RENDERLIBDIR) $(FREETYPE2BUILDDIR) \ 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 +++ xc/lib/XprintAppUtil/Imakefile 13 Apr 2004 02:45:12 -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 +++ xc/lib/XprintAppUtil/xpapputil.c 13 Apr 2004 02:45:13 -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 +++ xc/lib/XprintAppUtil/xpapputil.h 13 Apr 2004 02:45:13 -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 +++ xc/lib/XprintUtil/Imakefile 13 Apr 2004 02:45:13 -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 +++ xc/lib/XprintUtil/xprintutil.c 13 Apr 2004 02:45:14 -0000 @@ -0,0 +1,1681 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the X11 print system utilities library. + * + * The Initial Developer of the Original Code is Roland Mainz + * . + * All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#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 +++ xc/lib/XprintUtil/xprintutil.h 13 Apr 2004 02:45:14 -0000 @@ -0,0 +1,220 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +#ifndef XPRINTUTIL_H +#define XPRINTUTIL_H 1 +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the X11 print system utilities library. + * + * The Initial Developer of the Original Code is Roland Mainz + * . + * All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +/* 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 +++ xc/lib/XprintUtil/xprintutil_printtofile.c 13 Apr 2004 02:45:14 -0000 @@ -0,0 +1,501 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the X11 print system utilities library. + * + * The Initial Developer of the Original Code is Roland Mainz + * . + * All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +#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/font/FreeType/ftfuncs.c =================================================================== RCS file: /cvs/xorg/xc/lib/font/FreeType/ftfuncs.c,v retrieving revision 1.1.4.4.2.2.6.2 diff -u -r1.1.4.4.2.2.6.2 ftfuncs.c --- xc/lib/font/FreeType/ftfuncs.c 12 Apr 2004 12:20:51 -0000 1.1.4.4.2.2.6.2 +++ xc/lib/font/FreeType/ftfuncs.c 13 Apr 2004 02:45:16 -0000 @@ -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/packager/Imakefile =================================================================== RCS file: xc/packager/Imakefile diff -N xc/packager/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/Imakefile 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,16 @@ +XCOMM $Xorg: Imakefile,v 1.2 2003/01/20 15:05:12 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +# Compatibility for 007 and early 008 releases +make_xprint_tarball:: + cd tarball ; make make_xprint_tarball + +SUBDIRS = \ + tarball \ + rpm \ + solaris \ + mozilla_xpi + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/packager/mozilla_xpi/Imakefile =================================================================== RCS file: xc/packager/mozilla_xpi/Imakefile diff -N xc/packager/mozilla_xpi/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/mozilla_xpi/Imakefile 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,11 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/01/20 19:54:53 gisburn Exp $ + +#if BuildMozillaXprintXPIPackage +make_mozilla_xpi:: + XPRINTDIR=$(XPRINTDIR) XBINDIR=$(BINDIR) XTOP=$(TOP) ; \ + export XPRINTDIR XBINDIR XTOP ; \ + /bin/ksh -e ./make_mozilla_xpi.sh + +clean:: + $(RM) mozilla_xprint_xpi.xpi +#endif /* BuildMozillaXprintXPIPackage */ Index: xc/packager/mozilla_xpi/K98xprint_xpi.sh =================================================================== RCS file: xc/packager/mozilla_xpi/K98xprint_xpi.sh diff -N xc/packager/mozilla_xpi/K98xprint_xpi.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/mozilla_xpi/K98xprint_xpi.sh 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,22 @@ +echo "# Stopping Xprint server" + +if [ -z "${MOZ_USER_DIR}" ] ; then + echo "Internal error: MOZ_USER_DIR not set." + exit 1 +fi + +# Make sure we pick the right binary - users may share one profile +# between different architectures +uname_os="`uname -s`" +uname_cpu="`uname -p 2>/dev/null`" # uname -p may fail on old Debian +if [ "${uname_cpu}" = "unknown" -o "${uname_cpu}" = "" ] ; then + uname_cpu="`uname -m`" +fi + +MOZXPSTARTSCRIPT="${HOME}/${MOZ_USER_DIR}/xprint_xpi/${uname_os}_${uname_cpu}/run_xprint_from_tarball.sh" + +if [ -f "${MOZXPSTARTSCRIPT}" ] ; then + /bin/sh "${MOZXPSTARTSCRIPT}" stop +fi + +echo "# Done." Index: xc/packager/mozilla_xpi/S98xprint_xpi.sh =================================================================== RCS file: xc/packager/mozilla_xpi/S98xprint_xpi.sh diff -N xc/packager/mozilla_xpi/S98xprint_xpi.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/mozilla_xpi/S98xprint_xpi.sh 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,39 @@ +echo "# Starting Xprint server" + +if [ -z "${MOZ_USER_DIR}" ] ; then + echo "Internal error: MOZ_USER_DIR not set." + moz_startstop_addon_scripts stop + exit 1 +fi + +# Make sure we pick the right binary - users may share one profile +# between different architectures +uname_os="`uname -s`" +uname_cpu="`uname -p 2>/dev/null`" # uname -p may fail on old Debian +if [ "${uname_cpu}" = "unknown" -o "${uname_cpu}" = "" ] ; then + uname_cpu="`uname -m`" +fi + +MOZXPSTARTSCRIPT="${HOME}/${MOZ_USER_DIR}/xprint_xpi/${uname_os}_${uname_cpu}/run_xprint_from_tarball.sh" + +if [ -f "${MOZXPSTARTSCRIPT}" ] ; then + echo "# Starting Xprint server" + /bin/sh "${MOZXPSTARTSCRIPT}" start + + echo "# Populating XPSERVERLIST" + + XPSERVERLIST="`/bin/sh "${MOZXPSTARTSCRIPT}" get_xpserverlist`" + export XPSERVERLIST + + echo "XPSERVERLIST=${XPSERVERLIST}" + + if [ -z "${XPSERVERLIST}" ] ; then + echo "Fatal error: XPSERVERLIST empty." + moz_startstop_addon_scripts stop + exit 1 + fi +else + echo "# Warning: No Xprint XPI start script found for \"${uname_os}_${uname_cpu}\"." +fi + +echo "# Done." Index: xc/packager/mozilla_xpi/install.js =================================================================== RCS file: xc/packager/mozilla_xpi/install.js diff -N xc/packager/mozilla_xpi/install.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/mozilla_xpi/install.js 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,151 @@ +// Install script for Xprint XPI + +var err; + +var regname="xprint"; +var version="20040214"; + +err = initInstall("XprintXPI v0.0.2", // name for install UI + regname, // registered name + version); // package version + +logComment("initInstall: " + err); + +logComment("# Main start."); +doXpXPIInstall(); +logComment("# Main done."); + +function doXpXPIInstall() +{ + var srDest = 16384; // Disk space required for installation (KB) + + var fProgram = getFolder("Program"); + var fComponents = getFolder("Components"); + var userProfileBaseDir = getUserProfileBaseDir(); + + logComment("# fProgram: '" + fProgram + "'."); + logComment("# fComponents: '" + fComponents + "'."); + logComment("# userProfileBaseDir: '" + userProfileBaseDir + "'."); + + /* Test whether Xprint's client side module was compiled-in (this is the + * default for Mozilla builds, but Red Hat has turned it off... ;-( ) */ + var libgfxxprintPath = getFolder(fComponents, "libgfxxprint.so"); + logComment("# Checking whether '" + libgfxxprintPath + "' exists."); + if (!File.exists(libgfxxprintPath)) { + logComment("# libgfxxprint.so missing"); + alert("It seems that your version of Mozilla was build with --disable-xprint\n" + + "which means the Xprint client support was EXPLICITLY TURNED OFF at build time.\n" + + "Please contact the creator of the Mozilla package to provide a build where this flag was not set."); + cancelInstall(ACCESS_DENIED); + return; + } + + /* Test whether we're running mozilla or something else */ + logComment("# Checking application type exists."); + var is_mozilla = File.exists(getFolder(fProgram, "mozilla-bin")); + var is_firefox = File.exists(getFolder(fProgram, "firefox-bin")) || File.exists(getFolder(fProgram, "firebird-bin")); + var is_thunderbird = File.exists(getFolder(fProgram, "thunderbird-bin")); + if ( (!is_mozilla) && (!is_firefox) && (!is_thunderbird)) { + logComment("# unknown application type"); + alert("This XPI currently only supports Mozilla, FirdBird and ThunderBird.\n" + + "Please contact file a bug at http://xprint.mozdev.org if you see this error."); + cancelInstall(ACCESS_DENIED); + return; + } + + /* Test whether this mozilla supports pluggable shell scripts */ + var init_d_readme_path = getFolder(fProgram, "init.d/README"); + logComment("# Checking whether '" + init_d_readme_path + "' exists."); + if (!File.exists(init_d_readme_path)) { + logComment("# init_d_readme_path missing"); + if (is_firefox) { + alert("Your version of FireFox does not support pluggable shell scripts.\n" + + "You need at least FireFox 0.9 (or later)."); + } + else if (is_thunderbird) { + alert("Your version of ThunderBird does not support pluggable shell scripts.\n" + + "You need at least ThunderBird 0.6 (or later)."); + } + else + { + alert("Your version of Mozilla does not support pluggable shell scripts.\n" + + "You need at least Mozilla 1.7a (or later)."); + } + cancelInstall(ACCESS_DENIED); + return; + } + + /* Verify available disk space */ + if (!verifyDiskSpace(fProgram, srDest)) { + logComment("# verifyDiskSpace failure."); + cancelInstall(INSUFFICIENT_DISK_SPACE); + return; + } + + /* Add the files which should be installed */ + logComment("# addDirectory sequence begin."); + addDirectory(regname, version, "xprint_xpi", userProfileBaseDir, "xprint_xpi", true); + addDirectory(regname, version, "init.d", userProfileBaseDir, "init.d", true); + logComment("# addDirectory sequence end."); + + err = getLastError(); + + if (err == ACCESS_DENIED) { + logComment("# ACCESS_DENIED"); + alert("Unable to write to directory " + userProfileBaseDir + ".\n" + + "You will need to restart the browser with administrator/root " + + "privileges to install this software." + + "After installing as root (or administrator), " + + "you will need to restart the browser one more time to " + + "register the installed software.\n After the second restart, " + + "you can go back to running the browser without privileges!"); + + logComment("# cancelInstall(), ACCESS_DENIED"); + cancelInstall(ACCESS_DENIED); + return; + } + else if (err != SUCCESS) { + logComment("# cancelInstall(), err=" + err); + cancelInstall(err); + return; + } + + logComment("# performInstall()"); + performInstall(); +} + +// this function verifies disk space in kilobytes +function verifyDiskSpace(dirPath, spaceRequired) { + var spaceAvailable; + + // Get the available disk space on the given path + spaceAvailable = fileGetDiskSpaceAvailable(dirPath); + + // Convert the available disk space into kilobytes + spaceAvailable = parseInt(spaceAvailable / 1024); + + // do the verification + if(spaceAvailable < spaceRequired) { + logComment("Insufficient disk space: " + dirPath); + logComment(" required : " + spaceRequired + " K"); + logComment(" available: " + spaceAvailable + " K"); + return false; + } + + return true; +} + +function getUserProfileBaseDir() +{ + var userPofileBaseDir; + + logComment("# getUserProfileBaseDir"); + + userPofileBaseDir = getFolder("Profile", "../.."); + + logComment("# getUserProfileBaseDir='" + userPofileBaseDir + "'"); + + return userPofileBaseDir; +} + +/* EOF. */ Index: xc/packager/mozilla_xpi/make_mozilla_xpi.sh =================================================================== RCS file: xc/packager/mozilla_xpi/make_mozilla_xpi.sh diff -N xc/packager/mozilla_xpi/make_mozilla_xpi.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/mozilla_xpi/make_mozilla_xpi.sh 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,125 @@ +#!/bin/ksh + +# Set search path for commands +export PATH=/usr/xpg4/bin:/usr/sbin:/usr/bin:/bin:/sbin + +set -x +set -e + +#XPRINTDIR=/usr/openwin/server/etc/XpConfig/ +#XBINDIR=/usr/openwin/bin + +PKG_NAME="mozilla_xprint_xpi" + +PKG_FILES="/tmp/tmp_${PKG_NAME}" + + +if [ "${XPRINTDIR}" = "" ] ; then + echo "$0: Error: XPRINTDIR not set" + exit 1 +fi + +if [ "${XBINDIR}" = "" ] ; then + echo "$0: Error: XBINDIR not set" + exit 1 +fi + + +# Do not edit +# REL_* vars are paths relative to '/' +# Thanks to the "wonders" of some /bin/sh I cannot use ... +# REL_XPRINTDIR=${XPRINTDIR#*/} +# REL_XBINDIR=${XBINDIR#*/} +# ... ;-( +REL_XPRINTDIR="`echo ${XPRINTDIR} | sed 's/\///'`" +REL_XBINDIR="`echo ${XBINDIR} | sed 's/\///'`" + + +#### Main + +# Create and test tarball of files which should be in the final RPM... +if true ; then +echo "###### Fetching files from build dir..." +( + # Go to xc/packager/tarball + cd ../tarball + # ${XPDESTTARFILE} is used by "make make_xprint_tarball" + export XPDESTTARFILE="/tmp/xprint_pkg_`date +%y%m%d%H%M%S`.tar.gz" + make make_xprint_tarball + + # Check if the temp. tarball was being build + if [ ! -f "${XPDESTTARFILE}" ] ; then + echo "# temp. tarball missing." + exit 1 + fi + + # ... and then unpack the temp. tarball in the ${PKG_FILES} dir + [ -d "${PKG_FILES}" ] && rm -Rf "${PKG_FILES}" + mkdir "${PKG_FILES}" + cd "${PKG_FILES}" + gunzip -c ${XPDESTTARFILE} | tar -xf - + rm -f ${XPDESTTARFILE} + + cd xprint/install + + # Remove old ReadMe + rm -f ${REL_XPRINTDIR}/README + # Remove docs we do not need in the XPI + rm -Rf usr/X11R6/man +) +fi + +echo "###### Building pkgproto file..." + + +# Make sure we pick the right binary - users may share one profile +# between different architectures +uname_os="`uname -s`" +uname_cpu="`uname -p 2>/dev/null`" # uname -p may fail on old Debian +if [ "${uname_cpu}" = "unknown" -o "${uname_cpu}" = "" ] ; then + uname_cpu="`uname -m`" +fi + +XPIDIR="${PKG_FILES}/xpi" +echo "XPIDIR=${XPIDIR}." + +mkdir -p "${XPIDIR}/xprint_xpi" +mkdir -p "${XPIDIR}/xprint_xpi/${uname_os}_${uname_cpu}" +( + cd "${XPIDIR}/xprint_xpi" + # FixME: Need softlinks for all compatible |uname_cpu| types + case "${uname_cpu}" in + "i386" | "i486" | "i586" | "i686" | "x86_64" ) + [ ! -d "${uname_os}_i386" ] && ln -s "${uname_os}_${uname_cpu}" "${uname_os}_i386" + [ ! -d "${uname_os}_i486" ] && ln -s "${uname_os}_${uname_cpu}" "${uname_os}_i486" + [ ! -d "${uname_os}_i586" ] && ln -s "${uname_os}_${uname_cpu}" "${uname_os}_i586" + [ ! -d "${uname_os}_i686" ] && ln -s "${uname_os}_${uname_cpu}" "${uname_os}_i686" + [ ! -d "${uname_os}_x86_64" ] && ln -s "${uname_os}_${uname_cpu}" "${uname_os}_x86_64" + ;; + esac +) +mkdir -p "${XPIDIR}/init.d" +mv "${PKG_FILES}/xprint"/* "${XPIDIR}/xprint_xpi/${uname_os}_${uname_cpu}/." +cp "K98xprint_xpi.sh" "${XPIDIR}/init.d/." +cp "S98xprint_xpi.sh" "${XPIDIR}/init.d/." +chmod a+rx "${XPIDIR}/init.d"/*.sh +cp "install.js" "${XPIDIR}/." + +echo "###### Making package..." + +echo "#### zip..." +( + OLDPWD="${PWD}" + cd "${XPIDIR}" + zip -r -y -9 "${OLDPWD}/${PKG_NAME}.xpi" . +) + +#echo "###### Cleaning up..." +rm -rf "${PKG_FILES}" + +echo "###### Package done:" +ls -lad "${PKG_NAME}.xpi" + +echo "###### Done." +exit 0 +# Index: xc/packager/rpm/Imakefile =================================================================== RCS file: xc/packager/rpm/Imakefile diff -N xc/packager/rpm/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/rpm/Imakefile 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,3 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/02/10 19:54:53 gisburn Exp $ + +XCOMM dummy for now Index: xc/packager/rpm/xprint.spec =================================================================== RCS file: xc/packager/rpm/xprint.spec diff -N xc/packager/rpm/xprint.spec --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/rpm/xprint.spec 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,201 @@ +%define name xprint +%define version 20040212trunk +%define release 0.9 + +Summary: Xprint +Name: %{name} +Version: %{version} +Release: %{release} +Copyright: MIT +Group: X11/Applications +URL: http://xprint.mozdev.org/ +Source: xprint-%{version}.tar.gz +#BuildPrereq: XFree86-devel +BuildRoot: %{_tmppath}/%{name}-%{version} +Prefix: %{_prefix} +Packager: Roland Mainz +Patch0: xprint_rpmpackage.patch + +%description +Xprint provides an advanched print API for X11-based +(incl. CDE, Xt/Motif-, Xt/LessTif-, Xt/Athena-, Qt- and +Mozilla-based) applications. + +%prep + +%setup -q -n xprint +%patch0 -p0 + +%build +cd src/xprint_main/xc/ +make World + +%install +if [ -d ${RPM_BUILD_ROOT} ] ; then + rm -rf ${RPM_BUILD_ROOT} +fi +mkdir -p ${RPM_BUILD_ROOT} + +# Create and test tarball of files which should be in the final RPM... +cd src/xprint_main/xc/packager/ +# ${XPDESTTARFILE} is used by "make make_xprint_tarball" +XPDESTTARFILE="/tmp/xprint_rpm_`date +%y%m%d%H%M%S`.tar.gz" +export XPDESTTARFILE +make make_xprint_tarball + +# Check if the temp. tarball was being build +if [ ! -f "${XPDESTTARFILE}" ] ; then + echo "# temp. tarball missing." + exit 1 +fi + +# ... and then unpack the temp. tarball in the ${RPM_BUILD_ROOT} dir +cd ${RPM_BUILD_ROOT} +gunzip -c ${XPDESTTARFILE} | tar -xvf - +rm -f ${XPDESTTARFILE} + +# the tarball generation script puts the files which should be installed +# in the "install/" subdir. we strip the tarball README and the +# tarball-specific "run_xprint_from_tarball.sh" and then move all stuff +# in install/* to $PWD +rm -f xprint/run_xprint_from_tarball.sh +rm -f xprint/README +mv xprint/install/* . +rmdir xprint/install +rmdir xprint + +# remove obsolete README and SECURITY extension config "SecurityPolicy" +rm -f ${RPM_BUILD_ROOT}/usr/X11R6/lib/X11/xserver/README +rm -f ${RPM_BUILD_ROOT}/usr/X11R6/lib/X11/xserver/SecurityPolicy + +mv ${RPM_BUILD_ROOT}/usr/X11R6/bin/Xprt ${RPM_BUILD_ROOT}/usr/X11R6/bin/Xprt_xprint_org + +if [ ! -f ${RPM_BUILD_ROOT}/usr/X11R6/lib/X11/xserver/C/print/models/PSdefault/model-config ] ; then + echo "# ERROR: ${RPM_BUILD_ROOT}/usr/X11R6/lib/X11/xserver/C/print/models/PSdefault/model-config missing." + exit 1 +fi + +%clean +rm -rf ${RPM_BUILD_ROOT} + +%post +if [ -x /usr/lib/lsb/install_initd ] ; then + # (hopefully) LSB-compliant distribution + /usr/lib/lsb/install_initd /etc/init.d/xprint +else + if [ -f /etc/redhat-release ] ; then + if [ $1 = 1 ]; then + /sbin/chkconfig --add xprint + fi + else + # SuSE(-like) ? + if [ -d /etc/rc.d/rc2.d/ ] ; then + echo "# Detected SuSE(-like) distribution" + echo "# Creating links..." + ln -sf ../xprint /etc/rc.d/rc2.d/K21xprint + ln -sf ../xprint /etc/rc.d/rc2.d/S21xprint + ln -sf ../xprint /etc/rc.d/rc3.d/K21xprint + ln -sf ../xprint /etc/rc.d/rc3.d/S21xprint + + # Older SuSE versions (like SuSE 6.4) do not have /etc/init.d/ + if [ ! -f /etc/rc.d/xprint ] ; then + echo "# Creating old SuSE compatibility link..." + ln -s /etc/init.d/xprint /etc/rc.d/xprint + fi + else + # RedHat(-like) ? + if [ -d "/etc/rc1.d" -a -d "/etc/init.d/" ] ; then + echo "# Detected RedHat(-like) distribution" + echo "# Creating links..." + ln -sf /etc/init.d/xprint /etc/rc.d/rc0.d/K61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc1.d/K61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc2.d/S61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc3.d/S61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc4.d/S61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc5.d/S61xprint + ln -sf /etc/init.d/xprint /etc/rc.d/rc6.d/K61xprint + else + echo "# Unsupported version of Linux, cannot create links for /etc/init.d/." + exit 1 + fi + fi + fi +fi + +ln -sf /usr/X11R6/bin/Xprt_xprint_org /usr/X11R6/bin/Xprt + +echo "#" +echo "# Notes:" +echo "# 1. You have to start the Xprint servers using % /etc/init.d/xprint start #" +echo "# and relogin (to populate the XPSERVERLIST env variable using" +echo "# /etc/profile.d/xprint) before using any Xprint-based applications." +echo "# 2. Please consult the FAQ (/usr/doc/packages/xprint/Xprint_FAQ.txt)" +echo "# or http://xprint.mozdev.org/ if there are any problems." + +%preun +if [ -x /usr/lib/lsb/remove_initd ] ; then + # (hopefully) LSB-compliant distribution + /usr/lib/lsb/remove_initd /etc/init.d/xprint +else + if [ -f /etc/redhat-release ] ; then + if [ $1 = 0 ]; then + /sbin/service xprint stop >/dev/null 2>&1 + /sbin/chkconfig --del xprint + fi + else + # SuSE(-like) ? + if [ -d /etc/rc.d/rc2.d/ ] ; then + echo "# Detected SuSE(-like) distribution" + echo "# Removing links..." + rm -f /etc/rc.d/rc2.d/K21xprint + rm -f /etc/rc.d/rc2.d/S21xprint + rm -f /etc/rc.d/rc3.d/K21xprint + rm -f /etc/rc.d/rc3.d/S21xprint + + # See comment above about old SuSE versions + if [ -L /etc/rc.d/xprint ] ; then + echo "# Removing old SuSE compatibility link..." + rm -f /etc/rc.d/xprint + fi + else + # RedHat(-like) ? + if [ -d "/etc/rc1.d" -a -d "/etc/init.d/" ] ; then + echo "# Detected RedHat(-like) distribution" + echo "# Removing links..." + rm -f /etc/rc.d/rc0.d/K61xprint + rm -f /etc/rc.d/rc1.d/K61xprint + rm -f /etc/rc.d/rc2.d/S61xprint + rm -f /etc/rc.d/rc3.d/S61xprint + rm -f /etc/rc.d/rc4.d/S61xprint + rm -f /etc/rc.d/rc5.d/S61xprint + rm -f /etc/rc.d/rc6.d/K61xprint + else + echo "# Unsupported version of Linux, cannot remove links for /etc/init.d/." + exit 1 + fi + fi + fi +fi + +%postun +if [ $1 -ge 1 ]; then + /sbin/service xprint condrestart >/dev/null 2>&1 +fi + +%files +%defattr(-,root,root) +%doc src/xprint_main/xc/doc/hardcopy/XPRINT/Xprint_FAQ.html +%doc src/xprint_main/xc/doc/hardcopy/XPRINT/Xprint_FAQ.txt +/etc/init.d/* +/etc/profile.d/* +/etc/X11/Xsession.d/92xprint-xpserverlist +/etc/X11/xinit/xinitrc.d/92xprint-xpserverlist +/usr/X11R6/bin/Xprt_xprint_org +/usr/X11R6/bin/xplsprinters +/usr/X11R6/bin/xphelloworld +/usr/X11R6/bin/xpxthelloworld +/usr/X11R6/bin/xpsimplehelloworld +/usr/X11R6/lib/X11/xserver/* +/usr/X11R6/man/man1/* +/usr/X11R6/man/man7/* +# EOF. Index: xc/packager/rpm/xprint_rpmpackage.patch =================================================================== RCS file: xc/packager/rpm/xprint_rpmpackage.patch diff -N xc/packager/rpm/xprint_rpmpackage.patch --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/rpm/xprint_rpmpackage.patch 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,14 @@ +Index: src/xprint_main/xc/config/cf/site.def +=================================================================== +RCS file: /cvs/xprint/src/xprint_main/xc/config/cf/site.def,v +retrieving revision 1.23 +diff -u -r1.23 site.def +--- src/xprint_main/xc/config/cf/site.def 27 Jan 2003 00:58:05 -0000 1.23 ++++ src/xprint_main/xc/config/cf/site.def 17 Nov 2003 23:44:55 -0000 +@@ -1,4 +1,6 @@ + ++#define BuildXprintRPMPackage YES ++ + /* Include xprint.org defaults */ + #include "xprint_site.def" + Index: xc/packager/solaris/Imakefile =================================================================== RCS file: xc/packager/solaris/Imakefile diff -N xc/packager/solaris/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/Imakefile 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,10 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/01/20 19:54:53 gisburn Exp $ +#define IHaveSubdirs +#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" + +SUBDIRS = \ + GISWxprintglue \ + GISWxprint + +MakeSubdirs($(SUBDIRS)) +DependSubdirs($(SUBDIRS)) Index: xc/packager/solaris/GISWxprint/Imakefile =================================================================== RCS file: xc/packager/solaris/GISWxprint/Imakefile diff -N xc/packager/solaris/GISWxprint/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/Imakefile 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,11 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/01/20 19:54:53 gisburn Exp $ + +#if BuildGISWxprint +make_GISWxprint:: + XPRINTDIR=$(XPRINTDIR) XBINDIR=$(BINDIR) XTOP=$(TOP) ; \ + export XPRINTDIR XBINDIR XTOP ; \ + /bin/ksh -e ../GISWxprintglue/make_solaris_pkg.sh "GISWxprint" + +clean:: + $(RM) GISWxprint.tar.gz pkgproto.tmp +#endif /* BuildGISWxprint */ Index: xc/packager/solaris/GISWxprint/README =================================================================== RCS file: xc/packager/solaris/GISWxprint/README diff -N xc/packager/solaris/GISWxprint/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/README 13 Apr 2004 02:45:17 -0000 @@ -0,0 +1,91 @@ +README for GISWxprint (=Xprint server for Solaris) package + +This package contains the Xprint server side (e.g. server, startup and +configuration files) which are required to use Xprint-based applications +(like Mozilla, Phoenix, Eclipse, Motif2, Qt etc.) + +For futher information please consult the Xprint FAQ (available under +/opt/GISWxprint/docs/Xprint_FAQ.txt after installation - or see +http://xprint.mozdev.org/ for the newest version) and/or +http://xprint.mozdev.org/ + +Installation requirements: +========================== +The following Solaris patches are REQUIRED to gurantee correct behaviour of +this package: +* Solaris 2.7/SPARC: + 106541-27 SunOS 5.7: Kernel Update Patch + 107443-17 SunOS 5.7: packaging utilities patch + 107650-08 OpenWindows 3.6.1 X11R6.4 Xprint Extension Patch + 107654-10 OpenWindows 3.6.1: X11R6.4 LBX & XRX Extensions Patch + 107656-11 OpenWindows 3.6.1 libXt Patch + 108376-44 OpenWindows 3.6.1: Xsun Patch + 115228-01 CDE 1.3: dtksh patch +* Solaris 2.7/x86: + 106542-27 SunOS 5.7_x86: Kernel Update Patch + 107444-17 SunOS 5.7_x86: packaging utilities patch + 107651-08 OpenWindows 3.6.1_x86: X11R6.4 Xprint Extension Patch + 107655-10 OpenWindows 3.6.1_x86: X11R6.4 LBX & XRX Extensions Patch + 107657-09 OpenWindows 3.6.1_x86: ERC X11R6.4 Extension Patch + 108377-39 OpenWindows 3.6.1_x86: Xsun Patch + +* Solaris 2.8/SPARC: + 108652-74 X11 6.4.1: Xsun patch + 108897-01 X11 6.4.1 Xprint patch + 110934-14 SunOS 5.8: pkgtrans, pkgadd, pkgchk, pkgmk and libpkg.a patch + 114956-02 CDE 1.4: dtksh patch +* Solaris 2.8/x86: + 108653-63 X11 6.4.1_x86: Xsun patch + 110934-14 SunOS 5.8: pkgtrans, pkgadd, pkgchk, pkgmk and libpkg.a patch + +* Solaris 2.9/SPARC: + 112785-26 X11 6.6.1: Xsun patch + 113713-03 SunOS 5.9: pkginstall Patch +* Solaris 2.9/x86: + 112786-15 X11 6.6.1_x86: Xsun patch + 114568-02 SunOS 5.9_x86: usr/sadm/install/bin/pkginstall Patch + + +Installation: +============ +1. Install the package: + % /usr/sbin/pkgadd -d GISWxprint.pkg + +2. Start Xprint server side: + a) reboot + or + b) start the Xprint servers manually using + % /etc/init.d/xprint start + % sleep 30 + and restart your user CDE sessions (e.g. re-login.) + +3. Verification: + After (re-)login into CDE the env variable ${XPSERVERLIST} should be + set and + % /opt/GISWxprint/bin/xplsprinters + should list all available printer queues. + + +Deinstallation: +=============== +1. Stop Xprint servers: + % /etc/init.d/xprint stop + +2. Remove the package + % /usr/sbin/pkgrm GISWxprint + + +Known bugs/issues: +================== +- Not all paper sizes defined in the "PSdefault" printer models may be + available since the Xprint drivers(including the PostScript DDX) within + Xprt will validate those lists against a buildin list and this list may + not have been updated yet in Solaris's version of Xprt. + + +Reporting bugs: +=============== +Please send bug reports/comments/questions to +mailto:roland.mainz@nrubsig.org or +mailto:xprint@mozdev.org + Index: xc/packager/solaris/GISWxprint/depend =================================================================== RCS file: xc/packager/solaris/GISWxprint/depend diff -N xc/packager/solaris/GISWxprint/depend --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/depend 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,41 @@ +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +# $Id: depend,v 1.3 2004/02/13 04:43:47 gisburn Exp $ +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# see pkginfo(4), PKG parameter +# see pkginfo(4), NAME parameter +# see pkginfo(4), VERSION parameter +# see pkginfo(4), ARCH parameter +# +# () +# () +# ... +# +# ... + +P SUNWcsr Core Solaris, (Root) +P SUNWxwplt X Window System platform software +P SUNWpcu SunSoft Print - Client, (usr) +P SUNWxcu4 XCU4 Utilities +P SUNWxwfnt X Window System platform required fonts +P SUNWdtbas CDE application basic runtime environment + +# "GISWxprint" is the full version (incl. Xprt binary; "GISWxprintglue" +# uses Solaris's own /usr/openwin/bin/Xprt instead) of the package +# (which installs it's own /etc/init.d/xprint) +I GISWxprintglue Xprint server glue +# "GISWxprintcommon" may be used in the future for /etc/init.d/xprint and co. +I GISWxprintcommon + +# make sure we don't collide with the blastwave.org versions of these packages +I CSWxprint +I CSWxprintglue +I CSWxprintcommon +# EOF. Index: xc/packager/solaris/GISWxprint/pkginfo =================================================================== RCS file: xc/packager/solaris/GISWxprint/pkginfo diff -N xc/packager/solaris/GISWxprint/pkginfo --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/pkginfo 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,23 @@ +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: pkginfo,v 1.3 2004/02/13 04:43:47 gisburn Exp $" +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# +PKG="GISWxprint" +NAME="Xprint server (full version)" +ARCH="sparc" +VERSION="0.9" +CATEGORY="system" +DESC="Xprint server" +VENDOR="xprint.mozdev.org" +HOTLINE="Please contact your local service provider" +EMAIL="xprint@mozdev.org" +CLASSES="none" +BASEDIR=/ +# EOF. Index: xc/packager/solaris/GISWxprint/postinstall =================================================================== RCS file: xc/packager/solaris/GISWxprint/postinstall diff -N xc/packager/solaris/GISWxprint/postinstall --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/postinstall 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: postinstall,v 1.2 2004/02/13 04:43:47 gisburn Exp $" +# +# postinstall for GISWxprint package + +print_package_usage() +{ +cat <<'@EOF' +# To finish the installation please +# a) reboot +# or +# b) start the Xprint servers manually using +# % /etc/init.d/xprint start +# % sleep 30 +# and restart your user CDE sessions (e.g. re-login.) +# +# Verification: +# After login the env variable ${XPSERVERLIST} should be set and +# % /opt/GISWxprint/bin/xplsprinters +# should list all available printer queues. +@EOF +} + +# Print postinstall notice about the steps todo after installation +print_package_usage + +exit 0 +# EOF. Index: xc/packager/solaris/GISWxprint/preinstall =================================================================== RCS file: xc/packager/solaris/GISWxprint/preinstall diff -N xc/packager/solaris/GISWxprint/preinstall --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprint/preinstall 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: preinstall,v 1.2 2004/02/13 04:43:47 gisburn Exp $" +# +# preinstall for GISWxprint package + +# NO-OP for now + +exit 0 +# EOF. Index: xc/packager/solaris/GISWxprintglue/Imakefile =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/Imakefile diff -N xc/packager/solaris/GISWxprintglue/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/Imakefile 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,11 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/01/20 19:54:53 gisburn Exp $ + +#if BuildGISWxprintglue +make_GISWxprintglue:: + XPRINTDIR=$(XPRINTDIR) XBINDIR=$(BINDIR) XTOP=$(TOP) ; \ + export XPRINTDIR XBINDIR XTOP ; \ + /bin/ksh -e ./make_solaris_pkg.sh "GISWxprintglue" + +clean:: + $(RM) GISWxprintglue.tar.gz pkgproto.tmp +#endif /* BuildGISWxprintglue */ Index: xc/packager/solaris/GISWxprintglue/README =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/README diff -N xc/packager/solaris/GISWxprintglue/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/README 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,121 @@ +README for GISWxprintglue (=Xprint glue for Solaris) package + +This package contains the Xprint glue (startup and configuration files) +which are currently missing in Solaris to use Xprint-based applications +(like Mozilla, Phoenix, Eclipse, Motif2, Qt etc.) + +For futher information please consult the Xprint FAQ (available under +/opt/GISWxprintglue/docs/Xprint_FAQ.txt after installation - or see +http://xprint.mozdev.org/ for the newest version) and/or +http://xprint.mozdev.org/ + +Installation requirements: +========================== +The following Solaris patches are REQUIRED to gurantee correct behaviour of +this package: +* Solaris 2.7/SPARC: + 106541-27 SunOS 5.7: Kernel Update Patch + 107443-17 SunOS 5.7: packaging utilities patch + 107650-08 OpenWindows 3.6.1 X11R6.4 Xprint Extension Patch + 107654-10 OpenWindows 3.6.1: X11R6.4 LBX & XRX Extensions Patch + 107656-11 OpenWindows 3.6.1 libXt Patch + 108376-44 OpenWindows 3.6.1: Xsun Patch + 115228-01 CDE 1.3: dtksh patch +* Solaris 2.7/x86: + 106542-27 SunOS 5.7_x86: Kernel Update Patch + 107444-17 SunOS 5.7_x86: packaging utilities patch + 107651-08 OpenWindows 3.6.1_x86: X11R6.4 Xprint Extension Patch + 107655-10 OpenWindows 3.6.1_x86: X11R6.4 LBX & XRX Extensions Patch + 107657-09 OpenWindows 3.6.1_x86: ERC X11R6.4 Extension Patch + 108377-39 OpenWindows 3.6.1_x86: Xsun Patch + +* Solaris 2.8/SPARC: + 108652-74 X11 6.4.1: Xsun patch + 108897-01 X11 6.4.1 Xprint patch + 110934-14 SunOS 5.8: pkgtrans, pkgadd, pkgchk, pkgmk and libpkg.a patch + 114956-02 CDE 1.4: dtksh patch +* Solaris 2.8/x86: + 108653-63 X11 6.4.1_x86: Xsun patch + 110934-14 SunOS 5.8: pkgtrans, pkgadd, pkgchk, pkgmk and libpkg.a patch + +* Solaris 2.9/SPARC: + 112785-26 X11 6.6.1: Xsun patch + 113713-03 SunOS 5.9: pkginstall Patch +* Solaris 2.9/x86: + 112786-15 X11 6.6.1_x86: Xsun patch + 114568-02 SunOS 5.9_x86: usr/sadm/install/bin/pkginstall Patch + + +Installation: +============ +1. Install the package: + % /usr/sbin/pkgadd -d GISWxprintglue.pkg + +2. Start Xprint server side: + a) reboot + or + b) start the Xprint servers manually using + % /etc/init.d/xprint start + % sleep 30 + and restart your user CDE sessions (e.g. re-login.) + +3. Verification: + After (re-)login into CDE the env variable ${XPSERVERLIST} should be + set and + % /opt/GISWxprintglue/bin/xplsprinters + should list all available printer queues. + + +Deinstallation: +=============== +1. Stop Xprint servers: + % /etc/init.d/xprint stop + +2. Remove the package + % /usr/sbin/pkgrm GISWxprintglue + + +Known bugs/issues: +================== +- Printing may remove spaces when monotype fonts (like "-monotype-arial-*") + are being used by the PostScript driver. + This is a bug in the Solaris Xprint server binary (/usr/openwin/bin/Xprt). + + Various bug reports have been filed, see + - SunSolve bugid 4843234 + - http://xprint.mozdev.org/bugs/show_bug.cgi?id=3353 ("Solaris Xprt looses + space when rendering with '-monotype-arial-*'-fonts") + - http://bugzilla.mozilla.org/show_bug.cgi?id=199957 ("Solaris 8 Mozilla + removes spaces for text within ...") + + Solution: + Please apply the patches listed in the section "Installation requirements" + of this document. + + Known workarounds: + - Remove the '-monotype-arial-*' fonts from the font path + - Use an alternate Xprint server like available in the "GISWxprint" package + (this package is identical to the "GISWxprintglue" package except that it + uses a Xprint server build from xprint.mozdev.org sources and not the + /usr/openwin/bin/Xprt binary from Solaris) + - Mozilla-only: Adding + -- snip -- + user_pref("print.xprint.font.rejectfontpattern", + "fname=-dt-.*;scalable=.*;outline_scaled=false;xdisplay=.*;xdpy=.*;ydpy=.*;xdevice=.*|" + + "fname=-monotype-arial.*;scalable=.*;outline_scaled=.*;xdisplay=.*;xdpy=.*;ydpy=.*;xdevice=.*"); + -- snip -- + to prefs.js works around the problem (see + http://bugzilla.mozilla.org/show_bug.cgi?id=199957#c6 , too). + +- Not all paper sizes defined in the "PSdefault" printer models may be + available since the Xprint drivers(including the PostScript DDX) within + Xprt will validate those lists against a buildin list and this list may + not have been updated yet in Solaris's version of Xprt. + + +Reporting bugs: +=============== +Please send bug reports/comments/questions to +mailto:roland.mainz@nrubsig.org or +mailto:xprint@mozdev.org + Index: xc/packager/solaris/GISWxprintglue/depend =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/depend diff -N xc/packager/solaris/GISWxprintglue/depend --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/depend 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,41 @@ +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +# $Id: depend,v 1.3 2004/02/13 04:43:47 gisburn Exp $ +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# see pkginfo(4), PKG parameter +# see pkginfo(4), NAME parameter +# see pkginfo(4), VERSION parameter +# see pkginfo(4), ARCH parameter +# +# () +# () +# ... +# +# ... + +P SUNWcsr Core Solaris, (Root) +P SUNWxwplt X Window System platform software +P SUNWpcu SunSoft Print - Client, (usr) +P SUNWxcu4 XCU4 Utilities +P SUNWxwfnt X Window System platform required fonts +P SUNWdtbas CDE application basic runtime environment + +# "GISWxprint" is the full version (incl. Xprt binary; "GISWxprintglue" +# uses Solaris's own /usr/openwin/bin/Xprt instead) of the package +# (which installs it's own /etc/init.d/xprint) +I GISWxprint Xprint server (full version) +# "GISWxprintcommon" may be used in the future for /etc/init.d/xprint and co. +I GISWxprintcommon + +# make sure we don't collide with the blastwave.org versions of these packages +I CSWxprint +I CSWxprintglue +I CSWxprintcommon +# EOF. Index: xc/packager/solaris/GISWxprintglue/make_solaris_pkg.sh =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/make_solaris_pkg.sh diff -N xc/packager/solaris/GISWxprintglue/make_solaris_pkg.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/make_solaris_pkg.sh 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,184 @@ +#!/bin/ksh + +# Set search path for commands +export PATH=/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/dt/bin:/usr/openwin/bin + +#XPRINTDIR=/usr/openwin/server/etc/XpConfig/ +#XBINDIR=/usr/openwin/bin + +case "$1" in + 'GISWxprintglue') + PKG_NAME="GISWxprintglue" + ;; + 'GISWxprint') + PKG_NAME="GISWxprint" + ;; + *) + echo "## Error illegal target" + exit 1 + ;; +esac + + +PKG_FILES=/tmp/tmp_${PKG_NAME} + + +if [ "${XPRINTDIR}" = "" ] ; then + echo "$0: Error: XPRINTDIR not set" + exit 1 +fi + +if [ "${XBINDIR}" = "" ] ; then + echo "$0: Error: XBINDIR not set" + exit 1 +fi + + +# Do not edit +# REL_* vars are paths relative to '/' +# Thanks to the "wonders" of some /bin/sh I cannot use ... +# REL_XPRINTDIR=${XPRINTDIR#*/} +# REL_XBINDIR=${XBINDIR#*/} +# ... ;-( +REL_XPRINTDIR="`echo ${XPRINTDIR} | sed 's/\///'`" +REL_XBINDIR="`echo ${XBINDIR} | sed 's/\///'`" + +createpkgproto() +{ + pkgproto | + while read i1 i2 i3 i4 i5 ; do + if [ "${i1}" = "f" ] ; then + if [ ! -r "${i3}" ] ; then + echo "${0}: \"${i3}\" not found." >&2 + exit 1 + fi + fi + + if [ "${i1}" = "d" -o -x "${i3}" ] ; then + echo "$i1 $i2 $i3 0755" + else + echo "$i1 $i2 $i3" + fi + done +} + +#### Main + +# Create and test tarball of files which should be in the final RPM... +if true ; then +echo "###### Fetching files from build dir..." +( + # Go to xc/packager/tarball + cd ../../tarball + # ${XPDESTTARFILE} is used by "make make_xprint_tarball" + export XPDESTTARFILE="/tmp/xprint_pkg_`date +%y%m%d%H%M%S`.tar.gz" + make make_xprint_tarball + + # Check if the temp. tarball was being build + if [ ! -f "${XPDESTTARFILE}" ] ; then + echo "# temp. tarball missing." + exit 1 + fi + + # ... and then unpack the temp. tarball in the ${PKG_FILES} dir + [ -d "${PKG_FILES}" ] && rm -Rf "${PKG_FILES}" + mkdir "${PKG_FILES}" + cd "${PKG_FILES}" + gunzip -c ${XPDESTTARFILE} | tar -xf - + rm -f ${XPDESTTARFILE} + + cd xprint/install + + # Remove old ReadMe + rm -f ${REL_XPRINTDIR}/README + + if [ "${PKG_NAME}" = "GISWxprintglue" ] ; then + # Remove our own Xprt binary, Solaris has it's own working version + # under /usr/openwin/bin/Xprt and the GISWxprintglue will use that + # (only the "GISWxprint" package will ship it's own version of Xprt) + rm -f ${REL_XBINDIR}/Xprt + fi +) +fi + +echo "###### Building pkgproto file..." + +rm -f pkgproto.tmp +( + OLD_PWD="${PWD}" + cd "${PKG_FILES}/xprint/install" + + # Add files in /etc but skip any dirs (they are part of SUNWcsr) + # (and treat them all as executable) + echo '!default 755 root bin' + find etc '!' -type d -print | createpkgproto + + # Add entry for package base dir ("/opt/GISWxprintglue" or "/opt/GISWxprint") + echo "opt/${PKG_NAME}" | createpkgproto + + # Add files in opt/${PKG_NAME}/bin (executables) + echo '!default 755 root bin' + find opt/${PKG_NAME}/bin -print | createpkgproto + + # Add CDE/1.x glue + find usr/dt/config/Xsession.d '!' -type d -print | createpkgproto + + # Add config files in opt/${PKG_NAME}/server (all non-executable) + echo '!default 644 root bin' + find opt/${PKG_NAME}/server -print | createpkgproto + + # Add Xfree86 encoding files for GISWxprint + # (GISWxprintglue uses Solaris Xprt which uses the Solaris encoding/ttmap files) + if [ "${PKG_NAME}" = "GISWxprint" ] ; then + find opt/${PKG_NAME}/lib/X11/fonts/encodings -print | createpkgproto + fi + + # Add files in opt/${PKG_NAME}/man (manual pages) + if [ -d opt/${PKG_NAME}/man ] ; then + echo '!default 644 root bin' + find opt/${PKG_NAME}/man -print | createpkgproto + fi + + # Add FAQ, README etc. + echo '!default 644 root bin' + [ ! -d "opt/${PKG_NAME}/docs" ] && mkdirhier "opt/${PKG_NAME}/docs" + cp "${OLD_PWD}/../../../doc/hardcopy/XPRINT/Xprint_FAQ.txt" opt/${PKG_NAME}/docs/. + cp "${OLD_PWD}/README" opt/${PKG_NAME}/docs/. + find opt/${PKG_NAME}/docs -print | createpkgproto + + # List package info files + echo "# packaging files" + echo "i pkginfo" + echo "i depend" + echo "i preinstall=./preinstall" + echo "i postinstall=./postinstall" +) >pkgproto.tmp +ls -l pkgproto.tmp + +echo "###### Making package..." +[ -d "/tmp/${PKG_NAME}" ] && rm -R "/tmp/${PKG_NAME}" + +echo "#### pkgmk..." +pkgmk -f pkgproto.tmp -d /tmp -o -r "${PKG_FILES}/xprint/install" ${PKG_NAME} + +echo "#### pkgtrans..." +pwd +rm -f "./${PKG_NAME}.pkg" +pkgtrans /tmp "${PWD}/${PKG_NAME}.pkg" ${PKG_NAME} + +echo "#### compressing..." +rm -f "${PKG_NAME}.tar.gz" +tar -cvf - "${PKG_NAME}.pkg" README | gzip --best --stdout >"${PKG_NAME}.tar.gz" +rm -f "${PKG_NAME}.pkg" + +echo "###### Cleaning up..." +rm -rf "${PKG_FILES}" +rm -R "/tmp/${PKG_NAME}" +#rm -f pkgproto.tmp + +echo "###### Package done:" +ls -lad "${PKG_NAME}.tar.gz" + +echo "###### Done." +exit 0 +# Index: xc/packager/solaris/GISWxprintglue/pkginfo =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/pkginfo diff -N xc/packager/solaris/GISWxprintglue/pkginfo --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/pkginfo 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,23 @@ +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: pkginfo,v 1.4 2004/02/13 04:43:47 gisburn Exp $" +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# +PKG="GISWxprintglue" +NAME="Xprint server glue" +ARCH="sparc" +VERSION="0.9" +CATEGORY="system" +DESC="Runtime glue for Xprint server" +VENDOR="xprint.mozdev.org" +HOTLINE="Please contact your local service provider" +EMAIL="xprint@mozdev.org" +CLASSES="none" +BASEDIR=/ +# EOF. Index: xc/packager/solaris/GISWxprintglue/postinstall =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/postinstall diff -N xc/packager/solaris/GISWxprintglue/postinstall --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/postinstall 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: postinstall,v 1.2 2004/02/13 04:43:47 gisburn Exp $" +# +# postinstall for GISWxprintglue package + +print_package_usage() +{ +cat <<'@EOF' +# To finish the installation please +# a) reboot +# or +# b) start the Xprint servers manually using +# % /etc/init.d/xprint start +# % sleep 30 +# and restart your user CDE sessions (e.g. re-login.) +# +# Verification: +# After login the env variable ${XPSERVERLIST} should be set and +# % /opt/GISWxprintglue/bin/xplsprinters +# should list all available printer queues. +@EOF +} + +# Print postinstall notice about the steps todo after installation +print_package_usage + +exit 0 +# EOF. Index: xc/packager/solaris/GISWxprintglue/preinstall =================================================================== RCS file: xc/packager/solaris/GISWxprintglue/preinstall diff -N xc/packager/solaris/GISWxprintglue/preinstall --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/solaris/GISWxprintglue/preinstall 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Copyright 2003-2004 Roland Mainz +# All Rights Reserved. +# Use is subject to license terms. +# +#ident "$Id: preinstall,v 1.4 2004/02/13 04:43:47 gisburn Exp $" +# +# preinstall for GISWxprintglue package + +# nothing here + +exit 0 +# EOF. Index: xc/packager/tarball/Imakefile =================================================================== RCS file: xc/packager/tarball/Imakefile diff -N xc/packager/tarball/Imakefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/tarball/Imakefile 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,15 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/02/10 19:54:53 gisburn Exp $ + +#if InstallXF86EncodingFiles +INSTALLXF86ENCODINGFILES=1 +#else +INSTALLXF86ENCODINGFILES=0 +#endif /* InstallXF86EncodingFiles */ + +FONT_ENCODINGS_PATH = XF86EncodingsPath +FONT_ENCODINGS_DIRECTORY = $(FONT_ENCODINGS_PATH)/encodings.dir + +make_xprint_tarball:: + XPRINTDIR=$(XPRINTDIR) XBINDIR=$(BINDIR) XTOP=$(TOP) XMANPATH=$(MANPATH) XFONTENCPATH=$(FONT_ENCODINGS_PATH) XINSTALLXF86ENCODINGFILES=$(INSTALLXF86ENCODINGFILES) ; \ + export XPRINTDIR XBINDIR XTOP XMANPATH XFONTENCPATH XINSTALLXF86ENCODINGFILES ; \ + $(SHELL) make_xprint_binary_tarball.sh Index: xc/packager/tarball/README_tarball =================================================================== RCS file: xc/packager/tarball/README_tarball diff -N xc/packager/tarball/README_tarball --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/tarball/README_tarball 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,121 @@ + +Xprint server for Linux/AIX/IRIX README + +8th release of the Xprt (X11 print server) build from xprint.mozdev.org sources + +Disclaimer: +We do not guarantee that any source code or executable code available from the +in this package is Year 2000 compliant, works in any way or may not eat your +harddisk alive. + +Please read the the Xprint_FAQ.txt how to configure Xprint. + +* Installation and usage + (short version, reading the Xprint_FAQ.txt first is better): +a) For the impatient, the hurry or if you do not have the "root"-password or if + you do not want to try this as "root": + 1. Unpack the tarball to your favourite dir: + % mkdir /tmp/test_xprint + % cd /tmp/test_xprint + % gunzip -c xprint_linux_tarball.tar.gz | tar -xvf - + + 2. Start the Xprint server + ("./run_xprint_from_tarball.sh" is a wrapper script + for the "/etc/init.d/xprint" script which tells that script where the + Xprint server files are currently be located.) + % cd xprint + % ./run_xprint_from_tarball.sh start + + 3. Set the ${XPSERVERLIST} env var (and/or put this into your shell profile, + do not forget to specify the _full_ path to the "run_xprint_from_tarball.sh" + script): + # sh + % XPSERVERLIST="`./run_xprint_from_tarball.sh get_xpserverlist`" + % export XPSERVERLIST + + # ksh/bash syntax + % export XPSERVERLIST="$(./run_xprint_from_tarball.sh get_xpserverlist)" + + 4. Verifying that Xprint is running and working + (this is usually "done" by /usr/X11R6/bin/xplsprinters - but the + "./run_xprint_from_tarball.sh" / "/etc/init.d/xprint" scripts provide + a wrapper for that tool, too): + % ./run_xprint_from_tarball.sh lsprinters + + 5. Run the application you want to use + % /usr/local/bin/bin/mozilla + + * Alternatively you can replace step [3] and [5] with: + % ./run_xprint_from_tarball.sh wrapper /usr/local/bin/bin/mozilla + +a) If you have adminstrator priviledges ("root") on your machine: + # There are binary and source RPMs for Linux, *.deb packages for Debian and + # *.pkg packages for Solaris available at http://xprint.mozdev.org, + # the tarball installation is only for those platforms which are not coverd + # by the list above or for those people who only want to run Xprint per-user + # without installing it permanently <-- + + 1. Make sure that you eliminate any existing Xfree86-based Xprt servers. + All Xprt binares build from Xfree86 sources up to today are broken and + will not work. + Example: + % which Xprt + /usr/X11R6/bin/Xprt + % mv /usr/X11R6/bin/Xprt /usr/X11R6/bin/Xprt_xf86_disabled + + 2. Copy the files in dist/usr into the matching dirs on your hard disk: + Example: + % (cd install; chmod -R og=u,og-w . ; tar -cf - usr etc) | (cd / ; tar -xf -) + + 3. Start X print server: + % /etc/init.d/xprint start + + 4. Make the info available where the applications can find Xprint server(s): + For all users (maybe in /etc/profile): + % XPSERVERLIST="`/etc/init.d/xprint get_xpserverlist`" + % export XPSERVERLIST + (this step is optional for systems which support /etc/profile.d/ ; the tarball + comes with /etc/profile.d/xprint.sh and /etc/profile.d/xprint.csh which will + set the XPSERVERLIST env var for all users if the Xprint servers are running) + + # Do not set $DISPLAY to the Xprt server. You still need your normal + # Xserver for your video card(=framebuffer) - Xprt is only for your + # printer(s). + + 5. Verifying that Xprint is running and working + % /usr/X11R6/bin/xplsprinters + OR + % ./run_xprint_from_tarball.sh lsprinters + +* Top two of the issues on Linux (all items from the FAQ): + ("P"=problem, "B"=background, "S"=solution", "W"=Workaround) + 1. P: "Printing works but the printout is covers only 1/4 of the page" + B: This is usually an indicator for a wrong DPI setting. The default + "PSdefault" model config uses 300DPI but some printers use 600DPI. + W: Edit ${XPCONFIGDIR}/C/print/attributes/document and replace the line + "*default-printer-resolution: 300" with + "*default-printer-resolution: 600" + S: Create a model-config for your printer which only contains attributes + supported by your printer (read the docs... :) + + 2. P: "Printing works but I get large borders..." + B: Same issue as issue [2] - wrong DPI + S: Check the DPI value and adjust it as described in [2]. Common DPI + values are 240, 300, 360, 400 and 600 DPI. + +More info will follow when I have time, take a look at the Xprint pages at +http://xprint.mozdev.org/ in the meantime... + +---- + +Bye, +Roland + +-- + __ . . __ + (o.\ \/ /.o) roland.mainz@nrubsig.org + \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer + /O /==\ O\ TEL +49 2426 901568 FAX +49 2426 901569 + (;O/ \/ \O;) + + Index: xc/packager/tarball/make_xprint_binary_tarball.sh =================================================================== RCS file: xc/packager/tarball/make_xprint_binary_tarball.sh diff -N xc/packager/tarball/make_xprint_binary_tarball.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/tarball/make_xprint_binary_tarball.sh 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,343 @@ +#!/bin/sh +# +# make_xprint_binary_tarball.sh - packager script for Xprint stuff +# +# $Xorg: make_xprint_binary_tarball.sh,v 1.2 2003/02/09 04:41:52 gisburn Exp $ +# +# This script creates a binary tarball for Xprint stuff (Xprt, Xprt config +# files and Xprint helper applications. +# +# Written by Roland Mainz +# + +# These should be provided by Imakefile +#XTOP=.. +#XPRINTDIR=/usr/openwin/lib/X11/xserver +#XBINDIR=/usr/openwin/bin +# +# XPDESTTARFILE may be optionally set as a command line argument to give the +# destination filepath for the tarball, otherwise it will be found in /tmp. +# Note that the tarball is automatically compressed (to .gz, if gzip is +# available, otherwise to .Z); your name for XPDESTTARFILE should reflect this. + +PATH=/usr/bin:/bin:/usr/sbin:/sbin +if [ "`uname -s`" = "SunOS" ] ; then + PATH=/usr/xpg4/bin:/usr/ccs/bin:${PATH} +fi +export PATH + +fatal_error() +{ + echo "${this_script}: ## FATAL ERROR: ${1}" 1>&2 + exit 1 +} + +# Check if mandatory env vars have been set +[ "${XTOP}" = "" ] && fatal_error "XTOP env var not set." +[ "${XPRINTDIR}" = "" ] && fatal_error "XPRINTDIR env var not set." +[ "${XBINDIR}" = "" ] && fatal_error "XBINDIR env var not set." +[ "${XMANPATH}" = "" ] && fatal_error "XMANPATH env var not set." +[ "${XFONTENCPATH}" = "" ] && fatal_error "XFONTENCPATH env var not set." +[ "${XINSTALLXF86ENCODINGFILES}" = "" ] && fatal_error "XINSTALLXF86ENCODINGFILES env var not set." + + +# Do not edit +# REL_* vars are paths relative to '/' +# Thanks to the "wonders" of some /bin/sh I cannot use ... +# REL_XPRINTDIR=${XPRINTDIR#*/} +# REL_XBINDIR=${XBINDIR#*/} +# ... ;-( +REL_XPRINTDIR="`echo ${XPRINTDIR} | sed 's/\///'`" +REL_XBINDIR="`echo ${XBINDIR} | sed 's/\///'`" +REL_XMANPATH="`echo ${XMANPATH} | sed 's/\///'`" +REL_XFONTENCPATH="`echo ${XFONTENCPATH} | sed 's/\///'`" + +XPINSTALL_SESSION="`date +%y%m%d%H%M%S`" +XPINSTALLDIR_BASE=/tmp/xpinstall_${XPINSTALL_SESSION} +XPINSTALLDIR=${XPINSTALLDIR_BASE}/xprint +XPINSTALLDIR_X11=${XPINSTALLDIR}/install +XPLOGFILE=/tmp/xpinstall_${XPINSTALL_SESSION}.log +XPTARFILE=/tmp/xprint_server_${XPINSTALL_SESSION}.tar + +CURR_DIR="`pwd`" + +DO_BUILD=false + +# List of files/dirs which should be put into the tarball +if [ "`uname -s`" = "FreeBSD" ] ; then + REL_XETCDIR="`echo ${XBINDIR} | sed 's/\///' | sed 's/bin/etc/'`" +else + REL_XETCDIR="etc" +fi +BINFILELIST=" \ + xprint/install/${REL_XBINDIR}/Xprt \ + xprint/install/${REL_XBINDIR}/xplsprinters \ + xprint/install/${REL_XBINDIR}/xphelloworld \ + xprint/install/${REL_XBINDIR}/xpxthelloworld \ + xprint/install/${REL_XBINDIR}/xpsimplehelloworld \ + xprint/install/${REL_XETCDIR} \ + xprint/install/${REL_XPRINTDIR} \ + xprint/install/${REL_XPRINTDIR}/C/print/models/PSdefault/fonts/fonts.dir \ + xprint/install/${REL_XPRINTDIR}/C/print/models/PSdefault/fonts/Courier.pmf \ + xprint/install/${REL_XPRINTDIR}/C/print/attributes/document \ + xprint/install/${REL_XPRINTDIR}/en_US/print/attributes/document \ + xprint/install/${REL_XMANPATH} \ + xprint/run_xprint_from_tarball.sh \ + xprint/README" + +# Solaris/CDE1.x || AIX/CDE extra files +if [ "`uname -s`" = "SunOS" -o "`uname -s`" = "AIX" ] ; then + BINFILELIST="${BINFILELIST} \ + xprint/install/usr/dt/config/Xsession.d" +fi + +# Should we install our own copies of the XF86 encoding files ? +if [ ${XINSTALLXF86ENCODINGFILES} -eq 1 ] ; then + BINFILELIST="${BINFILELIST} \ + xprint/install/${REL_XFONTENCPATH}" +fi + +# List of manual page names (suffix is omitted here since it differs +# from platform to platform) +MANPAGELIST=" \ + Xprint. \ + Xprt. \ + xplsprinters. \ + xphelloworld \ + xpxthelloworld. \ + xpawhelloworld. \ + xpxmhelloworld. \ + xpsimplehelloworld." + +step=0 + +umask 022 + +inc_step_counter() +{ + step=`expr ${step} + 1` +} + +has_gzip() +{ + for i in `echo ${PATH} | tr ":" " "` + do + if [ -x "${i}/gzip" ] ; then + return 0 + fi + done + + return 1 +} + +# Step 1: +# Build xc/ tree... +if ${DO_BUILD} ; then + inc_step_counter + echo "## Step ${step}: Building..." + ( + ( + cd ${XTOP} + if make World 2>&1 | tee -a buildlog.log >&${XPLOGFILE} ; then + echo "Build OK." + else + echo "Build failed:" + echo "-- snip --" + tail ${XPLOGFILE} + echo "-- snip --" + exit 1 + fi + ) + ) + echo "## Build completed DONE." +fi # ${DO_BUILD} + +# Step 2: +# Verification... +inc_step_counter +echo "## Step ${step}: Verifying..." +( + status=true + + if [ ! -x ${XTOP}/programs/Xserver/Xprt ] ; then + echo "error: X print server (${XTOP}/programs/Xserver/Xprt) binary missing." + status=false + fi + + if [ ! -x ${XTOP}/programs/xplsprinters/xplsprinters ] ; then + echo "error: ${XTOP}/programs/xplsprinters/xplsprinters binary missing." + status=false + fi + + if [ ! -x ${XTOP}/programs/xphelloworld/xpxthelloworld/xpxthelloworld ] ; then + echo "error: ${XTOP}/programs/xphelloworld/xpxthelloworld/xpxthelloworld binary missing." + status=false + fi + + if [ ! -x ${XTOP}/programs/xphelloworld/xphelloworld/xphelloworld ] ; then + echo "error: ${XTOP}/programs/xphelloworld/xphelloworld/xphelloworld binary missing." + status=false + fi + + if [ ! -x ${XTOP}/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld ] ; then + echo "error: ${XTOP}/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld binary missing." + status=false + fi + + if ${status} ; then + echo "No errors found." + else + fatal_error "Verification failed." + fi +) +[ $? != 0 ] && exit 1; +echo "## Verification DONE." + +# Step 3: +# Install into temp. location +inc_step_counter +echo "## Step ${step}: Install into temporary location..." +( + [ -d ${XPINSTALLDIR} ] && fatal_error "Temp. installation dir ${XPINSTALLDIR} already exists." + mkdir -p ${XPINSTALLDIR} + [ ! -d ${XPINSTALLDIR} ] && fatal_error "Could not create temp. installation dir ${XPINSTALLDIR}." + + mkdir ${XPINSTALLDIR_X11} + [ ! -d ${XPINSTALLDIR_X11} ] && fatal_error "Could not create temp. installation dir ${XPINSTALLDIR_X11}." + + ( + cd ${XTOP} + + # Install binaries, config files etc. + if make install DESTDIR=${XPINSTALLDIR_X11} >>${XPLOGFILE} 2>&1 ; then + echo "Installation (1/3) OK." + else + echo "Installation (1/3) failed:" + echo "-- snip --" + tail ${XPLOGFILE} + echo "-- snip --" + exit 1 + fi + + # Install manual pages... + if make install.man DESTDIR=${XPINSTALLDIR_X11} >>${XPLOGFILE} 2>&1 ; then + echo "Installation (2/3) OK." + else + echo "Installation (2/3) failed:" + echo "-- snip --" + tail ${XPLOGFILE} + echo "-- snip --" + exit 1 + fi + + # Copy tarball startxprint.sh and README_tarball + cp "${CURR_DIR}/README_tarball" "${XPINSTALLDIR}/README" + cp "${CURR_DIR}/startxprint.sh" "${XPINSTALLDIR}/run_xprint_from_tarball.sh" + chmod a+rx "${XPINSTALLDIR}/run_xprint_from_tarball.sh" + echo "Installation (3/3) OK." + + # Search the ${XPINSTALLDIR_X11}/${REL_XMANPATH} dir for manual pages which + # do not occur in the ${MANPAGELIST} list and remove those files + cd ${XPINSTALLDIR_X11}/${REL_XMANPATH} + for i in */*.* ; do + NO_MATCH="true" + + for j in ${MANPAGELIST} ; do + [ "`echo "${i}" | fgrep "${j}"`" != "" ] && NO_MATCH="false" + done + + if ${NO_MATCH} ; then + rm -f "${i}" + fi + done + ) +) +[ $? != 0 ] && exit 1; +echo "## Temp. installation DONE." + +# Step 4: +# Verify installation +inc_step_counter +echo "## Step ${step}: Verifying installation..." +( + # Part 1: Test for missing files + cd ${XPINSTALLDIR_BASE} + status=true + for i in ${BINFILELIST} ; do + if [ ! -r ${i} ] ; then + echo "File ${i} missing." + status=false + fi + done + + # Part 2: Test "PSdefault" printer model + cd ${XPINSTALLDIR_BASE} + x=`cat "xprint/install/${REL_XPRINTDIR}/C/print/models/PSdefault/fonts/fonts.dir" | wc -l` + if [ "$x" -ne 31 ] ; then + echo "PSdefault model fonts.dir misses font entries." + status=false + fi + + if ${status} ; then + echo "No errors found." + else + fatal_error "Verification failed." + fi +) +[ $? != 0 ] && exit 1; +echo "## Verification of installation DONE." + +# Step 5.a: +# Create binary tarball +inc_step_counter +echo "## Step ${step}: Create binary tarball..." +( + cd ${XPINSTALLDIR_BASE} + if has_gzip ; then + tar -cf - ${BINFILELIST} | gzip --best --stdout >${XPTARFILE}.gz + else + tar -cf - ${BINFILELIST} | compress >${XPTARFILE}.Z + fi +) +[ $? != 0 ] && exit 1; +echo "## Binary tarball creation DONE." + +# Step 5.b: +# Copy binary tarball to destination, if required. +if [ "${XPDESTTARFILE}" != "" ] ; then + inc_step_counter + echo "## Step ${step}: Copying binary tarball to destination..." + ( + if has_gzip ; then + mv ${XPTARFILE}.gz ${XPDESTTARFILE} + else + mv ${XPTARFILE}.Z ${XPDESTTARFILE} + fi + ) + echo "## Copying tarball to destination DONE." +fi + +# Step 6: +# Cleaning up +inc_step_counter +echo "## Step ${step}: Cleaning up..." +( + # Be carefull... =:-) + if [ "${XPINSTALLDIR_BASE}" != "/" ] ; then + rm -Rf ${XPINSTALLDIR_BASE} + fi +) +echo "## Cleanup done." + + +# Done. +echo "#### Binary tarball is now available at " +if [ "${XPDESTTARFILE}" != "" ] ; then + ls -l ${XPDESTTARFILE}* +else + ls -l ${XPTARFILE}* +fi +echo "#### All done." + +exit 0 +# EOF. Index: xc/packager/tarball/startxprint.sh =================================================================== RCS file: xc/packager/tarball/startxprint.sh diff -N xc/packager/tarball/startxprint.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/packager/tarball/startxprint.sh 13 Apr 2004 02:45:18 -0000 @@ -0,0 +1,85 @@ +#!/bin/sh +# +# Copyright (c) 2003-2004 by Roland Mainz +# All rights reserved. +# +#ident "@(#)startxprint.sh 0.1 2003/02/08 gisburn" +# +# (Hack-like) wrapper script to use /etc/init.d/xprint directly from a +# tarball without the need to be "root" nor to do any special installation +# steps +# +############################################################################ + +# Force use of a POSIX conformant sh +# (Solaris /sbin/sh is plain Bourne shell) +[ "$1" != "posix_sh_forced" -a -x /usr/dt/bin/dtksh ] && exec /usr/dt/bin/dtksh "$0" posix_sh_forced "$@" +[ "$1" != "posix_sh_forced" -a -x /bin/ksh93 ] && exec /bin/ksh93 "$0" posix_sh_forced "$@" +[ "$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/ksh93 ] && exec /usr/local/bin/ksh93 "$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" + +PATH=/usr/sbin:/usr/bin:/sbin:/bin +export PATH + +fatal_error() +{ + echo "${this_script}: ## FATAL ERROR: ${1}" 1>&2 + exit 1 +} + +relpath2abspath() +{ + ( + dirpart="`dirname "${1}"`" + basepart="`basename "${1}"`" + + echo "`cd "${dirpart}" ; pwd`/${basepart}" + ) + return 0 +} + +##### main +this_script="$(relpath2abspath "${0}")" +unpackdir="$(dirname "${this_script}")/install" +if [ -d ${unpackdir}/usr/X11R6/etc/rc.d ]; then +xinitdir="usr/X11R6/etc/rc.d" +else +xinitdir="etc/init.d" +fi + +## prechecks +[ ! -d "${unpackdir}/usr" ] && fatal_error "${unpackdir}/usr not found" +[ ! -r "${unpackdir}/${xinitdir}/xprint" ] && fatal_error "${unpackdir}/${xinitdir}/xprint not found" + +xprt_path="$(find "${unpackdir}" -name Xprt -print)" +xplsprinters_path="$(find "${unpackdir}" -name xplsprinters -print)" +psdefault_path="$(find "${unpackdir}" -name PSdefault -print)" +xf86encodingsdir_path="$(find "${unpackdir}" -name encodings.dir -print)" + +[ "${psdefault_path}" = "" ] && fatal_error "no PSdefault model found in ${unpackdir}" +[ "${xprt_path}" = "" ] && fatal_error "no Xprt binary found in ${unpackdir}" +[ "${xplsprinters_path}" = "" ] && fatal_error "no xplsprinters binary found in ${unpackdir}" +[ ! -r "${psdefault_path}" ] && fatal_error "PSdefault model \"${psdefault_path}\" found in ${unpackdir} not accessible" +[ ! -x "${xprt_path}" ] && fatal_error "Xprt binary \"${xprt_path}\" found in ${unpackdir} not accessible/executable" + +xpconfig_dir="${psdefault_path%*/C/print/models/PSdefault}" + +# run the "/etc/init.d/xprint start" using the binaries/config files/scripts in the tarball +ETC_INITD_XPRINT_XPRT_PATH="${xprt_path}" +ETC_INITD_XPRINT_XPLSPRINTERS_PATH="${xplsprinters_path}" +ETC_INITD_XPRINT_XPCONFIGDIR="${xpconfig_dir}" +ETC_INITD_XPRINT_XF86ENCODINGSDIR="${xf86encodingsdir_path}" +export ETC_INITD_XPRINT_XPRT_PATH ETC_INITD_XPRINT_XPCONFIGDIR ETC_INITD_XPRINT_XPLSPRINTERS_PATH ETC_INITD_XPRINT_XF86ENCODINGSDIR +/bin/sh "${unpackdir}/${xinitdir}/xprint" "$@" + +# EOF. Index: xc/programs/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/Imakefile,v retrieving revision 1.1.4.2.6.2.2.1 diff -u -r1.1.4.2.6.2.2.1 Imakefile --- xc/programs/Imakefile 10 Apr 2004 09:04:11 -0000 1.1.4.2.6.2.2.1 +++ xc/programs/Imakefile 13 Apr 2004 02:45:18 -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.4.2.2.6.2 diff -u -r1.1.4.4.2.2.6.2 Imakefile --- xc/programs/Xserver/Imakefile 12 Apr 2004 12:20:52 -0000 1.1.4.4.2.2.6.2 +++ xc/programs/Xserver/Imakefile 13 Apr 2004 02:45:19 -0000 @@ -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 +++ xc/programs/Xserver/XpConfig/Imakefile 13 Apr 2004 02:45:19 -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 +++ xc/programs/Xserver/XpConfig/C/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/Imakefile 13 Apr 2004 02:45:20 -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 --- xc/programs/Xserver/XpConfig/C/print/Xprinters 14 Nov 2003 15:54:43 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/Xprinters 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/attributes/Imakefile 13 Apr 2004 02:45:20 -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 --- xc/programs/Xserver/XpConfig/C/print/attributes/document 14 Nov 2003 15:54:43 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/attributes/document 13 Apr 2004 02:45:20 -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 --- xc/programs/Xserver/XpConfig/C/print/attributes/printer 14 Nov 2003 15:54:43 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/attributes/printer 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/ddx-config/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/ddx-config/raster/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/CANONBJ10E-GS/model-config 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/GSdefault/Imakefile 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/GSdefault/model-config 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/Imakefile 13 Apr 2004 02:45:20 -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 --- xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config 14 Nov 2003 15:54:43 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/model-config 13 Apr 2004 02:45:20 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/Imakefile 13 Apr 2004 02:45:25 -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 --- xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias 17 Nov 2003 19:03:43 -0000 1.1.4.1 +++ xc/programs/Xserver/XpConfig/C/print/models/HPDJ1600C/fonts/fonts.alias 13 Apr 2004 02:45:25 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/Imakefile 13 Apr 2004 02:45:25 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/model-config 13 Apr 2004 02:45:25 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4050-PS/fonts/Imakefile 13 Apr 2004 02:45:25 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/Imakefile 13 Apr 2004 02:45:25 -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 --- xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config 14 Nov 2003 15:54:44 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/model-config 13 Apr 2004 02:45:25 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/Imakefile 13 Apr 2004 02:45:32 -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 --- xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias 17 Nov 2003 19:03:43 -0000 1.1.4.1 +++ xc/programs/Xserver/XpConfig/C/print/models/HPLJ4family/fonts/fonts.alias 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/Imakefile 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/model-config 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSdefault/Imakefile 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSdefault/model-config 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSdefault/fonts/Imakefile 13 Apr 2004 02:45:32 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/Imakefile 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/model-config 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/PSspooldir/spooltodir.sh 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/Imakefile 13 Apr 2004 02:45:34 -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 --- xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config 14 Nov 2003 15:54:44 -0000 1.1 +++ xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/model-config 13 Apr 2004 02:45:34 -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/cvsF2s314 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/cvsW4NVxK 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/cvsbI8Buq 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/cvsAafFw4 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/cvsftMa2I 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/cvsM516Sn 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/cvsp5vds5 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/cvswAk2oN 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/cvs7yqiJv 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/cvs4Gfudc 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/cvsb4fxbT 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/cvsGHEDVC 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 +++ xc/programs/Xserver/XpConfig/C/print/models/SPSPARC2/fonts/Imakefile 13 Apr 2004 02:45:34 -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/cvsD5xV5m 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/cvs2JsxG7 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/cvsBpraoQ 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/cvsAQJwwz 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/cvsJmYm7i 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/cvsgNjvv5 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/cvsJp6FlS 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/cvs0jDahD 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/cvsLTJKBo 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/cvssBbPna 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/cvsZvgdYY 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/cvsk8e9XN 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/cvszBWDnD 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/cvsoDS7Oq 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/cvsrMWhEe 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/cvscQmKR2 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/cvsB0xCMT 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/cvsy6PH3K and /dev/null differ 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 +++ xc/programs/Xserver/XpConfig/en_US/Imakefile 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/en_US/print/Imakefile 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/en_US/print/attributes/Imakefile 13 Apr 2004 02:45:34 -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 +++ xc/programs/Xserver/XpConfig/en_US/print/attributes/document 13 Apr 2004 02:45:34 -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.1.6.1 diff -u -r1.1.4.1.6.1 AttrValid.c --- xc/programs/Xserver/Xprint/AttrValid.c 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/AttrValid.c 13 Apr 2004 02:45:35 -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.1.6.1 diff -u -r1.1.4.1.6.1 AttrValid.h --- xc/programs/Xserver/Xprint/AttrValid.h 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/AttrValid.h 13 Apr 2004 02:45:35 -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.1.6.1 diff -u -r1.1.4.1.6.1 DiPrint.h --- xc/programs/Xserver/Xprint/DiPrint.h 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/DiPrint.h 13 Apr 2004 02:45:35 -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.2.6.1 diff -u -r1.1.4.2.6.1 Imakefile --- xc/programs/Xserver/Xprint/Imakefile 4 Mar 2004 17:47:23 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/Imakefile 13 Apr 2004 02:45:35 -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.2.6.1 diff -u -r1.1.4.2.6.1 Init.c --- xc/programs/Xserver/Xprint/Init.c 4 Mar 2004 17:47:23 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/Init.c 13 Apr 2004 02:45:36 -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,11 +274,47 @@ 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; /* + * 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 * of the next option to process. @@ -340,6 +325,7 @@ char **argv, int i) { + extern void ddxUseMsg(); if(strcmp(argv[i], "-XpFile") == 0) { if ((i + 1) >= argc) { @@ -349,8 +335,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 +414,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 +426,7 @@ */ xfree(pCurEntry); } - printerDb = 0; + printerDb = (PrinterDbPtr)NULL; } /* @@ -460,11 +457,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 +470,10 @@ { name[strlen(name) - 1] = (char)'\0'; /* strip the \n */ AddPrinterDbName(name); + num_printers++; } pclose(fp); + return num_printers; } /* @@ -592,7 +592,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 +650,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 +669,7 @@ xfree(filePath); } - if ((dirName = XpGetConfigDir(FALSE)) != 0) + if(dirName = XpGetConfigDir(FALSE)) { filePath = (char *)xalloc(strlen(dirName) + strlen(XPRINTERSFILENAME) + 2); @@ -701,6 +701,7 @@ static PrinterDbPtr BuildPrinterDb(void) { + char *printerList, *augmentCmd = (char *)NULL; Bool defaultAugment = TRUE, freeConfigFileName; if(configFileName && access(configFileName, R_OK) != 0) @@ -727,7 +728,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 +769,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 +988,7 @@ return (char *)NULL; configDir = XpGetConfigDir(TRUE); - if ((fontDir = ValidateFontDir(configDir, modelName)) != 0) + if(fontDir = ValidateFontDir(configDir, modelName)) { xfree(configDir); return fontDir; @@ -1013,8 +1050,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 +1109,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 +1199,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)) { @@ -1254,10 +1291,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 +1450,7 @@ } if(callInit == TRUE) { - pBFunc initFunc; + Bool (*initFunc)(); initFunc = GetInitFunc(pDb->driverName); if(initFunc(index, pScreen, argc, argv) == FALSE) { @@ -1451,9 +1487,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 +1514,7 @@ { if(pDb->screenNum == index) { + XpValidatePoolsRec *pValRec; pVFunc dimensionsFunc; @@ -1506,6 +1544,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 +1637,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 +1686,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 +1736,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 +1769,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.2.6.1 diff -u -r1.1.4.2.6.1 Oid.c --- xc/programs/Xserver/Xprint/Oid.c 4 Mar 2004 17:47:23 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/Oid.c 13 Apr 2004 02:45:37 -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.1.6.1 diff -u -r1.1.4.1.6.1 Oid.h --- xc/programs/Xserver/Xprint/Oid.h 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/Oid.h 13 Apr 2004 02:45:37 -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 --- xc/programs/Xserver/Xprint/OidDefs.h 14 Nov 2003 15:54:45 -0000 1.1 +++ xc/programs/Xserver/Xprint/OidDefs.h 13 Apr 2004 02:45:37 -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.1.6.1 diff -u -r1.1.4.1.6.1 OidStrs.h --- xc/programs/Xserver/Xprint/OidStrs.h 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/OidStrs.h 13 Apr 2004 02:45:37 -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 +++ xc/programs/Xserver/Xprint/Xprint.html 13 Apr 2004 02:45:38 -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 +++ xc/programs/Xserver/Xprint/Xprint.man 13 Apr 2004 02:45:39 -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 +++ xc/programs/Xserver/Xprint/Xprint.sgml 13 Apr 2004 02:45:39 -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.3.4.1 diff -u -r1.1.4.3.4.1 attributes.c --- xc/programs/Xserver/Xprint/attributes.c 4 Mar 2004 17:47:23 -0000 1.1.4.3.4.1 +++ xc/programs/Xserver/Xprint/attributes.c 13 Apr 2004 02:45:40 -0000 @@ -1,4 +1,3 @@ -/* $XdotOrg: xc/programs/Xserver/Xprint/attributes.c,v 1.1.4.3.4.1 2004/03/04 17:47:23 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.1.6.1 diff -u -r1.1.4.1.6.1 attributes.h --- xc/programs/Xserver/Xprint/attributes.h 4 Mar 2004 17:47:23 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/attributes.h 13 Apr 2004 02:45:40 -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.2.6.1 diff -u -r1.1.4.2.6.1 ddxInit.c --- xc/programs/Xserver/Xprint/ddxInit.c 4 Mar 2004 17:47:23 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ddxInit.c 13 Apr 2004 02:45:40 -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) @@ -235,7 +238,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 +276,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.1.6.1 diff -u -r1.1.4.1.6.1 mediaSizes.c --- xc/programs/Xserver/Xprint/mediaSizes.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/mediaSizes.c 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/spooler.c 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/spooler.h 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/etc/Imakefile 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/etc/Xsession.d/Imakefile 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/etc/Xsession.d/cde_xsessiond_xprint.sh 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/etc/init.d/Imakefile 13 Apr 2004 02:45:41 -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 +++ xc/programs/Xserver/Xprint/etc/init.d/xprint 13 Apr 2004 02:45:42 -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 +++ xc/programs/Xserver/Xprint/etc/profile.d/Imakefile 13 Apr 2004 02:45:42 -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 +++ xc/programs/Xserver/Xprint/etc/profile.d/xprint.csh 13 Apr 2004 02:45:42 -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 +++ xc/programs/Xserver/Xprint/etc/profile.d/xprint.sh 13 Apr 2004 02:45:42 -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 +++ xc/programs/Xserver/Xprint/pdf/README 13 Apr 2004 02:45:46 -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.1.6.1 diff -u -r1.1.4.1.6.1 Imakefile --- xc/programs/Xserver/Xprint/ps/Imakefile 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/Imakefile 13 Apr 2004 02:45:46 -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.2.6.1 diff -u -r1.1.4.2.6.1 Ps.h --- xc/programs/Xserver/Xprint/ps/Ps.h 4 Mar 2004 17:47:24 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ps/Ps.h 13 Apr 2004 02:45:47 -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 --- xc/programs/Xserver/Xprint/ps/PsArea.c 17 Nov 2003 19:03:44 -0000 1.1.4.1 +++ xc/programs/Xserver/Xprint/ps/PsArea.c 13 Apr 2004 02:45:47 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsAttVal.c --- xc/programs/Xserver/Xprint/ps/PsAttVal.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsAttVal.c 13 Apr 2004 02:45:47 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsAttr.c --- xc/programs/Xserver/Xprint/ps/PsAttr.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsAttr.c 13 Apr 2004 02:45:47 -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 --- xc/programs/Xserver/Xprint/ps/PsCache.c 17 Nov 2003 19:03:44 -0000 1.1.4.1 +++ xc/programs/Xserver/Xprint/ps/PsCache.c 13 Apr 2004 02:45:47 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsColor.c --- xc/programs/Xserver/Xprint/ps/PsColor.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsColor.c 13 Apr 2004 02:45:47 -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 +++ xc/programs/Xserver/Xprint/ps/PsFTFonts.c 13 Apr 2004 02:45:47 -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.2.6.1 diff -u -r1.1.4.2.6.1 PsGC.c --- xc/programs/Xserver/Xprint/ps/PsGC.c 4 Mar 2004 17:47:24 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ps/PsGC.c 13 Apr 2004 02:45:48 -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.2.6.1 diff -u -r1.1.4.2.6.1 PsInit.c --- xc/programs/Xserver/Xprint/ps/PsInit.c 4 Mar 2004 17:47:24 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ps/PsInit.c 13 Apr 2004 02:45:48 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsLine.c --- xc/programs/Xserver/Xprint/ps/PsLine.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsLine.c 13 Apr 2004 02:45:48 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsMisc.c --- xc/programs/Xserver/Xprint/ps/PsMisc.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsMisc.c 13 Apr 2004 02:45:48 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsPixel.c --- xc/programs/Xserver/Xprint/ps/PsPixel.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsPixel.c 13 Apr 2004 02:45:48 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsPixmap.c --- xc/programs/Xserver/Xprint/ps/PsPixmap.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsPixmap.c 13 Apr 2004 02:45:48 -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.1.6.1 diff -u -r1.1.4.1.6.1 PsPolygon.c --- xc/programs/Xserver/Xprint/ps/PsPolygon.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/PsPolygon.c 13 Apr 2004 02:45:48 -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.2.6.1 diff -u -r1.1.4.2.6.1 PsText.c --- xc/programs/Xserver/Xprint/ps/PsText.c 4 Mar 2004 17:47:24 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ps/PsText.c 13 Apr 2004 02:45:49 -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.2.6.1 diff -u -r1.1.4.2.6.1 PsWindow.c --- xc/programs/Xserver/Xprint/ps/PsWindow.c 4 Mar 2004 17:47:24 -0000 1.1.4.2.6.1 +++ xc/programs/Xserver/Xprint/ps/PsWindow.c 13 Apr 2004 02:45:49 -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.1.6.1 diff -u -r1.1.4.1.6.1 psout.c --- xc/programs/Xserver/Xprint/ps/psout.c 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/psout.c 13 Apr 2004 02:45:50 -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.1.6.1 diff -u -r1.1.4.1.6.1 psout.h --- xc/programs/Xserver/Xprint/ps/psout.h 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/ps/psout.h 13 Apr 2004 02:45:50 -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 +++ xc/programs/Xserver/Xprint/ps/psout_ft.c 13 Apr 2004 02:45:50 -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 +++ xc/programs/Xserver/Xprint/ps/psout_ftpstype1.c 13 Apr 2004 02:45:50 -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 +++ xc/programs/Xserver/Xprint/ps/psout_ftpstype3.c 13 Apr 2004 02:45:51 -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.1.6.1 diff -u -r1.1.4.1.6.1 Imakefile --- xc/programs/Xserver/Xprint/raster/Imakefile 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/raster/Imakefile 13 Apr 2004 02:45:51 -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.1.6.1 diff -u -r1.1.4.1.6.1 Raster.h --- xc/programs/Xserver/Xprint/raster/Raster.h 4 Mar 2004 17:47:24 -0000 1.1.4.1.6.1 +++ xc/programs/Xserver/Xprint/raster/Raster.h 13 Apr 2004 02:45:51 -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 +++ xc/programs/Xserver/Xprint/svg/README 13 Apr 2004 02:45:52 -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 +++ xc/programs/Xserver/Xprint/windows/README 13 Apr 2004 02:45:52 -0000 @@ -0,0 +1 @@ +Tracking bug for this work is http://xprint.mozdev.org/bugs/show_bug.cgi?id=3530 Index: xc/programs/xlogo/Imakefile =================================================================== RCS file: /cvs/xorg/xc/programs/xlogo/Imakefile,v retrieving revision 1.1.4.2.6.1 diff -u -r1.1.4.2.6.1 Imakefile --- xc/programs/xlogo/Imakefile 4 Mar 2004 17:49:14 -0000 1.1.4.2.6.1 +++ xc/programs/xlogo/Imakefile 13 Apr 2004 02:45:55 -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 +++ xc/programs/xphelloworld/Imakefile 13 Apr 2004 02:45:55 -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.c =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.c diff -N xc/programs/xphelloworld/xphelloworld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xphelloworld/xphelloworld.c 13 Apr 2004 02:45:55 -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.html =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.html diff -N xc/programs/xphelloworld/xphelloworld.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xphelloworld/xphelloworld.html 13 Apr 2004 02:45:55 -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.man =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.man diff -N xc/programs/xphelloworld/xphelloworld.man --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xphelloworld/xphelloworld.man 13 Apr 2004 02:45:55 -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.sgml =================================================================== RCS file: xc/programs/xphelloworld/xphelloworld.sgml diff -N xc/programs/xphelloworld/xphelloworld.sgml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ xc/programs/xphelloworld/xphelloworld.sgml 13 Apr 2004 02:45:55 -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/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 +++ xc/programs/xphelloworld/xpawhelloworld/Imakefile 13 Apr 2004 02:45:55 -0000 @@ -0,0 +1,3 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/07/26 20:54:53 gisburn Exp $ + +XCOMM nothing here yet 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 +++ xc/programs/xphelloworld/xpsimplehelloworld/Imakefile 13 Apr 2004 02:45:55 -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 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.c 13 Apr 2004 02:45:56 -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 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.html 13 Apr 2004 02:45:56 -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 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.man 13 Apr 2004 02:45:56 -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 +++ xc/programs/xphelloworld/xpsimplehelloworld/xpsimplehelloworld.sgml 13 Apr 2004 02:45:56 -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 +++ xc/programs/xphelloworld/xpxmhelloworld/Imakefile 13 Apr 2004 02:45:56 -0000 @@ -0,0 +1,19 @@ +XCOMM $Xorg: Imakefile,v 1.1 2003/05/12 19:54:53 gisburn Exp $ + +LOCAL_LIBRARIES = $(XLIB) -lXm -lXt -lXp -lXprintUtil +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 +++ xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.c 13 Apr 2004 02:45:56 -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 +++ xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.html 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.man 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxmhelloworld/xpxmhelloworld.sgml 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxthelloworld/Imakefile 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.c 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.html 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.man 13 Apr 2004 02:45:57 -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 +++ xc/programs/xphelloworld/xpxthelloworld/xpxthelloworld.sgml 13 Apr 2004 02:45:57 -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 +++ xc/programs/xplsprinters/Imakefile 13 Apr 2004 02:45:57 -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 +++ xc/programs/xplsprinters/xplsprinters.c 13 Apr 2004 02:45:57 -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 +++ xc/programs/xplsprinters/xplsprinters.html 13 Apr 2004 02:45:57 -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 +++ xc/programs/xplsprinters/xplsprinters.man 13 Apr 2004 02:45:57 -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 +++ xc/programs/xplsprinters/xplsprinters.sgml 13 Apr 2004 02:45:57 -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/) + + + + + +