Example #1
0
  virtual bool emit( void )
  {
    bool bRet = false;
    xmlParser ctrlParse(control);
    ctrlParse.parse();
    node_vector & xnodes = ctrlParse.nodeList();
    int i;

    // start with 1 to skip xml container
    for(i=1;i<xnodes.size();i++)
    {
      xmlNode & node = xnodes[i];
      bRet = emit( node );      
    }
    return bRet;
  }
Example #2
0
/**
 * Main thread entry function for a data/control channel.
 */
static DWORD WINAPI ctrlClientFunc(LPVOID pVClient) {
	ClientElem_t *pClient = (ClientElem_t *) pVClient;
	int n;
	int argIx[CMD_BUF_LEN/2];
	int argCount = 0;
	pClient->running = 1;

	DBG_PRINT("client running 0x%08X", (int)pClient);

	/* Control channel */
	while (pClient->running && pClient->type == TYPE_CONTROL) {
		n = readLine(pClient->sockfd, pClient->cmdbuf, CMD_BUF_LEN,
				argIx, &argCount, &pClient->running);
		if (n == 0) {
			pClient->running = 0;
		} else if (pClient->running) {
			n = ctrlParse(pClient, argIx, argCount, n);
		}
	}

	/* Request to turn this into a data channel? */
	if (pClient->running && pClient->type == TYPE_DATA) {
		startDataClient(pClient);
		closeDataClient(pClient);
	}

	/* Cleanup */
	closesocket(pClient->sockfd);
	if (pClient->type == TYPE_CONTROL && pClient->portNumerator != -1) {
		if (pClient->serialHdl != INVALID_HANDLE_VALUE) {
			CloseHandle(pClient->serialHdl);
		}
		closeDataChannels(pClient->portNumerator);
	}

	DBG_PRINT("client dead 0x%08X: %s", (int)pClient, pClient->type == TYPE_DATA ? "DATA" : "CTRL");
	CloseHandle(pClient->thread);
	removeElementByAddress(pClient);

	g_liveClients--;
	return 0;
}