BaseGDL* sem_create(EnvT *e)
  {
    SizeT nParam = e->NParam(1); // 1 is the minimal number of parameter required

    DString name;
    e->AssureStringScalarPar(0, name); // IDL accepts null-string name

    int destroyIx = e->KeywordIx("DESTROY_SEMAPHORE");
    bool destroyKWPresent = e->KeywordPresent(destroyIx);
    DLong destroy = 0;
    if (destroyKWPresent) 
    {
      destroy = (*e->GetKWAs<DLongGDL>(0))[0];
    }

    bool owner = true;
#if defined(_WIN32) && !defined(__CYGWIN__)
    // TODO: Needs error handling with name length > 256
    const char* cname = name.c_str();
    WCHAR tname[256] = {0,};

    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cname, strlen(cname), tname, 256);
    HANDLE sem = CreateSemaphoreW(NULL,1,1,tname);
    if (sem == NULL) {
	owner = false;
	return new DIntGDL(0);
    }
#else
    sem_t *sem = sem_open(name.c_str(), O_CREAT | O_EXCL, 0666, 1);
    if (sem == SEM_FAILED)
    {  // semaphore exists. make another one, locked (value=0)
      owner = false;
      if (errno == EEXIST)
      {
        sem = sem_open(name.c_str(), O_CREAT ,0666, 0);
      }
      if (sem == SEM_FAILED)
      {
        return new DIntGDL(0);
      }
    }
#endif

    // Behavior for different values of DESTROY_SEMAPHORE:
    // DESTROY_SEMAPHORE | owner    | other (== !owner)
    // ------------------+----------+-----------
    // not set           | delete   | ignore
    // != 0              | delete   | delete
    // 0                 | ignore   | ignore
    sem_data_t data;
    data.sem = sem;

    sem_set_owner(data, owner);
    sem_set_deletable(data, (!destroyKWPresent && owner) || (destroy != 0));
    sem_set_locked(data, false);

    sem_add(name, data);

    return new DIntGDL(1);
  }
Esempio n. 2
0
void ObjFileEditDialog::OnChangeAttributeHints(wxCommandEvent &e)
{

	if(NULL == m_pAttributeHintsComboBox
	|| NULL == m_pAttributeNameComboBox
	|| NULL == GetDataManipulatr())
		return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;
	
	DString Attributename = m_pAttributeNameComboBox->GetStringSelection().c_str();

	if(Attributename.empty())
		Attributename     = m_pAttributeNameComboBox->GetValue().c_str();

	DString AttributeHints = m_pAttributeHintsComboBox->GetStringSelection().c_str();

	bool bResult = pModel->ChangeHints(Attributename,AttributeHints);

	if(bResult)
	{
		wxMessageBox(wxString::Format("成功修改属性<%s>提示为<%s>!",Attributename.c_str(),AttributeHints.c_str()));
	}
	else
	{
		wxMessageBox(wxString::Format("操作失败!没有找到属性<%s>!",Attributename.c_str()));
	}
}
Esempio n. 3
0
void ObjFileEditDialog::OnChangeSlot(wxCommandEvent &e)
{
	if(NULL == m_pLocatorNameComboBox)
		return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	DString attachobjname		  = m_pAttachObjNameComboBox->GetStringSelection().c_str();

	DString slotname		      = m_pSlotNameComboBox->GetStringSelection().c_str();

	int nResult = pModel->ChangeSlot(slotname,attachobjname);

	if(0 == nResult)
	{
		wxMessageBox(wxString::Format("不存在slot<%s>对应的骨头,请检查美术资源!",slotname.c_str()));
	}
	else if(2 == nResult)
	{
		wxMessageBox(wxString::Format("属性slot<%s>的提示说明不为挂点!",slotname.c_str()));
	}
	else if(3 == nResult)
	{
		wxMessageBox(wxString::Format("未找到插槽slot<%s>对应的属性,请检查obj模板!",slotname.c_str()));
	}
}
Esempio n. 4
0
	sockaddr_in DSocket::parseAddress( const DString& addr, uint16 port )
	{
		sockaddr_in ret;
		std::memset(&ret, 0, sizeof(ret));

		if (addr.empty())
		{
			ret.sin_addr.s_addr = htonl(INADDR_ANY);
		}
		else
		{
			ret.sin_addr.s_addr = inet_addr(addr.c_str());
		}

		if (INADDR_NONE == ret.sin_addr.s_addr)
		{
			hostent* pHostEnt = gethostbyname(addr.c_str());
			if (pHostEnt != NULL)
			{
				std::memcpy(&ret.sin_addr.s_addr,
					pHostEnt->h_addr_list[0], pHostEnt->h_length);
			}
			else
			{
				DUEL_EXCEPT_BRIEF(DException::ET_InvalidParameters,
					"Invalid address: " + addr,
					"Duel::DSocket::parseAddress");	
			}
		}

		ret.sin_family = AF_INET;
		ret.sin_port = htons(port);

		return ret;
	}
