core::string VTSharedMemoryImpl::InjectCommand(const core::string& cmd, const core::string& args)
{
	if (!m_data->agent->data)
		return "";
	if (cmd.equals_ignore_case("calib"))
	{
		m_data->agent->data->status.calibration = true;
		m_data->agent->data->status.finger_calibrate = true;
		Update(0.01f);
		Sleep(20);
		m_data->agent->data->status.finger_calibrate = false;
		m_data->agent->data->status.calibration = false;
		return "done";
	}
	if (cmd.equals_ignore_case("done?"))
	{
		if (args.equals_ignore_case("glove"))
		{
			return "no";
		}
		if (args.equals_ignore_case("posture"))
		{
			return "no";
		}
	}
	return "";
}
Exemplo n.º 2
0
//! Changes the current Working Directory to the given string.
bool CFileSystem::changeWorkingDirectoryTo(const core::string<c16>& newDirectory)
{
	bool success=false;

	if (FileSystemType != FILESYSTEM_NATIVE)
	{
		WorkingDirectory[FILESYSTEM_VIRTUAL].append(newDirectory);
		flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], "");
		success = 1;
	}
	else
	{
		WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory;

#if defined(_IRR_USE_WINDOWS_CE_DEVICE_)
		success = true;
#elif defined(_MSC_VER)
	#if defined(_IRR_WCHAR_FILESYSTEM)
		success=(_wchdir(newDirectory.c_str()) == 0);
	#else
		success=(_chdir(newDirectory.c_str()) == 0);
	#endif
#else
		success=(chdir(newDirectory.c_str()) == 0);
#endif
	}

	return success;
}
Exemplo n.º 3
0
void Sqlite::re_key(core::string const& key)
{
    if (key.length())
        sqlite3_rekey(d_ptr->db, key.c_str(), key.length());
    else
        sqlite3_rekey(d_ptr->db, NULL, 0);
}
const mchar* getZzipError(zzip_error_t zzipError) 
{
	static core::string errorMsg;
    switch (zzipError)
    {
    case ZZIP_NO_ERROR:
        break;
    case ZZIP_OUTOFMEM:
        errorMsg = mT("Out of memory.");
        break;            
    case ZZIP_DIR_OPEN:
    case ZZIP_DIR_STAT: 
    case ZZIP_DIR_SEEK:
    case ZZIP_DIR_READ:
        errorMsg = mT("Unable to read zip file.");
        break;            
    case ZZIP_UNSUPP_COMPR:
        errorMsg = mT("Unsupported compression format.");
        break;            
    case ZZIP_CORRUPTED:
        errorMsg = mT("Corrupted archive.");
        break;            
    default:
        errorMsg = mT("Unknown error.");
        break;            
    };

    return errorMsg.c_str();
}
Exemplo n.º 5
0
core::string AlphabetFlow::prevValue(const core::string & value)
{
    char *ret = alphabetflow_prev(value.c_str(), (uint)value.length());
    core::string str = ret;
    free(ret);
    return str;   
}
Exemplo n.º 6
0
bool mdlWriter::canWrite(const core::string& fileName)
{
	int i=fileName.findlast('.');
	if(i==-1)
		return false;
	core::string s= fileName.substr(i+1,m_extension.length());
	return s.equals_ignore_case(m_extension);
}
Exemplo n.º 7
0
//! returns the directory part of a filename, i.e. all until the first
//! slash or backslash, excluding it. If no directory path is prefixed, a '.'
//! is returned.
core::string<c16> CFileSystem::getFileDir(const core::string<c16>& filename) const
{
	// find last forward or backslash
	s32 lastSlash = filename.findLast('/');
	const s32 lastBackSlash = filename.findLast('\\');
	lastSlash = lastSlash > lastBackSlash ? lastSlash : lastBackSlash;

	if ((u32)lastSlash < filename.size())
		return filename.subString(0, lastSlash);
	else
		return ".";
}
Exemplo n.º 8
0
bool delete_db()
{
    if (db == NULL)
        return false;
    
    // close db.
    close();
    
    // remove.
    DB* agent = NULL;
    if (db_create(&agent, NULL, 0) != 0)
    {
        trace_msg("failed to create agent bdb.");
        return false;
    }
    
    if (agent->remove(agent, dbpath.c_str(), NULL, 0) != 0)
    {
        trace_msg("failed to delete db.");
        return false;
    }
    
    // had free while remove.
    //agent->close(agent, DB_NOSYNC);

    return true;
}
bool OFSerialPort::OpenByName(const core::string& port,int baudRate)
{
	if(m_open)
		Close();
	m_open=m_sp->setup(port.c_str(),baudRate);
	return m_open;
}
Exemplo n.º 10
0
bool open(core::string const& file)
{
    this->close();
    
    fd.open(file.c_str(), ::std::ios_base::app | ::std::ios_base::out);
    if (!fd.is_open())
        return false;
    
    // open.
    appender = new log4cpp::OstreamAppender(file.c_str(), &fd);        
    log4cpp::PatternLayout* layout = new log4cpp::PatternLayout;
    layout->setConversionPattern("%d: %p %c %x: %m%n");
    appender->setLayout(layout);
    category->addAppender(appender);
    
    return true;
}
Exemplo n.º 11
0
Arquivo: App.cpp Projeto: imace/nnt
core::string Environment::workingDirectory()
{
    if (__preferred_workingdirectory.empty() == false)
        return __preferred_workingdirectory;

    char* path = (char*)malloc(PATH_MAX);
    core::string ret = getcwd(path, PATH_MAX);
    free(path);
    ret = core::dot(ret);
    return ret;
}
Exemplo n.º 12
0
//! determines if a file exists and would be able to be opened.
bool CFileSystem::existFile(const core::string<c16>& filename) const
{
	for (u32 i=0; i < FileArchives.size(); ++i)
		if ( FileArchives[i]->findFile(filename)!=-1)
			return true;

#if defined ( _IRR_WCHAR_FILESYSTEM )
	FILE* f = _wfopen(filename.c_str(), L"rb");
#else
	FILE* f = fopen(filename.c_str(), "rb");
#endif

	if (f)
	{
		fclose(f);
		return true;
	}

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return false;
}
Exemplo n.º 13
0
core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename) const
{
	c16 *p=0;

#if defined(_IRR_USE_WINDOWS_CE_DEVICE_)
	return filename;
#elif defined(_IRR_WINDOWS_API_)

	#if defined(_IRR_WCHAR_FILESYSTEM )
		c16 fpath[_MAX_PATH];
		p = _wfullpath(fpath, filename.c_str(), _MAX_PATH);
	#else
		c8 fpath[_MAX_PATH];
		p = _fullpath(fpath, filename.c_str(), _MAX_PATH);
	#endif

#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
	c8 fpath[4096];
	fpath[0]=0;
	p = realpath(filename.c_str(), fpath);
	if (!p)
	{
		// content in fpath is undefined at this point
		if ('0'==fpath[0]) // seems like fpath wasn't altered
		{
			// at least remove a ./ prefix
			if ('.'==filename[0] && '/'==filename[1])
				return filename.subString(2, filename.size()-2);
			else
				return filename;
		}
		else
			return core::string<c16>(fpath);
	}

#endif

	return core::string<c16>(p);
}
Exemplo n.º 14
0
NNT_BEGIN_HEADER_C

