Example #1
0
int main()
{
    setlocale(LC_ALL, "");
    std::ifstream in (BINARY_DIR "/Input.txt");
    std::ofstream out (BINARY_DIR "/Output.txt");
	if (!in.is_open()|| !out.is_open())
    {
        return 1;
    }
    std::string base_str;
    std::getline(in, base_str);
    PrepareString(base_str);
    while (!in.eof())
    {
        std::string str;        
        std::getline(in, str);
        if(!str.empty())
        {
            PrepareString(str);
            std::reverse(str.begin(), str.end());
            out << ((base_str.find(str)!=std::wstring::npos) ? "YES" : "NO") << std::endl;
        }
    }
	return 0;
}
Example #2
0
UTF8String StringPrep::SASLPrep(UTF8String str, bool checkUnassigned)
{
	UTF32String str32 = UTF::utf8to32(str);

	std::vector<MappingTable> maps;
	maps.push_back(m_B1map);
	maps.push_back(RangeTableToMappingTable(m_C12ranges, UTF32String()));

	std::vector<RangeTable> prohibitRanges;
	prohibitRanges.push_back(m_C11ranges);
	prohibitRanges.push_back(m_C12ranges);
	prohibitRanges.push_back(m_C21ranges);
	prohibitRanges.push_back(m_C22ranges);
	prohibitRanges.push_back(m_C3ranges);
	prohibitRanges.push_back(m_C4ranges);
	prohibitRanges.push_back(m_C5ranges);
	prohibitRanges.push_back(m_C6ranges);
	prohibitRanges.push_back(m_C7ranges);
	prohibitRanges.push_back(m_C8ranges);
	prohibitRanges.push_back(m_C9ranges);

	UTF32String preparedString = 
		PrepareString(str32, checkUnassigned, true, true, maps, prohibitRanges);

	return UTF::utf32to8(preparedString);
}
Example #3
0
bool ConfigAPI::HasKey(QString file, QString section, QString key) const
{
    if (configFolder_.isEmpty())
    {
        LogError("ConfigAPI::HasKey: Config folder has not been prepared, returning false.");
        return false;
    }

    PrepareString(file);
    PrepareString(section);
    PrepareString(key);

    if (!IsFilePathSecure(file))
        return false;

    QSettings config(GetFilePath(file), QSettings::IniFormat);
    if (!section.isEmpty())
        key = section + "/" + key;
    return config.allKeys().contains(key);
}
Example #4
0
bool EdiComposer::ComposeTrailer()
{
    BufferClean();  

    BufferWriteRawData(GetTrailer().RecordType, 1);
    BufferWriteRawData(GetTrailer().Carrier, 9);
    wxString total;
    total << GetTrailer().TotalRecords;
    BufferWriteRawData(PrepareString(total, 9), 9);
    wxString added;
    added << GetTrailer().TotalAdds;
    BufferWriteRawData(PrepareString(added, 9), 9);
    wxString changed;
    changed << GetTrailer().TotalChanges;
    BufferWriteRawData(PrepareString(changed, 9), 9);
    wxString moved;
    moved << GetTrailer().TotalMoveHistory;
    BufferWriteRawData(PrepareString(moved, 9), 9);
    wxString rolled;
    BufferWriteRawData(PrepareString(rolled, 9), 9);
    wxString replaced;
    replaced << GetTrailer().TotalReplacements;
    BufferWriteRawData(PrepareString(replaced, 9), 9);

    BufferFlush();
    return true;
};
Example #5
0
QVariant ConfigAPI::Read(QString file, QString section, QString key, const QVariant &defaultValue) const
{
    if (configFolder_.isEmpty())
    {
        LogError("ConfigAPI::Read: Config folder has not been prepared, returning null QVariant.");
        return "";
    }

    PrepareString(file);
    PrepareString(section);
    PrepareString(key);

    // Don't return 'defaultValue' but null QVariant
    // as this is an error situation.
    if (!IsFilePathSecure(file))
        return QVariant();

    QSettings config(GetFilePath(file), QSettings::IniFormat);
    if (section.isEmpty())
        return config.value(key, defaultValue);
    else
        return config.value(section + "/" + key, defaultValue);
}
Example #6
0
void ConfigAPI::Write(QString file, QString section, QString key, const QVariant &value)
{
    if (configFolder_.isEmpty())
    {
        LogError("ConfigAPI::Write: Config folder has not been prepared, can not write value to config.");
        return;
    }

    PrepareString(file);
    PrepareString(section);
    PrepareString(key);

    if (!IsFilePathSecure(file))
        return;

    QSettings config(GetFilePath(file), QSettings::IniFormat);
    if (!config.isWritable())
        return;
    if (section.isEmpty())
        config.setValue(key, value);
    else
        config.setValue(section + "/" + key, value);
    config.sync();
}
Example #7
0
int FindExactMatches(char *SourcePhrase)
{
    char SQLString[200] = "";
    char strOriginal[200] = "";

    sqlite3_stmt *stmt = NULL;
    char *data = NULL;

    int nResponse = 0;
    int nLength = strlen(SourcePhrase);

    PrepareString(SourcePhrase);
    strcpy(strOriginal, SourcePhrase);

    // quicksort the string into alphabetical order
    qsort(SourcePhrase, nLength, sizeof(char), CompareElements);

    sprintf(SQLString, "SELECT * FROM words WHERE alpha=\'%s\'", SourcePhrase);

    nResponse = sqlite3_prepare_v2( WordsDb, SQLString, -1, &stmt, NULL );

    if ( nResponse != SQLITE_OK)
        return (-1);

    nResponse = sqlite3_step( stmt );

    while (nResponse == SQLITE_ROW) {

        data = (char*)sqlite3_column_text( stmt, 1 );

        if (strcmp(data, strOriginal) != 0)
            AddWordToList(data);

        nResponse = sqlite3_step( stmt );
    }

    sqlite3_finalize( stmt );

    // return from function
    return (0);

}	// end of FindExactMatches
Example #8
0
void LoadScriptFile(pzllst *lst,FManNode *filename, bool control, MList *controlst)
{
#ifdef TRACE
    printf("Loading script file %s\n",filename->File);
#endif

    if (control)
    {
        Rend_SetRenderer(RENDER_FLAT);
    }

    mfile *fl=mfopen(filename);
    if (fl == NULL)
    {
        printf("Error opening file %s\n",filename->File);
        exit(1);
        return;
    }

    char buf[FILE_LN_BUF];

    while(!mfeof(fl))
    {
        mfgets(buf,FILE_LN_BUF,fl);

        char *str=PrepareString(buf);


        if (strCMP(str,"puzzle")==0)
        {
            Parse_Puzzle(lst,fl,str);
        }
        else if (strCMP(str,"control")==0 && control )
        {
            Parse_Control(controlst,fl,str);
        }
    }

    mfclose(fl);
}
Example #9
0
 void AppendProperty(const ACE_TString& prop, 
     const ACE_TString& value, ACE_TString& dest_str)
 {
     ACE_TString newprop = ACE_TString(ACE_TEXT(" ")) + prop + ACE_TString(ACE_TEXT("=\"")) + PrepareString(value) + ACE_TString(ACE_TEXT("\""));
     dest_str += newprop;
 }