Esempio n. 5
0
  BaseGDL* sem_create(EnvT *e)
  {
    SizeT nParam = e->NParam(1); // 1 is the minimal number of parameter required

    DString name;
    e->AssureStringScalarPar(0, name); // IDL accepts null-string name

    int destroyIx = e->KeywordIx("DESTROY_SEMAPHORE");
    bool destroyKWPresent = e->KeywordPresent(destroyIx);
    DLong destroy = 0;
    if (destroyKWPresent) 
    {
      destroy = (*e->GetKWAs<DLongGDL>(0))[0];
    }

    bool owner = true;
#ifdef _MSC_VER
    HANDLE sem = CreateSemaphore(NULL,1,1,name.c_str());
    if (sem == NULL) {
	owner = false;
	return new DIntGDL(0);
    }
#else
    sem_t *sem = sem_open(name.c_str(), O_CREAT | O_EXCL, 0666, 1);
    if (sem == SEM_FAILED)
    {
      owner = false;
      if (errno == EEXIST)
      {
        sem = sem_open(name.c_str(), 0);
      }
      if (sem == SEM_FAILED)
      {
        return new DIntGDL(0);
      }
    }
#endif

    // Behavior for different values of DESTROY_SEMAPHORE:
    // DESTROY_SEMAPHORE | owner    | other (== !owner)
    // ------------------+----------+-----------
    // not set           | delete   | ignore
    // != 0              | delete   | delete
    // 0                 | ignore   | ignore
    sem_data_t data;
    data.sem = sem;

    sem_set_owner(data, owner);
    sem_set_deletable(data, (!destroyKWPresent && owner) || (destroy != 0));
    sem_set_locked(data, false);

    sem_add(name, data);

    return new DIntGDL(1);
  }
Esempio n. 6
0
void DProcess::run()
{
	DString buffer;
	DString cmode;
	DStringList::iterator it;
	char * buf;
	int bufsize = 80 * sizeof( char );

	// construct exe line
	buffer = m_exe;
	for ( it = m_args.begin() ; it != m_args.end() ; ++it )
	{
		if ( !buffer.isEmpty() )
		{
			buffer.append( " " );
		}
		buffer.append( *it );
	}

	if ( m_com_mode == READ_ONLY)
	{
		cmode = "r";
	}
	else
	{
		cmode = "w";
	}
	m_file = popen( buffer.c_str(), cmode.c_str() );

	if ( !m_file )
	{
		return;
	}
	
	if ( m_com_mode == READ_ONLY)
	{
		buf = new char[ bufsize ];

		while ( fgets( buf, bufsize, m_file ) != 0 )
		{
			addOutput( buf );
		}
		delete[]( buf );
	}
	
	pclose( m_file );

	m_file = 0;
}
Esempio n. 7
0
File: grib.cpp Progetto: cenit/GDL
  BaseGDL* grib_get_size_fun(EnvT* e)
  {
#ifndef USE_GRIB
    e->Throw("GDL was compiled without support for GRIB");
    return NULL;
#else
    {
      SizeT nParam = e->NParam(2);
    }

    DLong gribid;
    e->AssureScalarPar<DLongGDL>(0, gribid);

    if (GribHandleList.find(gribid) == GribHandleList.end()) e->Throw("unrecognized message id: " + i2s(gribid));

    DString key;
    e->AssureScalarPar<DStringGDL>(1, key);

    size_t size;
    int err = GRIB_SUCCESS;
    if (GRIB_SUCCESS != (err = grib_get_size(GribHandleList[gribid], key.c_str(), &size)))
      e->Throw("failed to get size of: " + key + "\n%   GRIB API message: " + grib_get_error_message(err)); 

    return new DLongGDL(size);
#endif
  }
