int main(int argc, char** argv)
{
	QCoreApplication app(argc,argv);

	AmbProperty speed;

	double totalLatency=0;
	int numSamples=0;

	QObject::connect(&speed, &AmbProperty::signalChanged,[&](QVariant val)
	{
		double t1 = speed.time();
		double t2 = amb::currentTime();

		double latency = (t2-t1)*1000.0;

		DebugOut(0)<<"latency: "<<latency<<std::endl;
		totalLatency+=latency;
		numSamples++;
		DebugOut(0)<<"Average: "<<totalLatency / numSamples<<std::endl;
	});

	speed.setPropertyName("VehicleSpeed");
	speed.connect();

	return app.exec();
}
示例#2
0
bool TextureShader::CreateShaders(ID3D11Device *device)
{
	HRESULT hr;

	// create vertex shader object from compiled shader code
	hr = device->CreateVertexShader(m_vsBlob->GetBufferPointer(), m_vsBlob->GetBufferSize(), nullptr, &m_VertexShader);
	if (FAILED(hr)) {
		DebugOut("ID3D11Device::CreateVertexShader failed!\n");
		m_vsBlob->Release();
		m_psBlob = nullptr;

		return false;
	}

	// create pixel shader
	hr = device->CreatePixelShader(m_psBlob->GetBufferPointer(), m_psBlob->GetBufferSize(), nullptr, &m_PixelShader);	
	if (FAILED(hr)) {
		DebugOut("ID3D11Device::CreatePixelShader failed!\n");
		m_psBlob->Release();
		m_psBlob = nullptr;

		return false;
	}

	return true;
};
TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config)
	: AbstractSource(re, config)
{
  DebugOut() << "Testing MapPropertyType... " << endl;
  MapPropertyType<BasicPropertyType<Zone::Type>,BasicPropertyType<Door::Status>> propmap("something");
  MapPropertyType<BasicPropertyType<Zone::Type>,BasicPropertyType<Door::Status>> propmaptwo("something");
  propmap.append(Zone::RearLeft,Door::Ajar);
  GVariant *var = propmap.toVariant();
  gsize dictsize = g_variant_n_children(var);
  //DebugOut() << var << endl;
  propmaptwo.fromVariant(var);

  g_assert(propmaptwo.toString() == propmap.toString());

  DebugOut() << "Testing ListPropertyType... " << endl;
  VehicleProperty::TripMetersType* tfirst = new VehicleProperty::TripMetersType();
  VehicleProperty::TripMetersType* tsecond = new VehicleProperty::TripMetersType();
  BasicPropertyType<uint16_t> v1(0);
  BasicPropertyType<uint16_t> v2(5);
  BasicPropertyType<uint16_t> v3(10);
  tfirst->append(&v1);
  tfirst->append(&v2);
  tfirst->append(&v3);
  tsecond->fromVariant(tfirst->toVariant());

  g_assert (tfirst->toString() == tsecond->toString());

  testBooleanToStringFromString();

  g_assert (testCoreUpdateSupported());

  DebugOut() << "Exiting..." << endl;
  exit(-1);
}
bool gioPollingFunc(GIOChannel *source, GIOCondition condition, gpointer data)
{
	DebugOut(5) << "Polling..." << condition << endl;

	if(condition & G_IO_ERR)
	{
		DebugOut(0)<< __SMALLFILE__ <<":"<< __LINE__ <<" websocketsink polling error."<<endl;
	}

	if (condition & G_IO_HUP)
	{
		//Hang up. Returning false closes out the GIOChannel.
		//printf("Callback on G_IO_HUP\n");
		DebugOut(0)<<"socket hangup event..."<<endl;
		return false;
	}

	//This is the polling function. If it return false, glib will stop polling this FD.
	//printf("Polling...%i\n",condition);
	
	lws_tokens token;
	struct pollfd pollstruct;
	int newfd = g_io_channel_unix_get_fd(source);
	pollstruct.fd = newfd;
	pollstruct.events = condition;
	pollstruct.revents = condition;
	libwebsocket_service_fd(context,&pollstruct);

	return true;
}
void CCmdAlphaWeightModulate::UnExecute()
{
	CCmd::UnExecute();

	CTerrainMesh * pTerrain = CMapEditApp::GetInstance()->GetTerrainMesh();

	for ( std::vector<SVertex>::iterator iter = m_vecDiffs.begin(); iter != m_vecDiffs.end(); ++iter )
	{
		pTerrain->SetAlphaWeightAlpha(iter->dwVertexIndex, iter->weightColor);
	}

	DebugOut("UnExecute Test %d, %d",  m_processParams.dwBrushSizeInX,  m_processParams.dwBrushSizeInZ);

	int width = 0, depth = 0;
	width = m_processParams.dwBrushSizeInX;
	depth = m_processParams.dwBrushSizeInZ;

	if ( width != pTerrain->GetWidth() )
		width *= 2;

	if ( depth != pTerrain->GetDepth() )
		depth *= 2;

	DebugOut("FillBlendTexture %d, %d",  width,  depth);
	pTerrain->FillBlendTexture(m_vecDiffs[0].dwVertexIndex , width, depth ) ;
}
void OBD2Source::getPropertyAsync(AsyncPropertyReply *reply)
{
	DebugOut(5) << __SMALLFILE__ <<":"<< __LINE__ << "getPropertyAsync requested for " << reply->property << endl;

	VehicleProperty::Property property = reply->property;


	if(!ListPlusPlus<VehicleProperty::Property>(&m_supportedProperties).contains(property))
	{
		DebugOut(0)<<"obd plugin does not support: "<<property<<endl;
		return;
	}

	if(reply->property == Obd2Connected)
	{
		reply->success = true;
		reply->value = &obd2Connected;
		reply->completed(reply);
		return;
	}

	propertyReplyMap[reply->property] = reply;

	ObdPid* requ = obd2AmbInstance->createPidforProperty(property);
	g_async_queue_push(singleShotQueue,requ);
	CommandRequest *req = new CommandRequest();
	req->req = "connectifnot";
	g_async_queue_push(commandQueue,req);
}
void Matrix34::WriteToDebugStream()
{
    DebugOut("%5.2f %5.2f %5.2f\n", r.x, r.y, r.z);
    DebugOut("%5.2f %5.2f %5.2f\n", u.x, u.y, u.z);
    DebugOut("%5.2f %5.2f %5.2f\n", f.x, f.y, f.z);
    DebugOut("%5.2f %5.2f %5.2f\n\n", pos.x, pos.y, pos.z);
}
示例#8
0
    void SimpleAction::OnActivate()
    {
        auto gameObject = _gameObject.lock();
        auto gameWorld = gameObject->GetGameWorld();

        if (!_actionComplete)
        {
            //_actionComplete = true;

            switch(_type)
            {
            case SimpleAction::Type::PlaySound:
                // Play sound
                DebugOut("PLAY SOUND: %S",_data.c_str());
                gameWorld->GetDeviceContext().audioDevice->PlayClip(Quake2Game::GetContentCache()->GetAudioClip(_data));
                break;
            case SimpleAction::Type::PrintText:
                // Print text to window
                // _data is the text to output
                DebugOut("TEXT MESSAGE: %S",_data.c_str());
                break;
            default:
                break;
            }
        }
    }
