Esempio n. 1
0
void usePathWrite::parse(const ST::string & usetext)
  {

  path = "";
  errormessages.clear();
  notext = true;

  if (usetext.length() > 0)
	 {
	 notext = false;
	 int k = usetext.isvalidfile();

	 if (k == 1)
		{
		errormessages.push_back("ERROR: file " + usetext +
		" could not be opened for writing\n");
		alreadyexisting = false;
		}
	 else if (k == 0)
		alreadyexisting = false;
	 else
		alreadyexisting = true;

	 if (errormessages.empty())
		path = usetext;
	 }

  }
Esempio n. 2
0
/*****************************************************************************
 ** pfMacPasswordStore                                                      **
 *****************************************************************************/
ST::string pfMacPasswordStore::GetPassword(const ST::string& username)
{
    ST::string service = GetServerDisplayName();

    void* passwd = nullptr;
    uint32_t passwd_len = 0;

    if (SecKeychainFindGenericPassword(nullptr,
                                       service.size(),
                                       service.c_str(),
                                       username.size(),
                                       username.c_str(),
                                       &passwd_len,
                                       &passwd,
                                       nullptr) != errSecSuccess)
    {
        return ST::null;
    }

    ST::string ret(reinterpret_cast<const char*>(passwd), size_t(passwd_len));

    SecKeychainItemFreeContent(nullptr, passwd);

    return ret;
}
Esempio n. 3
0
TEST(plCmdParser, wchar_argv_parsing)
{
    const plCmdArgDef cmds[] = {
        { kCmdArgRequired | kCmdTypeString, "path", 0}
    };

    plCmdParser parser(cmds, arrsize(cmds));

    const wchar_t* args[] = {L"plCmdParser", L"~/.plasma/config.dat"};
    int argc = 2;

    std::vector<ST::string> tokens(argc);
    for (int i = 0; i < argc; i++) {
        tokens.push_back(ST::string::from_wchar(args[i]));
    }

    bool success = parser.Parse(tokens);

    ST::string prog = parser.GetProgramName();
    ST::string path = parser.GetString(0);

    EXPECT_EQ(success, true);
    EXPECT_STREQ(prog.c_str(), "plCmdParser");
    EXPECT_STREQ(path.c_str(), "~/.plasma/config.dat");
    EXPECT_EQ(parser.GetError(), kCmdErrorSuccess);
}
Esempio n. 4
0
void plAgeLinkStruct::IPrcParse(const pfPrcTag* tag, plResManager* mgr) {
    if (tag->getName() == "AgeInfo") {
        fFlags |= kHasAgeInfo;
        if (tag->hasChildren())
            fAgeInfo.prcParse(tag->getFirstChild(), mgr);
        else
            fAgeInfo.clear();
    } else if (tag->getName() == "LinkingRules") {
        fFlags |= kHasLinkingRules;
        ST::string lRule = tag->getParam("value", "kBasicLink");
        fLinkingRules = -1;
        for (size_t i=0; i<=kChildAgeBook; i++) {
            if (lRule == kLinkingRuleNames[i])
                fLinkingRules = i;
        }
        if (fLinkingRules == -1) {
            fLinkingRules = lRule.to_int();
        }
    } else if (tag->getName() == "SpawnPoint") {
        fFlags |= kHasSpawnPt;
        if (tag->hasChildren())
            fSpawnPoint.prcParse(tag->getFirstChild());
        else
            fSpawnPoint.clear();
    } else if (tag->getName() == "AmCCR") {
        fFlags |= kHasAmCCR;
        fAmCCR = tag->getParam("value", "0").to_uint();
    } else if (tag->getName() == "ParentAgeFilename") {
        fFlags |= kHasParentAgeFilename;
        fParentAgeFilename = tag->getParam("value", "");
    } else {
        plCreatable::IPrcParse(tag, mgr);
    }
}
Esempio n. 5
0
void plAgeDescInterface::INewPage()
{
    ST::string name = ST_LITERAL("New Page Name");

    // Get the name of the new age from the user
    int ret = DialogBoxParam(hInstance,
                            MAKEINTRESOURCE(IDD_AGE_NAME),
                            GetCOREInterface()->GetMAXHWnd(),
                            NewAgeDlgProc,
                            (LPARAM)&name);
    if (ret != 1)
        return;

    HWND hPages = GetDlgItem(fhDlg, IDC_PAGE_LIST);

    // Make sure this page doesn't already exist
    int count = ListBox_GetCount(hPages);
    for (int i = 0; i < count; i++)
    {
        char pageName[256];
        ListBox_GetText(hPages, i, pageName);
        if (!name.compare_i(pageName))
            return;
    }

    // Add the new page and select it
    int idx = ListBox_AddString(hPages, name.c_str());

    // Choose a new sequence suffix for it
    plAgePage *newPage = new plAgePage( name, IGetFreePageSeqSuffix( hPages ), 0 );
    ListBox_SetItemData( hPages, idx, (LPARAM)newPage );
   
    fDirty = true;
}
Esempio n. 6
0
void DS::Stream::writeSafeString(const ST::string& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        ST::utf16_buffer buffer = value.to_utf16();
        uint16_t length = value.size() & 0x0FFF;
        ST::utf16_buffer work;
        char16_t* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char16_t));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char16_t));
        write<char16_t>(0);
    } else {
        ST::char_buffer buffer = (format == e_StringUTF8) ? value.to_utf8()
                               : value.to_latin_1(ST::substitute_invalid);
        uint16_t length = value.size() & 0x0FFF;
        ST::char_buffer work;
        char* data = work.create_writable_buffer(length);
        memcpy(data, buffer.data(), length * sizeof(char));
        for (uint16_t i=0; i<length; ++i)
            data[i] = ~data[i];
        write<uint16_t>(length | 0xF000);
        writeBytes(data, length * sizeof(char));
    }
}
Esempio n. 7
0
ST::string plAnimComponentBase::GetIfaceSegmentName( bool allowNil )
{
    ST::string name = GetAnimName();
    if( allowNil || !name.is_empty() )
        return name;
    return ENTIRE_ANIMATION_NAME;
}
Esempio n. 8
0
ST::string cdUp(ST::string path) {
    // Check for root paths, we can't go up from there!
#ifdef _WIN32
    if (path.substr(1) == ":\\")
        return path;
#else
    if (path == "/")
        return path;
#endif

    // Not very robust, but it works for one level of parent scanning
    if (path.is_empty())
        return ".." PATHSEPSTR;

    // Strip the ending slash, if necessary, and then go up one dir
    if (path.char_at(path.size()-1) == PATHSEP)
        path = path.left(path.size() - 1);
    ST::string up = path.before_last(PATHSEP);
    if (path.char_at(0) == PATHSEP) {
        // Absolute path specified -- make sure we keep it that way
        return up + PATHSEPSTR;
    } else {
        // Relative path specified
        return up.is_empty() ? "" : up + PATHSEPSTR;
    }
}
Esempio n. 9
0
void plPythonMgr::LoadPythonFiles()
{
    plFileName clientPath = plMaxConfig::GetClientPath(false, true);
    if (clientPath.IsValid())
    {
        plFileName oldCwd = plFileSystem::GetCWD();
        plFileSystem::SetCWD(clientPath);

        // Get the path to the Python subdirectory of the client
        plFileName pythonPath = plFileName::Join(clientPath, "Python");

        PythonInterface::initPython();

        // Iterate through all the Python files in the folder
        std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py");
        for (auto iter = pys.begin(); iter != pys.end(); ++iter)
        {
            // Get the filename without the ".py" (module name)
            ST::string fileName = iter->GetFileNameNoExt();

            IQueryPythonFile(fileName.c_str());
        }

        PythonInterface::finiPython();

        plFileSystem::SetCWD(oldCwd);
    }
}
Esempio n. 10
0
ST::string GetInternalName(const ST::string& filename) {
    // Different files are stored in different locations; this function
    // will try to guess where to put things based on the file's extension.
    // This is all based on the contents of .sum files included with the
    // games that I examined for this.

    ST::string split = s_oldFormat ? "/" : "\\";
    ST::string name = FixSlashes(filename).after_last(PATHSEP);
    ST::string ext = name.after_last('.');
    if (s_oldFormat && ext == "prp")
        return name;
    if (ext == "ogg" || ext == "wav")
        return ST::string("sfx") + split + name;
    if (ext == "exe" || ext == "dll" || ext == "map" || ext == "pdb")
        return name;
    if (ext == "sdl")
        return ST::string("SDL") + split + name;
    if (ext == "pak")
        return ST::string("Python") + split + name;
    if (ext == "fx")
        return ST::string("fx") + split + name;

    // dat is the default, since so many file types go there...
    // To name a few,
    // prp, age, fni, csv, sub, node, pfp, dat, tron, hex, tga, loc
    return ST::string("dat") + split + name;
}
Esempio n. 11
0
void droprun(dataobject & o)
  {
  list<ST::string> names = o.m.getModelVarnames();
  ST::string boolexp = o.methods[1].getexpression();

  if ( (names.size() > 0) && (boolexp.length() == 0) )
	 {
	 o.d.dropvariables(names);
	 o.errormessages = o.d.geterrormessages();
	if (o.errormessages.empty())
	  o.out("NOTE: " + ST::inttostring(names.size()) + " variables dropped\n");
	 }
  else if ( (names.size() == 0) && (boolexp.length() > 0) )
	 {
     unsigned nrelim;
	 nrelim = o.d.dropobservations(boolexp);
	 o.errormessages = o.d.geterrormessages();
	 if (o.errormessages.empty())
		o.out("NOTE: " + ST::inttostring(nrelim) + " observations dropped\n");
	 }
  else if ( (names.size() == 0) && (boolexp.length() == 0) )
	 {
	 o.outerror("ERROR: varlist or boolean expression expected\n");
	 }
  else
    o.outerror("ERROR: dropping variables and observations in one step not allowed\n");

  o.changedescription();
  }
