Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
xprintutil.h File Reference
#include <X11/Xlibint.h>
#include <X11/extensions/Print.h>
#include <X11/Intrinsic.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XpuMediumSourceSizeRec
struct  XpuResolutionRec
struct  XpuOrientationRec
struct  XpuPlexRec
struct  XpuColorspaceRec

Defines

#define FUNCPROTO   15
#define XPU_TRACE(EX)   (EX)
#define XPU_TRACE_CHILD(EX)   (EX)
#define XPU_DEBUG_ONLY(EX)
#define XPU_NULLXSTR(s)   (((s)!=NULL)?(s):("<NULL>"))
#define XPUATTRIBUTESUPPORTED_JOB_NAME   (1L<<0)
#define XPUATTRIBUTESUPPORTED_JOB_OWNER   (1L<<1)
#define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE   (1L<<2)
#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)
#define XPUATTRIBUTESUPPORTED_LISTFONTS_MODES   (1L<<10)
#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 )

Typedefs

typedef struct
XpuMediumSourceSizeRec
XpuMediumSourceSizeList
typedef struct XpuResolutionRecXpuResolutionList
typedef struct XpuOrientationRecXpuOrientationList
typedef struct XpuPlexRecXpuPlexList
typedef struct XpuColorspaceRecXpuColorspaceList
typedef long XpuSupportedFlags

Functions

_XFUNCPROTOBEGIN int XpuCheckExtension (Display *pdpy)
Bool XpuXprintServersAvailable (void)
int XpuGetPrinter (const char *printername, Display **pdpyptr, XPContext *pcontextptr)
void XpuClosePrinterDisplay (Display *pdpy, XPContext pcontext)
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)
void XpuWaitForPrintNotify (Display *pdpy, int xp_event_base, int detail)
XPPrinterList XpuGetPrinterList (const char *printer, int *res_list_count)
void XpuFreePrinterList (XPPrinterList list)
int XpuSetDocumentCopies (Display *pdpy, XPContext pcontext, long num_copies)
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)
XpuMediumSourceSizeRecXpuFindMediumSourceSizeBySize (XpuMediumSourceSizeList mlist, int mlist_count, float page_width_mm, float page_height_mm, float tolerance)
XpuMediumSourceSizeRecXpuFindMediumSourceSizeByBounds (XpuMediumSourceSizeList mlist, int mlist_count, float m1, float m2, float m3, float m4, float tolerance)
XpuMediumSourceSizeRecXpuFindMediumSourceSizeByName (XpuMediumSourceSizeList mlist, int mlist_count, const char *tray_name, const char *medium_name)
XpuResolutionList XpuGetResolutionList (Display *pdpy, XPContext pcontext, int *numEntriesPtr)
void XpuFreeResolutionList (XpuResolutionList list)
Bool XpuGetResolution (Display *pdpy, XPContext pcontext, long *x_dpi, long *y_dpi)
Bool XpuSetPageResolution (Display *pdpy, XPContext pcontext, XpuResolutionRec *)
Bool XpuSetDocResolution (Display *pdpy, XPContext pcontext, XpuResolutionRec *)
XpuResolutionRecXpuFindResolutionByName (XpuResolutionList list, int list_count, const char *resolution_name)
XpuOrientationList XpuGetOrientationList (Display *pdpy, XPContext pcontext, int *numEntriesPtr)
void XpuFreeOrientationList (XpuOrientationList list)
XpuOrientationRecXpuFindOrientationByName (XpuOrientationList list, int list_count, const char *orientation)
int XpuSetDocOrientation (Display *pdpy, XPContext pcontext, XpuOrientationRec *rec)
int XpuSetPageOrientation (Display *pdpy, XPContext pcontext, XpuOrientationRec *rec)
XpuPlexList XpuGetPlexList (Display *pdpy, XPContext pcontext, int *numEntriesPtr)
void XpuFreePlexList (XpuPlexList list)
XpuPlexRecXpuFindPlexByName (XpuPlexList list, int list_count, const char *plex)
int XpuSetDocPlex (Display *pdpy, XPContext pcontext, XpuPlexRec *rec)
int XpuSetPagePlex (Display *pdpy, XPContext pcontext, XpuPlexRec *rec)
Bool XpuGetEnableFontDownload (Display *pdpy, XPContext pcontext)
int XpuSetEnableFontDownload (Display *pdpy, XPContext pcontext, Bool enableFontDownload)
XpuColorspaceList XpuGetColorspaceList (Display *pdpy, XPContext pcontext, int *numEntriesPtr)
void XpuFreeColorspaceList (XpuColorspaceList list)
XpuColorspaceRecXpuFindColorspaceByName (XpuColorspaceList list, int list_count, const char *colorspace)
void XpuStartJobToSpooler (Display *pdpy)
voidXpuStartJobToFile (Display *pdpy, XPContext pcontext, const char *filename)
XPGetDocStatus XpuWaitForPrintFileChild (void *handle)
XpuSupportedFlags XpuGetSupportedJobAttributes (Display *pdpy, XPContext pcontext)
XpuSupportedFlags XpuGetSupportedDocAttributes (Display *pdpy, XPContext pcontext)
XpuSupportedFlags XpuGetSupportedPageAttributes (Display *pdpy, XPContext pcontext)
char * XpuResourceEncode (const char *str)
char * XpuResourceDecode (const char *str)
void XpuResourceFreeString (char *s)
const char * XpuXmbToCompoundText (Display *dpy, const char *xmbtext)
void XpuFreeCompundTextString (const char *s)
const char * XpuCompoundTextToXmb (Display *dpy, const char *ct)
void XpuFreeXmbString (const char *s)