int main(int argc, char** argv)
{
	DebugOut::setDebugThreshhold(7);
	DebugOut::setThrowErr(true);
	DebugOut::setThrowWarn(false);

	DebugOut(0) << "Testing AMB json server/client" << endl;

	QCoreApplication app(argc, argv);

	DomainSocket socket;

	socket.open();

	if(!socket.getSocket()->waitForConnected())
	{
		DebugOut("Could not connect");
		return -1;
	}

	DebugOut(0) << "We are connected!" << endl;

	amb::AmbRemoteClient client(&socket);

	runTest(&client);

	app.exec();
}
void WebSocketSinkManager::removePoll(int fd)
{
	g_io_channel_shutdown(m_ioChannelMap[fd],false,0);
	//printf("Shutting down IO Channel\n");
	DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Shutting down IO Channel\n";
	g_source_remove(m_ioSourceMap[fd]); //Since the watch owns the GIOChannel, this should unref it enough to dissapear.
	//for (map<int,guint>::const_iterator i=m_ioSourceMap.cbegin();i!=m_ioSourceMap.cend();i++)
	for (map<int,guint>::iterator i=m_ioSourceMap.begin();i!=m_ioSourceMap.end();i++)
	{
		if((*i).first == fd)
		{
			//printf("Erasing source\n");
			DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Erasing source\n";
			m_ioSourceMap.erase(i);
			i--;
		}
	}
	//for (map<int,GIOChannel*>::const_iterator i=m_ioChannelMap.cbegin();i!=m_ioChannelMap.cend();i++)
	for (map<int,GIOChannel*>::iterator i=m_ioChannelMap.begin();i!=m_ioChannelMap.end();i++)
	{
		if((*i).first == fd)
		{
			//printf("Erasing channel\n");
			DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Erasing channel\n";
			m_ioChannelMap.erase(i);
			i--;
		}
	}
}
示例#11
0
    void DspTempo::AdjustTempo()
    {
        if (m_tempo != m_ftempo)
        {
            assert(m_tempo != m_ftempo1);
            assert(m_tempo != m_ftempo2);

            double ratio21 = std::abs((m_tempo - m_ftempo1) / (m_tempo - m_ftempo2));

            if (m_ftempo != m_ftempo2 &&
                m_outSamples1 * ratio21 - m_outSamples2 > 60 * m_rate)
            {
                DebugOut(ClassName(this), "adjusting for float/double imprecision (2), ratio", ratio21);
                m_ftempo = m_ftempo2;
                m_stouch.setTempo(m_ftempo);
            }
            else if (m_ftempo != m_ftempo1 &&
                     m_outSamples2 - m_outSamples1 * ratio21 > 60 * m_rate)
            {
                DebugOut(ClassName(this), "adjusting for float/double imprecision (1), ratio", ratio21);
                m_ftempo = m_ftempo1;
                m_stouch.setTempo(m_ftempo);
            }
        }
    }