Esempio n. 8
0
int DServerSock::sendPacket ( int hSock, const DString & packet, bool checkSock )
{
	ssize_t numberChar;
	fd_set stFdSet;
	struct timeval stTime;
	DString buffer;
	long int timeout;

	if ( checkSock )
	{
		// check if socket is opened
		timeout = m_timeout;
		setTimeout ( 10 );
		m_status = readMessage ( hSock, buffer );
		setTimeout ( timeout );
	}

	if ( m_hSocket < 0 || m_status == NO_SOCKET )
	{
		m_status = NO_SOCKET;
		m_lastError = "No opened socket found";
		return m_status;
	}
	FD_ZERO ( &stFdSet );
	FD_SET ( hSock, &stFdSet );
	stTime.tv_sec = m_timeout;
	stTime.tv_usec = 0;

	if (m_debug)
	{
		printMessage(packet);
	}
	// Check if data can be sent without any blocking
	if ( ( select ( hSock+1, NULL, &stFdSet, NULL, &stTime ) != -1 ) &&
			  ( FD_ISSET ( hSock, &stFdSet ) ) )
	{
		numberChar = send ( hSock, packet.c_str(), packet.length(), 0 );
		if ( numberChar == static_cast<ssize_t> ( packet.length() ) )
		{
			m_lastError = "";
			m_status = SUCCESS;
		}
		else
		{
			m_lastError = "No data sent, ";
			m_lastError =  + strerror ( errno );
			m_status = NO_SEND;
		}
	}
	else
	{
		m_lastError = "No data sent, ";
		m_lastError =  + strerror ( errno );
		m_status = NO_SEND;
	}
	return m_status;
}
Esempio n. 9
0
void ObjFileEditDialog::OnDelSkeleton(wxCommandEvent &e)
{
	if(NULL == m_pSkeletonAdd
	|| NULL == m_pSkeletonName
	|| NULL == GetDataManipulatr())

	return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	DString skeletonname			  = m_pSkeletonName->GetStringSelection().c_str();

	if(skeletonname.empty())
	{
		wxMessageBox("请选择要删除的骨骼!");
		return;
	}

	int nSize = pModel->m_AniSkelist.size();

	DStringList::iterator it;

	for(int i=0;i<nSize;i++)
	{
		it = pModel->m_AniSkelist.begin()+i;

		if(skeletonname.compare(pModel->m_AniSkelist[i]) == 0)
		{
			pModel->m_AniSkelist.erase(it);
			break;
		}
	}

	Fairy::CGod::AniSkelistLink::iterator itlink = pModel->m_AniSkelistLink.find(skeletonname);

	if(itlink != pModel->m_AniSkelistLink.end())
	{
		pModel->m_AniSkelistLink.erase(skeletonname);
	}

	wxMessageBox(wxString::Format("删除骨骼<%s>成功!",skeletonname.c_str()));

	m_pSkeletonName->Clear();

	for(int i=0;i<(int)pModel->m_AniSkelist.size();i++)
	{
		m_pSkeletonName->AppendString(pModel->m_AniSkelist[i].c_str());
	}
}
Esempio n. 10
0
int32 DexSkinMesh::FindMaterial(DString materialName)
{
	int32 index = -1;
	for (size_t i = 0; i < m_vecMaterials.size(); ++i)
	{
		if (dexstrcmp(materialName.c_str(), m_vecMaterials[i].name) == 0)
		{
			index = i;
			break;
		}
	}
	return index;
}
Esempio n. 11
0
int DClientSock::openSock ( const DString & host, int port )
{
	string buffer;
	struct sockaddr_in serv_addr;
	struct hostent *host_addr;

	// Open the socket
	m_hSocket = socket ( AF_INET, SOCK_STREAM, 0 );
	if ( m_hSocket < 0 )
	{
		m_lastError = "Cannot open the socket, ";
		m_lastError += strerror ( errno );
		m_status = NO_SOCKET;
		return m_status;
	}

	// Connect socket to host
	memset ( reinterpret_cast<char *> ( &serv_addr ), 0x00, sizeof ( struct sockaddr_in ) );
	serv_addr.sin_family = AF_INET;

	host_addr = gethostbyname(host.c_str());
	if (!host_addr)
	{
		//m_lastError = "Cannot get address by hostname";
		m_lastError = "Cannot get address of hostname " + host + ", ";
		m_lastError += strerror ( errno );
		return NO_HOST;
	}
	serv_addr.sin_addr.s_addr = ((struct in_addr*) host_addr->h_addr)->s_addr;
	//serv_addr.sin_addr.s_addr =  inet_addr ( host.c_str() );
	serv_addr.sin_port = htons ( port );

	if ( connect ( m_hSocket, reinterpret_cast<struct sockaddr *> ( &serv_addr ),
	               sizeof ( serv_addr ) ) < 0 )
	{
		m_lastError = "Cannot connect to host " + host + ", ";
		m_lastError += strerror ( errno );
		m_status = NO_HOST;
		this->closeSock();
		return m_status;
	}
	m_lastError = "";
	m_status = SUCCESS;

	// to have an non-blocked socket
	fcntl ( m_hSocket, F_SETFL, O_NONBLOCK );

	return m_status;
}
Esempio n. 12
0
  BaseGDL* ncdf_groupdef(EnvT* e)
  {
    size_t nParam=e->NParam(2);

    DLong grpid;
    e->AssureLongScalarPar( 0, grpid);

    DString s;
    e->AssureScalarPar<DStringGDL>(1, s);

    int status;
    int new_grpid;

    status=nc_def_grp(grpid, s.c_str(), &new_grpid);
    ncdf_handle_error(e, status,"NCDF_GROUPDEF");

    return new DLongGDL(new_grpid);
  }
