예제 #1
0
파일: httpmt.c 프로젝트: Budskii/ulib-win
unsigned __stdcall ClientThread(void *pVoid)
{
	int nRet;
	BYTE buf[1024];
	LPREQUEST lpReq = (LPREQUEST)pVoid;

	//
	// Count this client
	//
	IncrementClientCount();

	//
	// Recv the request data
	//
	if (!RecvRequest(lpReq, buf, sizeof(buf)))
	{
		CloseConnection(lpReq);
		free(lpReq);
		DecrementClientCount();
		return 0;
	}

	//
	// Parse the request info
	//
	nRet = ParseRequest(lpReq, buf);
	if (nRet)
	{
		SendError(lpReq, nRet);
		CloseConnection(lpReq);
		free(lpReq);
		DecrementClientCount();
		return 0;
	}

	//
	// Send the file to the client
	//
	SendFile(lpReq);

	//
	// Clean up
	CloseConnection(lpReq);
	free(pVoid);

	//
	// Subtract this client
	//
	DecrementClientCount();
	return 0;
}
예제 #2
0
파일: lbxdix.c 프로젝트: aosm/X11
int
LbxSendConnSetup(ClientPtr   client,
		 char       *reason)
{
    int		dlength;
    int         i, ndex, lim, wndex;
    CARD32      dataBuf[16];
    xLbxConnSetupPrefix csp;
    NewClientInfoRec nci;
    LbxProxyPtr proxy = LbxProxy(client);

    if (reason) {
	SendConnSetup(client, reason);
	LbxForceOutput(proxy); /* expedient to avoid another state variable */
	return (client->noClientException);
    }

    IncrementClientCount();

    client->requestVector = client->swapped ? SwappedProcVector : ProcVector;
    client->sequence = 0;
    dataBuf[0] = client->clientAsMask;

    csp.success = TRUE;
    csp.majorVersion = connSetupPrefix.majorVersion;
    csp.minorVersion = connSetupPrefix.minorVersion;
    csp.tag = 0;
#ifdef XAPPGROUP
    if (!client->appgroup) {
#endif
    csp.changeType = 1; /* LbxNormalDeltas */
    csp.length = 2 +			/* tag + resource-id-base */
		 screenInfo.numScreens; /* input-mask per screen */
    wndex = 0; ndex = 1; lim = screenInfo.numScreens;
#ifdef XAPPGROUP
    } else {
	csp.changeType = 2; /* LbxAppGroupDeltas */
	csp.length = 7 + /* tag, res-id-base, root, visual, colormap, b&w-pix */
		     1 + screenInfo.numScreens - screenInfo.numVideoScreens;
	XagGetDeltaInfo (client, &dataBuf[1]);
	for (i = 0; i < MAXSCREENS; i++) {
	    if ((CARD32) WindowTable[i]->drawable.id == dataBuf[1]) {
		dataBuf[6] =  WindowTable[i]->eventMask | wOtherEventMasks(WindowTable[i]);
		break;
	    }
	}
	wndex = screenInfo.numVideoScreens;
	ndex = 7;
	lim = screenInfo.numScreens - screenInfo.numVideoScreens;
    }
#endif
    for (i = 0; i < lim; i++, ndex++, wndex++) {
	dataBuf[ndex] = 
	    WindowTable[wndex]->eventMask | wOtherEventMasks(WindowTable[wndex]);
    }
    dlength = (csp.length - 1) << 2;

    if (LbxProxyClient(proxy)->swapped) {
	swaps(&csp.length, i);
    }

    if (client->swapped) {
	LbxWriteSConnSetupPrefix(client, &csp);
	SwapLongs(dataBuf, (1 + screenInfo.numScreens));
	WriteToClient(client, dlength, (pointer) dataBuf);
    } else {
	WriteToClient(client, sizeof(xLbxConnSetupPrefix), (char *) &csp);
	WriteToClient(client, dlength, (pointer) dataBuf);
    }

    LbxForceOutput(proxy); /* expedient to avoid another state variable */
    client->clientState = ClientStateRunning;
    if (ClientStateCallback) {
	if (LbxProxyClient(proxy)->swapped != client->swapped) {
	    swaps(&csp.length, i);
	}
	nci.client = client;
	nci.prefix = (xConnSetupPrefix*) &csp;
	nci.setup = (xConnSetup *) ConnectionInfo;
	CallCallbacks(&ClientStateCallback, (pointer) &nci);
    }

    return client->noClientException;
}