Class Documentation

struct XpuMediumSourceSizeRec

Definition at line 83 of file xprintutil.h.

Collaboration diagram for XpuMediumSourceSizeRec:
Class Members
float ma1
float ma2
float ma3
float ma4
int mbool
const char * medium_name
const char * tray_name
struct XpuResolutionRec

Definition at line 98 of file xprintutil.h.

Class Members
const char * name
long x_dpi
long y_dpi
struct XpuOrientationRec

Definition at line 109 of file xprintutil.h.

Class Members
const char * orientation
struct XpuPlexRec

Definition at line 117 of file xprintutil.h.

Class Members
const char * plex
struct XpuColorspaceRec

Definition at line 124 of file xprintutil.h.

Class Members
const char * name
XVisualInfo visualinfo

Define Documentation

#define FUNCPROTO   15

Definition at line 42 of file xprintutil.h.

Definition at line 72 of file xprintutil.h.

#define XPU_NULLXSTR (   s)    (((s)!=NULL)?(s):("<NULL>"))

Definition at line 76 of file xprintutil.h.

#define XPU_TRACE (   EX)    (EX)

Definition at line 70 of file xprintutil.h.

#define XPU_TRACE_CHILD (   EX)    (EX)

Definition at line 71 of file xprintutil.h.

Definition at line 141 of file xprintutil.h.

Definition at line 139 of file xprintutil.h.

Definition at line 143 of file xprintutil.h.

Definition at line 144 of file xprintutil.h.

Definition at line 142 of file xprintutil.h.

Definition at line 140 of file xprintutil.h.

Definition at line 135 of file xprintutil.h.

Definition at line 136 of file xprintutil.h.

Definition at line 146 of file xprintutil.h.

Definition at line 137 of file xprintutil.h.

Definition at line 145 of file xprintutil.h.

#define XpuGetDocAttributes (   pdpy,
  pcontext 
)    XpGetAttributes( (pdpy), (pcontext), XPDocAttr )

Definition at line 250 of file xprintutil.h.

#define XpuGetJobAttributes (   pdpy,
  pcontext 
)    XpGetAttributes( (pdpy), (pcontext), XPJobAttr )

Definition at line 249 of file xprintutil.h.