Esempio n. 12
0
void    plAnimStealthNode::GetLoopPoints( float &start, float &end ) const
{
    start = GetSegStart();
    end = GetSegEnd();

    ST::string loopName = GetLoopName();
    if( !loopName.is_empty() && fCachedSegMap != nil )
        GetSegMapAnimTime( loopName, fCachedSegMap, SegmentSpec::kLoop, start, end );
}
Esempio n. 13
0
void FindSubDirs(std::vector<plFileName> &dirnames, const plFileName &path)
{
    std::vector<plFileName> subdirs = plFileSystem::ListSubdirs(path);
    for (auto iter = subdirs.begin(); iter != subdirs.end(); ++iter) {
        ST::string name = iter->GetFileName();
        if (name.compare_i("system") != 0 && name.compare_i("plasma") != 0)
            dirnames.push_back(name);
    }
}
Esempio n. 14
0
ST::string getOutputDir(const ST::string& filename, plPageInfo* page) {
    ST::string odir = filename;
    ST_ssize_t sepLoc = odir.find_last(PATHSEP);
    if (sepLoc < 0)
        odir = ST::string();
    else
        odir = odir.left(sepLoc + 1);
    return odir + ST::format("{}_{}_PRP" PATHSEPSTR, page->getAge(), page->getPage());
}
Esempio n. 15
0
void DS::Stream::writeString(const ST::string& value, DS::StringType format)
{
    if (format == e_StringUTF16) {
        ST::utf16_buffer buffer = value.to_utf16();
        writeBytes(buffer.data(), buffer.size() * sizeof(char16_t));
    } else {
        ST::char_buffer buffer = (format == e_StringUTF8) ? value.to_utf8()
                               : value.to_latin_1(ST::substitute_invalid);
        writeBytes(buffer.data(), buffer.size() * sizeof(char));
    }
}
Esempio n. 16
0
ST::string FixSlashes(const ST::string& src) {
    if (src.is_empty())
        return src;

    ST::char_buffer dest;
    char* pbuf = dest.create_writable_buffer(src.size());
    memcpy(pbuf, src.c_str(), src.size() + 1);
    for (char* pc = pbuf; *pc != 0; pc++) {
        if (*pc == '/' || *pc == '\\')
            *pc = PATHSEP;
    }
    return dest;
}
Esempio n. 17
0
ST::string CleanFileName(const ST::string& fname) {
    ST::char_buffer result;
    char* buf = result.create_writable_buffer(fname.size());
    memcpy(buf, fname.c_str(), fname.size() + 1);
    for (char* bp = buf; *bp; bp++) {
        if (*bp == '?' || *bp == '*' || *bp == '<' || *bp == '>' ||
            *bp == '"' || *bp == '|' || *bp < (char)0x20)
            *bp = '_';
        if (*bp == '/' || *bp == '\\' || *bp == ':')
            *bp = '_';
    }
    return result;
}
Esempio n. 18
0
TEST(plCmdParser, flagged_string_bystring)
{
    const plCmdArgDef cmds[] = {
        { kCmdTypeString, "path", 0}
    };

    plCmdParser parser(cmds, arrsize(cmds));
    parser.Parse("plCmdParser --path foo");

    ST::string path = parser.GetString("path");

    EXPECT_STREQ(path.c_str(), "foo");
}
Esempio n. 19
0
plLocation plPluginResManager::ICreateLocation(const ST::string& age, const ST::string& page, int32_t seqNum, bool itinerant)
{
    bool willBeReserved = age.compare_i("global") == 0;

    int32_t oldNum = seqNum;
    seqNum = VerifySeqNumber(seqNum, age, page);
    if (seqNum != oldNum)
    {
        hsAssert(false, "Conflicting page sequence number. Somebody called NameToLoc without verifying their seq# first!"); 
    }

    if (seqNum < 0)
    {
        willBeReserved = true;
        seqNum = -seqNum;
    }

    plLocation newLoc;
    if (willBeReserved)
        newLoc = plLocation::MakeReserved(seqNum);
    else
        newLoc = plLocation::MakeNormal(seqNum);

    // Flag common pages
    for (int i = 0; i < plAgeDescription::kNumCommonPages; i++)
    {
        if (page.compare(plAgeDescription::GetCommonPage(i)) == 0)
        {
            newLoc.SetFlags(plLocation::kBuiltIn);
            break;
        }
    }

    // If we have an age description file for the age we're creating a location
    // for, grab some extra flags from it
    plAgeDescription* ageDesc = plPageInfoUtils::GetAgeDesc(age.c_str());
    plAgePage* agePage = ageDesc ? ageDesc->FindPage(page.c_str()) : nil;
    if (agePage)
    {
        if (agePage->GetFlags() & plAgePage::kIsLocalOnly)
            newLoc.SetFlags(plLocation::kLocalOnly);

        if (agePage->GetFlags() & plAgePage::kIsVolatile)
            newLoc.SetFlags(plLocation::kVolatile);
    }
    if (itinerant)
        newLoc.SetFlags(plLocation::kItinerant);

    delete ageDesc;
    return newLoc;
}
Esempio n. 20
0
void plAnimEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb)
{
    HWND hList = GetDlgItem(hWnd, IDC_EVENT_LIST);
    ListBox_ResetContent(hList);

    plAnimComponentBase* comp;
    plMaxNode* node;

    //
    // If we don't have a valid comp and node, we should be disabled
    //
    if (!GetCompAndNode(pb, (plComponentBase*&)comp, node))
    {
        EnableWindow(hList, FALSE);
        return;
    }
    else
        EnableWindow(hList, TRUE);

    //
    // Load the events
    //
    int idx;

    idx = ListBox_AddStringData(hList, "(Begin)", kAnimEventBegin);
    if (pb->GetInt(kAnimBegin))
        ListBox_SetSel(hList, TRUE, idx);

    idx = ListBox_AddStringData(hList, "(End)", kAnimEventEnd);
    if (pb->GetInt(kAnimEnd))
        ListBox_SetSel(hList, TRUE, idx);

    if (comp)
    {
        // Get the shared animations for all the nodes this component is applied to
        plNotetrackAnim anim(comp, nil);
        plAnimInfo info = anim.GetAnimInfo(comp->GetAnimName());

        RemoveDeadMarkers(pb, kAnimMarkers, info);

        // Get all the markers in this animation
        ST::string marker;
        while (!(marker = info.GetNextMarkerName()).is_empty())
        {
            idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker);

            if (IsMarkerSelected(pb, kAnimMarkers, marker))
                ListBox_SetSel(hList, TRUE, idx);
        }
    }
}
Esempio n. 21
0
void plMtlEventProc::ILoadUser(HWND hWnd, IParamBlock2* pb)
{
    HWND hList = GetDlgItem(hWnd, IDC_EVENT_LIST);
    ListBox_ResetContent(hList);

    //
    // If we don't have a valid material, we should be disabled
    //
    Mtl* mtl = pb->GetMtl(kMtlMtl);
    if (!mtl)
    {
        EnableWindow(hList, FALSE);
        return;
    }
    else
        EnableWindow(hList, TRUE);

    //
    // Load the events
    //
    int idx;

    idx = ListBox_AddStringData(hList, "(Begin)", kAnimEventBegin);
    if (pb->GetInt(kMtlBegin))
        ListBox_SetSel(hList, TRUE, idx);

    idx = ListBox_AddStringData(hList, "(End)", kAnimEventEnd);
    if (pb->GetInt(kMtlEnd))
        ListBox_SetSel(hList, TRUE, idx);

    if (mtl)
    {
        ST::string mtlAnim = ST::string::from_utf8(pb->GetStr(kMtlAnim));

        // Get the shared animations for all the nodes this component is applied to
        plNotetrackAnim anim(mtl, nil);
        plAnimInfo info = anim.GetAnimInfo(mtlAnim);

        RemoveDeadMarkers(pb, kMtlMarkers, info);

        // Get all the markers in this animation
        ST::string marker;
        while (!(marker = info.GetNextMarkerName()).is_empty())
        {
            idx = ListBox_AddStringData(hList, marker.c_str(), kAnimEventMarker);

            if (IsMarkerSelected(pb, kMtlMarkers, marker))
                ListBox_SetSel(hList, TRUE, idx);
        }
    }
}
Esempio n. 22
0
static void SendBasic(unsigned char*& buf, const msgparm_t& data,
                      unsigned int size, unsigned int count)
{
    // Also works for floats and doubles
    if (count == 0) {
        if (size == 1) {
            *(uint8_t*)buf = (uint8_t)data.fUint;
            buf += sizeof(uint8_t);
        } else if (size == 2) {
            *(uint16_t*)buf = (uint16_t)data.fUint;
            buf += sizeof(uint16_t);
        } else if (size == 4) {
            *(uint32_t*)buf = data.fUint;
            buf += sizeof(uint32_t);
        }

#ifdef COMMDEBUG
        plDebug::Debug("     -> Int{}: {}", size * 8, data.fUint);
#endif
    } else {
        if (size == 1) {
            memcpy(buf, data.fData, count * sizeof(uint8_t));
            buf += count * sizeof(uint8_t);
        } else if (size == 2) {
            memcpy(buf, data.fData, count * sizeof(uint16_t));
            buf += count * sizeof(uint16_t);
        } else if (size == 4) {
            memcpy(buf, data.fData, count * sizeof(uint32_t));
            buf += count * sizeof(uint32_t);
        }

#ifdef COMMDEBUG
        ST::string ln = ST::format("     -> Int{}[{}]: ", size * 8, count);
        size_t lnbufSize = count * ((size * 2) + 1);
        char* lnbuf = new char[lnbufSize + 1];
        for (size_t i=0; i<count; i++) {
            if (size == 1)
                sprintf(lnbuf + (i * 3), "%02X ", ((uint8_t*)data.fData)[i]);
            else if (size == 2)
                sprintf(lnbuf + (i * 5), "%04X ", ((uint16_t*)data.fData)[i]);
            else if (size == 4)
                sprintf(lnbuf + (i * 9), "%08X ", ((uint32_t*)data.fData)[i]);
        }
        lnbuf[lnbufSize] = 0;
        ln += lnbuf;
        delete[] lnbuf;
        plDebug::Debug(ln.c_str());
#endif
    }
}
Esempio n. 23
0
void outfilerun(dataobject & o)
  {

  unsigned nrwritten;
  ST::string path  = o.uwrite.getPath();
  list<ST::string> names = o.m.getModelVarnames();
  ST::string expression = o.methods[6].getexpression();

  if ( (o.uwrite.isexisting() == true) && (o.replace.getvalue() == false) )
	 o.errormessages.push_back(
	 "ERROR: file " + path + " is already existing\n");
  else
	 {
	 ofstream fout;
	 ST::open(fout,path);
	 if (expression.length() > 0)
		{
		realvar v = o.d.eval_exp(expression);
        #if defined(JAVA_OUTPUT_WINDOW)
		nrwritten = o.d.write(o.adminb_p,fout,names,o.header.getvalue(),v);
        #else
        nrwritten = o.d.write(fout,names,o.header.getvalue(),v);
        #endif
		}
	 else
       {
        #if defined(JAVA_OUTPUT_WINDOW)
	   nrwritten = o.d.write(o.adminb_p,fout,names,o.header.getvalue());
       #else
	   nrwritten = o.d.write(fout,names,o.header.getvalue());
       #endif
       }

     o.errormessages = o.d.geterrormessages();
     if (o.errormessages.empty())
       {
       o.out("NOTE: " + ST::inttostring(names.size()) + " variable(s) with " +
             ST::inttostring(nrwritten) +  " observations written to file\n");
       o.out("      " + path + "\n");
       }
     else
       {
       fout.close();
       remove(path.strtochar());
       }


	 }
  }
