예제 #1
0
void
XpDestroyContext (
    Display    *dpy,
    XPContext  print_context
)
{
    xPrintDestroyContextReq   *req;
    XExtensionVersion       *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return; /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintDestroyContext,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintDestroyContext;
    req->printContext = print_context;

    UnlockDisplay(dpy);
    SyncHandle();

    return;
}
예제 #2
0
파일: XpInput.c 프로젝트: aosm/X11
unsigned long
XpInputSelected (
    Display       *dpy,
    XPContext     print_context,
    unsigned long *all_events_mask
)
{
    xPrintInputSelectedReq     *req;
    xPrintInputSelectedReply   rep;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return (/* No such extension */ 0L );

    LockDisplay (dpy);

    GetReq(PrintInputSelected,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintInputSelected;
    req->printContext = print_context;

    if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return(/* No such extension */ 0L);
    }

    *all_events_mask = rep.allEventsMask;

    UnlockDisplay(dpy);
    SyncHandle();
    return ( rep.eventMask );
}
예제 #3
0
XPContext
XpGetContext (
    Display  *dpy
)
{
    xPrintGetContextReq     *req;
    xPrintGetContextReply   rep;
    XExtensionVersion       *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return ( (XPContext) None ); /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintGetContext,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetContext;

    if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return ( (XPContext) None ); /* No such extension */
    }

    UnlockDisplay(dpy);
    SyncHandle();

    return ( (XPContext) rep.printContext );
}
예제 #4
0
XPContext
XpCreateContext (
    Display  *dpy,
    char     *printer_name
)
{
    xPrintCreateContextReq     *req;
    XExtensionVersion           *ext;
    char                        *locale;
    int                         locale_len;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return ( (XPContext) None ); /* No such extension */

    /*
     * Fetch locale information.  Note: XpGetLocaleNetString has
     * a thread-safe mutex on _Xglobal_lock.
     */
    locale = XpGetLocaleNetString();

    LockDisplay (dpy);

    GetReq(PrintCreateContext,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintCreateContext;

    req->contextID      = XAllocID(dpy);
    req->printerNameLen = strlen(printer_name);

    if ( locale == (char *) NULL )
        req->localeLen = 0;
    else if ( *locale == (char) NULL )
        req->localeLen = 0;
    else {
        locale_len     = strlen( locale );
        req->length   += _XpPadOut(locale_len) >> 2;
        req->localeLen = (unsigned long) locale_len;
    }

    /*
     * Attach variable data
     */
    req->length += _XpPadOut(req->printerNameLen) >> 2;
    Data( dpy, (char *) printer_name, (long) req->printerNameLen );

    if (req->localeLen)
	Data( dpy, (char *) locale, (long) req->localeLen );

    UnlockDisplay(dpy);
    SyncHandle();

    XFree(locale);

    return ( (XPContext) req->contextID );
}
예제 #5
0
Screen *
XpGetScreenOfContext (
    Display    *dpy,
    XPContext  print_context
)
{
    xPrintGetContextScreenReq     *req;
    xPrintGetContextScreenReply   rep;
    XExtensionVersion             *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    int    i;
    Screen *checkScr;
    Screen *screen;
    int    ok;


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return ( (Screen *) NULL ); /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintGetContextScreen,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetContextScreen;

    req->printContext = print_context;

    if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return ( (Screen *) NULL ); /* No such extension */
    }

    /*
     * Pull rootWindow ID and convert to the corresponding
     * Screen rec.
     */
    ok = False;

    for ( i = 0; i < XScreenCount(dpy); i++ ) {
	checkScr = XScreenOfDisplay(dpy, i);
	if ( XRootWindowOfScreen( checkScr ) == (Window) rep.rootWindow  ) {
	    ok = True;
	    break;
	}
    }

    if (!ok)
	checkScr = (Screen *) NULL;

    UnlockDisplay(dpy);
    SyncHandle();

    return ( (Screen *) checkScr );
}
예제 #6
0
char *
XpGetAttributes (
    Display       *dpy,
    XPContext     print_context,
    XPAttributes  type
)
{
    char *buf;

    xPrintGetAttributesReq     *req;
    xPrintGetAttributesReply   rep;
    XExtensionVersion          *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return( (char *) NULL ); /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintGetAttributes,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetAttributes;
    req->printContext = print_context;
    req->type = type;

    if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* No such extension */
    }

    /*
     * Read pool and return to caller.
     */
    buf = Xmalloc( (unsigned) rep.stringLen + 1 );

    if (!buf) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* malloc error */
    }

    _XReadPad (dpy, (char *) buf, (long) rep.stringLen );

    buf[rep.stringLen] = 0;

    UnlockDisplay(dpy);
    SyncHandle();

    return( buf );
}
예제 #7
0
파일: XpJob.c 프로젝트: aosm/X11libs
void
XpCancelJob (
    Display  *dpy,
    Bool     discard
)
{
    xPrintEndJobReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    _XpDiscardJobRec disrec;
    XEvent event;


    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintEndJob,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintEndJob;
    req->cancel = True;

    UnlockDisplay (dpy);
    SyncHandle ();

    if (discard) {
	/*
	 * get context and effectively do a sync of events.
	 */
	disrec.event_base_return = info->codes->first_event;
	disrec.context = XpGetContext(dpy);

	/*
	 * discard job, and also doc and page XPPrintNotify events.
	 */
	while (XCheckIfEvent(dpy, &event, _XpDiscardJob, (XPointer) &disrec))
	{
	    /*EMPTY*/
	}
    }
}
예제 #8
0
void
XpSetAttributes (
    Display           *dpy,
    XPContext         print_context,
    XPAttributes      type,
    char              *pool,
    XPAttrReplacement replacement_rule
)
{
    int     i;

    xPrintSetAttributesReq     *req;
    XExtensionVersion          *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return; /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintSetAttributes,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintSetAttributes;

    req->printContext = print_context;
    req->type = type;
    req->rule = replacement_rule;

    /*
     * Attach variable data and adjust request length.
     */
    req->stringLen = (CARD32) strlen( (char *) pool );
    req->length += _XpPadOut(req->stringLen) >> 2 ;

    Data( dpy, (char *) pool, req->stringLen );      /* n bytes + pad */

    UnlockDisplay(dpy);
    SyncHandle();

    return;
}
예제 #9
0
파일: XpPrinter.c 프로젝트: aosm/X11
void
XpRehashPrinterList (
    Display    *dpy
)
{
    xPrintRehashPrinterListReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
        return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintRehashPrinterList,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintRehashPrinterList;

    UnlockDisplay (dpy);
    SyncHandle ();
}
예제 #10
0
파일: XpPageDim.c 프로젝트: aosm/X11libs
Status
XpGetPageDimensions (
    Display        *dpy,
    XPContext      print_context,
    unsigned short *width,
    unsigned short *height,
    XRectangle     *reproducible_area
)
{
    xPrintGetPageDimensionsReq     *req;
    xPrintGetPageDimensionsReply   rep;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return (/* No such extension */ 0L );

    LockDisplay (dpy);

    GetReq(PrintGetPageDimensions,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetPageDimensions;
    req->printContext = print_context;

    if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return(/* No such extension */ 0L);
    }

    *width = rep.width;
    *height = rep.height;
    reproducible_area-> x = rep.rx;
    reproducible_area-> y = rep.ry;
    reproducible_area-> width = rep.rwidth;
    reproducible_area-> height = rep.rheight;

    UnlockDisplay(dpy);
    SyncHandle();
    return ( 1L );
}
예제 #11
0
void
XpStartPage (
    Display  *dpy,
    Window   window
)
{
    xPrintStartPageReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintStartPage,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintStartPage;
    req->window = window;

    UnlockDisplay (dpy);
    SyncHandle ();
}
예제 #12
0
파일: XpInput.c 프로젝트: aosm/X11
void
XpSelectInput (
    Display       *dpy,
    XPContext     print_context,
    unsigned long event_mask
)
{
    xPrintSelectInputReq   *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension NULL */

    LockDisplay (dpy);

    GetReq(PrintSelectInput,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintSelectInput;
    req->printContext = print_context;
    req->eventMask = event_mask;

    UnlockDisplay (dpy);
    SyncHandle ();
}
예제 #13
0
파일: XpJob.c 프로젝트: aosm/X11libs
void
XpStartJob (
    Display    *dpy,
    XPSaveData save_data
)
{
    xPrintStartJobReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    XPContext    context;


    /****************************************************************
     *
     * PRIOR TO XPSTARTJOB, set the job attribute "job-owner"
     * which will be used by the X-Server when it spools the
     * output.  When XpStartJob completes, the job attribute
     * pool is frozen, disallowing "job-owner" to be modified.
     */
    {
	char            *joa;		/* job owner attribute */
 	char *PwName;
#ifndef WIN32
#ifdef X_NEEDS_PWPARAMS
	_Xgetpwparams pwparams;
#endif
	struct passwd *pw;
	pw = _XGetpwuid(getuid(),pwparams);

	if (pw && (PwName = pw->pw_name)) {
#else
	if ((PwName = getenv("USERNAME"))) {
#endif
	    joa = (char *) Xmalloc( strlen( PwName ) + 20 );
	    sprintf( joa, "*job-owner: %s", PwName );
            context = XpGetContext( dpy );
	    XpSetAttributes( dpy, context, XPJobAttr, joa, XPAttrMerge );

	    Xfree( joa );
	}
    }

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintStartJob,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintStartJob;
    req->saveData = (CARD8) save_data;

    UnlockDisplay (dpy);
    SyncHandle ();
}


void
XpEndJob (
    Display  *dpy
)
{
    xPrintEndJobReq *req;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    if (XpCheckExtInit(dpy, XP_INITIAL_RELEASE) == -1)
	return; /* NoSuchExtension */

    LockDisplay (dpy);

    GetReq(PrintEndJob,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintEndJob;
    req->cancel = False;

    UnlockDisplay (dpy);
    SyncHandle ();
}
예제 #14
0
char *
XpGetOneAttribute (
    Display       *dpy,
    XPContext     print_context,
    XPAttributes  type,
    char          *attribute_name
)
{
    int     buflen = 0;
    char    *buf;

    xPrintGetOneAttributeReq     *req;
    xPrintGetOneAttributeReply   rep;
    XExtensionVersion          *ext;
    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return( (char *) NULL ); /* No such extension */

    LockDisplay (dpy);

    GetReq(PrintGetOneAttribute,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetOneAttribute;
    req->type = type;
    req->printContext = print_context;
    req->nameLen = strlen( attribute_name );

    /*
     * Attach variable data and adjust request length.
     */
    req->length += _XpPadOut(req->nameLen) >> 2 ;
    Data( dpy, (char *) attribute_name, req->nameLen );    /* n bytes + pad */

    if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* No such extension */
    }

    /*
     * Read variable answer.
     */
    buf = Xmalloc( (unsigned) rep.valueLen + 1 );

    if (!buf) {
        UnlockDisplay(dpy);
        SyncHandle();
        return( (char *) NULL ); /* malloc error */
    }

    buf[rep.valueLen] = 0;

    _XReadPad (dpy, (char *) buf, (long) rep.valueLen );
    buf[rep.valueLen] = 0;

    UnlockDisplay(dpy);
    SyncHandle();

    return( buf );
}
예제 #15
0
파일: XpPrinter.c 프로젝트: aosm/X11
XPPrinterList
XpGetPrinterList (
    Display     *dpy,
    char        *printer_name,
    int         *list_count             /* return value */
)
{
    xPrintGetPrinterListReq     *req;
    xPrintGetPrinterListReply   rep;

    int		printer_name_len, locale_len;
    char        *locale;

    /* For decoding the variable portion of Reply */
    long	dataLenVR;
    CARD8	*dataVR;	/* aka STRING8 */

    XPPrinterList ptr_list;

    XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy);

    /* For converting root winID to corresponding ScreenPtr */
    int    i;


    if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1)
        return ( (XPPrinterList) NULL ); /* No such extension */

    /*
     * Fetch locale information. Note: XpGetLocaleNetString has
     * a thread-safe mutex on _Xglobal_lock.
     */
    locale = XpGetLocaleNetString();

    LockDisplay (dpy);

    GetReq(PrintGetPrinterList,req);
    req->reqType = info->codes->major_opcode;
    req->printReqType = X_PrintGetPrinterList;

    /*
     * Compute lengths of variable portions.
     */
    if ( printer_name == (char *) NULL )
	req->printerNameLen = 0;
    else if ( *printer_name == (char) NULL )
	req->printerNameLen = 0;
    else {
	printer_name_len    = strlen( printer_name );
	req->length        += _XpPadOut(printer_name_len) >> 2;
	req->printerNameLen = (unsigned long) printer_name_len;
    }

    if ( locale == (char *) NULL )
	req->localeLen = 0;
    else if ( *locale == (char) NULL )
	req->localeLen = 0;
    else {
	locale_len     = strlen( locale );
	req->length   += _XpPadOut(locale_len) >> 2;
	req->localeLen = (unsigned long) locale_len;
    }

    /*
     * Attach variable data.
     */
    if (req->printerNameLen)
	Data( dpy, (char *) printer_name, (long) req->printerNameLen );

    if (req->localeLen)
	Data( dpy, (char *) locale, (long) req->localeLen );

    if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
        UnlockDisplay(dpy);
        SyncHandle();
        return ( (XPPrinterList) NULL ); /* error */
    }

    XFree(locale);

    *list_count = rep.listCount;

    if (*list_count) {
	ptr_list = (XPPrinterList)
		Xmalloc( (unsigned) (sizeof(XPPrinterRec) * (*list_count + 1)));

	if (!ptr_list) {
            UnlockDisplay(dpy);
            SyncHandle();
            return ( (XPPrinterList) NULL ); /* malloc error */
	}

	/*
	 * NULL last entry so XpFreePrinterList can work without a list_count
	 */
	ptr_list[*list_count].name = (char *) NULL;
	ptr_list[*list_count].desc = (char *) NULL;

	for ( i = 0; i < *list_count; i++ ) {
	    /*
	     * Pull printer length and then name.
	     */
	    _XRead32 (dpy, &dataLenVR, (long) sizeof(CARD32) );

	    if (dataLenVR) {
		dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );

		if (!dataVR) {
		    UnlockDisplay(dpy);
		    SyncHandle();
		    return ( (XPPrinterList) NULL ); /* malloc error */
		}

		_XReadPad (dpy, (char *) dataVR, (long) dataLenVR);
		dataVR[dataLenVR] = 0;
		ptr_list[i].name = (char *) dataVR;
	    }
	    else {
		ptr_list[i].name = (char *) NULL;
	    }

	    /*
	     * Pull localized description length and then description.
	     */
	    _XRead32 (dpy, &dataLenVR, (long) sizeof(CARD32) );

	    if (dataLenVR) {
		dataVR = (CARD8 *) Xmalloc( (unsigned) dataLenVR + 1 );

		if (!dataVR) {
		    UnlockDisplay(dpy);
		    SyncHandle();
		    return ( (XPPrinterList) NULL ); /* malloc error */
		}

		_XReadPad (dpy, (char *) dataVR, (long) dataLenVR);
		dataVR[dataLenVR] = 0;
		ptr_list[i].desc = (char *) dataVR;
	    }
	    else {
		ptr_list[i].desc = (char *) NULL;
	    }
	}
    }
    else {
	ptr_list = (XPPrinterList) NULL;
    }

    UnlockDisplay(dpy);
    SyncHandle();

    return ( ptr_list );
}