#define XpuGetPageAttributes (   pdpy,
  pcontext 
)    XpGetAttributes( (pdpy), (pcontext), XPPageAttr )

Definition at line 251 of file xprintutil.h.

#define XpuGetPrinterAttributes (   pdpy,
  pcontext 
)    XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr )

Definition at line 252 of file xprintutil.h.

#define XpuGetServerAttributes (   pdpy,
  pcontext 
)    XpGetAttributes( (pdpy), (pcontext), XPServerAttr )

Definition at line 253 of file xprintutil.h.


Typedef Documentation

typedef struct XpuPlexRec * XpuPlexList

Definition at line 133 of file xprintutil.h.


Function Documentation

_XFUNCPROTOBEGIN int XpuCheckExtension ( Display pdpy)

Definition at line 84 of file xprintutil.c.

{
  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);
}

Here is the caller graph for this function:

int XpuCheckSupported ( Display pdpy,
XPContext  pcontext,
XPAttributes  type,
const char *  attribute_name,
const char *  query 
)

Definition at line 328 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

void XpuClosePrinterDisplay ( Display pdpy,
XPContext  pcontext 
)

Definition at line 285 of file xprintutil.c.

{
  if( pdpy )
  {
    if( pcontext != None )
      XpDestroyContext(pdpy, pcontext);
      
    XCloseDisplay(pdpy);
  }
}

Here is the caller graph for this function:

const char* XpuCompoundTextToXmb ( Display dpy,
const char *  ct 
)

Definition at line 2048 of file xprintutil.c.

{
  XTextProperty   xtp;
  int             xcr;
  char          **xtl = NULL;
  int             xtl_count = 0;
  char           *xmb;
  int             xmb_len = 0;
  int             i;

  if (strlen(ct) == 0)
    return strdup(ct);
    
  xtp.value    = (unsigned char *)ct;
  xtp.nitems   = strlen(ct); 
  xtp.encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
  xtp.format   = 8;
  
  xcr = XmbTextPropertyToTextList(dpy, &xtp, &xtl, &xtl_count);
  
  if (xcr == XNoMemory || xcr == XLocaleNotSupported)
  {
    fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 1.\n");
    return strdup(ct);
  }

  /* Did conversion succeed (some unconvertible characters
   * are not a problem) ? */
  if ( !((xcr == Success) || (xcr > 0)) ||
       (xtl == NULL))
  {
    fprintf(stderr, "XpuCompoundTextToXmb: XmbTextPropertyToTextList failure 2.\n");
    return strdup(ct);
  }
   
  for (i = 0; i < xtl_count; i++)
  {
    xmb_len += strlen(xtl[i]);
  }
  xmb = malloc (xmb_len + 1);
  if (!xmb)
  {
    XFreeStringList(xtl);
    return NULL;
  }
  xmb[0] = '\0'; /* Catch zero-length case */
  for (i = 0; i < xtl_count; i++)
  {
    strcat(xmb, xtl[i]);
  }
  
  XFreeStringList(xtl); 
  
  return xmb;
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuColorspaceRec* XpuFindColorspaceByName ( XpuColorspaceList  list,
int  list_count,
const char *  colorspace 
)

Definition at line 1771 of file xprintutil.c.

{
  int i;
  
  for( i = 0 ; i < list_count ; i++ )
  {
    XpuColorspaceRec *curr = &list[i];
    if (!strcmp(curr->name, name))
      return curr;
  }

  return(NULL);
}

Here is the caller graph for this function:

XpuMediumSourceSizeRec* XpuFindMediumSourceSizeByBounds ( XpuMediumSourceSizeList  mlist,
int  mlist_count,
float  m1,
float  m2,
float  m3,
float  m4,
float  tolerance 
)

Definition at line 1160 of file xprintutil.c.

{
  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 
)

Definition at line 1182 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuMediumSourceSizeRec* XpuFindMediumSourceSizeBySize ( XpuMediumSourceSizeList  mlist,
int  mlist_count,
float  page_width_mm,
float  page_height_mm,
float  tolerance 
)

Definition at line 1138 of file xprintutil.c.

{
  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);
}
XpuOrientationRec* XpuFindOrientationByName ( XpuOrientationList  list,
int  list_count,
const char *  orientation 
)

