Пример #1
0
eServerSocket::eServerSocket(std::string path, eMainloop *ml) : eSocket(ml, AF_LOCAL)
{
	struct sockaddr_un serv_addr;
	strRemoteHost = "";

	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sun_family = AF_LOCAL;
	strcpy(serv_addr.sun_path, path.c_str());

	okflag=1;

	unlink(path.c_str());
#if HAVE_LINUXSOCKADDR
	if(bind(getDescriptor(),
	(struct sockaddr *) &serv_addr,
	strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family))<0)
#else
	if(bind(getDescriptor(),
		(struct sockaddr *) &serv_addr,
		sizeof(serv_addr))<0)
#endif
	{
		eDebug("[SERVERSOCKET] ERROR on bind() (%m)");
		okflag=0;
	}
	listen(getDescriptor(), 0);

	rsn->setRequested(eSocketNotifier::Read);
}
Пример #2
0
//! Describe all features in the supplied vector
void Surf::getDescriptors(bool upright)
{
  // Check there are Ipoints to be described
  if (!ipts.size()) return;

  // Get the size of the vector for fixed loop bounds
  int ipts_size = (int)ipts.size();

  if (upright)
  {
    // U-SURF loop just gets descriptors
    for (int i = 0; i < ipts_size; ++i)
    {
      // Set the Ipoint to be described
      index = i;

      // Extract upright (i.e. not rotation invariant) descriptors
      getDescriptor(true);
    }
  }
  else
  {
    // Main SURF-64 loop assigns orientations and gets descriptors
    for (int i = 0; i < ipts_size; ++i)
    {
      // Set the Ipoint to be described
      index = i;

      // Assign Orientations and extract rotation invariant descriptors
      getOrientation();
      getDescriptor(false);
    }
  }
}
Пример #3
0
eServerSocket::eServerSocket(int port, eMainloop *ml): eSocket(ml)
{
	struct sockaddr_in serv_addr;
	strRemoteHost = "";

	bzero(&serv_addr, sizeof(serv_addr));
	serv_addr.sin_family=AF_INET;
	serv_addr.sin_addr.s_addr=INADDR_ANY;
	serv_addr.sin_port=htons(port);

	okflag=1;
	int val=1;

	setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));

	if(bind(getDescriptor(),
		(struct sockaddr *) &serv_addr,
		sizeof(serv_addr))<0)
	{
		eDebug("[SERVERSOCKET] ERROR on bind() (%m)");
		okflag=0;
	}
	listen(getDescriptor(), 0);

	rsn->setRequested(eSocketNotifier::Read);
}
Пример #4
0
int eServerSocket::startListening(struct addrinfo *addr)
{
	struct addrinfo *ptr = addr;
	for (ptr = addr; ptr != NULL; ptr = ptr->ai_next)
	{
		if (setSocket(socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol), 1) < 0)
		{
			continue;
		}

		int val = 1;
		setsockopt(getDescriptor(), SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));

		if (bind(getDescriptor(), ptr->ai_addr, ptr->ai_addrlen) < 0)
		{
			eDebug("[eServerSocket] ERROR on bind: %m");
			close();
			continue;
		}
	}

	if (getDescriptor() < 0)
	{
		return -1;
	}

	if (listen(getDescriptor(), 0) < 0)
	{
		close();
		return -1;
	}
	return 0;
}
Пример #5
0
void eServerSocket::notifier(int)
{
	int clientfd;
	socklen_t clientlen;
	struct sockaddr client_addr;
	char straddr[INET6_ADDRSTRLEN];

#ifdef DEBUG_SERVERSOCKET
	eDebug("[SERVERSOCKET] incoming connection!");
#endif

	clientlen = sizeof(client_addr);
	clientfd = accept(getDescriptor(), &client_addr, &clientlen);
	if (clientfd < 0)
	{
		eDebug("[SERVERSOCKET] error on accept()");
		return;
	}

	if (client_addr.sa_family == AF_LOCAL)
	{
		strRemoteHost = "(local)";
	}
	else
	{
		strRemoteHost = inet_ntop(client_addr.sa_family, client_addr.sa_data, straddr, sizeof(straddr));
	}
	newConnection(clientfd);
}
Пример #6
0
static void *surfSubGetDescriptorsSub( THREAD_HANDLE_T *threadHandle )
{
    SurfSubGetDescriptorsParam  *arg;
    int                          startNum;
    int                          endNum;
    int                          i;
    
    arg = (SurfSubGetDescriptorsParam *)threadGetArg(threadHandle);
    
    for(;;) {
        if( threadStartWait(threadHandle) < 0 ) break;
        startNum = arg->startNum;
        endNum = arg->endNum;
        for( i = startNum; i <= endNum; i++ ) {
            if( getOrientation(&(arg->iPoint[i]), arg->image, arg->width, arg->height, arg->border) < 0 ) {
                arg->flag[i] = 0;
                continue;
            }
            if( getDescriptor(&(arg->iPoint[i]), arg->image, arg->width, arg->height, arg->border) < 0 ) {
                arg->flag[i] = 0;
                continue;
            }
            arg->flag[i] = 1;
        }
        threadEndSignal(threadHandle);
    }
    
    return NULL;
}
Пример #7
0
	xdl_int XdevLWindowServerAndroid::create(XdevLWindow** window, const XdevLWindowAttribute& attribute) {
		XdevLWindowAndroid* wnd = new XdevLWindowAndroid(nullptr, getDescriptor());
		wnd->create(attribute);
		*window = wnd;
		m_windowList[wnd->getWindowID()] = wnd;
		return RET_SUCCESS;
	}