Esempio n. 24
0
static void RecvBasic(pnSocket* sock, msgparm_t& data,
                      unsigned int size, unsigned int count)
{
    // Also works for floats
    if (count == 0) {
        if (size == 1) {
            uint8_t v;
            sock->recv(&v, sizeof(uint8_t));
            data.fUint = v;
        } else if (size == 2) {
            uint16_t v;
            sock->recv(&v, sizeof(uint16_t));
            data.fUint = v;
        } else if (size == 4) {
            uint32_t v;
            sock->recv(&v, sizeof(uint32_t));
            data.fUint = v;
        }

#ifdef COMMDEBUG
        plDebug::Debug("     <- Int{}: {}", size * 8, data.fUint);
#endif
    } else {
        if (size == 1)
            sock->recv(data.fData, count * sizeof(uint8_t));
        else if (size == 2)
            sock->recv(data.fData, count * sizeof(uint16_t));
        else if (size == 4)
            sock->recv(data.fData, count * sizeof(uint32_t));

#ifdef COMMDEBUG
        ST::string ln = ST::format("     <- Int{}[{}]: ", size * 8, count);
        size_t lnbufSize = count * ((size * 2) + 1);
        char* lnbuf = new char[lnbufSize + 1];
        for (size_t i=0; i<count; i++) {
            if (size == 1)
                sprintf(lnbuf + (i * 3), "%02X ", ((uint8_t*)data.fData)[i]);
            else if (size == 2)
                sprintf(lnbuf + (i * 5), "%04X ", ((uint16_t*)data.fData)[i]);
            else if (size == 4)
                sprintf(lnbuf + (i * 9), "%08X ", ((uint32_t*)data.fData)[i]);
        }
        lnbuf[lnbufSize] = 0;
        ln += lnbuf;
        delete[] lnbuf;
        plDebug::Debug(ln.c_str());
#endif
    }
}
Esempio n. 25
0
void    plAnimStealthNode::StuffToTimeConvert( plAnimTimeConvert &convert, float maxLength )
{
    ST::string segName = GetSegmentName();
    bool isEntire = ( segName.is_empty() || segName.compare( ENTIRE_ANIMATION_NAME ) == 0 );

    if( isEntire )
    {
        convert.SetBegin( 0 );
        convert.SetEnd( maxLength );
    }
    else
    {
        SegmentSpec *spec = IGetSegmentSpec();
        convert.SetBegin( ( spec != nil ) ? spec->fStart : 0.f );
        convert.SetEnd( ( spec != nil ) ? spec->fEnd : 0.f );
    }

    // Even if we're not looping, set the loop points. (A responder
    // could tell us later to start looping.)
    if( isEntire )
        convert.SetLoopPoints( 0, maxLength );
    else
    {
        float loopStart, loopEnd;
        GetLoopPoints( loopStart, loopEnd );
        convert.SetLoopPoints( loopStart, loopEnd );
    }   
    convert.Loop( GetLoop() );

    // Auto-start
    if( GetAutoStart() )
        convert.Start( 0 );
    else
        convert.Stop( true );

    // Stuff stop points
    GetAllStopPoints( convert.GetStopPoints() );

    // Ease curve stuff
    if( GetEaseInType() != plAnimEaseTypes::kNoEase )
    {
        convert.SetEase( true, GetEaseInType(), GetEaseInMin(), GetEaseInMax(), GetEaseInLength() );
    }
    if( GetEaseOutType() != plAnimEaseTypes::kNoEase )
    {
        convert.SetEase( false, GetEaseOutType(), GetEaseOutMin(), GetEaseOutMax(), GetEaseOutLength() );
    }
}
Esempio n. 26
0
ST::string pfFilePasswordStore::GetPassword(const ST::string& username)
{
    plFileName loginDat = plFileName::Join(plFileSystem::GetInitPath(), "login.dat");
    ST::string password = ST::null;

#ifndef PLASMA_EXTERNAL_RELEASE
    // internal builds can use the local init directory
    plFileName local("init\\login.dat");
    if (plFileInfo(local).Exists())
        loginDat = local;
#endif

    hsStream* stream = plEncryptedStream::OpenEncryptedFile(loginDat, fCryptKey);
    if (stream && !stream->AtEnd())
    {
        uint32_t savedKey[4];
        stream->Read(sizeof(savedKey), savedKey);

        if (memcmp(fCryptKey, savedKey, sizeof(savedKey)) == 0 && !stream->AtEnd())
        {
            ST::string uname = stream->ReadSafeString();
            if (username.compare_i(uname) == 0) {
                password = stream->ReadSafeString();
            }
        }

        stream->Close();
        delete stream;
    }

    return password;
}
Esempio n. 27
0
void useDataset::parse(const ST::string & usetext)
  {

  errormessages.clear();
  notext = true;

  if (usetext.length() > 0)
	 {
	 notext = false;
	 if (! datasets->empty())
		{
		int i = 0;
		bool existing = false;
		while ( (i < datasets->size()) && (existing == false) )
		  {
		  if (usetext == (*((*datasets)[i])).getname())
			 {
			 existing = true;
			 datasetpointer = (*datasets)[i];
			 }
		  i++;
		  }
		if (existing == false)
		  errormessages.push_back(
		  "ERROR: dataset " + usetext + " is not existing\n");

		}
	 else
		errormessages.push_back(
		"ERROR: dataset " + usetext + " is not existing\n");
	 }

  }