# include <openssl/des.h>
# include <math.h>

NNT_END_HEADER_C

NNT_BEGIN_CXX

void des::encrypt(char const* key, core::string const& in, core::vector<byte>& out)
{
    DES_cblock key_block;
    DES_key_schedule schedule;
    DES_string_to_key(key, &key_block);
    DES_set_key_checked(&key_block, &schedule);

    usize sz = (usize)ceil((double)in.size() / sizeof(DES_cblock)) * sizeof(DES_cblock);
    out.resize(sz);

    core::string::const_iterator iter = in.begin();
    DES_cblock* output = (DES_cblock*)core::pointer(out);

    DES_cblock input;
    while (iter != in.end())
    {
        usize sz = in.end() - iter;
        if (sz >= 8)
            sz = 8;
        else
            memset(input, 0, sizeof(DES_cblock));
        memcpy(input, &*iter, sz);
        DES_ecb_encrypt(&input, output, &schedule, DES_ENCRYPT);
        iter += sz;
        output += 1;
    }
}
Exemplo n.º 15
0
//! returns the base part of a filename, i.e. all except for the directory
//! part. If no directory path is prefixed, the full name is returned.
core::string<c16> CFileSystem::getFileBasename(const core::string<c16>& filename, bool keepExtension) const
{
	// find last forward or backslash
	s32 lastSlash = filename.findLast('/');
	const s32 lastBackSlash = filename.findLast('\\');
	lastSlash = core::max_(lastSlash, lastBackSlash);
	s32 end = 0;
	if (!keepExtension)
	{
		end = filename.findLast('.');
		if (end == -1)
			end=0;
		else
			end = filename.size()-end;
	}

	if ((u32)lastSlash < filename.size())
		return filename.subString(lastSlash+1, filename.size()-lastSlash-1-end);
	else if (end != 0)
		return filename.subString(0, filename.size()-end);
	else
		return filename;
}
Exemplo n.º 16
0
bool ofGstUtils::setPipelineWithSink(const core::string &pipeline, const core::string & sinkname, bool isStream){
	ofGstUtils::startGstMainLoop();

	gchar* pipeline_string =
		g_strdup((pipeline).c_str());

	GError * error = NULL;
	gstPipeline = gst_parse_launch (pipeline_string, &error);

	gLogManager.log( core::string("gstreamer pipeline: ")+ pipeline_string,ELL_INFO);
	if(error!=NULL){
		gLogManager.log(core::string("couldnt create pipeline: ") + error->message,ELL_WARNING);
		return false;
	}

	gstSink = gst_bin_get_by_name(GST_BIN(gstPipeline),sinkname.c_str());

	if(!gstSink){
		gLogManager.log( "couldn't get sink from string pipeline",ELL_WARNING);
	}

	return setPipelineWithSink(gstPipeline,gstSink,isStream);
}
Exemplo n.º 17
0
core::data md5::hex(core::string const& str)
{
    core::data re(MD5_DIGEST_LENGTH);
    MD5((byte*)str.c_str(), str.length(), core::pointer(re));
    return re;
}
Exemplo n.º 18
0
core::string md5::digest(core::string const& str)
{
    core::data re(MD5_DIGEST_LENGTH);
    MD5((byte*)str.c_str(), str.length(), core::pointer(re));
    return core::present_cast<core::string>(re);
}
bool BrowserWindow::NavigateToUrl(const core::string& url)
{
	return m_impl->GetWindow()->navigateTo(url.c_str(),url.length());
}
Exemplo n.º 20
0
const mchar* getMessage(int msgCode){

	static core::string msgStr;
	switch(msgCode){
		case HMSG_NET_START:
			msgStr+=mT("Network startup.");
			break;
		case HMSG_SOCKET_OPEN:
			msgStr+=mT("Socket Open.");
			break;
		case HMSG_TCP_SOCKET_CREATE:
			msgStr+=mT("TCP Socket Create.");
			break;
		case HMSG_UDP_SOCKET_CREATE:
			msgStr+=mT("UDP Socket Create.");
			break;
		case HMSG_GETHOST:
			msgStr+=mT("Get Host Name.");
			break;
		case HMSG_BIND:
			msgStr+=mT("socket Bind.");
			break;
		case HMSG_GETSOCKNAME:
			msgStr+=mT("Getting socket name.");
			break;
		case HMSG_ACCEPT:
			msgStr+=mT("accept data.");
			break;
		case HMSG_LISTEN:
			msgStr+=mT("Socket Listning.");
			break;
		case HMSG_FIND_REMOTE_HOST:
			msgStr+=mT("Find Remote Host.");
			break;
		case HMSG_CREATE_CONNECTION:
			msgStr+=mT("Creating Connection to Remote Host.");
			break;
		case HMSG_SEND:
			msgStr+=mT("Send Data.");
			break;
		case HMSG_RECIVE:
			msgStr+=mT("Recive Data.");
			break;
		case HMSG_SERVER_LOST:
			msgStr+=mT("Server Lost.");
			break;
		case HMSG_CANOT_CONNECT:
			msgStr+=mT("Cann't connect to server.");
			break;
		case HMSG_MAX_CLIENTS:
			msgStr+=mT("Max Clients Reached.");
			break;
		case HMSG_CLIENT_LOST:
			msgStr+=mT("Client Lost.");
			break;
		case HMSG_SETBROADCAST:
			msgStr+=mT("set Broadcast.");
			break;
		case HMSG_BROADCAST:
			msgStr+=mT("Broadcasting!.");
			break;
		case HMSG_TIMEOUT:
			msgStr+=mT("timeout!.");
			break;
		case HMSG_UNREACHABLEHOST:
			msgStr+=mT("Unreachable remote host!.");
			break;

		default:
			msgStr+=mT("Unkwon.");
			break;
	}


	return msgStr.c_str();
}
int UnicodeEncoding::GetBytesCount(const core::string& str)
{
	return str.length()*2;
}
int UnicodeEncoding::GetBytes(const core::string& str,byte* buff,int maxLen)
{
	return GetBytes(&str[0],str.length(),buff,maxLen);
}
Exemplo n.º 23
0
bool luaengine::eval(const core::string & code)
{
	return _state(code.c_str());
}
Exemplo n.º 24
0
void Sqlite::set_key(core::string const& key)
{
    sqlite3_key(d_ptr->db, key.c_str(), key.length());
}
Exemplo n.º 25
0
bool luaengine::load(const core::string & file)
{
	//TODO - actually load file from packages
	return _state.load(file.c_str());
}
Exemplo n.º 26
0
sel::selector luaengine::operator [] (const core::string & variable)
{
	return _state[variable.c_str()];
}
Exemplo n.º 27
0
Error::Error(const core::string& message)
	: std::runtime_error(message.c_str())
{
}