Esempio n. 13
0
void Search::readStrGraph(Patterns &patterns,StrGraph &desc) {
    clear();
    map<StrGraph::Node*,Node*> recollect;
    for(StrGraph::node_iter ni = desc.nodes().begin(); ni!=desc.nodes().end(); ++ni) {
        Node *n = create_node(gd<Name>(*ni));
        recollect[*ni] = n;
        SearchStage &stage = gd<SearchStage>(n);
        DString limit = gd<StrAttrs>(*ni).look("limit","50");
        stage.limit = atoi(limit.c_str());
        DString action = gd<StrAttrs>(*ni).look("action","union");
        if(action=="union")
            stage.type = UnionInquiry;
        else if(action=="intersection")
            stage.type = IntersectionInquiry;
        else if(action=="pattern") {
            stage.type = PatternInquiry;
            DString pattern = gd<StrAttrs>(*ni).look("pattern","");
            Patterns::iterator pi = patterns.find(pattern);
            if(pi==patterns.end())
                throw UndefinedPattern(pattern);
            stage.pattern = &pi->second;
        }
        else if(action=="path") {
            stage.type = PathInquiry;
            DString ways = gd<StrAttrs>(*ni)["ways"];
            if(ways=="in")
                stage.goIn = true, stage.goOut = false;
            else if(ways=="both")
                stage.goIn = stage.goOut = true;
            else  // ways=="out" default
                stage.goIn = false, stage.goOut = true;
            stage.firstOnly = gd<StrAttrs>(*ni)["firstonly"]=="true";
            stage.shortest = gd<StrAttrs>(*ni)["shortest"]=="true";
            stage.weightattr = gd<StrAttrs>(*ni).look("weightattr","weight");
        }
        else
            throw UnknownAction(action);
    }
    for(StrGraph::graphedge_iter ei = desc.edges().begin(); ei!=desc.edges().end(); ++ei) {
        Edge *e = create_edge(recollect[(*ei)->tail],recollect[(*ei)->head]).first;
        DString input = gd<StrAttrs>(*ei).look("input","");
        gd<Name>(e) = input;
    }
}
Esempio n. 14
0
  BaseGDL* ncdf_ncidinq(EnvT* e)
  {
 
    // it is mandatory to have 2 parameters !
    size_t nParam=e->NParam(2);

    // in fact, we can use the "grpid" to check the file format it-self.
    DLong grpid;
    e->AssureLongScalarPar( 0, grpid);

    DString s;
    e->AssureScalarPar<DStringGDL>(1, s);

    // before going further we have to chech the file format, must be NetCDF-4

    int status;
    int fileformat;
    status=nc_inq_format(grpid, &fileformat);
    ncdf_handle_error(e, status,"NCDF_NCIDINQ");

    if (fileformat == NC_FORMAT_CLASSIC) 
      Warning("NCDF_NCIDINQ: NetCDF 3 Classic format found. not OK");
    if (fileformat == NC_FORMAT_64BIT)
      Warning("NCDF_NCIDINQ: NetCDF 3 64-BIT format found. not OK");
    
    if ((fileformat == NC_FORMAT_64BIT) || (fileformat == NC_FORMAT_CLASSIC)) {
      return new DLongGDL(-1);
    }

    int sub_grpid;
    status=nc_inq_ncid(grpid, s.c_str(), &sub_grpid);

    if (status != 0) {
      if (status == -125) {
	Warning("NCDF_NCIDINQ: No group found. (NC_ERROR=-125)");      
	return new DLongGDL(-1);
      } else {
	ncdf_handle_error(e, status,"NCDF_NCIDINQ");
      }
    }
    return new DLongGDL(sub_grpid);

  }