示例#12
0
DWORD WINAPI ServiceCtrlHandlerEx(DWORD dwOpcode, DWORD dwEventType, LPVOID lpEventData, LPVOID /*lpContext*/) {
	DWORD dwRes = ERROR_CALL_NOT_IMPLEMENTED;
	switch (dwOpcode) {
	case SERVICE_CONTROL_STOP:
		DebugOut("SERVICE_CONTROL_STOP\n");
		if (hDevNotify) UnregisterDeviceNotification(hDevNotify);
		ServiceStatus.dwWin32ExitCode = 0;
		ServiceStatus.dwCurrentState = SERVICE_STOPPED;
		ServiceStatus.dwCheckPoint = 0;
		ServiceStatus.dwWaitHint = 0;
		if (gpSid) free(gpSid);
		dwRes = NO_ERROR;
		break;
	case SERVICE_CONTROL_INTERROGATE:
		DebugOut("SERVICE_CONTROL_INTERROGATE\n");
		dwRes = NO_ERROR;
		break;
	case SERVICE_CONTROL_DEVICEEVENT:
		DebugOut("SERVICE_CONTROL_DEVICEEVENT");
		DeviceEventNotify(dwEventType, lpEventData);
		dwRes = NO_ERROR;
		break;
	}
	if (!SetServiceStatus(hServiceStatus, &ServiceStatus)) { // Send current status.
		DebugOut("SetServiceStatus failed! (LastError=0x%x)\n", GetLastError());
	}
	return dwRes;
}
static void signalCallback( GDBusConnection *connection,
							const gchar *sender_name,
							const gchar *object_path,
							const gchar *interface_name,
							const gchar *signal_name,
							GVariant *parameters,
							gpointer user_data)
{
	AutomotiveManager* manager = static_cast<AutomotiveManager*>(user_data);

	if(!manager)
	{
		DebugOut(DebugOut::Error)<<"Bad user_data"<<endl;
		return;
	}

	gchar* name=nullptr;
	gchar* newOwner=nullptr;
	gchar* oldOwner = nullptr;
	g_variant_get(parameters,"(sss)",&name, &oldOwner, &newOwner);

	std::list<AbstractDBusInterface*> toRemove;

	if(std::string(newOwner) == "")
	{
		for(auto &i : manager->subscribedProcesses)
		{
			AbstractDBusInterface* iface = i.first;

			for(auto itr = i.second.begin(); itr != i.second.end(); itr++)
			{
				std::string n = *itr;
				if(n == name)
				{
					DebugOut()<<"unreferencing "<<n<<" from the subscription of "<<iface->objectPath()<<endl;
					itr = manager->subscribedProcesses[iface].erase(itr);
					DebugOut()<<"new ref count: "<<manager->subscribedProcesses[iface].size()<<endl;
				}
			}

			if(manager->subscribedProcesses[iface].empty())
			{
				DebugOut()<<"No more subscribers.  Unregistering: "<<iface->objectPath()<<endl;
				///Defer removal to not screw up the list
				toRemove.push_back(iface);
				iface->unregisterObject();
			}
		}

		for(auto & i : toRemove)
		{
			manager->subscribedProcesses.erase(i);
		}
	}

	g_free(name);
	g_free(newOwner);
	g_free(oldOwner);
}
示例#14
0
文件: main.cpp 项目: CCJY/coliru
int main() {
    std::string name = "bob";
    int age = 25;
    DebugOut(L"HI");
    DebugOut("my name is %s", name.c_str());
    DebugOut() << name << " is age " << age;
    return 0;
}
void WebSocketSinkManager::addSingleShotSink(libwebsocket* socket, VehicleProperty::Property property, Zone::Type zone, string id)
{
	AsyncPropertyRequest request;
	PropertyList foo = VehicleProperty::capabilities();
	if (ListPlusPlus<VehicleProperty::Property>(&foo).contains(property))
	{
		request.property = property;
	}
	else
	{
		DebugOut(0)<<"websocketsink: Invalid property requested: "<<property;
		return;
	}

	request.zoneFilter = zone;
	request.completed = [socket,id,property](AsyncPropertyReply* reply)
	{
		DebugOut()<<"Got property: "<<reply->property.c_str()<<endl;
		if(!reply->success || !reply->value)
		{
			DebugOut()<<"Property value is null"<<endl;
			delete reply;
			return;
		}

		QVariantMap data;
		data["property"] = property.c_str();
		data["zone"] = reply->value->zone;
		data["value"] = reply->value->toString().c_str();
		data["timestamp"] = reply->value->timestamp;
		data["sequence"] = reply->value->sequence;

		QVariantMap replyvar;

		replyvar["type"]="methodReply";
		replyvar["name"]="get";
		replyvar["data"]= data;
		replyvar["transactionid"]=id.c_str();

		QByteArray replystr;

		if(doBinary)
			replystr = QJsonDocument::fromVariant(replyvar).toBinaryData();
		else
		{
			replystr = QJsonDocument::fromVariant(replyvar).toJson();
			cleanJson(replystr);
		}

		lwsWrite(socket, replystr, replystr.length());

		delete reply;
	};

	AsyncPropertyReply* reply = routingEngine->getPropertyAsync(request);
}
std::shared_ptr<AbstractPropertyType> amb::jsonToProperty(const picojson::value &json)
{
	std::string name = json.get("name").to_str();
	std::string type = json.get("type").to_str();

	auto t = VehicleProperty::getPropertyTypeForPropertyNameValue(name);

	if(!t)
	{
		bool ret = VehicleProperty::registerProperty(name, [name, type]() -> AbstractPropertyType* {
			if(type == amb::BasicTypes::UInt16Str)
			{
				return new BasicPropertyType<uint16_t>(name, 0);
			}
			else if(type == amb::BasicTypes::Int16Str)
			{
				return new BasicPropertyType<int16_t>(name, 0);
			}
			else if(type == amb::BasicTypes::UInt32Str)
			{
				return new BasicPropertyType<uint32_t>(name, 0);
			}
			else if(type == amb::BasicTypes::Int32Str)
			{
				return new BasicPropertyType<int32_t>(name, 0);
			}
			else if(type == amb::BasicTypes::StringStr)
			{
				return new StringPropertyType(name);
			}
			else if(type == amb::BasicTypes::DoubleStr)
			{
				return new BasicPropertyType<double>(name, 0);
			}
			else if(type == amb::BasicTypes::BooleanStr)
			{
				return new BasicPropertyType<bool>(name, false);
			}
			DebugOut(DebugOut::Warning) << "Unknown or unsupported type: " << type << endl;
			return nullptr;
		});

		if(!ret)
		{
			DebugOut(DebugOut::Error) << "failed to register property: " << name << endl;
			return nullptr;
		}

		t = VehicleProperty::getPropertyTypeForPropertyNameValue(name);
	}

	t->fromJson(json);

	return std::shared_ptr<AbstractPropertyType>(t);
}
int lwsWrite(libwebsocket *lws, QByteArray d)
{
	if(!lws)
	{
		DebugOut(DebugOut::Error)<<__FUNCTION__<<": libwebsockets is not valid.  Perhaps it has not been initialized?" << endl;
		return -1;
	}

	DebugOut() << "Writing to websocket: " << d.constData() << endl;

	int retval = -1;

	QByteArray temp = d;

	int numframes = 1;
	int framesize = 5012;

	if(d.length() > framesize)
	{
		numframes = ceil((double)d.length() / double(framesize));
		QVariantMap multiFrameMessage;
		multiFrameMessage["type"] = "multiframe";
		multiFrameMessage["frames"] = numframes;

		lwsWriteVariant(lws, multiFrameMessage);
	}

	while(numframes--)
	{
		int range = 0;
		if(temp.length() > framesize)
			range = framesize;
		else range = temp.length();

		QByteArray toWrite = temp.mid(0,range);
		const char* strToWrite = toWrite.data();

		temp = temp.mid(range);

		if(doBinary)
		{
			retval = libwebsocket_write(lws, (unsigned char*)strToWrite, toWrite.length(), LWS_WRITE_BINARY);
		}
		else
		{
			std::unique_ptr<char[]> buffer(new char[LWS_SEND_BUFFER_PRE_PADDING + toWrite.length() + LWS_SEND_BUFFER_POST_PADDING]);
			char *buf = buffer.get() + LWS_SEND_BUFFER_PRE_PADDING;
			memcpy(buf, strToWrite, toWrite.length());

			retval = libwebsocket_write(lws, (unsigned char*)strToWrite, toWrite.length(), LWS_WRITE_TEXT);
		}
	}
	return retval;
}
示例#18
0
void CLocalDriver::Disconnect(CBaseConn *id, EDisconnectReason reason)
{
	if (g_TransportDebug > 0 || g_bLocalDebug)
	{
		if (m_pConnection)
			DebugOut( "CLocalDriver::Disconnect\n" );
		else
			DebugOut( "CLocalDriver::Disconnect (not connected)\n" );
	}
	m_pNetMgr->DisconnectNotify( id, reason );
	Term();
}
示例#19
0
//检查SocketFd是否为可写不可读状态
int HttpRequest::SocketFdCheck(const int iSockFd)
{
	struct timeval timeout ;
	fd_set rset,wset;
	FD_ZERO(&rset);
	FD_ZERO(&wset);
	FD_SET(iSockFd, &rset);
    FD_SET(iSockFd, &wset);
    timeout.tv_sec = 3;
	timeout.tv_usec = 500;
	int iRet = select(iSockFd+1, &rset, &wset, NULL, &timeout);
	if(iRet > 0)
	{
		//判断SocketFd是否为可写不可读状态
		int iW = FD_ISSET(iSockFd,&wset);
		int iR = FD_ISSET(iSockFd,&rset);
		if(iW && !iR)
		{
			char error[4] = "";
			socklen_t len = sizeof(error);
			int ret = getsockopt(iSockFd,SOL_SOCKET,SO_ERROR,error,&len);
			if(ret == 0)
			{
				if(!strcmp(error, ""))
				{
					return iRet;//表示已经准备好的描述符数
				}
				else 
				{
					DebugOut("%s %s %d\tgetsockopt error code:%d,error message:%s", __FILE__, __FUNCTION__, __LINE__, errno, strerror(errno));
				}
			}
			else
			{
				DebugOut("%s %s %d\tgetsockopt failed. error code:%d,error message:%s", __FILE__, __FUNCTION__, __LINE__, errno, strerror(errno));
			}
		}
		else
		{			
			DebugOut("%s %s %d\tsockFd是否在可写字符集中:%d,是否在可读字符集中:%d\t(0表示不在)\n", __FILE__, __FUNCTION__, __LINE__, iW, iR);
		}
	}
	else if(iRet == 0)
	{
		return 0;//表示超时
	}
	else
	{
		return -1;//select出错,所有描述符集清0
	}
	return -2;//其他错误
}
static int updateProperties( gpointer data)
{

	OBD2Source* src = (OBD2Source*)data;
	
	while (gpointer retval = g_async_queue_try_pop(src->statusQueue))
	{
		StatusMessage *reply = (StatusMessage*)retval;
		if (reply->statusStr == "disconnected")
		{
			OBD2Source::Obd2ConnectType val(Obd2Connected,false);
			src->updateProperty(Obd2Connected,&val);
		}
		else if (reply->statusStr == "connected")
		{
			OBD2Source::Obd2ConnectType val(Obd2Connected, true);
			src->updateProperty(Obd2Connected,&val);
		}
		else if (reply->statusStr == "error:nodata" || reply->statusStr == "error:timeout")
		{
			if (src->propertyReplyMap.find(reply->property) != src->propertyReplyMap.end())
			{
				DebugOut(5) << __SMALLFILE__ <<":"<< __LINE__ << reply->statusStr << " on property:" << reply->property << endl;
				src->propertyReplyMap[reply->property]->success = false;
				src->propertyReplyMap[reply->property]->error = AsyncPropertyReply::InvalidOperation;
				src->propertyReplyMap[reply->property]->completed(src->propertyReplyMap[reply->property]);
				src->propertyReplyMap.erase(reply->property);

				/// Remove support for this pid:
				PropertyList list = src->supported();
				list.remove(reply->property);
				src->setSupported(list);
			}
			else
			{
				DebugOut(5) << __SMALLFILE__ <<":"<< __LINE__ << reply->statusStr << " on unrequested property:" << reply->property << endl;
			}
		}
		delete reply;
	}
	while(gpointer retval = g_async_queue_try_pop(src->responseQueue))
	{
		ObdPid *reply = (ObdPid*)retval;

		
		AbstractPropertyType* value = VehicleProperty::getPropertyTypeForPropertyNameValue(reply->property, reply->value);
		src->updateProperty(reply->property, value);
		delete value;
	}

	return true;
}
static void
on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data)
{
	DebugOut(DebugOut::Error)<<"DBus: Lost bus name"<<endl;

	DBusInterfaceManager* iface = static_cast<DBusInterfaceManager*>(user_data);

	iface->setValue(iface->dbusConnected, false);

	if(!connection){
		DebugOut(DebugOut::Error)<<"DBus: Connection could not be established."<<endl;
		throw std::runtime_error("Could not establish DBus connection.");
	}
}
示例#22
0
void QuadTree::printTree(int type){
	DebugOut("==================== TREE ====================");
	if(root != NULL){
		switch(type) {
			case 0:
				root->printDetails();
				break;
			case 1:
				root->printShortDetails();
				break;
		}
	}
	DebugOut("==============================================");
}
示例#23
0
void CGras::InitGras(int menge)
{
	if (menge>MAXIMUM_GRAS_OBJECTS)menge=MAXIMUM_GRAS_OBJECTS;
	Invalidate();

	Indices=new WORD[MAX_GRAS_PRO_VB*6];

	for (int i=0;i<MAX_GRAS_PRO_VB*6;i+=6)
	{
		const int v1=i/6*4;
		Indices[i+0]=v1;
		Indices[i+1]=v1+1;
		Indices[i+2]=v1+2;
		Indices[i+3]=v1;
		Indices[i+4]=v1+2;
		Indices[i+5]=v1+3;
	}

	vertexbuffers=menge/MAX_GRAS_PRO_VB+1;

	lpVertices=new LPDIRECT3DVERTEXBUFFER7[vertexbuffers];
	ZeroMemory(lpVertices,sizeof(LPDIRECT3DVERTEXBUFFER7)*vertexbuffers);
	vertexnum=new WORD[vertexbuffers];

#ifdef _DEBUG
	DebugOut("Initialisiere Gras:");

	CHAR c[100];
	sprintf(&c[0],"  Graspartikel: %d",menge);
	DebugOut(&c[0]);
	sprintf(&c[0],"  Grasvertices: %d",menge*4);
	DebugOut(&c[0]);
	sprintf(&c[0],"  Vertexbuffer: %d",vertexbuffers);
	DebugOut(&c[0]);
#endif

	for (int i=0;i<vertexbuffers;i++)
	{
		CreateGras(i,menge>MAX_GRAS_PRO_VB?MAX_GRAS_PRO_VB:menge);

		menge-=MAX_GRAS_PRO_VB;
		if (menge<=0)
		{
			vertexbuffers=i+1;
			break;
		}
	}
	return;
}
示例#24
0
文件: h_mfmt.c 项目: hydrix1/tacacs
void h_mfmt(struct context *ctx, char *arg)
{
    char *t;
    struct stat st;
    struct tm tm;

    DebugIn(DEBUG_COMMAND);

    t = arg;

    while (*arg && !isspace((int) *arg))
	arg++;

    if (!isspace((int) *arg)) {
	reply(ctx, MSG_500_arguments_required);
	DebugOut(DEBUG_COMMAND);
	return;
    }

    memset(&tm, 0, sizeof(tm));
    *arg++ = 0;

    if (*arg && 6 == sscanf(t, "%4d%2d%2d%2d%2d%2d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec)) {
	struct utimbuf ut;
	tm.tm_year -= 1900;
	tm.tm_mon--;
	ut.modtime = mktime(&tm);

	if ((t = buildpath(ctx, arg)) && (!pickystat(ctx, &st, t))
	    && (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))
	    && st.st_uid == ctx->uid) {
	    ut.actime = st.st_atime;
	    if (utime(t, &ut))
		reply(ctx, MSG_550_Permission_denied);
	    else {
		struct stat sst;
		char u[40];
		if (stat(t, &sst))
		    sst.st_mtime = ut.modtime;
		strftime(u, sizeof(u), "213 Modify=%Y%m%d%H%M%S; ", gmtime(&sst.st_mtime));
		replyf(ctx, "%s%s\r\n", u, t);
	    }
	} else
	    reply(ctx, MSG_550_Permission_denied);
    } else
	reply(ctx, MSG_500_missing_filename);

    DebugOut(DEBUG_COMMAND);
}
示例#25
0
BOOL SetSecurityPrivilage(BOOL bEnablePrivilege) {
	LPCTSTR lpszPrivilege = L"SeSecurityPrivilege";
	HANDLE hToken;
	// Open a handle to the access token for the calling process. That is this running program
	if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) {
		DebugOut("OpenProcessToken() error %u\n", GetLastError());
		return FALSE;
	}
	// Call the user defined SetPrivilege() function to enable and set the needed privilege
	if (!SetPrivilege(hToken, lpszPrivilege, bEnablePrivilege)) {
		DebugOut("Failed to adjust Privilege\n");
		return FALSE;
	}
	return TRUE;
}
示例#26
0
VOID DeviceEventNotify(DWORD dwEventType, PVOID lpEventData) {
	PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lpEventData;
	if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
		PDEV_BROADCAST_DEVICEINTERFACE pInterface = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;
		switch (dwEventType) {
		case DBT_DEVICEREMOVECOMPLETE:
			DebugOut("Device Removal \"%S\"\n", pInterface->dbcc_name);
			break;
		case DBT_DEVICEARRIVAL:
			DebugOut("Device Arrival \"%S\"\n", pInterface->dbcc_name);
			ScanApplyObjectsRules();
			break;
		}
	}
}
void CANGenPlugin::getValue(libwebsocket* socket, const std::string& property, int zone, const std::string& id)
{
    AsyncPropertyRequest request;
    PropertyList foo = VehicleProperty::capabilities();
    if (ListPlusPlus<VehicleProperty::Property>(&foo).contains(property))
    {
        request.property = property;
    }
    else
    {
        DebugOut(0)<<"websocketsink: Invalid property requested: "<<property;
        return;
    }

    request.zoneFilter = zone;
    request.completed = [socket,id,property](AsyncPropertyReply* reply)
    {
        DebugOut()<<"Got property: "<<reply->property.c_str()<<endl;
        if(!reply->value){
            DebugOut()<<"Property value is null"<<endl;
            delete reply;
            return;
        }

        stringstream s;
        s.precision(15);

        s << "{\"type\":\"methodReply\",\"name\":\"get\",\"data\":{";
        s << "\"property\":\"" << property << "\",\"zone\":\"" << reply->value->zone << "\",\"value\":\"" << reply->value->toString() << "\",\"timestamp\":\""<<reply->value->timestamp<<"\",";
        s <<"\"sequence\": \""<<reply->value->sequence<<"\"}";
        s << ",\"transactionid\":\"" << id << "\"}";

        string replystr = s.str();
        //printf("Reply: %s\n",replystr.c_str());
        LOG_MESSAGE("Reply:" << replystr << endl);

        //if(replystr.length() > 4096){
        //    WebSockets::Write(socket, replystr.substr(0,4096));
        //    WebSockets::Write(socket, replystr.substr(4096, 4096));
        //}
        //else WebSockets::Write(socket, replystr);
        WebSockets::Write(socket, replystr);

        delete reply;
    };

    routingEngine->getPropertyAsync(request);
}
示例#28
0
REFERENCE_TIME AudioDevicePush::Finish(CAMEvent* pFilledEvent)
{
    if (m_error)
        throw E_FAIL;

    if (!m_endOfStream)
    {
        DebugOut(ClassName(this), "finish");

        m_endOfStream = true;
        m_endOfStreamPos = GetEnd();

        try
        {
            if (!m_thread.joinable())
            {
                assert(!m_exit);
                m_thread = std::thread(std::bind(&AudioDevicePush::SilenceFeed, this));
            }
        }
        catch (std::system_error&)
        {
            throw E_OUTOFMEMORY;
        }
    }

    if (pFilledEvent)
        pFilledEvent->Set();

    return m_endOfStreamPos - GetPosition();
}
GVariant *amb::jsonToGVariant(const picojson::value & value, const std::string& type)
{
	GVariant* v = nullptr;

	if (type == "i") {
		v = g_variant_new(type.c_str(), (int32_t)value.get<double>());
	} else if (type == "d") {
		v = g_variant_new(type.c_str(), value.get<double>());
	} else if (type == "q") {
		v = g_variant_new(type.c_str(), (uint16_t)value.get<double>());
	} else if (type == "n") {
		v = g_variant_new(type.c_str(), (int16_t)value.get<double>());
	} else if (type == "u") {
		v = g_variant_new(type.c_str(), (uint32_t)value.get<double>());
	} else if (type == "x") {
		v = g_variant_new(type.c_str(), (int64_t)value.get<double>());
	} else if (type == "t") {
		v = g_variant_new(type.c_str(), (uint64_t)value.get<double>());
	} else if (type == "b") {
		v = g_variant_new(type.c_str(), value.get<bool>());
	} else if (type == "s") {
		v = g_variant_new(type.c_str(), value.get<std::string>().c_str());
	} else {
		DebugOut(DebugOut::Error) << "Unsupported type: " << type << endl;
	}

	return v;
}
示例#30
0
文件: h_user.c 项目: hydrix1/tacacs
void h_user(struct context *ctx, char *arg)
{
    char *host;

    DebugIn(DEBUG_COMMAND);

    if (ctx->state == ST_conn) {
	ctx->state = ST_user;

	host = strchr(arg, '@');
	if (host) {
	    *host++ = 0;
	    strset(&ctx->vhost, host);
	}

	if (!strcasecmp(arg, "ftp") || !strcasecmp(arg, "anonymous")) {
	    reply(ctx, MSG_331_anon);
	    strset(&ctx->user, "ftp");
	    ctx->anonymous = 1;
	} else {
	    reply(ctx, MSG_331_user);
	    strset(&ctx->user, arg);
	    ctx->anonymous = 0;
	}
    } else
	reply(ctx, MSG_503_Already_logged_in);

    DebugOut(DEBUG_COMMAND);
}