Пример #8
0
void CastEffect::init(  CastCommandState* originState, int effectIdx, ICastEntity* from, bool isChannelEffect  )
{
	m_pParent = originState;
	m_pModel = originState->m_pModel;
	m_pModel->retain();
	m_modelEffectIndex = effectIdx;
	m_isChannelEffect = isChannelEffect;

	
	Json::Value json = getDescriptor();

	String type = json.get("effectType", "damage").asString();
	if( type.compare("damage") == 0 ){
		m_type = CET_DAMAGE_STAT;
	}else if( type.compare("heal") == 0 ) {
		m_type = CET_HEAL_STAT;
	}else if( type.compare("buff") == 0 ) {
		m_type = CET_BUFF_STAT;
	}else if( type.compare("debuff") == 0 ) {
		m_type = CET_SUPPRESS_STAT;
	}

	m_pOrigin = from;

	m_isAoeEffect = json.isMember("aoeRadius");
	m_damageType = json.get("damageType", "").asString(); //ex: fire
	m_targetStat = json.get("targetStat", "").asString(); //ex: hp_curr

	m_value = json.get("valueBase", 0.0f).asDouble(); //ex: 10 damage
	//todo: handle caster stat modifiers

	m_lifeTime = json.get("effectLifetime", 0.0f).asDouble(); //ex: 1.0 seconds

	m_tickFreq = json.get("tickFreq", m_tickFreq).asDouble();
}
Пример #9
0
bool CastEffect::hasReturnEffect()
{
	Json::Value json = getDescriptor();

	return json.isMember("returnEffect");

}
Пример #10
0
    void ServerImpl::addExternalDevice(std::string const &path,
                                       std::string const &deviceName,
                                       std::string const &server,
                                       std::string const &descriptor) {
        Json::Value descriptorVal;
        Json::Reader reader;
        if (!reader.parse(descriptor, descriptorVal)) {
            BOOST_ASSERT_MSG(0, "Should never get here - string descriptor "
                                "handed to us should have been generated from "
                                "a JSON value.");
            return;
        }
        m_callControlled([&] {
            /// Get the node
            auto &node = m_tree.getNodeByPath(path);

            /// Create the DeviceElement and set it as the node value
            auto elt = common::elements::DeviceElement{deviceName, server};
            elt.getDescriptor() = descriptorVal;
            node.value() = elt;
            m_treeDirty.set();

            /// Process device descriptor
            common::processDeviceDescriptorFromExistingDevice(node, elt);
        });
    }