Esempio n. 15
0
void ObjFileEditDialog::OnChangeEffect(wxCommandEvent &e)
{
	if(NULL == m_pEffectNameComboBox)
		return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	DString locatorname			  = m_pLocatorNameComboBox->GetStringSelection().c_str();

	if(locatorname.empty())
		locatorname			      = m_pLocatorNameComboBox->GetValue().c_str();

	if(locatorname.empty())
		return;

	std::vector<Ogre::String> locatorvec = Ogre::StringUtil::split(locatorname,"\\");

	if(locatorvec.size() < 2)
		return;

	const DString bone			  = locatorvec[0];

	const DString locator		  = locatorvec[1];

	DString effectname			  = m_pEffectNameComboBox->GetStringSelection().c_str();

	if(effectname.empty())
		return;

	std::vector<Ogre::String> effectvec = Ogre::StringUtil::split(effectname,".");

	const DString effect		  = effectvec[0];

	bool nResult = pModel->ChangeEffect(effect,locator,bone);

	if(!nResult)
	{
		wxMessageBox(wxString::Format("不存在特效对应的挂点<%s>,请检查美术资源!",locator.c_str()));
	}
}
Esempio n. 16
0
bool FileTools::makeDirectory( DString in_strDirectory )
{
	if (0 == chdir(in_strDirectory.c_str()))
	{
		return true;
	}
	DString tmp_strCmd = "";
#ifdef WIN32
	tmp_strCmd = "md " + in_strDirectory;
#else
	tmp_strCmd = "mkdir " + in_strDirectory;
#endif
	int tmp_iStatus = system(tmp_strCmd.c_str());
	if ( 0 != tmp_iStatus)
	{
		return false;
	}
	return true;
}
Esempio n. 17
0
  void sem_delete(EnvT *e)
  {
    SizeT nParam = e->NParam(1);

    DString name;
    e->AssureStringScalarPar(0, name);

    const sem_data_t &data = sem_get_data(name, e);
#if defined(_WIN32) && !defined(__CYGWIN__)
    CloseHandle(data.sem);
#else
    sem_close(data.sem);

    if (sem_is_deletable(data))
    {
      sem_unlink(name.c_str());
    }
#endif

    sem_remove(name);
  }
Esempio n. 18
0
void ObjFileEditDialog::OnAddSkeleton(wxCommandEvent &e)
{
	if(NULL == m_pSkeletonAdd
	|| NULL == m_pSkeletonTable
	|| NULL == m_pSkeletonName
	|| NULL == GetDataManipulatr())

	return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	DString skeletonname			  = m_pSkeletonTable->GetStringSelection().c_str();

	if(skeletonname.empty())
		skeletonname			      = m_pSkeletonTable->GetValue().c_str();

	if(skeletonname.empty())
	{
		wxMessageBox("请选择要添加的骨骼!");
		return;
	}

	pModel->m_AniSkelist.push_back(skeletonname);

	DStringList Anilist;

	pModel->m_AniSkelistLink.insert(Fairy::CGod::AniSkelistLink::value_type(skeletonname,Anilist));

	wxMessageBox(wxString::Format("添加骨骼<%s>成功!",skeletonname.c_str()));

	m_pSkeletonName->Clear();

	for(int i=0;i<(int)pModel->m_AniSkelist.size();i++)
	{
		m_pSkeletonName->AppendString(pModel->m_AniSkelist[i].c_str());
	}
}
Esempio n. 19
0
File: grib.cpp Progetto: cenit/GDL
  BaseGDL* grib_open_file_fun(EnvT* e)
  {
#ifndef USE_GRIB
    e->Throw("GDL was compiled without support for GRIB");
    return NULL;
#else
    {
      SizeT nParam = e->NParam(1);
    }

    DString filename;
    e->AssureScalarPar<DStringGDL>( 0, filename); 

    FILE* in = NULL; 
    // TODO: handle RO/RW parameters (but currently anyhow no write methods are implemented...)
    in = fopen(filename.c_str(), "r"); 
    if (!in) e->Throw("unable to open file: " + filename);

    DLong ifile = GribFileList.end()->first;
    GribFileList[ifile] = in;
 
    return new DLongGDL(ifile);
#endif
  }
