Пример #1
0
	void LightCategory::bind( castor::PxBufferBase & p_texture, uint32_t index )const
	{
		uint32_t offset = 0u;
		doCopyComponent( getColour(), index, offset, p_texture );
		doCopyComponent( getIntensity(), getFarPlane(), index, offset, p_texture );
		doBind( p_texture, index, offset );
	}
Пример #2
0
int doResponse(char *recv_buf,int recv_len,char *send_buf,int &send_len)
{
	KS_YKT_Clt ykt_clt;
	int retcode = 0;
	Message recv_msg;
	str2struct(recv_buf,&recv_msg);
	print_recv_msg(&recv_msg);
	if(strcmp(recv_msg.txcode,"10000")==0)  //10000:新增委托关系
	{
		retcode = doBind(ykt_clt,recv_msg);

	}
	else if(strcmp(recv_msg.txcode,"10001")==0) //  10001:撤销委托关系
	{
		retcode = doUnbind(ykt_clt,recv_msg);
	}
	else
	{
		return E_TRANS_NONSUPPORT;
	}
	struct2str(&recv_msg,send_buf);
	send_len=strlen(send_buf);
	print_send_msg(&recv_msg);  
	return 0;
  }
Пример #3
0
int TcpSocket::getSocket() {
	if(_sock == INVALID_SOCKET) {
		if((_sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
			throw NetworkException("socket", errno);
		doBind();
	}
	return _sock;
}
Пример #4
0
void ODBCStatementImpl::bindImpl()
{
	doBind();

	SQLRETURN rc = SQLExecute(_stmt);

	if (SQL_NEED_DATA == rc) putData();
	else checkError(rc, "SQLExecute()");

	_pBinder->synchronize();
}
Пример #5
0
	int main( int argc, const char* argv[] )
	{
		/*Connection parameters variables */
		struct sockaddr_in server;
		struct sockaddr_in dest;
		int socket_fd=0;int client_fd=0;
		socklen_t size;
		pthread_t thread_id;
		thread_args *list_args=NULL;
		list_args=(thread_args*)malloc(sizeof(thread_args));
		
		int yes =1; 

		/*Socket creation*/ 
		socket_fd = createSocket(socket_fd, yes, server, dest);

		/* define connexion parameters : port,host,ect ... */
		server.sin_family = AF_INET;
		server.sin_port = htons(PORT);
		server.sin_addr.s_addr = INADDR_ANY;
		
		/*bind socket c'est à dire associcer la socket à notre adresse local*/
		doBind(socket_fd, server);	

		/* Listen :*/
		listenAConnection(socket_fd);
		
		/* If we have listener*/
		size = sizeof(struct sockaddr_in); 
			
		while((client_fd = accept(socket_fd, (struct sockaddr *)&dest, (socklen_t*)&size))) {
		/*Accept connexion*/ 
			if (client_fd==-1) {
				perror("not accept");
				exit(1);
			}
			/* Send acceptation message */
			list_args->client_fd=client_fd;
			printf("Server got connection from client %s\n", inet_ntoa(dest.sin_addr));
			if( pthread_create( &thread_id , NULL ,  connection_plusieurs , (void*) list_args) < 0)
			{
				perror("could not create thread");
				return 1;
			}
		}	
		
	return 0;
	}
Пример #6
0
    void storeBatch (NodeStore::Batch const& batch)
    {
        // VFALCO TODO Rewrite this to use Beast::db

        DeprecatedScopedLock sl (m_db->getDBLock());

        static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
        static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;");
        static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
            "INSERT OR IGNORE INTO CommittedObjects "
                "(Hash,ObjType,LedgerIndex,Object) VALUES (?, ?, ?, ?);");

        pStB.step();
        pStB.reset();

        BOOST_FOREACH (NodeObject::Ptr const& object, batch)
        {
            doBind (pSt, object);

            pSt.step();
            pSt.reset();
        }
Пример #7
0
void ODBCStatementImpl::compileImpl()
{
	if (!_canCompile) return;

	_stepCalled = false;
	_nextResponse = 0;

	if (_preparations.size())
		PreparationVec().swap(_preparations);

	addPreparation();

	Binder::ParameterBinding bind = session().getFeature("autoBind") ? 
		Binder::PB_IMMEDIATE : Binder::PB_AT_EXEC;

	TypeInfo* pDT = 0;
	try
	{
		Poco::Any dti = session().getProperty("dataTypeInfo");
		pDT = AnyCast<TypeInfo*>(dti);
	}catch (NotSupportedException&) { }

	std::size_t maxFieldSize = AnyCast<std::size_t>(session().getProperty("maxFieldSize"));
	
	_pBinder = new Binder(_stmt, maxFieldSize, bind, pDT);
	
	// This is a hack to conform to some ODBC drivers behavior (e.g. MS SQLServer) with 
	// stored procedure calls: driver refuses to report the number of columns, unless all 
	// parameters for the stored procedure are bound. Since number of columns is essential 
	// information for the internal extraction creation, in order to allow for querying it,
	// these calls must occur before.
	fixupBinding(); doBind(false, true);

	makeInternalExtractors();
	doPrepare();

	 _canCompile = false;
}
Пример #8
0
int doResponse(char *recv_buf,int recv_len,char *send_buf,int &send_len)
{
	int retcode = 0;
	char tradecode[8] = "";
	char  trtype[3]="";
	INFO_BIND info_bind;
	INFO_TRADE info_trade;

	memset(&info_bind,0,sizeof info_bind);
	memset(&info_trade,0,sizeof info_trade);
	
    	memcpy(tradecode,recv_buf,TRADECODE_LEN);    
            
    	KS_YKT_Clt ykt_clt;
	char msghead[1024]="";
	char msgbody[1024]="";
	ykt_clt.ResetHandler();

	 if(strncmp(tradecode,TRADE_BIND,TRADECODE_LEN) == 0)                       // 签约
 	{
 		retcode= GetXmlValue(trtype, 3, "TrType", recv_buf);
		if(retcode)
		{
			writelog(LOG_INFO,"get TrType err,errcode[%d]",retcode);
			return retcode;
		}
	
		switch(atoi(trtype))
		{
			case 1:								// 签约
				retcode = doBind(ykt_clt,info_bind,recv_buf);
				break;
			case 2:								// 修改
				retcode = doUpbing(ykt_clt,info_bind,recv_buf);
				break;
			case 3:								// 撤约
				retcode = doUnbind(ykt_clt,info_bind,recv_buf);
				break;
			case 4:								// 查询
				retcode = doCkbing(ykt_clt,info_bind,recv_buf);
				break;
			default:
				return E_TRANS_NONSUPPORT;
		}
		if(retcode)
		{
			if(retcode<0)
				retcode = 1111;
		}
		GenResMsgHead(msghead,NULL,retcode,info_bind.ReMark);			// 生成msghead
		GenBindResMsgBody(msgbody,info_bind);
		GenTransResMSG(send_buf,"2140",msghead,msgbody);
		send_len = strlen(send_buf);
 	}
	 else
 	{
 		if(strncmp(tradecode,TRADE_PAY_NOCARD,TRADECODE_LEN) == 0)                       // 无卡充值
	 		retcode = doTrade(ykt_clt, info_trade, recv_buf, false);
		
		else if(strncmp(tradecode,TRADE_REV_NOCARD,TRADECODE_LEN) == 0)
			retcode = doTrade(ykt_clt, info_trade, recv_buf, true);
		
		else if(strncmp(tradecode,TRADE_CHK_NOCARD,TRADECODE_LEN) == 0)
			retcode = doCkbala(ykt_clt, info_trade, recv_buf);
		else
	        	return E_TRANS_NONSUPPORT;
		
		if(retcode)
		{
			if(retcode<0)
				retcode = 1111;
		}
		writelog(LOG_DEBUG,"未写卡余额[%.2f]\n",info_trade.ICCardNotWrt);
		GenResMsgHead(msghead,info_trade.Refno,retcode,info_trade.ReMark);			// 生成msghead
		GenTradeResMsgBody(msgbody,info_trade);		
		tradecode[1]='1';
		GenTransResMSG(send_buf,tradecode,msghead,msgbody);
		send_len = strlen(send_buf);

 	}
    	return 0;
    }
Пример #9
0
Error Socket::bind(const SocketAddress *addr)
{
	return doBind(addr);
}
Пример #10
0
void Shader::unbind()
{
    doBind(NULL);
}
Пример #11
0
void Shader::bind()
{
    doBind(mHandle);
}
Пример #12
0
int service_sudo(Connection *Conn,int svsock,int svport){
	int fc;
	int fv[2];
	int rv[2];
	CStr(req,1024);
	CStr(com,1024);
	CStr(arg,1024);
	CStr(a1,1024);
	CStr(a2,1024);
	CStr(a3,1024);
	const char *dp;
	CStr(resp,1024);
	int tsock = -1;
	int clsock;
	int isUDP;
	int rcc;
	int fd;
	CStr(local,MaxHostNameLen);
	CStr(remote,MaxHostNameLen);
	CStr(opts,MaxHostNameLen);
	CStr(clhost,128);
	int clport;

	gethostName(svsock,AVStr(local),"%A");
	sv1log("==SU START uid=%d/%d sock=%d port=%d udp=%d [%s]\n",
		getuid(),geteuid(),svsock,svport,isUDPsock(svsock),local);

	if( svport == 0 ){
		sprintf(local,"%s/sudo/port/P%s",DELEGATE_DGROOT,portSUDO);
		unlink(local);
		svsock = server_open_un("SUDO",AVStr(local),32);
		sv1log("==SU sock[%d] %s\n",svsock,local);
		if( svsock < 0 ){
			return -1;
		}
		if( geteuid() == 0 ){
			int omode = File_mod(local);
			/* set the owner of the socket to the one in OWNER */
			chmodShared(local);
			chmod(local,omode|0660);
		}
	}


	if( isUDP = isUDPsock(svsock) ){
	}else{
	}

	if( isUDP ){
		tsock = server_open_un("SUDO",AVStr(local),32);
		sv1log("---> tsock:%d [%s]\n",tsock,local);
	}else{
		tsock = svsock;
	}

	fc = 1;
	fv[0] = tsock;
	if( 0 <= isPrivateSUDO ){
		fc = 2;
		fv[1] = isPrivateSUDO;
	}

	for(;;){
		/*
		if( PollIn(tsock,0) <= 0 ){
			break;
		}
		*/
		if( PollIns(0,fc,fv,rv) <= 0 ){
			sv1log("==SU EXIT: poll error\n");
			break;
		}
		if( fc == 2 ){
			if( rv[1] ){
				sv1log("==SU EXIT: parent died\n");
				break;
			}
			if( rv[0] == 0 )
				continue;
		}

		clsock = tsock;
		if( !isUDP && !IsConnected(tsock,NULL) ){
			clsock = ACCEPT1(tsock,1,-1,10,AVStr(clhost));
			if( clsock < 0 ){
				msleep(100);
				continue;
			}
		}
		rcc = RecvFrom(clsock,req,sizeof(req)-1,AVStr(clhost),&clport);
		if( rcc <= 0 ){
			sv1log("==SU %d %d rcc=%d\n",tsock,clsock,rcc);
			if( clsock != tsock ){
				close(clsock);
				continue;
			}else{
				sv1log("==SU EXIT: read error\n");
				break;
			}
		}
		setVStrEnd(req,rcc);
		dp = wordScan(req,com);
		if( *dp == ' ' )
			textScan(dp+1,arg);
		else	lineScan(dp,arg);
		dp = wordScan(arg,a1);
		dp = wordScan(dp,a2);
		lineScan(dp,a3);
		sv1log("==SU Q[%s][%s]\n",com,arg);
		putLoadStat(ST_ACC,1);
		putLoadStat(ST_DONE,1);
		put_svstat();
		incRequestSerno(Conn);

		if( strcaseeq(com,"QUIT") ){
			if( isUDP ){
				continue;
			}else{
				sv1log("==SU EXIT: by QUIT command\n");
				break;
			}
		}
		if( strcaseeq(com,"PAM") ){
			doPAM(clsock,clhost,clport,tsock,arg);
			continue;
		}
		if( strcaseeq(com,"BIND") ){
			doBind(clsock,clhost,clport,tsock,arg);
			continue;
		}
/*
		if( strcaseeq(com,"STDERR") ){
			sv1log("==SU receiving @fd[%d]\n",usock);
			fd = recvFd(usock);
 fprintf(stderr,"---- STDERR %d -> %d\n",usock,fd);
			if( 0 <= fd ){
				dup2(fd,fileno(stderr));
 fprintf(stderr,"---- STDERR %d dup2\n",fd);
			}
		}
*/
	}
	return 0;
}