Esempio n. 28
0
plFileName plBrowseFolder::GetFolder(const plFileName &startPath, const ST::string &title, HWND hwndOwner)
{
    BROWSEINFOW bi;
    memset(&bi, 0, sizeof(bi));
    ST::wchar_buffer titleW = title.to_wchar();
    ST::wchar_buffer startPathW = startPath.WideString();
    bi.hwndOwner    = hwndOwner;
    bi.lpszTitle    = titleW.data();
    bi.lpfn         = BrowseCallbackProc;
    bi.lParam       = (LPARAM) startPathW.data();

    LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
    plFileName path;
    if (!iil) {
        // Browse failed, or cancel was selected
        path = ST::null;
    } else {
        // Browse succeded.  Get the path.
        wchar_t buffer[MAX_PATH];
        SHGetPathFromIDListW(iil, buffer);
        path = ST::string::from_wchar(buffer);
    }

    // Free the memory allocated by SHBrowseForFolder
    LPMALLOC pMalloc;
    SHGetMalloc(&pMalloc);
    pMalloc->Free(iil);
    pMalloc->Release();

    return path;
}
Esempio n. 29
0
void FindPackages(std::vector<plFileName>& fileNames, std::vector<plFileName>& pathNames, const plFileName& path, const ST::string& parent_package=ST::null)
{
    std::vector<plFileName> packages;
    FindSubDirs(packages, path);
    for (int i = 0; i < packages.size(); i++)
    {
        ST::string packageName;
        if (!parent_package.is_empty())
            packageName = parent_package + ".";
        packageName += packages[i].AsString();
        std::vector<plFileName> packageFileNames;
        std::vector<plFileName> packagePathNames;
        plFileName packagePath = plFileName::Join(path, packages[i]);
        FindFiles(packageFileNames, packagePathNames, packagePath);

        // Check for the magic file to make sure this is really a package...
        if (std::find(packageFileNames.begin(), packageFileNames.end(), kModuleFile) != packageFileNames.end()) {
            for (int j = 0; j < packageFileNames.size(); j++) {
                fileNames.push_back(packageName+"."+packageFileNames[j].AsString());
                pathNames.push_back(packagePathNames[j]);
            }
            FindPackages(fileNames, pathNames, packagePath, packageName);
        }
    }
}
Esempio n. 30
0
static int ISearchLayerRecur(hsGMaterial* mat, const ST::string &segName, hsTArray<plKey>& keys)
{
    ST::string name = ( segName.compare( ENTIRE_ANIMATION_NAME ) == 0 ) ? ST::null : segName;
    int i;
    for( i = 0; i < mat->GetNumLayers(); i++ )
        ISearchLayerRecur(mat->GetLayer(i), name, keys);
    return keys.GetCount();
}