Esempio n. 20
0
File: grib.cpp Progetto: cenit/GDL
  void grib_get_pro(EnvT* e)
  {
#ifndef USE_GRIB
    e->Throw("GDL was compiled without support for GRIB");
#else
    {
      SizeT nParam = e->NParam(3);
    }

    DLong gribid;
    e->AssureScalarPar<DLongGDL>(0, gribid);
    
    if (GribHandleList.find(gribid) == GribHandleList.end()) e->Throw("unrecognized message id: " + i2s(gribid));

    DString key;
    e->AssureScalarPar<DStringGDL>(1, key);
    
    int err = GRIB_SUCCESS, type = GRIB_TYPE_UNDEFINED;
    if (GRIB_SUCCESS != (err = grib_get_native_type(GribHandleList[gribid], key.c_str(), &type)))
      e->Throw("failed to get type of: " + key + "\n%   GRIB API message: " + grib_get_error_message(err));

    size_t size;
    if (GRIB_SUCCESS != (err = grib_get_size(GribHandleList[gribid], key.c_str(), &size)))
      e->Throw("failed to get size of: " + key + "\n%   GRIB API message: " + grib_get_error_message(err));

    BaseGDL* data;
 
    switch (type) 
    {
      case GRIB_TYPE_LONG: 
      {
        if (size == 1) 
        {
          data = new DLongGDL(0);
          err = grib_get_long(GribHandleList[gribid], key.c_str(), (long*)&(*(DLongGDL*)data)[0]);
        }
        else 
        {
          data = new DLongGDL(dimension(size), BaseGDL::NOZERO); 
          err = grib_get_long_array( GribHandleList[gribid], key.c_str(), (long*)&(*(DLongGDL*)data)[0], &size);
        }
        break;
      }
      case GRIB_TYPE_DOUBLE: 
      {
        if (size == 1)
        {
          data = new DDoubleGDL(0);
          err = grib_get_double(GribHandleList[gribid], key.c_str(), (double*) &(*(DDoubleGDL*)data)[0]);
        }
        else 
        {
          data = new DDoubleGDL(dimension(size), BaseGDL::NOZERO); 
          err = grib_get_double_array( GribHandleList[gribid], key.c_str(), (double*) &(*(DDoubleGDL*)data)[0], &size);
        }
        break;
      }
/*
      case GRIB_TYPE_STRING: 
      {
        data = new DStringGDL(dim, BaseGDL::NOZERO); 
        break;
      }
      case GRIB_TYPE_BYTES: 
      {
        data = new DByteGDL(dim, BaseGDL::NOZERO);
        break;
      }
*/
      default:
        e->Throw("unsupported native data type: " + string(grib_get_type_name(type)) + " (" + i2s(type) + ")");
    }

    if (err != GRIB_SUCCESS) 
      e->Throw("failed to get value[s] of: " + key + "\n%   GRIB API message: " + grib_get_error_message(err));

    GDLDelete(e->GetParGlobal(2));
    e->GetPar(2) = data;
#endif
  }
Esempio n. 21
0
void DLogEngineSyslog::insert ( const DString & text, Level loglevel )
{
	int sysloglevel = LOG_DEBUG;
	DString message;
	
	// write message only if loglevel is highter or equal to minimum log level
	// or not equal to NONE
	if ( ( loglevel < m_minLevel ) && ( loglevel != DLogShared::NONE ) )
	{
		return;
	}

	switch ( loglevel )
	{
		case DLogShared::NONE:
		case DLogShared::DEBUG:
		{
			sysloglevel = LOG_DEBUG;
			break;
		}

		case DLogShared::VERBOSE:
		{
			sysloglevel = LOG_NOTICE;
			break;
		}

		case DLogShared::INFO:
		{
			sysloglevel = LOG_INFO;
			break;
		}

		case DLogShared::SIGNALS:
		{
			sysloglevel = LOG_INFO;
			break;
		}

		case DLogShared::WARNING:
		{
			sysloglevel = LOG_WARNING;
			break;
		}

		case DLogShared::ERROR:
		{
			sysloglevel = LOG_ERR;
			break;
		}

		case DLogShared::CRITICAL:
		{
			sysloglevel = LOG_CRIT;
			break;
		}
	}
	message = "[";
	message.append( DLogParams::toString( loglevel ) );
	message.append( "] " );
	message.append( text );
	syslog ( sysloglevel, "%s", message.c_str() );
}