Definition at line 1483 of file xprintutil.c.

{
  int i;
  
  for( i = 0 ; i < list_count ; i++ )
  {
    XpuOrientationRec *curr = &list[i];
    if (!strcasecmp(curr->orientation, orientation))
      return curr;
  }

  return(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuPlexRec* XpuFindPlexByName ( XpuPlexList  list,
int  list_count,
const char *  plex 
)

Definition at line 1619 of file xprintutil.c.

{
  int i;
  
  for( i = 0 ; i < list_count ; i++ )
  {
    XpuPlexRec *curr = &list[i];
    if (!strcasecmp(curr->plex, plex))
      return curr;
  }

  return(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuResolutionRec* XpuFindResolutionByName ( XpuResolutionList  list,
int  list_count,
const char *  resolution_name 
)

Definition at line 1313 of file xprintutil.c.

{
  int i;
  
  for( i = 0 ; i < list_count ; i++ )
  {
    XpuResolutionRec *curr = &list[i];
    if (!strcasecmp(curr->name, name))
      return curr;
  }

  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1752 of file xprintutil.c.

{
  if( list )
  { 
    XpuColorspaceRec *curr = list;
  
    /* See the warning abouve about using this implementation detail for
     * checking for the list's end... */
    while( curr->name != NULL )
    {
      free((void *)curr->name);
      curr++;
    }  

    free(list);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2043 of file xprintutil.c.

{
  free((void *)s);
}

Definition at line 1059 of file xprintutil.c.

{
  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);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1465 of file xprintutil.c.

{
  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);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1601 of file xprintutil.c.

{
  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);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XpuFreePrinterList ( XPPrinterList  list)

Definition at line 932 of file xprintutil.c.

{
  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);
  }
}

Here is the call graph for this function:

Definition at line 1293 of file xprintutil.c.

{
  if( list )
  { 
    XpuResolutionRec *curr = list;
  
    /* See the warning abouve about using this implementation detail for
     * checking for the list's end... */
    while( curr->name != NULL )
    {
      free((void *)curr->name);
      curr++;
    }  

    free(list);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XpuFreeXmbString ( const char *  s)

Definition at line 2104 of file xprintutil.c.

{
  free((void *)s);
}

Here is the caller graph for this function:

XpuColorspaceList XpuGetColorspaceList ( Display pdpy,
XPContext  pcontext,
int numEntriesPtr 
)

Definition at line 1664 of file xprintutil.c.

{
  XpuColorspaceList list = NULL;
  int               rec_count = 1; /* Allocate one more |XpuColorspaceRec| structure
                                    * as terminator */
  char              namebuf[256];  /* Temporary name buffer for colorspace names */
  int               i;             /* Loop counter */
  int               nvi;           /* Number of visuals */
  Screen           *pscreen;       /* Print screen */
  XVisualInfo       viproto;       /* fill in for getting info */
  XVisualInfo      *vip;           /* retured info */

  pscreen = XpGetScreenOfContext(pdpy, pcontext);

  nvi = 0;
  viproto.screen = XScreenNumberOfScreen(pscreen);
  vip = XGetVisualInfo(pdpy, VisualScreenMask, &viproto, &nvi);
  if (!vip)
  {
    fprintf(stderr, "XpuGetColorspaceList: Internal error: vip == NULL\n");
    return NULL;
  }
  
  for( i = 0 ; i < nvi ; i++ )
  {
    XVisualInfo *vcurr = vip+i;
    char         cbuff[64];
    const char  *class = NULL;

#ifdef USE_MOZILLA_TYPES
    /* Workaround for the current limitation of the gfx/src/xlibrgb code
     * which cannot handle depths > 24bit yet */
    if( vcurr->depth > 24 )
      continue;
#endif /* USE_MOZILLA_TYPES */
 
    rec_count++;
    list = (XpuColorspaceRec *)realloc(list, sizeof(XpuColorspaceRec)*rec_count);
    if( !list )
      return NULL;

    /* ToDO: This needs to be updated for the COLORSPACE X11 extension
     * once it is ready and approved by the XOrg arch board. */
    switch (vcurr->class) {
      case StaticGray:   class = "StaticGray";  break;
      case GrayScale:    class = "GrayScale";   break;
      case StaticColor:  class = "StaticColor"; break;
      case PseudoColor:  class = "PseudoColor"; break;
      case TrueColor:    class = "TrueColor";   break;
      case DirectColor:  class = "DirectColor"; break;
      default: /* Needed for forward compatibility to the COLORSPACE extension */
        sprintf (cbuff, "unknown_class_%x", vcurr->class);
        class = cbuff;
        break;
    }

    if (vcurr->bits_per_rgb == 8)
    {
      sprintf(namebuf, "%s/%dbit", class, vcurr->depth);
    }
    else
    {
      sprintf(namebuf, "%s/%dbit/%dbpg", class, vcurr->depth, vcurr->bits_per_rgb);
    }
    list[rec_count-2].name       = strdup(namebuf);
    list[rec_count-2].visualinfo = *vcurr;
  }  
 
  XFree((char *)vip);

  if( list )
  {
    /* users: DO NOT COUNT ON THIS DETAIL 
     * (this is only to make current impl. of XpuGetResolutionList() easier)
     * We may remove this implementation detail in a later revision of
     * the library! */
    list[rec_count-1].name = NULL;
    rec_count--;
  }
  else
  {
    rec_count = 0;
  }

  *numEntriesPtr = rec_count; 
  return(list);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XpuGetEnableFontDownload ( Display pdpy,
XPContext  pcontext 
)

Definition at line 1785 of file xprintutil.c.

{
  Bool  enableFontDownload;
  char *value;
  
  value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported"); 
  if( !value )
  {
    fprintf(stderr, "XpuGetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n");
    return False;
  }
  
  enableFontDownload = (strstr(value, "xp-list-glyph-fonts") != NULL);
  XFree(value);
  return enableFontDownload;
}

Here is the call graph for this function:

XpuMediumSourceSizeList XpuGetMediumSourceSizeList ( Display pdpy,
XPContext  pcontext,
int numEntriesPtr 
)

Definition at line 969 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuGetOneLongAttribute ( Display pdpy,
XPContext  pcontext,
XPAttributes  type,
const char *  attribute_name,
long result 
)

Definition at line 386 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuOrientationList XpuGetOrientationList ( Display pdpy,
XPContext  pcontext,
int numEntriesPtr 
)

Definition at line 1391 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuPlexList XpuGetPlexList ( Display pdpy,
XPContext  pcontext,
int numEntriesPtr 
)

Definition at line 1527 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuGetPrinter ( const char *  printername,
Display **  pdpyptr,
XPContext *  pcontextptr 
)

Definition at line 222 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XPPrinterList XpuGetPrinterList ( const char *  printer,
int res_list_count 
)

Definition at line 814 of file xprintutil.c.

{
  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);
}      

Here is the call graph for this function:

Bool XpuGetResolution ( Display pdpy,
XPContext  pcontext,
long x_dpi,
long y_dpi 
)

Definition at line 1332 of file xprintutil.c.

{
  long dpi;

  /* 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) == 1 )
  {
    *x_dpi_ptr = dpi;
    *y_dpi_ptr = dpi;
    return True;
  }

  /* Get document resolution */
  if( XpuGetOneLongAttribute(pdpy, pcontext, XPDocAttr, "default-printer-resolution", &dpi) == 1 )
  {
    *x_dpi_ptr = dpi;
    *y_dpi_ptr = dpi;
    return True;
  }

  return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuResolutionList XpuGetResolutionList ( Display pdpy,
XPContext  pcontext,
int numEntriesPtr 
)

Definition at line 1201 of file xprintutil.c.

{
  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;
  char              namebuf[64];

  /* 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);
    
    sprintf(namebuf, "%lddpi", tmp);
    list[rec_count-2].name   = strdup(namebuf);
    list[rec_count-2].x_dpi  = tmp;
    list[rec_count-2].y_dpi  = tmp;

    if( default_resolution != -1 )
    {
      /* Is this the default resolution ? */
      if( (list[rec_count-2].x_dpi == default_resolution) &&
          (list[rec_count-2].y_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 XpuGetResolutionList() easier)
     * We may remove this implementation detail in a later revision of
     * the library! */
    list[rec_count-1].name   = NULL;
    list[rec_count-1].x_dpi  = -1;
    list[rec_count-1].y_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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuSupportedFlags XpuGetSupportedDocAttributes ( Display pdpy,
XPContext  pcontext 
)

Definition at line 1910 of file xprintutil.c.

{
  return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "document-attributes-supported");
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuSupportedFlags XpuGetSupportedJobAttributes ( Display pdpy,
XPContext  pcontext 
)

Definition at line 1905 of file xprintutil.c.

{
  return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "job-attributes-supported");
}

Here is the call graph for this function:

Here is the caller graph for this function:

XpuSupportedFlags XpuGetSupportedPageAttributes ( Display pdpy,
XPContext  pcontext 
)

Definition at line 1915 of file xprintutil.c.

{
  return XpuGetSupportedAttributes(pdpy, pcontext, XPPrinterAttr, "xp-page-attributes-supported");
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* XpuResourceDecode ( const char *  str)
char* XpuResourceEncode ( const char *  str)

Definition at line 1940 of file xprintutil.c.

{
  size_t  slen;
  char   *res;
  char   *d;
  int     i,
          c;

  slen = strlen(s);
  res  = malloc(slen*4+1);
  if (!res)
    return NULL;
  
  d = res;
  i = slen;
  while (i--) {
    c = *s++;
    if (c == '\n') {
      if (i) {
        *d++ = '\\';
        *d++ = 'n';
        *d++ = '\\';
        *d++ = '\n';
      }
      else {
        *d++ = '\\';
        *d++ = 'n';
      }
    } else if (c == '\\') {
        *d++ = '\\';
        *d++ = '\\';
    }
    else if ((c < ' ' && c != '\t') ||
            ((unsigned char)c >= 0x7F && (unsigned char)c < 0xA0)) {
        sprintf(d, "\\%03o", (unsigned char)c);
        d += 4;
    }
    else {
        *d++ = c;
    }
  }

  *d = '\0';
  
  return res;
}

Here is the caller graph for this function:

void XpuResourceFreeString ( char *  s)

Definition at line 1993 of file xprintutil.c.

{
  free(s);
}

Here is the caller graph for this function:

int XpuSetDocMediumSourceSize ( Display pdpy,
XPContext  pcontext,
XpuMediumSourceSizeRec medium_spec 
)

Definition at line 1095 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuSetDocOrientation ( Display pdpy,
XPContext  pcontext,
XpuOrientationRec rec 
)

Definition at line 1507 of file xprintutil.c.

{
  if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 )
    return( 0 );
    
  return XpuSetOrientation(pdpy, pcontext, XPDocAttr, rec);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuSetDocPlex ( Display pdpy,
XPContext  pcontext,
XpuPlexRec rec 
)

Definition at line 1643 of file xprintutil.c.

{
  if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 )
    return( 0 );
    
  return XpuSetContentPlex(pdpy, pcontext, XPDocAttr, rec);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XpuSetDocResolution ( Display pdpy,
XPContext  pcontext,
XpuResolutionRec  
)

Definition at line 1371 of file xprintutil.c.

{
  if( (XpuGetSupportedDocAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 )
    return( 0 );
    
  return XpuSetResolution(pdpy, pcontext, XPDocAttr, rec);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuSetDocumentCopies ( Display pdpy,
XPContext  pcontext,
long  num_copies 
)

Definition at line 953 of file xprintutil.c.

{
  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);
  }  
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuSetEnableFontDownload ( Display pdpy,
XPContext  pcontext,
Bool  enableFontDownload 
)

Definition at line 1802 of file xprintutil.c.

{
  char *value,
       *newvalue;
  
  value = XpGetOneAttribute(pdpy, pcontext, XPPrinterAttr, "xp-listfonts-modes-supported"); 
  if( !value )
  {
    fprintf(stderr, "XpuSetEnableFontDownload: xp-listfonts-modes-supported printer attribute not found.\n");
    return 0; /* failure */
  }
  
  /* Set "xp-list-glyph-fonts" */
  if( enableFontDownload )
  {
    /* Return success if "xp-list-glyph-fonts" is already set */
    if( strstr(value, "xp-list-glyph-fonts") != NULL )
    {
      XFree(value);
      return 1; /* success */
    }

    newvalue = malloc(strlen(value) + 33);
    if( !newvalue )
    {
      XFree(value);
      return 0; /* failure */
    }

    sprintf(newvalue, "%s xp-list-glyph-fonts", value);
    XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", newvalue, XPAttrMerge);

    free(newvalue);
    XFree(value);
    return 1; /* success */
  }
  else
  {
    char *s, /* copy string "source" */
         *d; /* copy string "destination" */
    
    /* Return success if "xp-list-glyph-fonts" not set */
    d = strstr(value, "xp-list-glyph-fonts");
    if( d == NULL )
    {
      XFree(value);
      return 1; /* success */
    }

    /* strip "xp-list-glyph-fonts" from |value| */
    s = d+19/*strlen("xp-list-glyph-fonts")*/;
    while( (*d++ = *s++) != '\0' )
      ;

    XpuSetOneAttribute(pdpy, pcontext, XPDocAttr, "*xp-listfonts-modes", value, XPAttrMerge);

    XFree(value);
    return 1; /* success */
  } 
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpuSetJobTitle ( Display pdpy,
XPContext  pcontext,
const char *  title 
)

Definition at line 366 of file xprintutil.c.

{
  if( XpuGetSupportedJobAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_JOB_NAME )
  {
    char *encoded_title;
    
    encoded_title = XpuResourceEncode(title);
    if (!encoded_title)
      return(0);
    XpuSetOneAttribute(pdpy, pcontext, XPJobAttr, "*job-name", encoded_title, XPAttrMerge);
    XpuResourceFreeString(encoded_title);
    return(1);
  }
  else
  {
    XPU_DEBUG_ONLY(printf("XpuSetJobTitle: XPUATTRIBUTESUPPORTED_JOB_NAME not supported ('%s')\n", XPU_NULLXSTR(title)));
    return(0); 
  }  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XpuSetOneAttribute ( Display pdpy,
XPContext  pcontext,
XPAttributes  type,
const char *  attribute_name,
const char *  value,
XPAttrReplacement  replacement_rule 
)

Definition at line 296 of file xprintutil.c.

{
  /* 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);
  }  
}

Here is the caller graph for this function:

void XpuSetOneLongAttribute ( Display pdpy,
XPContext  pcontext,
XPAttributes  type,
const char *  attribute_name,
long  value,
XPAttrReplacement  replacement_rule 
)

Definition at line 310 of file xprintutil.c.

{
  /* 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);
  }  
}

Here is the caller graph for this function:

int XpuSetPageMediumSourceSize ( Display pdpy,
XPContext  pcontext,
XpuMediumSourceSizeRec medium_spec 
)

Definition at line 1114 of file xprintutil.c.

{
  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);
}

Here is the call graph for this function:

int XpuSetPageOrientation ( Display pdpy,
XPContext  pcontext,
XpuOrientationRec rec 
)

Definition at line 1519 of file xprintutil.c.

{
  if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION) == 0 )
    return( 0 );
    
  return XpuSetOrientation(pdpy, pcontext, XPPageAttr, rec);
}

Here is the call graph for this function:

int XpuSetPagePlex ( Display pdpy,
XPContext  pcontext,
XpuPlexRec rec 
)

Definition at line 1655 of file xprintutil.c.

{
  if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_PLEX) == 0 )
    return( 0 );
    
  return XpuSetContentPlex(pdpy, pcontext, XPPageAttr, rec);
}

Here is the call graph for this function:

Bool XpuSetPageResolution ( Display pdpy,
XPContext  pcontext,
XpuResolutionRec  
)

Definition at line 1383 of file xprintutil.c.

{
  if( (XpuGetSupportedPageAttributes(pdpy, pcontext) & XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION) == 0 )
    return( 0 );
    
  return XpuSetResolution(pdpy, pcontext, XPPageAttr, rec);
}

Here is the call graph for this function:

void* XpuStartJobToFile ( Display pdpy,
XPContext  pcontext,
const char *  filename 
)

Definition at line 77 of file xprintutil_printtofile.c.

{
  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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 72 of file xprintutil_printtofile.c.

{
  XpStartJob(pdpy, XPSpool);
}

Here is the caller graph for this function:

XPGetDocStatus XpuWaitForPrintFileChild ( void handle)

Definition at line 367 of file xprintutil_printtofile.c.

{
  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);
}

Here is the caller graph for this function:

void XpuWaitForPrintNotify ( Display pdpy,
int  xp_event_base,
int  detail 
)

Definition at line 463 of file xprintutil.c.

{
  XEvent                  dummy;
  XpuIsNotifyEventContext matchcontext;

  matchcontext.event_base = xp_event_base;
  matchcontext.detail     = detail;
  XIfEvent(pdpy, &dummy, IsXpNotifyEvent, (XPointer)&matchcontext);
}      

Here is the call graph for this function:

Here is the caller graph for this function:

const char* XpuXmbToCompoundText ( Display dpy,
const char *  xmbtext 
)

Definition at line 1998 of file xprintutil.c.

{
  XTextProperty   xtp;
  int             xcr;
  char           *xtl[2];
  char           *ct;

  if (strlen(xmbtext) == 0)
    return strdup(xmbtext);
  
  memset(&xtp, 0, sizeof(xtp));
  xtl[0] = (char *)xmbtext;
  xtl[1] = NULL;
  
  xcr = XmbTextListToTextProperty(dpy, xtl, 1, XCompoundTextStyle, &xtp);
  
  if (xcr == XNoMemory || xcr == XLocaleNotSupported)
  {
    fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure.\n");
    return strdup(xmbtext);
  }

  /* Did conversion succeed (some unconvertible characters
   * are not a problem) ? */
  if ( !((xcr == Success) || (xcr > 0)) ||
       (xtp.value == NULL))
  {
    fprintf(stderr, "XpuXmbToCompoundText: XmbTextListToTextProperty failure 2.\n");
    return strdup(xmbtext);
  }
  
  ct = malloc(xtp.nitems+1);
  if (!ct)
  {
    XFree(xtp.value);
    return NULL;
  }
  memcpy(ct, xtp.value, xtp.nitems);
  ct[xtp.nitems] = '\0';  

  XFree(xtp.value);
  
  return ct;
}

Here is the call graph for this function:

Definition at line 144 of file xprintutil.c.

{
  const char *s;
  int         c = 0;
  /* BUGs/ToDo:
   * - XpServerList resource needs to be sourced, too...
   *   (see comment for |XpuGetXpServerList|, too)
   * - There should be some validation whether the server entries
   *   are
   *     a) valid (easy :)
   *   and
   *     b) available (hard to implement when XOpenDisplay() should be avoided)
   */
  s = getenv("XPSERVERLIST");
  /* Check if serverlist is non-empty */
  if (s)
  {
    while( *s++ )
    {
      if( !isspace(*s) )
        c++;
    }
  }
  /* a valid server name must at least contain the ':'-seperator
   * and a number (e.g. ":1") */
  return( c >= 2 );
}