Пример #11
0
bool Device::processSetupInRequest(SetupPacket * request, uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength) {
  // Device only handles standard requests.
  if (request->requestType() != SetupPacket::RequestType::Standard) {
    return false;
  }
  switch (request->bRequest()) {
    case (int) Request::GetStatus:
      return getStatus(transferBuffer, transferBufferLength, transferBufferMaxLength);
    case (int) Request::SetAddress:
      // Make sure the request is adress is valid.
      assert(request->wValue() < 128);
      /* According to the reference manual, the address should be set after the
       * Status stage of the current transaction, but this is not true.
       * It should be set here, after the Data stage. */
      setAddress(request->wValue());
      *transferBufferLength = 0;
      return true;
    case (int) Request::GetDescriptor:
      return getDescriptor(request, transferBuffer, transferBufferLength, transferBufferMaxLength);
    case (int) Request::SetConfiguration:
      *transferBufferLength = 0;
      return setConfiguration(request);
    case (int) Request::GetConfiguration:
      return getConfiguration(transferBuffer, transferBufferLength);
  }
  return false;
}
Пример #12
0
void PropertyObject::serialize ( ISerializeNode* _pNode )
{
    PropertiesDescriptor* pDesc = getDescriptor();
    if ( pDesc )
        pDesc->serializePropertyObject ( _pNode, this );
    else
        ex_warning ( "the Descriptor is not found!" );
}
Пример #13
0
String ObjectsSystem::getTypeName(PortalObjectType type) const
{
	shared_ptr<ObjectsIDescriptor> descriptor = getDescriptor(type);
	if(descriptor != nullptr)
		return descriptor->getTypeName();
	else
		return OS_PORTAL_OBJECT_UNKNOWN_TYPENAME;	
}
Пример #14
0
void BytecodeTranslatorVisitor::loadStore(const AstVar* x, bool load) {
    VarDescriptor* descriptor = getDescriptor(x);
    if (!load) descriptor->initialized = true;
    warningIf(load && !descriptor->initialized,
              ("Use of uninitialized var " + x->name()).c_str());

    if (descriptor->functionId == functionId())
        loadStoreLocal(descriptor->localIndex, x->type(), load);
    else
        loadStoreGlobal(descriptor, x->type(), load);
}
Пример #15
0
bool TextureListModel::isHighlited(const QModelIndex &index) const
{
	bool ret = false;
	DAVA::TextureDescriptor *descriptor = getDescriptor(index);

	if(NULL != descriptor)
	{
		ret = textureDescriptorsHighlight.contains(descriptor);
	}

	return ret;
}
Пример #16
0
DAVA::Texture* TextureListModel::getTexture(const QModelIndex &index) const
{
	DAVA::Texture *ret = NULL;
	DAVA::TextureDescriptor *desc = getDescriptor(index);

	if(index.isValid() && texturesAll.contains(desc))
	{
		ret = texturesAll[desc];
	}

	return ret;
}
Пример #17
0
PyObject* signalInstanceCall(PyObject* self, PyObject* args, PyObject* kw)
{
    PySideSignalInstance* PySideSignal = reinterpret_cast<PySideSignalInstance*>(self);
    if (!PySideSignal->d->homonymousMethod) {
        PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
        return 0;
    }

    descrgetfunc getDescriptor = PySideSignal->d->homonymousMethod->ob_type->tp_descr_get;
    Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod, PySideSignal->d->source, 0));
    return PyCFunction_Call(homonymousMethod, args, kw);
}
Пример #18
0
void Model::initializeDescriptorSets(ModelNode& node) {
    size_t i = 0;
    for (auto& node_data : node.mesh_data) {
        auto& mesh = _meshData[node_data.mesh_index];
        auto& material = _materials[mesh.material_index];

        auto descriptor_set = _renderer->createDescriptorSet(DescriptorSetType::ModelSet);
        descriptor_set->getDescriptor(DescriptorSetPart::ModelSet_DiffuseTexture)->setTexture(material.diffuse_texture.get());
        descriptor_set->getDescriptor(DescriptorSetPart::ModelSet_Uniforms)->setUniformBuffer(_nodeUniformData.get(),
                                                                                              _alignedUniformData.getOffset(
                                                                                                  node.index + i),
                                                                                              sizeof(ModelUniformData));

        node_data.model_descriptor_set = std::move(descriptor_set);

        ++i;
    }

    for (auto& child : node.child_nodes) {
        initializeDescriptorSets(*child);
    }
}
Пример #19
0
// Name: initialize_gdt
// Description: This function will create the global descriptor table and then loads the GDTR
// Parameter: -
// Return: - 
void initialize_gdt()
{

	struct descriptor null_entry, cs_entry, ds_entry;
	gdptr.base_address = (unsigned int)&global_desc_table;
	gdptr.size =(unsigned short int) sizeof(struct descriptor_table_entry)*3 - 1;	

	

	null_entry = getDescriptor(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	global_desc_table[0] = descriptortotableentry(null_entry);
	cs_entry = getDescriptor(0, 0xFFFFFFFF, 10, 1, 0, 0, 1, 1, 0, 1 );
	global_desc_table[1] = descriptortotableentry(cs_entry);
	ds_entry = getDescriptor(0, 0xFFFFFFFF, 2, 1, 0, 0, 1, 1, 0, 1 );
	global_desc_table[2] = descriptortotableentry(ds_entry);

	//putc('x');

	load_gdt();

	return;
}
Пример #20
0
cl_int IntelAccelerator::getInfo(cl_accelerator_info_intel paramName,
                                 size_t paramValueSize,
                                 void *paramValue,
                                 size_t *paramValueSizeRet) const {
    cl_int result = CL_SUCCESS;
    size_t ret = 0;

    switch (paramName) {
    case CL_ACCELERATOR_DESCRIPTOR_INTEL: {
        ret = getDescriptorSize();
        result = ::getInfo(paramValue, paramValueSize, getDescriptor(), ret);
    }

    break;

    case CL_ACCELERATOR_REFERENCE_COUNT_INTEL: {
        auto v = getReference();

        ret = sizeof(cl_uint);
        result = ::getInfo(paramValue, paramValueSize, &v, ret);
    }

    break;

    case CL_ACCELERATOR_CONTEXT_INTEL: {
        ret = sizeof(cl_context);
        cl_context ctx = static_cast<cl_context>(pContext);
        result = ::getInfo(paramValue, paramValueSize, &ctx, ret);
    }

    break;

    case CL_ACCELERATOR_TYPE_INTEL: {
        auto v = getTypeId();
        ret = sizeof(cl_accelerator_type_intel);
        result = ::getInfo(paramValue, paramValueSize, &v, ret);
    }

    break;

    default:
        result = CL_INVALID_VALUE;
        break;
    }

    if (paramValueSizeRet) {
        *paramValueSizeRet = ret;
    }

    return result;
}
Пример #21
0
 const std::set<std::string> &ImageEffectPlugin::getContexts() const {
   if (_madeKnownContexts) {
     return _knownContexts;
   } 
   else {
     const OFX::Host::Property::Set &eProps = getDescriptor().getProps();
     int size = eProps.getDimension(kOfxImageEffectPropSupportedContexts);
     for (int j=0;j<size;j++) {
       std::string context = eProps.getStringProperty(kOfxImageEffectPropSupportedContexts, j);
       addContextInternal(context);
     }
     return _knownContexts;
   }
 }
Пример #22
0
eServerSocket::eServerSocket(eString path, eMainloop *ml) : eSocket(ml, AF_LOCAL)
{
	struct sockaddr_un serv_addr;
	strRemoteHost = "";

	bzero(&serv_addr, sizeof(serv_addr));
	serv_addr.sun_family = AF_LOCAL;
	strcpy(serv_addr.sun_path, path.c_str());

	okflag=1;

	unlink(path.c_str());
	if(bind(getDescriptor(),
		(struct sockaddr *) &serv_addr,
		sizeof(serv_addr))<0)
	{
		eDebug("[SERVERSOCKET] ERROR on bind() (%m)");
		okflag=0;
	}
	listen(getDescriptor(), 0);

	rsn->setRequested(eSocketNotifier::Read);
}
Пример #23
0
int eSocket::setSocket(int s, int iss)
{
	socketdesc = s;
	if (socketdesc < 0) return -1;
	issocket = iss;
	fcntl(socketdesc, F_SETFL, O_NONBLOCK);
	last_break = -1;

	rsn = 0;
	rsn = eSocketNotifier::create(mainloop, getDescriptor(), 
		eSocketNotifier::Read|eSocketNotifier::Hungup);
	CONNECT(rsn->activated, eSocket::notifier);
	return 0;
}
Пример #24
0
int eSocket::setSocket(int s, int iss, eMainloop *ml)
{
	socketdesc=s;
	if (socketdesc < 0) return -1;
	issocket=iss;
	fcntl(socketdesc, F_SETFL, O_NONBLOCK);
	last_break = -1;

	if (rsn)
		delete rsn;  
	rsn=new eSocketNotifier(ml, getDescriptor(), 
		eSocketNotifier::Read|eSocketNotifier::Hungup);
	CONNECT(rsn->activated, eSocket::notifier);
	return 0;
}
Пример #25
0
nuiModuleDescriptor* nuiFactory::getDescriptor(const std::string &pipelineName,int id)
{
	if (pipelineDescriptors.find(pipelineName)==pipelineDescriptors.end())
		return NULL;
	nuiModuleDescriptor* pipelineDescriptor = pipelineDescriptors[pipelineName];
	nuiModuleDescriptor* tempChildDescriptor = pipelineDescriptor->getChildModuleDescriptor(id);
	if (tempChildDescriptor == NULL)
		return NULL;
	nuiModuleDescriptor* childDescriptor = getDescriptor(tempChildDescriptor->getName());
	if (childDescriptor == NULL)
		return NULL;
	childDescriptor->property("id") = new nuiProperty(id);
	for (std::map<std::string, nuiProperty*>::iterator iter = tempChildDescriptor->getProperties().begin();iter!= tempChildDescriptor->getProperties().end();iter++)
	{
		childDescriptor->property(iter->first) = iter->second;
	}
}
Пример #26
0
PyObject* signalCall(PyObject* self, PyObject* args, PyObject* kw)
{
    PySideSignal* signal = reinterpret_cast<PySideSignal*>(self);

    if (!signal->homonymousMethod) {
        PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
        return 0;
    }

    descrgetfunc getDescriptor = signal->homonymousMethod->ob_type->tp_descr_get;
    Shiboken::AutoDecRef homonymousMethod(getDescriptor(signal->homonymousMethod, 0, 0));

    if (PyCFunction_GET_FLAGS(homonymousMethod.object()) & METH_STATIC)
        return PyCFunction_Call(homonymousMethod, args, kw);

    ternaryfunc callFunc = signal->homonymousMethod->ob_type->tp_call;
    return callFunc(homonymousMethod, args, kw);
}
Пример #27
0
      PluginHandle *ImageEffectPlugin::getPluginHandle() 
      {
        if(!_pluginHandle.get()) {
          _pluginHandle.reset(new OFX::Host::PluginHandle(this, _pc.getHost())); 
          
          OfxPlugin *op = _pluginHandle->getOfxPlugin();
          
          if (!op) {
            _pluginHandle.reset(0);
            return 0;
          }

          OfxStatus stat;
          try {
#           ifdef OFX_DEBUG_ACTIONS
              std::cout << "OFX: "<<(void*)op<<"->"<<kOfxActionLoad<<"()"<<std::endl;
#           endif
            stat = op->mainEntry(kOfxActionLoad, 0, 0, 0);
#           ifdef OFX_DEBUG_ACTIONS
              std::cout << "OFX: "<<(void*)op<<"->"<<kOfxActionLoad<<"()->"<<StatStr(stat)<<std::endl;
#           endif
          } CatchAllSetStatus(stat, gImageEffectHost, op, kOfxActionLoad);

          if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) {
            _pluginHandle.reset(0);
            return 0;
          }
          
          try {
#           ifdef OFX_DEBUG_ACTIONS
              std::cout << "OFX: "<<(void*)op<<"->"<<kOfxActionDescribe<<"()"<<std::endl;
#           endif
            stat = op->mainEntry(kOfxActionDescribe, getDescriptor().getHandle(), 0, 0);
#           ifdef OFX_DEBUG_ACTIONS
              std::cout << "OFX: "<<(void*)op<<"->"<<kOfxActionDescribe<<"()->"<<StatStr(stat)<<std::endl;
#           endif
          } CatchAllSetStatus(stat, gImageEffectHost, op, kOfxActionDescribe);

          if (stat != kOfxStatOK && stat != kOfxStatReplyDefault) {
            _pluginHandle.reset(0);
            return 0;
          }
        }
Пример #28
0
void HumanClient::launch(struct timeval timeout){
	fd_set dsc;
	int inet = getDescriptor();
	int stdfd = STDIN_FILENO;
	struct timeval tmp;

	const int BUFFSIZE = 64;
	char buffer[BUFFSIZE];
	int length;


	while(true){
		FD_ZERO(&dsc);
		FD_SET(inet, &dsc);
		FD_SET(stdfd, &dsc);

		tmp = timeout;
		select(((inet>stdfd)?inet:stdfd)+1, &dsc, NULL, NULL, &tmp);

		if(FD_ISSET(stdfd, &dsc)){
			length = read(stdfd, buffer, BUFFSIZE);
			if(length != 0){
				send(buffer, length);
			}
		}
		if(FD_ISSET(inet, &dsc)){
			check(timeout);
			for(int i = 0; i <= PREFIX_QUANTITY; ++i){
				TypedClient::message_type type = TypedClient::message_type(i);
				while(!isEmpty(type)){
					char * s = getMessage(type);
					if(type != S_MACHINE && type != S_BROADCAST) {
						if(type == U_BROADCAST || type == U_PRIVATE){
							printf("[user message] ");
						}
						printf("%s", s);
					}
					free(s);
				}
			}
		}
	}
}
Пример #29
0
void eServerSocket::notifier(int)
{
	int clientfd, clientlen;
	struct sockaddr_in client_addr;

#ifdef DEBUG_SERVERSOCKET
	eDebug("[SERVERSOCKET] incoming connection!");
#endif

	clientlen=sizeof(client_addr);
	clientfd=accept(getDescriptor(),
			(struct sockaddr *) &client_addr,
			(socklen_t*)&clientlen);
	if(clientfd<0)
		eDebug("[SERVERSOCKET] error on accept()");

	strRemoteHost = inet_ntoa(client_addr.sin_addr);
	newConnection(clientfd);
}
Пример #30
0
/**
 * Dispatch an inbound operation to this service manager.
 *
 * @param message The message to process.
 */
void ServerMacroSpaceManager::dispatch(ServiceMessage &message)
{
    switch (message.operation)
    {
        case ADD_MACRO:
            addMacro(message);
            break;
        case ITERATE_MACRO_DESCRIPTORS:
            iterateMacros(message);
            break;
        case NEXT_MACRO_DESCRIPTOR:
            nextDescriptor(message);
            break;
        case GET_MACRO_IMAGE:
            getImage(message);
            break;
        case GET_MACRO_DESCRIPTOR:
            getDescriptor(message);
            break;
        case CLEAR_MACRO_SPACE:
            clear(message);
            break;
        case REMOVE_MACRO:
            deleteMacro(message);
            break;
        case QUERY_MACRO:
            queryMacro(message);
            break;
        case REORDER_MACRO:
            reorderMacro(message);
            break;
        case ITERATE_MACROS:
            iterateMacros(message);
            break;
        case NEXT_MACRO_IMAGE:
            nextImage(message);
            break;
        default:
            message.setExceptionInfo(INVALID_OPERATION, "Invalid macro space manager operation");
            break;
    }
}