Пример #1
0
static cString LastDir(const char *dir)
{
  const char *pt = strrchr(dir, '/');
  if (pt && pt[0] && pt[1])
    return cString(pt+1);
  return cString(NULL);
}
Пример #2
0
cTimeAndDate::cTimeAndDate() {
	time_t now;
	time(&now);
	char dateandtime[26];
	strcpy(dateandtime, asctime(localtime(&now)));


        strtok(dateandtime," \t"); // strip off 0th string
        thismonth=GetMonth(strtok(NULL," \t"));
	
        thisday.ofthemonth=cString(strtok(NULL," \t")).GetInt();

	strtok(NULL," \t"); //strip off more garbage so we can get the year
        thisyear=cString(strtok(NULL," \t")).GetInt();
	
	
	
	
	*this=cTimeAndDate(thismonth,thisday.ofthemonth,thisyear);
	
	timeofday[0]=12;
	for(int i=1; i<13; i++) {
		timeofday[i]=i;
		timeofday[i+12]=i;
	}
	Refresh();
	
}
Пример #3
0
void cException::print()
{
#ifdef DOT_NET
    // .NET application
  System::Console::WriteLine(getMessage());
#else
    // Normal Win32 application
    cString whereString;
    cString whatString = cString("Exception: message: ") << getMessage() << endl;
    whereExceptionOccured(whereString);
    whereString = cString("Exception: origin: ") << whereString << endl;

    TRACE(TRACE_VERY_HIGH, whatString);
    TRACE(TRACE_VERY_HIGH, whereString);

#ifndef XSTL_NTDDK
    cerr << whatString.getBuffer();
    cerr << whereString.getBuffer();
#endif

#if defined XSTL_WINDOWS
    //::MessageBox(NULL, getMessage(), XSTL_STRING("Exception"), MB_OK | MB_ICONSTOP);
#endif

#endif
}
Пример #4
0
cString::cString(const uint64 number,
                 uint        base   /* = DefaultStringBase*/,
                 uint        optMem /* = DefaultStringPage*/) :
    m_buffer(NULL),
    m_stringLength(0)
{
    ASSERT_MSG(base < cChar::getStrlen(m_baseStrip),
               XSTL_STRING("cString: There isn't engouth strip for conversion operation."));

    // Init members
    createEmptyString(optMem);

    uint digit = 0;  // The digit to convert
    uint64 x   = 0;  // The left number

    x = number;

    if (number == 0)
    {
        *this = cString(m_baseStrip[0]);
    }

    // Start with converting
    while (x > 0)
    {
        digit = x % base;
        x     = x / base;

        *this = cString(m_baseStrip[digit]) + *this;
    }
}
Пример #5
0
bool cRow::fetchColumn(cString* Column, cString* Value){
    char *Col, *Val;
    bool ret = this->fetchColumn(&Col, &Val);
    if(ret){
        *Column = cString(Col,true);
        *Value = cString(Val,true);
    }
    return ret;
}
Пример #6
0
tResult cSensorAnalyzer::LoadConfigurationData(cString filename)
{
    //Get path of configuration file
    //EDS macro is resolved automatically because it is a file property
    m_fileConfig = filename;//GetPropertyStr("Filename for Sensorpresets");

    if (m_fileConfig.IsEmpty())
        LOG_WARNING("Configuration file not found for Analyzer");    

    ADTF_GET_CONFIG_FILENAME(m_fileConfig);
    m_fileConfig = m_fileConfig.CreateAbsolutePath(".");

    if (cFileSystem::Exists(m_fileConfig))
    {
        cDOM oDOM;
        oDOM.Load(m_fileConfig);
        cDOMElementRefList oElems;
        if(IS_OK(oDOM.FindNodes("presets/sensorPreset", oElems)))
        {                
            for (cDOMElementRefList::iterator itElem = oElems.begin(); itElem != oElems.end(); ++itElem)
            {
                cDOMElement* pConfigElement;
                tSensorPreset newSensorPreset;
                if (IS_OK((*itElem)->FindNode("sensor", pConfigElement)))
                {
                    newSensorPreset.sensorName = cString(pConfigElement->GetData());
                    if (IS_OK((*itElem)->FindNode("nominalValue", pConfigElement)))
                        newSensorPreset.nominalValue = static_cast<tFloat32>(cString(pConfigElement->GetData()).AsFloat64());
                    if (IS_OK((*itElem)->FindNode("maxPosDeviation", pConfigElement)))
                        newSensorPreset.maxPosDeviation = static_cast<tFloat32>(cString(pConfigElement->GetData()).AsFloat64());
                    if (IS_OK((*itElem)->FindNode("maxNegDeviation", pConfigElement)))
                        newSensorPreset.maxNegDeviation = static_cast<tFloat32>(cString(pConfigElement->GetData()).AsFloat64());
                }          
                /*LOG_INFO(cString::Format("Name %s, Nominal: %f, NegDev: %f, PosDev: %f",
                newSensorPreset.sensorName.GetPtr(),
                newSensorPreset.nominalValue,
                newSensorPreset.maxNegDeviation,
                newSensorPreset.maxPosDeviation
                ));*/
                addParsedElement(newSensorPreset);
            }        
        }
        else
        {
            LOG_WARNING("Configured configuration file does not contain valid xml scheme");
        }
    }
    else
    {
        LOG_WARNING("Configured configuration file not found (yet).Will appear after extracting the extended data");
    }

    RETURN_NOERROR;
}
Пример #7
0
void Gdb::stack(const QString& data)
{
	QStringList frames = data.split("frame=");
	frames.removeFirst(); // Just the opening stuff
	foreach(const QString& frame, frames) {
		Frame f;
		qWarning() << frame;
		f.function = cString(frame, after(frame, "func="));
		f.file = cString(frame, after(frame, "file="));
		f.line = cString(frame, after(frame, "line=")).toInt();
		f.origin = cString(frame, after(frame, "shlibname="));
		qWarning() << f.function << f.file << f.line;
		m_frames.append(f);
	}
Пример #8
0
void Gdb::stopped(const QString& data)
{
	qWarning() << "STOPPED!";
	QString runningTime = cString(data, after(data, "wallclock="));
	QString reason = cString(data, after(data, "reason="));
	if(m_responder) m_responder->writeStdout("Program Stopped. Running Time: " + runningTime + ", Reason: " + reason + "\n");
	
	if(reason == "exited-normally") {
		m_run = false;
		m_libs.clear();
		if(m_responder) m_responder->programStopped();
	} else {
		if(m_responder) m_responder->programPaused();
	}
}
Пример #9
0
void CCheckerCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here

	//Fill the background color of the client area
	dc.FillRect(m_rcClient, &m_backgroundBrush);
	dc.SetBkMode(TRANSPARENT);

	UINT nColumn = 0, nRow = 0;
	
	//Calculate the index of the last visible block
	//within the client area
	UINT nBlockEndPos = m_nBlockStartPos + m_nTotalVisibleBlocks + m_nBlocksPerRow;
	if(nBlockEndPos > m_nNumberofBlocks)
		nBlockEndPos = m_nNumberofBlocks;

	for(UINT i = m_nBlockStartPos; i < nBlockEndPos; i++)
	{
		CString cString(m_crText.GetAt(i));
		if (cString.GetLength())
		{
			CBrush brush(m_crColor.GetAt(i));
			SetBlock(nRow, nColumn, brush, dc, cString);
		}
		if((i + 1 - m_nBlockStartPos) % m_nBlocksPerRow == 0)
		{
			nRow++;
			nColumn = 0;
		}
		else
			nColumn++;
	}
}
Пример #10
0
void cException::whereExceptionOccured(cString& ret)
{
    // XXX: NOT PORTABLE!
    ret = m_atFile;
    ret.concat(":");
    ret+= cString(m_atLine, 10, 10);
}
Пример #11
0
cString cString::mid(uint index, int size) const
{
    // Incase the size is negative...
    if (size <= 0) return cString();

    return part(index, index + size);
}
Пример #12
0
cString cTestObject::randomizeName(uint maxNumberOfDigits)
{
    CHECK(maxNumberOfDigits > 0);
    uint rnd = (cOSRand::rand() % (maxNumberOfDigits - 1)) + 1;
    cSArray<character> ret(rnd + 1);
    ret[rnd] = 0;
    for (uint i = 0; i < rnd; i++)
    {
        switch (cOSRand::rand() % 4)
        {
        case 0:
            ret[i] = (character)((cOSRand::rand() % 26) + 'a');
            break;
        case 1:
            ret[i] = (character)((cOSRand::rand() % 26) + 'A');
            break;
        case 2:
            ret[i] = (character)((cOSRand::rand() % 10) + '0');
            break;
        case 3:
            switch (cOSRand::rand() % 4)
            {
            case 0: ret[i] = '.'; break;
            case 1: ret[i] = '@'; break;
            case 2: ret[i] = '_'; break;
            case 3: ret[i] = '-'; break;
            }
        }
    }
    return cString(ret.getBuffer());
}
Пример #13
0
cString cPluginRssReader::SVDRPCommand(const char *commandP, const char *optionP, int &replyCodeP)
{
  if (strcasecmp(commandP, "LOAD") == 0) {
     if (!RssItems.Load(RssReaderConfig.GetConfigFile())) {
        replyCodeP = 550; // Requested action not taken
        return cString("Configuration file not found!");
        }
     return cString("Configuration file loaded");
     }
  else if (strcasecmp(commandP, "TRAC") == 0) {
     if (optionP && *optionP)
        RssReaderConfig.SetTraceMode(strtol(optionP, NULL, 0));
     return cString::sprintf("Tracing mode: 0x%04X\n", RssReaderConfig.GetTraceMode());
     }
  return NULL;
}
Пример #14
0
cString basicInput::readAsciiPascal16String(const uint numberOfCharacter /* = MAX_CHAR */)
{
    uint16 length;

    // Read the length
    streamReadUint16(length);

    if (length > numberOfCharacter)
    {
        // Invalid number of characters
        XSTL_THROW(cException, EXCEPTION_READ_ERROR);
    }

    // Allocate dynamic memory
    cBuffer string(length + 1);

    // Read all bytes
    uint read = pipeRead(string.getBuffer(), length);
    if (read != length)
    {
        // EOF reached!
        XSTL_THROW(cException, EXCEPTION_READ_ERROR);
    }
    string[length] = 0;

    return cString((char *)string.getBuffer());
}
Пример #15
0
cString cSatipDevice::GetSatipStatus(void)
{
  cString info = "";
  for (int i = 0; i < cDevice::NumDevices(); i++) {
      const cDevice *device = cDevice::GetDevice(i);
      if (device && strstr(device->DeviceType(), "SAT>IP")) {
         int timers = 0;
         bool live = (device == cDevice::ActualDevice());
         bool lock = device->HasLock();
         const cChannel *channel = device->GetCurrentlyTunedTransponder();
         for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
             if (timer->Recording()) {
                cRecordControl *control = cRecordControls::GetRecordControl(timer);
                if (control && control->Device() == device)
                   timers++;
                }
            }
         info = cString::sprintf("%sDevice: %s\n", *info, *device->DeviceName());
         if (lock)
            info = cString::sprintf("%sCardIndex: %d  HasLock: yes  Strength: %d  Quality: %d%s\n", *info, device->CardIndex(), device->SignalStrength(), device->SignalQuality(), live ? "  Live: yes" : "");
         else
            info = cString::sprintf("%sCardIndex: %d  HasLock: no\n", *info, device->CardIndex());
         if (channel && channel->Number() > 0)
            info = cString::sprintf("%sTransponder: %d  Channel: %s\n", *info, (channel && channel->Number() > 0) ? channel->Transponder() : 0, (channel && channel->Number() > 0) ? channel->Name() : "---");
         if (timers)
            info = cString::sprintf("%sRecording: %d timer%s\n", *info, timers, (timers > 1) ? "s" : "");
         info = cString::sprintf("%s\n", *info);
         }
      }
  return isempty(*info) ? cString(tr("SAT>IP information not available!")) : info;
}
Пример #16
0
void Gdb::parse(const QByteArray& inputs)
{
	foreach(const QByteArray& input, inputs.split('\n')) {
		qWarning() << "line" << input;
		if(input.startsWith("~")) { if(m_responder) { m_responder->writeDebugState(cString(input.data(), 1)); } }
		else if(input.startsWith("^error")) { if(m_responder) { m_responder->writeStderr(cString(input.data(), after(input.data(), "msg="))); } }
		else if(input.startsWith("^done,stack=")) stack(input.data());
		else if(input.startsWith("^done,stack-args=")) stackArgs(input.data());
		else if(input.startsWith("^done,locals=")) locals(input.data());
		else if(input.startsWith("^done,BreakpointTable=")) breakpointTable(input.data());
		else if(input.startsWith("^done,bkpt="));
		else if(input.startsWith("^done")) { if(m_responder) { m_responder->writeDebugState(cString(input.data(), after(input.data(), "reason="))); } }
		else if(input.startsWith("*stopped")) stopped(input.data());
		else if(input.startsWith("=shlibs-added")) m_libs += shlibsAdded(input.data());
	}
	if(m_responder) m_responder->update();
}
Пример #17
0
cString cTimeAndDate::ToString() { 

	cString m,d,y;
	
	if(thismonth<10) m="0"+cString(thismonth);
	else m=thismonth;

	if(thisday.ofthemonth<10) d="0"+cString(thisday.ofthemonth);
	else d=thisday.ofthemonth;
	
	if(thisyear>=2000) y=thisyear-2000;
	else y=thisyear-1900;
	
	if(y.AtoI()<10) y="0"+y;
	
	return m+d+y;
}
Пример #18
0
cString cString::right(int size) const
{
    cString ret;

    if (size > (int)length())
    {
        size = (int)length();
    }
    if (size <= 0)
    {
        return cString();
    }

    /* Create the return string */
    /* Copy the array */
    return cString(m_buffer->getBuffer() + length() - size, m_buffer->getPageSize());
}
Пример #19
0
INTERNAL String shaderSourceFromFile(const String& filename)
{
	String filePath = BaseDirectory::Shaders + filename;

	std::ifstream file;
	file.open(cString(filePath), std::ios::in | std::ios::binary);
	if (!file.is_open())
	{
		panic("Failed to open shader file: " + filePath);
		return {};
	}
	defer(file.close());

	String output;

	String line;

	while (file.good())
	{
		getline(file, line);
		line = Strings::trimSpace(line);

		if (Strings::hasPrefix(line, "#include"))
		{
			String includeFilename = substring(line, 8, len(line));
			includeFilename = Strings::trimSpace(includeFilename);
			includeFilename = Strings::trim(includeFilename, "\"");

			if (len(includeFilename) > 0)
			{
				// Recursively append source of header file and append header
				// extension
				const String& withExt = cString(includeFilename + ".head.glsl");
				append(output, shaderSourceFromFile(withExt));
			}
		}
		else
		{
			append(output, line);
		}
		append(output, '\n'); // Append a *nix newline
	}

	return output;
}
Пример #20
0
//-----------------------------------------------------------------------------
CPUTResult CPUTRenderStateBlockDX11::LoadRenderStateBlock(const cString &fileName)
{
    // TODO: If already loaded, then Release() all the old members

    // use the fileName for now, maybe we'll add names later?
    mMaterialName = fileName;

    // Open/parse the file
    CPUTConfigFile file;
    CPUTResult result = file.LoadFile(fileName);
    ASSERT( !FAILED(result), _L("Failed loading file: '") + fileName + _L("'.") );

    // Note: We ignore "not found error" results for ReadProperties() calls.
    // These blocks are optional.
    UINT ii;
    for( ii=0; ii<8; ii++ )
    {
        wchar_t pBlockName[64];
        wsprintf( pBlockName, _L("RenderTargetBlendStateDX11_%d"), ii+1 );
        ReadProperties( file, cString(pBlockName), pRenderTargetBlendDescMap, &mStateDesc.BlendDesc.RenderTarget[ii] );
    }
    ReadProperties( file, _L("BlendStateDX11"),        pBlendDescMap,        &mStateDesc.BlendDesc );
    ReadProperties( file, _L("DepthStencilStateDX11"), pDepthStencilDescMap, &mStateDesc.DepthStencilDesc);
    ReadProperties( file, _L("rasterizerstateDX11"),   pRasterizerDescMap,   &mStateDesc.RasterizerDesc);

    mNumSamplers = 0;
    for( ii=0; ii<D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ii++ )
    {
        // TODO: Use sampler names from .fx file.  Already did this for texture names.
        // The challenge is that the renderstate file is independent from the material (and the shaders).
        // Another feature is that the artists don't name the samplers (in the CPUTSL source).  Though, arbitrary .fx files can.
        // TODO: Add sampler-state properties to CPUTSL source (e.g., filter modes).  Then, have ShaderGenerator output a .rs file.
        wchar_t pBlockName[64];
        wsprintf( pBlockName, _L("SamplerDX11_%d"), ii+1 );
        CPUTResult result = ReadProperties( file, cString(pBlockName), pSamplerDescMap, &mStateDesc.SamplerDesc[ii] );
        if( CPUT_SUCCESS != result )
        {
            break; // Reached last sampler spec
        }
        ++mNumSamplers;
    }
    CreateNativeResources();

    return CPUT_SUCCESS;
} // CPUTRenderStateBlockDX11::LoadRenderStateBlock()
Пример #21
0
bool parseFloat(String s, f32& f)
{
	f32 out;
	if (sscanf(cString(s), "%f", &out) != 1)
		return false;

	f = out;
	return true;
}
Пример #22
0
bool parseFloat(String s, f64& f)
{
	f64 out;
	if (sscanf(cString(s), "%g", &out) != 1)
		return false;

	f = out;
	return true;
}
Пример #23
0
Файл: e1-24.c Проект: theme/K_R
char cquotes(char q){
    if( q == '\'' )
        return cCharConst();
    if( q == '\"' )
        return cString();
    else
        errc("not a quotes start", q);
    return q;
}
Пример #24
0
cString basicInput::readFixedSizeString(uint numberOfCharacters, int unicodeSize)
{
    cBuffer buffer((numberOfCharacters + 1) * unicodeSize);
    uint8* buf = buffer.getBuffer();
    pipeRead(buf, numberOfCharacters * unicodeSize);
    if (unicodeSize > 1)
    {
        buf[numberOfCharacters * unicodeSize] = 0;
        cBuffer ret(sizeof(character) * (numberOfCharacters + 1));
        character* retBuf = (character*)ret.getBuffer();
        cChar::covert2string(retBuf, numberOfCharacters+1, buf, unicodeSize);
        return cString(retBuf);
    } else
    {
        buf[numberOfCharacters] = 0;
        return cString((char*)buf);
    }
}
Пример #25
0
cSerialStream::cSerialStream(uint comport,
                             cSerialPort::BaudRate baudRate,
                             uint bitSize,
                             cSerialPort::ParityBit parity,
                             cSerialPort::StopBit stopBits) :
    m_serialHandle(cString(ntobjectComPrefix) + cString(comport),
                   cFile::READ | cFile::WRITE)
{
    initSeek();
    // Configure the stream
    cOSDef::fileHandle comHandle = m_serialHandle.getHandle()->getHandle();
    DCB dcb;
    CHECK(GetCommState(comHandle, &dcb));
    dcb.BaudRate = baudRate;
    dcb.ByteSize = bitSize;
    dcb.Parity   = parity;
    dcb.StopBits = stopBits;
    CHECK(SetCommState(comHandle, &dcb));
}
Пример #26
0
bool parseUint(String s, int base, u64& u)
{
	// TODO(bill): handle base
	u8 out;
	if (sscanf(cString(s), "%llu", &out) != 1)
		return false;

	u = out;
	return true;
}
Пример #27
0
void cSatipMenuInfo::UpdateInfo()
{
  cSatipDevice *device = cSatipDevice::GetSatipDevice(cDevice::ActualDevice()->CardIndex());
  if (device)
     textM = device->GetInformation(pageM);
  else
     textM = cString(tr("SAT>IP information not available!"));
  Display();
  timeoutM.Set(eInfoTimeoutMs);
}
Пример #28
0
bool parseInt(String s, int base, s32& i)
{
	// TODO(bill): handle base
	s32 out;
	if (sscanf(cString(s), "%d", &out) != 1)
		return false;

	i = out;
	return true;
}
Пример #29
0
b32 ShaderProgram::attachShaderFromMemory(ShaderType type,
                                          const String& shaderSource)
{
	if (!handle)
		handle = glCreateProgram();

	u32 shader = 0;
	if (type == ShaderType::Vertex)
		shader = glCreateShader(GL_VERTEX_SHADER);
	else if (type == ShaderType::Fragment)
		shader = glCreateShader(GL_FRAGMENT_SHADER);
	else
		panic("Unknown shader type.");

	const char* cStrSource = cString(shaderSource);
	glShaderSource(shader, 1, &cStrSource, nullptr);
	glCompileShader(shader);

	s32 status;
	glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
	if (status == false)
	{
		String msg;
		if (type == ShaderType::Vertex)
			msg = "Compile failure in vertex shader: \n";
		else if (type == ShaderType::Fragment)
			msg = "Compile failure in fragment shader: \n";
		else
			panic("Unknown shader type.");

		s32 infoLogLength;
		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);

		Allocator& a = defaultAllocator();

		char* strInfoLog =
		    (char*)a.allocate((infoLogLength + 1) * sizeof(char));
		defer(a.deallocate(strInfoLog));

		glGetShaderInfoLog(shader, infoLogLength, nullptr, strInfoLog);

		append(msg, strInfoLog);
		append(msg, '\n');

		append(errorLog, msg);

		glDeleteShader(shader);

		return false;
	}

	glAttachShader(handle, shader);

	return true;
}
Пример #30
0
s32 ShaderProgram::getUniformLocation(const String& name) const
{
	const u64 hash = stringHash(name);

	if (has(m_uniformLocations, hash))
		return get(m_uniformLocations, hash, 0);

	s32 loc = glGetUniformLocation(handle, cString(name));
	set(m_uniformLocations, hash, loc);
	return loc;
}