⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xprint.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 5 页
字号:
        pContext->state |= DOC_COOKED_STARTED;        SendXpNotify(pContext, XPStartDocNotify, (int)FALSE);    }    /* ensure the window's not already being used as a page */    if((pPage = (XpPagePtr)LookupIDByType(c->pWin->drawable.id, RTpage)) !=        (XpPagePtr)NULL)    {        if(pPage->context != (XpContextPtr)NULL)	{	    SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, 			      BadWindow);	    return TRUE;	}    }    else    {        if((pPage = (XpPagePtr)xalloc(sizeof(XpPageRec))) == (XpPagePtr)NULL)	{	    SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, 			      BadAlloc);	    return TRUE;	}        if(AddResource(c->pWin->drawable.id, RTpage, pPage) == FALSE)        {	    xfree(pPage);	    SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, 			      BadAlloc);	    return TRUE;        }    }    pPage->context = pContext;    pContext->pageWin = c->pWin->drawable.id;    pPrintScreen = XpScreens[pContext->screenNum];    if(pContext->funcs.StartPage != (int (*)())NULL)        result = pContext->funcs.StartPage(pContext, pWin);    else    {	SendErrorToClient(client, XpReqCode, X_PrintStartPage, 0, 			  BadImplementation);	return TRUE;    }    pContext->state |= PAGE_STARTED;    (void)MapWindow(pWin, client);    SendXpNotify(pContext, XPStartPageNotify, (int)FALSE);    return TRUE;}static intProcXpStartPage(client)    ClientPtr client;{    REQUEST(xPrintStartPageReq);    XpScreenPtr pPrintScreen;    WindowPtr pWin;    int result = Success;    XpContextPtr pContext;    XpPagePtr pPage;    XpStPagePtr c;    REQUEST_SIZE_MATCH(xPrintStartPageReq);    if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)       == (XpContextPtr)NULL)        return XpErrorBase+XPBadSequence;    if(!(pContext->state & JOB_STARTED))	return XpErrorBase+XPBadSequence;    /* can't have pages in a raw documented */    if(pContext->state & DOC_RAW_STARTED)	return XpErrorBase+XPBadSequence;        if(pContext->state & PAGE_STARTED)	return XpErrorBase+XPBadSequence;    pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,					   SecurityWriteAccess);    if (!pWin || pWin->drawable.pScreen->myNum != pContext->screenNum)	return BadWindow;    if((c = (XpStPagePtr)xalloc(sizeof(XpStPageRec))) == (XpStPagePtr)NULL)	return BadAlloc;    c->pContext = pContext;    c->slept = FALSE;    c->pWin = pWin;    (void)DoStartPage(client, c);    if (client->noClientException != Success)        return client->noClientException;    else        return result;}static intProcXpEndPage(client)    ClientPtr client;{    REQUEST(xPrintEndPageReq);    XpScreenPtr pPrintScreen;    int result = Success;    XpContextPtr pContext;    XpPagePtr page;    WindowPtr pWin;    REQUEST_SIZE_MATCH(xPrintEndPageReq);    if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)       == (XpContextPtr)NULL)        return XpErrorBase+XPBadSequence;    if(!(pContext->state & PAGE_STARTED))	return XpErrorBase+XPBadSequence;    pPrintScreen = XpScreens[pContext->screenNum];    pWin = (WindowPtr )LookupIDByType(pContext->pageWin, RT_WINDOW);    /* Call the ddx's EndPage proc. */    if(pContext->funcs.EndPage != (int (*)())NULL)        result = pContext->funcs.EndPage(pContext, pWin, stuff->cancel);    else	return BadImplementation;    if((page = (XpPagePtr)LookupIDByType(pContext->pageWin, RTpage)) !=       (XpPagePtr)NULL)	page->context = (XpContextPtr)NULL;    pContext->state &= ~PAGE_STARTED;    pContext->pageWin = 0; /* None, NULL??? XXX */    (void)UnmapWindow(pWin, FALSE);    SendXpNotify(pContext, XPEndPageNotify, stuff->cancel);    if (client->noClientException != Success)        return client->noClientException;    else        return result;}/******************************************************************************* * * Document Data Functions: PutDocumentData, GetDocumentData * ******************************************************************************/static intProcXpPutDocumentData(client)    ClientPtr client;{    REQUEST(xPrintPutDocumentDataReq);    XpContextPtr pContext;    DrawablePtr pDraw;    int result = Success;    int len, totalSize;    char *pData, *pDoc_fmt, *pOptions;    REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq);    if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)       == (XpContextPtr)NULL)        return XpErrorBase+XPBadSequence;    if(!(pContext->state & DOC_RAW_STARTED) &&       !(pContext->state & DOC_COOKED_STARTED))        return XpErrorBase+XPBadSequence;    if (stuff->drawable) {	if (pContext->state & DOC_RAW_STARTED)	    return BadDrawable;	pDraw = (DrawablePtr)LookupDrawable(stuff->drawable, client);	if (!pDraw || pDraw->pScreen->myNum != pContext->screenNum)	    return BadDrawable;    } else {	if (pContext->state & DOC_COOKED_STARTED)	    return BadDrawable;	pDraw = NULL;    }    pData = (char *)(&stuff[1]);    totalSize = (stuff->len_data + 3) >> 2;    pDoc_fmt = pData + (totalSize << 2);    totalSize += (stuff->len_fmt + 3) >> 2;    pOptions = pData + (totalSize << 2);    totalSize += (stuff->len_options + 3) >> 2;    if((totalSize + (sz_xPrintPutDocumentDataReq >> 2)) != client->req_len)	 return BadLength;        if(pContext->funcs.PutDocumentData != (int (*)())NULL)    {        result = (*pContext->funcs.PutDocumentData)(pContext, pDraw,					  pData, stuff->len_data,				          pDoc_fmt, stuff->len_fmt,				          pOptions, stuff->len_options,					  client);    }    else	return BadImplementation;    if (client->noClientException != Success)        return client->noClientException;    else        return result;}static intProcXpGetDocumentData(client)    ClientPtr client;{    REQUEST(xPrintGetDocumentDataReq);    xPrintGetDocumentDataReply rep;    XpScreenPtr pPrintScreen;    XpContextPtr pContext;    int result = Success;    REQUEST_SIZE_MATCH(xPrintGetDocumentDataReq);    if((pContext = (XpContextPtr)SecurityLookupIDByType(client,							stuff->printContext, 							RTcontext,							SecurityWriteAccess))       == (XpContextPtr)NULL)    {        client->errorValue = stuff->printContext;        return XpErrorBase+XPBadContext;    }    if(pContext->funcs.GetDocumentData == (int (*)())NULL)	return BadImplementation;    if(!(pContext->state & JOB_GET_DATA) ||        pContext->state & GET_DOC_DATA_STARTED)	return XpErrorBase+XPBadSequence;    if(stuff->maxBufferSize <= 0)    {	client->errorValue = stuff->maxBufferSize;        return BadValue; /* gotta have a positive buffer size */    }    result = (*pContext->funcs.GetDocumentData)(pContext, client, 						stuff->maxBufferSize);    if(result != Success)    {	rep.type = X_Reply;	rep.sequenceNumber = client->sequence;	rep.length = 0;	rep.dataLen = 0;	rep.statusCode = 1;	rep.finishedFlag = TRUE;        if (client->swapped) {            int n;            long l;            swaps(&rep.sequenceNumber, n);            swapl(&rep.statusCode, l); /* XXX Why are these longs??? */            swapl(&rep.finishedFlag, l); /* XXX Why are these longs??? */        }	(void)WriteToClient(client,sz_xPrintGetDocumentDataReply,(char *)&rep);    }    else        pContext->state |= GET_DOC_DATA_STARTED;    if(pContext->clientSlept != (ClientPtr)NULL)    {	ClientSignal(pContext->clientSlept);	ClientWakeup(pContext->clientSlept);	pContext->clientSlept = (ClientPtr)NULL;    }    return result;}/******************************************************************************* * * Attribute requests: GetAttributes, SetAttributes, GetOneAttribute * ******************************************************************************/static int ProcXpGetAttributes(client)    ClientPtr client;{    REQUEST(xPrintGetAttributesReq);    XpContextPtr pContext;    char *attrs;    xPrintGetAttributesReply *pRep;    int totalSize, n;    unsigned long l;    REQUEST_SIZE_MATCH(xPrintGetAttributesReq);    if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)    {	client->errorValue = stuff->type;	return BadValue;    }    if(stuff->type != XPServerAttr)    {        if((pContext = (XpContextPtr)SecurityLookupIDByType(						client,						stuff->printContext,						RTcontext,						SecurityReadAccess))	   == (XpContextPtr)NULL)        {	    client->errorValue = stuff->printContext;            return XpErrorBase+XPBadContext;        }        if(pContext->funcs.GetAttributes == (char *(*)())NULL)	    return BadImplementation;        if((attrs = (*pContext->funcs.GetAttributes)(pContext, stuff->type)) ==            (char *)NULL) 	    return BadAlloc;    }    else    {	if((attrs = XpGetAttributes((XpContextPtr)NULL, XPServerAttr)) ==	   (char *)NULL)	    return BadAlloc;    }    totalSize = sz_xPrintGetAttributesReply + QUADPAD(strlen(attrs));    if((pRep = (xPrintGetAttributesReply *)malloc(totalSize)) ==       (xPrintGetAttributesReply *)NULL)	return BadAlloc;    pRep->type = X_Reply;    pRep->length = (totalSize - sz_xPrintGetAttributesReply) >> 2;    pRep->sequenceNumber = client->sequence;    pRep->stringLen = strlen(attrs);    if (client->swapped) {        swaps(&pRep->sequenceNumber, n);        swapl(&pRep->length, l);        swapl(&pRep->stringLen, l);    }    strncpy((char*)(pRep + 1), attrs, strlen(attrs));    xfree(attrs);    WriteToClient(client, totalSize, (char *)pRep);    xfree(pRep);    return client->noClientException;}static int ProcXpSetAttributes(client)    ClientPtr client;{    REQUEST(xPrintSetAttributesReq);    int result = Success;    XpContextPtr pContext;    char *attr;    REQUEST_AT_LEAST_SIZE(xPrintSetAttributesReq);    if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)    {	client->errorValue = stuff->type;	return BadValue;    }    /*     * Disallow changing of read-only attribute pools     */    if(stuff->type == XPPrinterAttr || stuff->type == XPServerAttr)	return BadMatch;    if((pContext = (XpContextPtr)SecurityLookupIDByType(					client,					stuff->printContext,					RTcontext,					SecurityWriteAccess))       == (XpContextPtr)NULL)    {        client->errorValue = stuff->printContext;        return XpErrorBase+XPBadContext;    }    if(pContext->funcs.SetAttributes == (int (*)())NULL)	return BadImplementation;        /*      * Check for attributes being set after their relevant phase     * has already begun (e.g. Job attributes set after StartJob).     */    if((pContext->state & JOB_STARTED) && stuff->type == XPJobAttr)	return XpErrorBase+XPBadSequence;    if(((pContext->state & DOC_RAW_STARTED) ||        (pContext->state & DOC_COOKED_STARTED)) && stuff->type == XPDocAttr)	return XpErrorBase+XPBadSequence;    if((pContext->state & PAGE_STARTED) && stuff->type == XPPageAttr)	return XpErrorBase+XPBadSequence;    if((attr = (char *)malloc(stuff->stringLen + 1)) == (char *)NULL)	return BadAlloc;    strncpy(attr, (char *)(stuff + 1), stuff->stringLen);    attr[stuff->stringLen] = (char)'\0';    if(stuff->rule == XPAttrReplace)        (*pContext->funcs.SetAttributes)(pContext, stuff->type, attr);    else if(stuff->rule == XPAttrMerge)        (*pContext->funcs.AugmentAttributes)(pContext, stuff->type, attr);    else    {	client->errorValue = stuff->rule;	result = BadValue;    }    xfree(attr);    SendAttributeNotify(pContext, stuff->type);    return result;}static int ProcXpGetOneAttribute(client)    ClientPtr client;{    REQUEST(xPrintGetOneAttributeReq);    XpContextPtr pContext;    char *value, *attrName;    xPrintGetOneAttributeReply *pRep;    int totalSize, n;    unsigned long l;    REQUEST_AT_LEAST_SIZE(xPrintGetOneAttributeReq);    totalSize = ((sz_xPrintGetOneAttributeReq) >> 2) +                ((stuff->nameLen + 3) >> 2);    if(totalSize != client->req_len)	 return BadLength;    if(stuff->type < XPJobAttr || stuff->type > XPServerAttr)    {	client->errorValue = stuff->type;	return BadValue;    }        if((attrName = (char *)malloc(stuff->nameLen + 1)) == (char *)NULL)	return BadAlloc;    strncpy(attrName,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -