示例#1
0
文件: server.c 项目: torque/reki
int Server_listen( Server *server ) {
	struct sockaddr_storage address;
	checkFunction( Server_AddressInfo( server, &address ) );
	server->ipFamily = address.ss_family;

	unsigned int flags = 0;
	if ( address.ss_family == AF_INET6 )
		flags |= IPV6_V6ONLY;

	switch ( server->protocol ) {
		case ServerProtocol_TCP: {
			checkFunction( uv_tcp_bind( server->handle.tcpHandle, (struct sockaddr*)&address, flags ) );
			break;
		}
		case ServerProtocol_UDP: {
			checkFunction( uv_udp_bind( server->handle.udpHandle, (struct sockaddr*)&address, flags ) );
			log_err( "UDP actually isn't supported yet." );
			return 1;
			// break;
		}
		default: {
			log_err( "An unknown server protocol happened." );
			return 1;
		}
	}

	// e = uv_udp_recv_start( server->handle.udpHandle, allocCB, readCB );
	checkFunction( uv_listen( server->handle.stream, 128, Server_newTCPConnection ) );

	char namebuf[INET6_ADDRSTRLEN];
	checkFunction( getnameinfo( (struct sockaddr *)&address, sizeof(address), namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST ) );
	dbg_info( "Listening on [%s]:%d.", namebuf, ntohs(((struct sockaddr_in*)&address)->sin_port) );

	return 0;
}
示例#2
0
void InstructionStack::processLine(std::string const & line)
{
	std::vector<std::string> tokens;

	split(tokens, line, ';');
	if (tokens.size())
	{
		splitWhitespace(tokens, tokens[0]);
		if (tokens.size())
		{
			if (tokens.size() == 1)
			{
				Instruction * ins = new Instruction(tokens[0], m_countLine);
				checkFunction(tokens[0], false, ins);
				m_instructions.emplace_back(ins);
			}
			else if (tokens.size() == 2)
			{
				std::vector<std::string> subTokens;
				checkParam(subTokens, tokens[1], line);
				InstructionArgs * ins = new InstructionArgs(tokens[0], subTokens[2], checkOperandType(subTokens[1]),  m_countLine);
				checkFunction(tokens[0], true, ins);
				m_instructions.emplace_back(ins);
			}
			else if (tokens.size() > 2)
				throw SyntacticErrorExceptionException(line, m_countLine);
		}
	}
	m_countLine++;
}
示例#3
0
文件: server.c 项目: torque/reki
int Server_initWithLoop( Server *server, uv_loop_t *loop ) {
	switch ( server->protocol ) {
		case ServerProtocol_TCP: {
			server->handle.tcpHandle = malloc( sizeof(*server->handle.tcpHandle) );
			if ( !server->handle.tcpHandle ) return 1;

			checkFunction( uv_tcp_init( loop, server->handle.tcpHandle ) );
			break;
		}
		case ServerProtocol_UDP: {
			server->handle.udpHandle = malloc( sizeof(*server->handle.udpHandle) );
			if ( !server->handle.udpHandle ) return 1;

			checkFunction( uv_udp_init( loop, server->handle.udpHandle ) );
			break;
		}
		default: {
			log_err( "An unknown server protocol happened." );
			return 1;
		}
	}

	server->handle.stream->data = server;
	return 0;
}
示例#4
0
void TextField::onTextChanged(QString newText)
{
    if (checkFunction(newText)) {
        icon->setPixmap(QIcon(":/valid-icon").pixmap(20));
    } else {
        icon->setPixmap(QIcon(":/invalid-icon").pixmap(20));
    }
}
示例#5
0
Ref<NodeList> SVGSVGElement::collectIntersectionOrEnclosureList(SVGRect& rect, SVGElement* referenceElement, bool (*checkFunction)(const SVGElement*, SVGRect&))
{
    Vector<Ref<Element>> elements;
    for (auto& element : descendantsOfType<SVGElement>(referenceElement ? *referenceElement : *this)) {
        if (checkFunction(&element, rect))
            elements.append(element);
    }
    return StaticElementList::create(WTFMove(elements));
}
示例#6
0
Ref<NodeList> SVGSVGElement::collectIntersectionOrEnclosureList(const FloatRect& rect, SVGElement* referenceElement, bool (*checkFunction)(const SVGElement*, const FloatRect&))
{
    Vector<Ref<Element>> elements;
    for (auto& element : descendantsOfType<SVGElement>(referenceElement ? *referenceElement : *this)) {
        if (checkFunction(&element, rect))
            elements.append(element);
    }
    return RefPtr<NodeList>(StaticElementList::adopt(elements)).releaseNonNull();
}
示例#7
0
void TextField::setText(QString newText)
{
    editBox->setText(newText);
    onTextChanged(newText);
    if (checkFunction(newText)) {
        icon->hide();
    } else {
        icon->show();
    }
}
示例#8
0
void TextField::onTextModified(QString newText)
{
    if (checkFunction(newText)) {
        icon->hide();
    } else {
        icon->show();
    }

    InfoWidget::currentRecord.setValue(fieldName, newText);
    emit MainWindow::signaller.itemChanged(InfoWidget::currentRecord);
}
示例#9
0
void timerReceiveHandler(void *T)
{
	//askAboutSending();
	m++;

	read();

	if(!checkFunction(checkAnswersBt[stageOfInitializationBt]))
	{
		stageOfInitializationBt++;
	}
	statusSent = 1;
}
示例#10
0
bool InputOutputMaster::convertToPrintable (int cStart, int cEnd, Printable ** ppOutput ) {
    cRead=cStart;
    //for (cRead=cStart;cRead<MAXSIZE;cRead++){
    if (findLastOperator (cStart,cEnd,ppOutput)) return true;
    Expression ** peProduct=new Expression *;
    Expression ** peMultiplyBy=new Expression *;
    bool bFirst=true;
    for (; cRead<cEnd; cRead++) {
        int cAscii=(int) hTest [cRead];
        if (! (cAscii==41) ) {//ignore close brackets
            if (cAscii==40) {
                int cCloseBracket=findClosingBracket(cRead,cEnd);//(
                Printable ** ppBracket=new Printable *;
                if(  ! (convertToPrintable (cRead+1,cCloseBracket,ppBracket) )) return false;//if (hTest[cRead]== '(') deal with brackets
                *peMultiplyBy=static_cast<Expression*> (*ppBracket);
                cRead=cCloseBracket;
            }
            else if (cAscii==91) checkNamedConstant (peMultiplyBy,cEnd);//[
            else if (cAscii>47&&cAscii<58) checkConstant (peMultiplyBy);//0-9
            else if(checkFunction (peMultiplyBy,cEnd)) ;
            else if(cAscii==45) {
                checkMinus (peMultiplyBy,cEnd);   //-
            }
            else if (cAscii==105) {
                checkImaginary (peMultiplyBy);   //i
            }
            else checkVariable(cAscii, peMultiplyBy);
            checkForPostFunctions(peMultiplyBy);
            if (bFirst) {
                *peProduct = *peMultiplyBy;
                bFirst = false;
            } else {
                *peProduct = createOperator(MULTIPLY, *peProduct, *peMultiplyBy);
            }
        }
    }
    *ppOutput = static_cast<Printable*> (*peProduct);
    //delete peProduct;delete peMultiplyBy; //? I get an error with this in, but should it not be there?
    return true;
}
void timerHandlerInitBluetoothReceive(void *T)
{
	char* answer = (char*)read();
	//delay(10000);
	//askAboutSending();

	if(answer != NULL)
	{
		if(checkFunction((unsigned char*)answer, (unsigned char*)initCommandsAnswer.answersBluetooth[stageOfInit]))
		{
			stageOfInit++;
		}
		free(answer);
		answer = NULL;
		if(8 == stageOfInit)
		{
			stageOfInit = 0;
			initStatus = TRUE;
		}
	}
	canSend = TRUE;
	removeInitTimerRx = TRUE;
}
示例#12
0
 forv_Vec(FnSymbol, fn, gFnSymbols) {
   checkFunction(fn);
 }
 void assignFunction ( BCBaseType& base )
 {
     checkFunction ( base );
 }