Esempio n. 1
0
static Bool
EnumDatabase(XrmDatabase *db, XrmBindingList bindings, XrmQuarkList quarks,
	     XrmRepresentation *type, XrmValue *value, XPointer closure)
{
    char *res = XrmQuarkToString(quarks[1]);

    if (res) {
	option = module_options->option;
	while (option->name) {
	    if (strcasecmp(option->name, res) == 0)
		return (False);
	    ++option;
	}
	CheckMsg(CHECKER_OPTION_UNUSED,
		 "WARNING %s.%s is not used\n",
		 XrmQuarkToString(quarks[0]), res);
	++error_level;
    }

    return (False);
}
Esempio n. 2
0
void
CheckChipsets(xf86cfgModuleOptions *opts, int *err)
{
    int i, j, ichk, ivnd = 0, vendor = -1, device;
    const pciDeviceInfo **pDev;
    SymTabPtr chips = opts->chipsets;
    chipset_check *check = NULL;
    int num_check = 0;

    if (!chips) {
	CheckMsg(CHECKER_NO_CHIPSETS, "WARNING No chipsets specified.\n");
	++*err;
	return;
    }

    while (chips->name) {
	device = chips->token & 0xffff;
	vendor = (chips->token & 0xffff0000) >> 16;
	if (vendor == 0)
	    vendor = opts->vendor;

	for (ichk = 0; ichk < num_check; ichk++)
	    if (check[ichk].vendor == vendor)
		break;
	if (ichk >= num_check) {
	    check = (chipset_check*)
		XtRealloc((XtPointer)check,
			  sizeof(chipset_check) * (num_check + 1));
	    check[num_check].vendor = vendor;
	    memset(&check[num_check], 0, sizeof(chipset_check));
	    ++num_check;
	}

	/* Search for vendor in xf86PCIVendorInfo */
	if (xf86PCIVendorInfo) {
	    for (ivnd = 0; xf86PCIVendorInfo[ivnd].VendorID; ivnd++)
		if (vendor == xf86PCIVendorInfo[ivnd].VendorID)
		    break;
	}
	if (xf86PCIVendorInfo && xf86PCIVendorInfo[ivnd].VendorID) {
	    check[ichk].valid_vendor = 1;
	    check[ichk].ivendor = ivnd;
	}
	else {
	    CheckMsg(CHECKER_CANNOT_VERIFY_CHIPSET,
		     "WARNING Cannot verify chipset \"%s\" (0x%x)\n",
		      chips->name, device);
	    ++*err;
	    ++chips;
	    continue;
	}

	if (xf86PCIVendorInfo &&
	    (pDev = xf86PCIVendorInfo[ivnd].Device) != NULL) {
	    if (check[ichk].chipsets == NULL) {
		for (j = 0; pDev[j]; j++)
		    ;
		check[ichk].chipsets = (char*)XtCalloc(1, j);
	    }
	    for (j = 0; pDev[j]; j++) {
		if (device == pDev[j]->DeviceID) {
		    if (strcmp(chips->name, pDev[j]->DeviceName)) {
			CheckMsg(CHECKER_NOMATCH_CHIPSET_STRINGS,
			     "WARNING chipset strings don't match: \"%s\" \"%s\" (0x%x)\n",
			     chips->name, xf86PCIVendorInfo[ivnd].Device[j]->DeviceName,
			     device);
			++*err;
		    }
		    break;
		}
	    }
	    if (!pDev[j]) {
		CheckMsg(CHECKER_CHIPSET_NOT_LISTED,
		     "WARNING chipset \"%s\" (0x%x) not in list.\n", chips->name, device);
		++*err;
	    }
	    else
		check[ichk].chipsets[j] = 1;
	}
	++chips;
    }

    for (i = 0; i < num_check; i++) {
	if (!check[i].valid_vendor) {
	    CheckMsg(CHECKER_CHIPSET_NO_VENDOR,
		     "WARNING No such vendor 0x%x\n", vendor);
	    ++*err;
	}
	for (j = 0; j < check[i].num_chipsets; j++) {
	    if (xf86PCIVendorInfo && !check[i].chipsets[j]) {
		CheckMsg(CHECKER_CHIPSET_NOT_SUPPORTED,
			 "NOTICE chipset \"%s\" (0x%x) not listed as supported.\n",
			 xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceName,
			 xf86PCIVendorInfo[check[i].ivendor].Device[j]->DeviceID);
	    }
	}
	XtFree(check[i].chipsets);
    }

    XtFree((XtPointer)check);
}
Esempio n. 3
0
int NS_main(int argc, NS_tchar **argv)
{

  if (argc < 3) {
    fprintf(stderr, \
            "\n" \
            "Application Update Service Test Helper\n" \
            "\n" \
            "Usage: WORKINGDIR INFILE OUTFILE -s SECONDS [FILETOLOCK]\n"  \
            "   or: WORKINGDIR LOGFILE [ARG2 ARG3...]\n" \
            "   or: signature-check filepath\n" \
            "   or: setup-symlink dir1 dir2 file symlink\n" \
            "   or: remove-symlink dir1 dir2 file symlink\n" \
            "   or: check-symlink symlink\n" \
            "\n" \
            "  WORKINGDIR  \tThe relative path to the working directory to use.\n" \
            "  INFILE      \tThe relative path from the working directory for the file to\n" \
            "              \tread actions to perform such as finish.\n" \
            "  OUTFILE     \tThe relative path from the working directory for the file to\n" \
            "              \twrite status information.\n" \
            "  SECONDS     \tThe number of seconds to sleep.\n" \
            "  FILETOLOCK  \tThe relative path from the working directory to an existing\n" \
            "              \tfile to open exlusively.\n" \
            "              \tOnly available on Windows platforms and silently ignored on\n" \
            "              \tother platforms.\n" \
            "  LOGFILE     \tThe relative path from the working directory to log the\n" \
            "              \tcommand line arguments.\n" \
            "  ARG2 ARG3...\tArguments to write to the LOGFILE after the preceding command\n" \
            "              \tline arguments.\n" \
            "\n" \
            "Note: All paths must be relative.\n" \
            "\n");
    return 1;
  }

  if (!NS_tstrcmp(argv[1], NS_T("check-signature"))) {
#ifdef XP_WIN
    if (ERROR_SUCCESS == VerifyCertificateTrustForFile(argv[2])) {
      return 0;
    } else {
      return 1;
    }
#else 
    // Not implemented on non-Windows platforms
    return 1;
#endif
  }

  if (!NS_tstrcmp(argv[1], NS_T("setup-symlink"))) {
#ifdef XP_UNIX
    NS_tchar path[MAXPATHLEN];
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s"), NS_T("/tmp"), argv[2]);
    mkdir(path, 0755);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s/%s"), NS_T("/tmp"), argv[2], argv[3]);
    mkdir(path, 0755);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s/%s/%s"), NS_T("/tmp"), argv[2], argv[3], argv[4]);
    FILE * file = NS_tfopen(path, NS_T("w"));
    if (file) {
      NS_tfputs(NS_T("test"), file);
      fclose(file);
    }
    symlink(path, argv[5]);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s"), NS_T("/tmp"), argv[2]);
    if (argc > 6 && !NS_tstrcmp(argv[6], NS_T("change-perm"))) {
      chmod(path, 0644);
    }
    return 0;
#else
    // Not implemented on non-Unix platforms
    return 1;
#endif
  }

  if (!NS_tstrcmp(argv[1], NS_T("remove-symlink"))) {
#ifdef XP_UNIX
    NS_tchar path[MAXPATHLEN];
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s"), NS_T("/tmp"), argv[2]);
    chmod(path, 0755);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s/%s/%s"), NS_T("/tmp"), argv[2], argv[3], argv[4]);
    unlink(path);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s/%s"), NS_T("/tmp"), argv[2], argv[3]);
    rmdir(path);
    NS_tsnprintf(path, sizeof(path)/sizeof(path[0]),
                 NS_T("%s/%s"), NS_T("/tmp"), argv[2]);
    rmdir(path);
    return 0;
#else
    // Not implemented on non-Unix platforms
    return 1;
#endif
  }

  if (!NS_tstrcmp(argv[1], NS_T("check-symlink"))) {
#ifdef XP_UNIX
    struct stat ss;
    lstat(argv[2], &ss);
    return S_ISLNK(ss.st_mode) ? 0 : 1;
#else
    // Not implemented on non-Unix platforms
    return 1;
#endif
  }

  if (!NS_tstrcmp(argv[1], NS_T("wait-for-service-stop"))) {
#ifdef XP_WIN
    const int maxWaitSeconds = NS_ttoi(argv[3]);
    LPCWSTR serviceName = argv[2];
    DWORD serviceState = WaitForServiceStop(serviceName, maxWaitSeconds);
    if (SERVICE_STOPPED == serviceState) {
      return 0;
    } else {
      return serviceState;
    }
#else 
    // Not implemented on non-Windows platforms
    return 1;
#endif
  }

  if (!NS_tstrcmp(argv[1], NS_T("wait-for-application-exit"))) {
#ifdef XP_WIN
    const int maxWaitSeconds = NS_ttoi(argv[3]);
    LPCWSTR application = argv[2];
    DWORD ret = WaitForProcessExit(application, maxWaitSeconds);
    if (ERROR_SUCCESS == ret) {
      return 0;
    } else if (WAIT_TIMEOUT == ret) {
      return 1;
    } else {
      return 2;
    }
#else 
    // Not implemented on non-Windows platforms
    return 1;
#endif
  }

  int i = 0;

  if (NS_tchdir(argv[1]) != 0) {
    return 1;
  }

  // File in use test helper section
  if (!NS_tstrcmp(argv[4], NS_T("-s"))) {
    NS_tchar *cwd = NS_tgetcwd(nullptr, 0);
    NS_tchar inFilePath[MAXPATHLEN];
    NS_tsnprintf(inFilePath, sizeof(inFilePath)/sizeof(inFilePath[0]),
                 NS_T("%s/%s"), cwd, argv[2]);
    NS_tchar outFilePath[MAXPATHLEN];
    NS_tsnprintf(outFilePath, sizeof(outFilePath)/sizeof(outFilePath[0]),
                 NS_T("%s/%s"), cwd, argv[3]);

    int seconds = NS_ttoi(argv[5]);
#ifdef XP_WIN
    HANDLE hFile = INVALID_HANDLE_VALUE;
    if (argc == 7) {
      hFile = CreateFileW(argv[6],
                          DELETE | GENERIC_WRITE, 0,
                          nullptr, OPEN_EXISTING, 0, nullptr);
      if (hFile == INVALID_HANDLE_VALUE) {
        WriteMsg(outFilePath, "error_locking");
        return 1;
      }
    }

    WriteMsg(outFilePath, "sleeping");
    while (!CheckMsg(inFilePath, "finish\n") && i++ <= seconds)  {
      Sleep(1000);
    }

    if (argc == 7) {
      CloseHandle(hFile);
    }
#else
    WriteMsg(outFilePath, "sleeping");
    while (!CheckMsg(inFilePath, "finish\n") && i++ <= seconds)  {
      sleep(1);
    }
#endif
    WriteMsg(outFilePath, "finished");
    return 0;
  }

  // Command line argument test helper section
  NS_tchar logFilePath[MAXPATHLEN];
  NS_tsnprintf(logFilePath, sizeof(logFilePath)/sizeof(logFilePath[0]),
               NS_T("%s"), argv[2]);

  FILE* logFP = NS_tfopen(logFilePath, NS_T("wb"));
  for (i = 1; i < argc; ++i) {
    fprintf(logFP, LOG_S "\n", argv[i]);
  }

  fclose(logFP);
  logFP = nullptr;

  return 0;
} 
Esempio n. 4
0
//除了一档行情需要调用ctp的login接口外,别的行情不需要进行相关的login/logout工作。
void CProvider::HandleMsgFromClient()
{
	int ret = 0;
	int rcvMsgSize = 0;
	char msgName[64] = {0};
	char *pBuf = m_tcpbuf;

	if(m_clientSock < 0)
		return;

	memset(m_curOpErrReason,0,sizeof(m_curOpErrReason));
	OP &rcvOpe = *m_iterCur;
	
	ret = MsgIDToMsgName(rcvOpe.msgID,msgName,sizeof(msgName));
	if(ATF_FAIL == ret)
		return;
	
	if(RCV == rcvOpe.direction)
	{
		int expectLen = GotMsgSize(rcvOpe.msgID);
		if(ATF_FAIL == expectLen)
			return;
		
		rcvMsgSize = TcpRecvData(m_clientSock, pBuf,expectLen);
		if(rcvMsgSize < 1)
		{
			g_log.error("[QuoteServer]TCP rcv %s error,expect %dB, actual %dB.\n",msgName,rcvOpe.msgSize,rcvMsgSize);
			rcvOpe.result = OPERATE_FAIL;
			sprintf(rcvOpe.errReason,"%s: TCP rcv error, expect %dB, actual %dB.",msgName,rcvOpe.msgSize,rcvMsgSize);
			m_iterCur = m_iterEnd - 2;
		}
		else
		{
			if(ATF_FAIL == CheckMsg(rcvOpe.pMsg, rcvOpe.msgSize, m_tcpbuf, rcvMsgSize))
			{
				rcvOpe.result = OPERATE_FAIL;
				sprintf(rcvOpe.errReason,"%s",m_curOpErrReason);
				m_iterCur = m_iterEnd - 2;
			}
			else
			{
				rcvOpe.result = OPERATE_SUCC;
				g_log.info("[QuoteServer]Receive %s(%dB), right.\n",msgName,rcvMsgSize);
				
				if(IS_DEBUG)
				{
					printf_green("[QuoteServer]Receive %s(%dB), right.\n",msgName,rcvMsgSize);
				}
			}
		}


		m_iterCur++;
		while(m_iterCur != m_iterEnd)
		{
			memset(m_curOpErrReason,0,sizeof(m_curOpErrReason));
			
			OP &sendOpe = *m_iterCur;
			

			MsgIDToMsgName(sendOpe.msgID,msgName,sizeof(msgName));		
			
			if(SEND == sendOpe.direction)
			{
				if(MSGID_S2C_QUOTE_RSP_LOGIN == sendOpe.msgID)
				{
					QuoteRspUserLoginFromATF *pRsp = (QuoteRspUserLoginFromATF *)(sendOpe.pMsg + sizeof(MsgHead));
					FillMsgOnRspLogin(pRsp);
				}
				else if(MSGID_S2C_QUOTE_DISCONNECT == sendOpe.msgID)
				{
					m_connect = DISCONNECTED;
					m_login = NOT_LOGIN;
					m_sessionID++;
				}
				else if(MSGID_S2C_QUOTE_RSP_SUBSCRIBE == sendOpe.msgID)
				{
					RspSubMarketFromATF *pRsp = (RspSubMarketFromATF *)(sendOpe.pMsg + sizeof(MsgHead));
					strcpy(pRsp->specificInstrument.InstrumentID,m_acInstrSubReq);
					printf_blue("InstrumentID:%s,%s\n,",m_acInstrSubReq,pRsp->specificInstrument.InstrumentID);
				}				
				else if(MSGID_S2C_QUOTE_RSP_UNSUBSCRIBE == sendOpe.msgID)
				{
					RspUnsubMarketFromATF *pRsp = (RspUnsubMarketFromATF *)(sendOpe.pMsg + sizeof(MsgHead));
					strcpy(pRsp->specificInstrument.InstrumentID,m_acInstrUnsubReq);
					printf_blue("InstrumentID:%s,%s\n,",m_acInstrUnsubReq,pRsp->specificInstrument.InstrumentID);
				}
								
				ret = TcpSendData(m_clientSock,sendOpe.pMsg,sendOpe.msgSize);
				if(ret != sendOpe.msgSize)	
				{
					g_log.error("[QuoteServer]TCP send error,expect %dB, actual %dB.\n",sendOpe.msgSize,ret);
					sendOpe.result = OPERATE_FAIL;
					sprintf(sendOpe.errReason,"%s: TCP send error",msgName);
					m_iterCur = m_iterEnd - 2;
				}
				else
				{
					sendOpe.result = OPERATE_SUCC;
					g_log.info("[QuoteServer]Send %s(%dB).\n",msgName,ret);

					if(IS_DEBUG)
					{
						printf_green("[QuoteServer]Send %s(%dB)\n",msgName,rcvMsgSize);
					}
				}

				if(MSGID_S2C_QUOTE_RSP_CONN == sendOpe.msgID)
					m_connect = CONNECTED;
				
				if(DISCONNECTED == m_connect)
					CloseFd();
				
				m_iterCur++;
			}
			else if(LOCAL == sendOpe.direction)
			{
				if(IS_DEBUG)
				{
					printf_green("[QuoteServer]handle %s\n",msgName);	
				}
								
				if(MSGID_LOCAL_SLEEP == sendOpe.msgID)
				{
					SleepTime *pMsgBody = (SleepTime *)(sendOpe.pMsg + sizeof(MsgHead));
					sleep(pMsgBody->time);
									
					sendOpe.result = OPERATE_SUCC;
				}
				m_iterCur++;
			}
			else if(RCV == sendOpe.direction)
			{
				return;
			}
			else
			{
				g_log.error("[QuoteServer]op.direction is not defined !\n");
			
				sendOpe.result = OPERATE_FAIL;
			
				sprintf(sendOpe.errReason,"%s: op.direction is not defined.",msgName);
			
				m_iterCur = m_iterEnd - 2;
			}

			if(m_iterCur == m_iterEnd)
			{
				m_iProgress = DONE;
				
				printf_blue("provider %u had finished his job.\n",m_frontID);
				//g_log.info("[quoteServer]task done.\n");
			}
			
		}

	}
	else
		return;
}
Esempio n. 5
0
void Marge (sizebuf_t *dest, int start, int end)
{
	zn_t zn1, zn2, zn3;
	header_t *d;
	source_t *who;
	sizebuf_t tmp, *m1, *m2, *m3;
	byte	buffer[45*MAX_MSGLEN];
	int num;

	memset(&tmp, 0, sizeof(tmp));
	tmp.data = buffer;
	tmp.maxsize = sizeof(buffer);

	SBCpy(dest,&sources->frames[start&UPDATE_MASK].buf);

	// mark place after this message as free
	//MoveFromDemoBuffer(sources, who->frames[world.lastwritten&UPDATE_MASK].buf.bufsize);

	for (who = sources + 1; who - sources < sworld.fromcount; who++)
	{
		m1 = dest;
		m2 = &who->frames[start&UPDATE_MASK].buf;

		memset(&zn1, 0, sizeof(zn1));
		memset(&zn2, 0, sizeof(zn2));

		zn1.fin = !m1->bufsize;
		zn2.fin = !m2->bufsize;

		(byte*)zn1.start = m1->data;
		(byte*)zn1.end = m1->data;
		(byte*)zn2.start = m2->data;
		(byte*)zn2.end = m2->data;

		(byte*)d = tmp.data;

		while(!zn1.fin || !zn2.fin)
		{
			if (!zn1.fin)
				CheckMsg(&zn1, &zn2, &d, NULL,0,0);

			if (!zn2.fin)
				CheckMsg(&zn2, &zn1, &d, NULL,0,0);

			zn1.fin = ((byte*)zn1.end - m1->data) == m1->bufsize;
			zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
		}

		// mark place after this message as free
		MoveFromDemoBuffer(who, start, (byte*)zn2.start - m2->data);

		if (who - sources == 1)
		{
			MoveFromDemoBuffer(sources, start, (byte*)zn1.start - m1->data);
			for (num = start + 1; zn2.start != zn2.end && num < end; num++)
			{
				m3 = &sources->frames[num&UPDATE_MASK].buf;
				memset(&zn3, 0, sizeof(zn3));

				(byte*)zn3.start = m3->data;
				(byte*)zn3.end = m3->data;

				while ((byte*)zn3.end - (byte*)zn3.start < m3->bufsize)
					CheckMsg(&zn3, &zn2, &d, sources, start, num);

			}

			if (!sources->frames[start&UPDATE_MASK].buf.bufsize)
				zn1.start = zn1.end;
		}

		MoveFromDemoBuffer(who, start, (byte*)zn2.start - m2->data);

		for (num = start + 1; zn1.start != zn1.end && num < end; num++)
		{
			m3 = &who->frames[num&UPDATE_MASK].buf;
			memset(&zn3, 0, sizeof(zn3));

			(byte*)zn3.start = m3->data;
			(byte*)zn3.end = m3->data;

			while ((byte*)zn3.end - (byte*)zn3.start < m3->bufsize)
				CheckMsg(&zn3, &zn1, &d, who, start, num);

		}

		if (!m2->bufsize)
			zn2.start = zn2.end;

		// copy what's left
		for (; zn1.start != zn1.end; NextMsg(zn1.start), NextMsg(d))
			Cpy(d,zn1.start);
		for (; zn2.start != zn2.end; NextMsg(zn2.start), NextMsg(d))
			Cpy(d,zn2.start);

		MoveFromDemoBuffer(who, start, m2->bufsize);

		tmp.bufsize = (byte*)d - tmp.data;
		SBCpy(dest, &tmp);
	}

	MoveFromDemoBuffer(sources, start, sources->frames[start&UPDATE_MASK].buf.bufsize);

	IntegrateMsgs(dest);
}
Esempio n. 6
0
void Marge (sizebuf_t *dest, int start, int end)
{
	zn_t zn1, zn2, znd;
	header_t *d, *t;
	source_t *who;
	sizebuf_t tmp, *m1, *m2;
	byte	buffer[45*MAX_MSGLEN];
	int num, n2, n3, num2;

	if (sworld.fromcount == 1)
	{
		SBCpy(dest,&sources->frames[start&UPDATE_MASK].buf);
		MoveFromDemoBuffer(sources, start, sources->frames[start&UPDATE_MASK].buf.bufsize);
		return;
	}

	desync_frames = desync_source = 0;

	//Sys_Printf("%d %d %d\n", start, end, world.messages.bufsize);
	for (; world.lastmarged < end; world.lastmarged++)
	{
		memset(&tmp, 0, sizeof(tmp));
		tmp.data = buffer;
		tmp.maxsize = sizeof(buffer);

		for (who = sources; who - sources < sworld.fromcount; who++)
		{
			//Sys_Printf("marge: %d, %d\n", world.lastmarged, who - sources);
			m1 = &world.messages;
			m2 = &who->frames[world.lastmarged&UPDATE_MASK].buf;
			//Sys_Printf("%d ", m1->bufsize ? ((header_t*)m1->data)->frame : -1);

			memset(&zn1, 0, sizeof(zn1));
			memset(&zn2, 0, sizeof(zn2));

			zn1.fin = true;//!m1->bufsize;
			zn2.fin = !m2->bufsize;

			zn1.start = (header_t *)m1->data;
			zn1.end = (header_t *)(m1->data + m1->bufsize);
			zn2.start = (header_t *)m2->data;
			zn2.end = (header_t *)m2->data;

			d = (header_t *)tmp.data;
			znd.start = (header_t *)tmp.data;
			znd.end = (header_t *)tmp.data;

			while (!zn2.fin)
			{
				for (t = zn1.start; t != zn1.end; NextMsg(t))
					if (Cmp(zn2.end, t))
						break;

				if (t != zn1.end)
				{
					Mrg(zn2.end, t, t, true);
				}
				else
				{
					Cpy(zn1.end, zn2.end);
					NextMsg(zn1.end);
				}
				NextMsg(zn2.end);

				zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
			}

			m1->bufsize = (byte*)zn1.end - (byte*)zn1.start;
			MoveFromDemoBuffer(who, world.lastmarged, m2->bufsize);
#if 0
			//Sys_Printf("petla:%d, %d\n", m1->bufsize, m2->bufsize);
			while(!zn1.fin || !zn2.fin)
			{
				//Sys_Printf("petla:%d, %d, %d\n", m1->bufsize, m2->bufsize,(byte*)znd.end - (byte*)znd.start);
				if (!zn1.fin)
					CheckMsg(&zn1, &zn2, &znd);

				if (!zn2.fin)
					CheckMsg(&zn2, &zn1, &znd);


				zn1.fin = ((byte*)zn1.end - m1->data) == m1->bufsize;
				zn2.fin = ((byte*)zn2.end - m2->data) == m2->bufsize;
			}
			//Sys_Printf("koniec\n");

			if (!m2->bufsize)
				zn2.start = zn2.end;

			//Sys_Printf("copy\n");
			// copy what's left
			for (; zn1.start != zn1.end; NextMsg(zn1.start), NextMsg(znd.end))
				Cpy(znd.end,zn1.start);

			for (; zn2.start != zn2.end; NextMsg(zn2.start), NextMsg(znd.end))
				Cpy(znd.end,zn2.start);

			//Sys_Printf("move\n");

			MoveFromDemoBuffer(who, world.lastmarged, m2->bufsize);

			tmp.bufsize = (byte*)znd.end - (byte*)znd.start;
			//Sys_Printf("copy to world %d\n",tmp.bufsize);

			SBCpy(&world.messages, &tmp);
			//Sys_Printf("%d done %d\n", who - sources, world.messages.bufsize);
#endif

		}
		//Sys_Printf("\n");
	}

	// find where messages for current frame ends
	t = d = (header_t*)world.messages.data;
	num = n2 = world.lastwritten;
	n3 = -1;
	//if (world.messages.bufsize)
	//	Sys_Printf ("%d %d:", world.lastwritten, world.lastmarged);
	while ((byte*)t - (byte*)world.messages.data < world.messages.bufsize)
	{
		//Sys_Printf("%d ", t->frame);
		if (t->frame <= world.lastwritten)
		{
			d = t;
			num = n2;
			num2 = n3;
		}

		if (t->frame > n2)
		{
			n2 = t->frame;
			n3 = t->source;
		}

		NextMsg(t);
	}

	if (world.messages.bufsize)
	{
		//Sys_Printf("\n");
		//if (num > world.lastwritten) {
		//	for (num = 0; num < sworld.fromcount; num++)
		//		if (num2
		//	Sys_Printf("%d\n", num - world.lastwritten);
		if (d->frame <= world.lastwritten)
			NextMsg(d);
	}
	//if (desync_frames > 0)
	//	Sys_Printf("%d %d %d\n", world.lastwritten, desync_frames, desync_source);
#if 0
	if (desync_frames > 1)
	{
		//Sys_Printf("%d %d %d\n", world.lastwritten, desync_frames, desync_source);
		for (num = 0; num < sworld.fromcount; num++)
			if (desync_source & (1 << num))
				sources[num].sync -= 0.0005*desync_frames;
	}
#endif

	dest->bufsize = (byte*)d - (byte*)world.messages.data;
	//Sys_Printf("here:%d, %d\n", dest->bufsize, world.messages.bufsize);
	memcpy(dest->data,world.messages.data, dest->bufsize);
	memmove(world.messages.data, &world.messages.data[dest->bufsize],world.messages.bufsize - dest->bufsize);
	world.messages.bufsize -= dest->bufsize;

	//Sys_Printf("out\n");

	IntegrateMsgs(dest);
	//Sys_Printf("integrated\n");
}
Esempio n. 7
0
Bool
LoaderInitializeOptions(void)
{
    static int first = 1;
    static char *modules = "lib/modules";
    volatile Bool options_ok = False;
    char *ptr, query[256];
    char *ptr2, query2[256];
    char *type;
    XrmValue value;
    XrmQuark names[2];
    XrmQuark classes[2];
    volatile int i;
    static ModuleType module_types[] = {
	GenericModule, FontRendererModule, InputModule, VideoModule, NullModule
    };

    /* The offset in this vector must match loader.h:enum ModuleType values */
    static char *module_strs[] = {
	"Null Module", "Video Module", "Input Module", "Generic Module", "Font Module"
    };

    if (first) {
	checkerLegend = (char**)
	    XtCalloc(1, sizeof(char*) * (CHECKER_LAST_MESSAGE + 1));
	checkerErrors = (int*)
	    XtCalloc(1, sizeof(int) * (CHECKER_LAST_MESSAGE + 1));
	xf86cfgLoaderInit();
	first = 0;

	checkerLegend[CHECKER_OPTIONS_FILE_MISSING] =
	"The Options file, normally /usr/X11R6/lib/X11/Options was not found.\n";
	checkerLegend[CHECKER_OPTION_DESCRIPTION_MISSING] =
	"No description for the module option. The description should be in\n"
	"in the Options file, and using the sintax:\n"
	"Module.Option:	any text describing the option";
	checkerLegend[CHECKER_LOAD_FAILED] =
	"Failed to load the module. Usually the loader will print a complete\n"
	"description for the reason the module was not loaded. Use the -verbose\n"
	"command line option if it is not printing any messages.";
	checkerLegend[CHECKER_RECOGNIZED_AS] =
	"This message means the module code did not follow what was expected\n"
	"by the checker. For video drivers, it did not call xf86AddDriver,\n"
	"a input module did not call xf86AddInputDriver and a font renderer\n"
	"module did not call LoadFont. This message can also be printed if\n"
	"the module is in the incorrect directory.";
	checkerLegend[CHECKER_NO_OPTIONS_AVAILABLE] =
	"The driver does not have an AvailableOptions function, or that\n"
	"function is returning NULL. If the driver is returning NULL, and\n"
	"really does not need any options from "__XCONFIGFILE__", than the message\n"
	"can be ignored.";
	checkerLegend[CHECKER_NO_VENDOR_CHIPSET] =
	"The checker could not fetch the PCI chipset/vendor information from\n"
	"the module. The checker currently wraps xf86PrintChipsets and\n"
	"xf86MatchPciInstances to read the information from the module.";
	checkerLegend[CHECKER_CANNOT_VERIFY_CHIPSET] =
	"The vendor id was not found, so it is not possible to search the list\n"
	"of chipsets.";
	checkerLegend[CHECKER_OPTION_UNUSED] =
	"The option description is defined in the Options file, but the option\n"
	"was name not retrieved when calling the module AvailableOptions.";
	checkerLegend[CHECKER_NOMATCH_CHIPSET_STRINGS] =
	"The string specified in the module does not match the one in\n"
	"common/xf86PciInfo.h";
	checkerLegend[CHECKER_CHIPSET_NOT_LISTED] =
	"This means that common/xf86PciInfo.h does not have an entry for the\n"
	"given vendor and id.";
	checkerLegend[CHECKER_CHIPSET_NOT_SUPPORTED] =
	"The chipset is listed in common/xf86PciInfo.h, but the driver does\n"
	"not support it, or does not list it in the chipsets fetched by the checker.";
	checkerLegend[CHECKER_CHIPSET_NO_VENDOR] =
	"The vendor id specified to xf86MatchPciInstances is not defined in\n"
	"common/xf86PciInfo.h";
	checkerLegend[CHECKER_NO_CHIPSETS] =
	"No chipsets were passed to xf86MatchPciIntances.";
	checkerLegend[CHECKER_FILE_MODULE_NAME_MISMATCH] =
	"The module name string does not match the the modname field of the\n"
	"XF86ModuleVersionInfo structure. This generally is not an error, but\n"
	"to may be a good idea to use the same string to avoid confusion.";
    }

    if (XF86Module_path == NULL) {
	XF86Module_path = malloc(strlen(XFree86Dir) + strlen(modules) + 2);
	sprintf(XF86Module_path, "%s/%s", XFree86Dir, modules);
    }

    if (loaderPath == NULL || strcmp(XF86Module_path, loaderPath))
	loaderPath = strdup(XF86Module_path);
    else
	/* nothing new */
	return (True);

    if (!noverify) {
	options_ok = InitializeOptionsDatabase();
	InitializePciInfo();
    }

    for (i = 0; module_types[i] != NullModule; i++) {
	xf86cfgLoaderInitList(module_types[i]);
	if (!noverify)
	    ErrorF("================= Checking modules of type \"%s\" =================\n",
		   module_strs[module_types[i]]);

	if (loaderList) {
	    for (ploaderList = loaderList; *ploaderList; ploaderList++) {
		signal_caught = 0;
		signal(SIGTRAP, sig_handler);
		signal(SIGBUS, sig_handler);
		signal(SIGSEGV, sig_handler);
		signal(SIGILL, sig_handler);
		signal(SIGFPE, sig_handler);
		if (sigsetjmp(jmp, 1) == 0) {
		    if (!noverify) {
			int ok, nfont_modules;

			nfont_modules = numFontModules;
			error_level = 0;
			ErrorF("CHECK MODULE %s\n", *ploaderList);
			if ((ok = xf86cfgCheckModule()) == 0) {
			    CheckMsg(CHECKER_LOAD_FAILED,
				     "ERROR Failed to load module.\n");
			    error_level += 50;
			}
			else if (module_type != module_types[i]) {
			    CheckMsg(CHECKER_RECOGNIZED_AS,
				     "WARNING %s recognized as a \"%s\"\n", *ploaderList,
				     module_strs[module_type]);
			    ++error_level;
			}
			if (ok) {
			    if (options_ok) {
				if ((module_options == NULL || module_options->option == NULL) &&
				    module_type != GenericModule) {
				    CheckMsg(CHECKER_NO_OPTIONS_AVAILABLE,
					     "WARNING Not a generic module, but no options available.\n");
				    ++error_level;
				}
				else if (module_options && strcmp(module_options->name, *ploaderList) == 0) {
				    ErrorF("  CHECK OPTIONS\n");
				    option = module_options->option;

				    while (option->name) {
					XmuSnprintf(query, sizeof(query), "%s.%s", *ploaderList, option->name);
					for (ptr = query, ptr2 = query2; *ptr; ptr++) {
					    if (*ptr != '_' && *ptr != ' ' && *ptr != '\t')
						*ptr2 = tolower(*ptr);
					}
					*ptr2 = '\0';
					/* all resources are in lowercase */
					if (!XrmGetResource(options_xrm, query2, "Module.Option", &type, &value) ||
					    value.addr == NULL) {
					    CheckMsg(CHECKER_OPTION_DESCRIPTION_MISSING,
						     "WARNING no description for %s\n", query);
					    ++error_level;
					}
					++option;
				    }

				    /* now do a linear search for Options file entries that are not
				     * in the driver.
				     */
				    names[0] = XrmPermStringToQuark(module_options->name);
				    classes[0] = XrmPermStringToQuark("Option");
				    names[1] = classes[1] = NULLQUARK;
				    (void)XrmEnumerateDatabase(options_xrm, (XrmNameList)&names, (XrmClassList)&classes,
							       XrmEnumOneLevel, EnumDatabase, NULL);
				}
			    }
			    else {
				CheckMsg(CHECKER_OPTIONS_FILE_MISSING,
					 "ERROR Options file missing.\n");
				error_level += 10;
			    }

			    if (module_type == VideoModule &&
				(module_options == NULL || module_options->vendor < 0 ||
				 module_options->chipsets == NULL)) {
				CheckMsg(CHECKER_NO_VENDOR_CHIPSET,
				         "WARNING No vendor/chipset information available.\n");
				++error_level;
			    }
			    else if (module_type == VideoModule) {
				if (module_options == NULL) {
				    /* No description for this, if this happen,
				     * something really strange happened. */
				    ErrorF("  ERROR No module_options!?!\n");
				    error_level += 50;
				}
				else {
				    ErrorF("  CHECK CHIPSETS\n");
				    CheckChipsets(module_options, &error_level);
				}
			    }

			    /* font modules check */
			    if (module_type == FontRendererModule) {
				if (strcmp(*ploaderList, font_module->name)) {
				    /* not an error */
				    ErrorF("  NOTICE FontModule->name specification mismatch: \"%s\" \"%s\"\n",
					   *ploaderList, font_module->name);
				}
				if (nfont_modules + 1 != numFontModules) {
				    /* not an error */
				    ErrorF("  NOTICE font module \"%s\" loaded more than one font renderer.\n",
					   *ploaderList);
				}
			    }
			    else if (nfont_modules != numFontModules) {
				ErrorF("  WARNING number of font modules changed from %d to %d.\n",
				       nfont_modules, numFontModules);
				++error_level;
			    }
			}
			ErrorF("  SUMMARY error_level set to %d.\n\n", error_level);
		    }
		    else
			(void)xf86cfgCheckModule();
		}
		signal(SIGTRAP, SIG_DFL);
		signal(SIGBUS, SIG_DFL);
		signal(SIGSEGV, SIG_DFL);
		signal(SIGILL, SIG_DFL);
		signal(SIGFPE, SIG_DFL);
	    }
	    xf86cfgLoaderFreeList();
	}
	else
	    ErrorF("  ERROR Failed to initialize module list.\n");
    }

    if (!noverify) {
	ErrorF("===================================== LEGEND ===============================\n");
	ErrorF("NOTICE lines are just informative.\n");
	ErrorF("WARNING lines add 1 to error_level.\n");
	ErrorF("ERROR lines add 2 or more (based on the severity of the error) to error_level.\n\n");
	for (i = 0; i <= CHECKER_LAST_MESSAGE; i++)
	    if (checkerErrors[i]) {
		ErrorF("%3d\n%s\n\n", i, checkerLegend[i]);
	    }
    }

    return (True);
}
Esempio n. 8
0
UINT32 WiFiService(void)
{
	static uint APScanStartTime;
    uint32 ret = -1;
    int temp;

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //WIFI Scan
    if (GetMsg(MSG_WIFI_SCAN_START))
    {
		if (wl_do_escan())
		{
			SendMsg(MSG_WIFI_SCAN_ERR);
		}
		else
		{
			SendMsg(MSG_WIFI_SCAN);
			APScanStartTime = SysTickCounter;//SysTickCounter unit is 0.5ms
			printf("APScanStartTime:%d\n", APScanStartTime);
		}
    }
	
	if (CheckMsg(MSG_WIFI_SCAN))
	{
		if (GetScanEventOpen())
		{
	        if (SDC_GetSdioEvent(0) == SDC_SUCCESS)
	        { 
	            process_sdio_pending_irqs();
	        }

			/* check the scan process..*/
			temp = rk_scan_work();
			if ((temp > 0) || 
				/* check the scan timeout.*/
				(SysTickCounter > APScanStartTime + AP_SCAN_TIMEOUT))
			{
				printf("scan tout\n");
				ClearMsg(MSG_WIFI_SCAN);
				SendMsg(MSG_WIFI_SCAN_OK);
			}
		}
		else
		{
			ClearMsg(MSG_WIFI_SCAN);
		}
	}
    
    //WIFI Scan end
    ////////////////////////////////////////////////////////////////////////////////////////////////
        
    ////////////////////////////////////////////////////////////////////////////////////////////////
    if (GetMsg(MSG_WIFI_CONNECT))
    {
		int APScanclrTail;

		ClearMsg(MSG_WIFI_APPW_JUMP);
		ClearMsg(MSG_WIFI_SCAN);
		
        ModuleOverlay(MODULE_ID_WIFI_WPA,  MODULE_OVERLAY_DATA | MODULE_OVERLAY_BSS); //goto scan code
        rk_printf_save_ap();
        if (0 != rk_wifi_connect_pro(gSysConfig.WiFiConfig.ssid, 
                                     gSysConfig.WiFiConfig.password, 
                                     strlen(gSysConfig.WiFiConfig.password)))
    	{		
    		SendMsg(MSG_WIFI_CONN_FAILURE);
    	}
        else
        {
            NETIF  *netif;
        	uint32 timeout;
        	IP_ADDR3 * pIp;	
			int i;

			if (GetMsg(MSG_WIFI_NO_ENCODE))
			{
				MSG_SET_WPA_SH();
			}

	        ModuleOverlay(MODULE_ID_WIFI_LWIP, MODULE_OVERLAY_ALL);
            ModuleOverlay(MODULE_ID_WIFI_DHCP, MODULE_OVERLAY_ALL);
			for (i=0; i<3; i++)
			{
	            tcp_pcb_init();
	        	udp_pcb_init();
	        	arp_list_init();
	            netif = netif_add(NULL, NULL, NULL);
	            
	        	eth_tickinit();
	           	
	        	dhcp_start(netif);

			udp_user_use();
	            
	        	dns_init();

	        	timeout = SysTickCounter;
	        	while(1)
	        	{									  
	        		if (netif_is_up())
	        		{
	                    netif->dhcp = NULL;
	                    SendMsg(MSG_WIFI_CONN_SUCCESS);
	        			return TRUE;
	        		}
	                if(SysTickCounter > (timeout + 2000))
	                {
	        			break;
	                }        
	        		/* Ethernet data packet received procession....*/
					//printf("fle-->eth service\n");
	        		eth_service(FALSE);
	        	}  
			}
            SendMsg(MSG_WIFI_CONN_FAILURE);
        }
    }

    if (CheckMsg(MSG_WIFI_TCP_CONNECTING))
    {       
    
        UserIsrDisable();

    		eth_service(0);

        UserIsrEnable(1);
    }

	if(CheckMsg(MSG_QPW_ENABLE)) {
		QpwNumber++;
		if(QpwNumber > 0x780000) {  // 1 min
			QpwNumber = 0;
			upload_connect(C_QPW);
		}
	}
    
	return ret;
}
Esempio n. 9
0
void CAccountTrade::HandleMsgFromClient()
{
	int ret = 0;
	int rcvMsgSize = 0;
	char msgName[64] = {0};
	char *pBuf = m_tcpbuf;

	if(m_clientSock < 0)
		return;

	memset(m_curOpErrReason,0,sizeof(m_curOpErrReason));
	OP &rcvOpe = *m_iterCur;
					
	ret = MsgIDToMsgName(rcvOpe.msgID,msgName,sizeof(msgName));
	if(ATF_FAIL == ret)
		return;
	
	if(RCV == rcvOpe.direction)
	{
		int expectLen = GotMsgSize(rcvOpe.msgID);
		
		rcvMsgSize = TcpRecvData(m_clientSock, pBuf,expectLen);
		if(rcvMsgSize < 1)
		{
			rcvOpe.result = OPERATE_FAIL;			
			sprintf(rcvOpe.errReason,"[ExchgServer]Failed to rcv %s(%d)",msgName,rcvMsgSize);
			g_log.error("[ExchgServer]Recv %s(%d) error.\n",msgName,rcvMsgSize);
			
			m_iterCur = m_iterEnd - 2;
		}
		else
		{
			char *pBuf = m_tcpbuf;
			if(ATF_FAIL == CheckMsg(rcvOpe.pMsg,rcvOpe.msgSize,pBuf,rcvMsgSize))
			{
				rcvOpe.result = OPERATE_FAIL;
				sprintf(rcvOpe.errReason,"%s",m_curOpErrReason);
				g_log.error("[ExchgServer]Recv %s(%d) error.\n",msgName,rcvMsgSize);
				
				m_iterCur = m_iterEnd - 2;
			}
			else
			{
				if(IS_DEBUG)
				{
					printf_red("[ExchgServer]Recv %s(%dB), right.\n",msgName,rcvMsgSize);
				}
								
				g_log.info("[ExchgServer]Recv %s(%d), right.\n",msgName,rcvMsgSize);
							
				rcvOpe.result = OPERATE_SUCC;
			}
		}
		
		m_iterCur++;
		while((m_iterCur != m_iterEnd))
		{
			memset(m_curOpErrReason,0,sizeof(m_curOpErrReason));
			OP &sendOp = *m_iterCur;			
			MsgIDToMsgName(sendOp.msgID,msgName,sizeof(msgName));
			
			if(SEND == sendOp.direction)
			{
				int result = ATF_SUCC;
				
				switch(sendOp.msgID)
				{
				case MSGID_S2C_TRADE_RSP_CONN:
					result = OnFrontConnected(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_RSP_LOGIN:
					result = OnRspUserLogin(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_DISCONNECT:
					result = OnFrontDisconnected(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_OnRtnOrder:
					result = OnRtnOrder(sendOp.pMsg, m_clientSock);
					break;	
					
				case MSGID_S2C_TRADE_OnRtnTrade:
					result = OnRtnTrade(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_OnRspOrderInsert:
					result = OnRspOrderInsert(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_OnErrRtnOrderInsert:
					result = OnErrRtnOrderInsert(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_OnRspOrderAction:
					result = OnRspOrderAction(sendOp.pMsg, m_clientSock);
					break;
					
				case MSGID_S2C_TRADE_OnErrRtnOrderAction:
					result = OnErrRtnOrderAction(sendOp.pMsg, m_clientSock);
					break;
					
				default:
					{
					}
					break;
				}

				if(ATF_FAIL == result)
				{
					sendOp.result = OPERATE_FAIL;
																
					sprintf(sendOp.errReason,"%s",m_curOpErrReason);
																
					m_iterCur = m_iterEnd - 2;
				}
				else
				{
					sendOp.result = OPERATE_SUCC;
				}

				++m_iterCur;

				//all operations are over
				if(m_iterCur == m_iterEnd)
				{
					if(LIMITED == m_tradeMode)
					{
						m_iProgress = DONE;
										
						if(IS_DEBUG)
						{
							//printf_red("[ExchgServer]:task done \n");
							
							printf_blue("client %u had finished his job.\n",m_frontID);
						}
					}
				}
			}
			else
				return;
		}
	}
}