Exemple #1
0
T_void *FilesLoadFile (T_word32 filename, T_word32 revlevel,
                       T_word32 *actual_revlevel, T_word32 *size)
{
   T_void *data;
   char realname[256];

   DebugRoutine ("FilesLoadFile");

   /** Ensure that it exists, and meets the revlevel. **/
   if ((*actual_revlevel = FilesGetRevlevel (filename)) < revlevel)
   {
      /** Doesn't exist, or fails to meet the revlevel. **/
      data = NULL;
      *size = 0;
   }
   else
   {
      /** Exists. Load the data file. **/
      /** Construct the real filename. **/
#ifdef TARGET_UNIX
      sprintf (realname, "_Files/f%07d.d", filename);
#else
      sprintf (realname, "_Files\\f%07d.d", filename);
#endif /** TARGET_UNIX **/

      data = FileLoad (realname, size);
   }

   DebugEnd ();

   return data;
}
//
// Toggle hook on/off.
// Enable caching and faster loading of clothes files
//
void CMultiplayerSA::SetFastClothesLoading(EFastClothesLoading fastClothesLoading)
{
    if (m_FastClothesLoading == fastClothesLoading)
        return;

    m_FastClothesLoading = fastClothesLoading;

    // Handle auto setting
    if (fastClothesLoading == FAST_CLOTHES_AUTO)
    {
        // Disable if less than 512MB installed ram
        long long llSystemRamKB = GetWMITotalPhysicalMemory() / 1024LL;
        if (llSystemRamKB > 0 && llSystemRamKB < 512 * 1024)
            fastClothesLoading = FAST_CLOTHES_OFF;
    }

    if (fastClothesLoading != FAST_CLOTHES_OFF)
    {
        // Load and cache player.img
        SString strGTASAPath = GetCommonRegistryValue("", "GTA:SA Path");
        SString strFilename = PathJoin(strGTASAPath, "models", "player.img");
        FileLoad(strFilename, m_PlayerImgCache);
    }
    else
    {
        // Remove cached data - Note: This method ensures the memory is actually freed
        std::vector<char>().swap(m_PlayerImgCache);
    }

    // Update the cache pointer
    if (!m_PlayerImgCache.empty())
        ms_PlayerImgCachePtr = &m_PlayerImgCache[0];
    else
        ms_PlayerImgCachePtr = NULL;
}
Exemple #3
0
//============================================================================
//リソースファイルの読み込み
//============================================================================
//[input]
//	pDataName:データファイル名
//============================================================================
bool CSceneBase::LoadResourceFile( const char *pDataName )
{
	
	bool IsLoadEnd = false;

	CFileLoader FileLoad( pDataName );
	
	int Size = FileLoad.GetStrList().size();
	
	for( int i = 0;i < Size; ++i )
	{
		vector< string > vecStr = CFileLoader::SplitString( FileLoad.GetStrList().at( i ), "," );
		
		string strFileName = vecStr.at( 0 );
		
		string strDataName = vecStr.at( 1 );
		
		string strTypeName = vecStr.at( 2 );
		
		string strDataFileName = vecStr.at( 3 ); 
		
		//リソースの追加
		CCommonObject::GetResMgr()->Push( new CFileData( strFileName.c_str(), strDataName.c_str(),
														 strTypeName.c_str(), strDataFileName.c_str() ) );
		
	}
	
	
	
	IsLoadEnd = true;

	return IsLoadEnd;

	
}
Exemple #4
0
//////////////////////////////////////////////////////////
//
// HandleNotUsedMainMenu
//
// Called when a problem occured before the main menu was used by user
// If fullscreen, then maybe change fullscreen mode
//
//////////////////////////////////////////////////////////
void HandleNotUsedMainMenu ( void )
{
    AddReportLog( 9310, "Loader - HandleNotUsedMainMenu" );
    {
        // Slighty hacky way of checking in-game settings
        SString strCoreConfigFilename = CalcMTASAPath( PathJoin( "mta", "config", "coreconfig.xml" ) );
        SString strCoreConfig;
        FileLoad( strCoreConfigFilename, strCoreConfig );
        SString strWindowed        = strCoreConfig.SplitRight( "<display_windowed>" ).Left( 1 );
        SString strFullscreenStyle = strCoreConfig.SplitRight( "<display_fullscreen_style>" ).Left( 1 );
        if ( strFullscreenStyle == "1" )
        {
            AddReportLog( 9315, "Loader - HandleNotUsedMainMenu - Already Borderless window" );
        }
        else
        if ( !strWindowed.empty() && !strFullscreenStyle.empty())
        {
            if ( strWindowed == "0" && strFullscreenStyle == "0" )   // 0=FULLSCREEN_STANDARD
            {
                // Inform user
                SString strMessage = _("Are you having problems running MTA:SA?.\n\nDo you want to change the following setting?");
                strMessage += "\n" + _("Fullscreen mode:") + " -> " + _("Borderless window");
                HideSplash();
                int iResponse = MessageBoxUTF8 ( NULL, strMessage, "MTA: San Andreas", MB_YESNO | MB_ICONQUESTION | MB_TOPMOST );
                if ( iResponse == IDYES )
                {
                    // Very hacky way of changing in-game settings
                    strCoreConfig = strCoreConfig.Replace( "<display_fullscreen_style>0", "<display_fullscreen_style>1" );
                    FileSave( strCoreConfigFilename, strCoreConfig );
                    AddReportLog( 9311, "Loader - HandleNotUsedMainMenu - User change to Borderless window" );
                }
                else
                    AddReportLog( 9313, "Loader - HandleNotUsedMainMenu - User said no" );
            }
            else
                AddReportLog( 9314, "Loader - HandleNotUsedMainMenu - Mode not fullscreen standard" );
        }
        else
        {
            // If no valid settings file yet, do the change without asking
            strCoreConfig = "<mainconfig><settings><display_fullscreen_style>1</display_fullscreen_style></settings></mainconfig>";
            FileSave( strCoreConfigFilename, strCoreConfig );
            AddReportLog( 9312, "Loader - HandleNotUsedMainMenu - Set Borderless window" );
        }
    }

    // Check if Evolve is active
    for ( auto processId : MyEnumProcesses( true ) )
    {
        SString strFilename = ExtractFilename( GetProcessPathFilename( processId ) );
        if ( strFilename.BeginsWithI( "Evolve" ) )
        {
            SString strMessage = _("Are you having problems running MTA:SA?.\n\nTry disabling the following products for GTA and MTA:");
            strMessage += "\n\nEvolve";
            DisplayErrorMessageBox ( strMessage, _E("CL43"), "not-used-menu-evolve" );
            break;
        }
    }
}
Exemple #5
0
//============================================================================
//パラメーターの読み込み
//============================================================================
void CEffectMaxCharge::LoadParameter( const char *pFileName )
{
	CFileLoader FileLoad( pFileName );

	vector< string > vecStr = CFileLoader::SplitString( FileLoad.GetStrList().at( 0 ), "," );

	//----------------------------------------------
	//位置の設定
	//----------------------------------------------
	SetParameter( m_vInitPos.x, vecStr.at( 0 ) );

	SetParameter( m_vInitPos.y, vecStr.at( 1 ) );

	//----------------------------------------------
	//角度の設定
	//----------------------------------------------
	SetParameter( m_InitAngle, vecStr.at( 2 ) );

	//----------------------------------------------
	//拡縮率の設定
	//----------------------------------------------
	SetParameter( m_fInitScale.x, vecStr.at( 3 ) );

	SetParameter( m_fInitScale.y, vecStr.at( 4 ) );

	//----------------------------------------------
	//分割数の設定
	//----------------------------------------------
	SetParameter( m_DivNum.x, vecStr.at( 5 ) );

	SetParameter( m_DivNum.y, vecStr.at( 6 ) );

	//----------------------------------------------
	//アニメーションの設定
	//----------------------------------------------
	SetParameter( m_IsAnim, vecStr.at( 7 ) );

	SetParameter( m_AnimTime, vecStr.at( 8 ) );

	//----------------------------------------------
	//ずらす座標の設定
	//----------------------------------------------
	SetParameter( m_vAdjPos.x, vecStr.at( 9 ) );

	SetParameter( m_vAdjPos.y, vecStr.at( 10 ) );

	//----------------------------------------------
	//加算の設定
	//----------------------------------------------
	SetParameter( m_IsAdd, vecStr.at(11) );
	
	SetParameter( m_IsBlend, vecStr.at(12) );	

	SetParameter( m_Alpha, vecStr.at( 13 ) );




}
Exemple #6
0
int EDirectory::FmLoad(const char *Name, EView *XView) {
    char FilePath[256];

    JustDirectory(Path, FilePath, sizeof(FilePath));
    Slash(FilePath, 1);
    strcat(FilePath, Name);
    return FileLoad(0, FilePath, NULL, XView);
}
SString SharedUtil::GetReportLogContents ( void )
{
    SString strReportFilename = PathJoin ( GetMTADataPath (), "report.log" );
    // Load file into a string
    std::vector < char > buffer;
    FileLoad ( strReportFilename, buffer );
    buffer.push_back ( 0 );
    return &buffer[0];
}
Exemple #8
0
//============================================================================
//コンストラクタ
//============================================================================
//[input]
//	pName:ファイル名
//	pDataName:データファイル名
//  vPos 設定する位置
//===========================================================================
CEnemy::CEnemy( const char *pName, const char *pDataName, Math::Vector2D vPos )
:CCharacter( pName, pDataName ),
 m_eState( STATE_NONE ),
 m_eMovePat( MOVE_STRAIGHT ),
 m_eShotPat( SHOT_NONE ),
 m_ShootCount( 30 ),
 m_Scroll( SCREEN_WIDTH ),
 m_eEnemyType( TYPE_SMALL ),
 m_RollAngle( DEG_TO_ANGLE( 90 ) ),
 m_StateTime( 0 ),
 m_IsShoot( false ),
 m_IsDamaged( false ),
 m_IsBlowed( false ),
 m_IsDead( false ),
 m_IsSwordDamage( true ),
 m_ShotNum( 0 ),
 m_MaxShot( 1 ),
 m_StreamCount( 0 ),
 m_StreamTime( 10 ),
 m_ShotTime( 0 ),
 m_DeadTime( 0 ),
 m_BombDamage( 4 ),
 m_IsSlash( false ),
 m_IsSlashEnd( false )
{
	m_eState = STATE_NONE;

	m_vPos = vPos;
	
	sp<CGameObject> spObj = CCommonObject::GetResMgr()->FindObject( "Player" );
	
	if( spObj != NULL )
	{	
		m_vTargetPos = spObj->GetPos();
	}
	
	else
	{
		m_vTargetPos = Math::Vector2D( 0, 0 );
	}
	
	m_vCenterPos = Math::Vector2D( 32, 32 );
	
	m_eType = CCharacter::TYPE_ENEMY;
	
	LoadParameter( pDataName );
	
	m_vInitPos = vPos;
	
	CFileLoader FileLoad( "sworddamage.csv" );
	
	vector< string > vecStr = CFileLoader::SplitString( FileLoad.GetStrList().at( 0 ), "," );
	
	SetParameter( m_IsSwordDamage, vecStr.at( 0 ) );
	
}
Exemple #9
0
bool SharedUtil::FileLoad ( const SString& strFilename, SString& strBuffer, int iMaxSize )
{
    strBuffer = "";
    std::vector < char > buffer;
    if ( !FileLoad ( strFilename, buffer, iMaxSize ) )
        return false;
    if ( buffer.size () )
        strBuffer = std::string ( &buffer.at ( 0 ), buffer.size () );

    return true;
}
///////////////////////////////////////////////////////////////
//
// CResourceChecker::CheckLuaFileForIssues
//
//
//
///////////////////////////////////////////////////////////////
void CResourceChecker::CheckLuaFileForIssues ( const string& strPath, const string& strFileName, const string& strResourceName, bool bClientScript )
{
    // Load the original file into a string
    SString strFileContents;

    // Open the file
    FileLoad ( strPath, strFileContents );
    if ( strFileContents.length () == 0 )
        return;

    // Update decrypt version requirements, and do no more checking if encrypted
    if ( CheckLuaDecryptRequirements( strFileContents, strFileName, strResourceName, bClientScript ) )
        return;

    // Check if a compiled script
    bool bCompiledScript = IsLuaCompiledScript( strFileContents.c_str(), strFileContents.length() );

    // Process
    if ( strFileContents.length () > 1000000 )
        CLogger::LogPrintf ( "Please wait...\n" );

    // Ouput warnings...
    if ( m_bUpgradeScripts == false )
    {
        CheckLuaSourceForIssues ( strFileContents, strFileName, strResourceName, bClientScript, bCompiledScript, ECheckerMode::WARNINGS );
    }
    else
    // ..or do an upgrade (if not compiled)
    if ( m_bUpgradeScripts == true && !bCompiledScript )
    {
        string strNewFileContents;
        CheckLuaSourceForIssues ( strFileContents, strFileName, strResourceName, bClientScript, bCompiledScript, ECheckerMode::UPGRADE, &strNewFileContents );

        // Has contents changed?
        if ( strNewFileContents.length () > 0 && strNewFileContents != strFileContents )
        {
            // Rename original to lua.old
            if( !RenameBackupFile( strPath, ".old" ) )
                return;

            // Save new content
            if ( FILE* pFile = fopen ( strPath.c_str (), "wb" ) )
            {
                fwrite ( strNewFileContents.c_str (), 1, strNewFileContents.length (), pFile );
                fclose ( pFile );
                CLogger::LogPrintf ( "Upgrading %s:%s ...........done\n", strResourceName.c_str (), strFileName.c_str () );

                m_upgradedFullPathList.push_back( strPath );
            }
        }
    }
}
Exemple #11
0
int  HttpCallback( httpd_file_sys_t *p_args,
                       httpd_file_t *p_file,
                       uint8_t *_p_request,
                       uint8_t **_pp_data, int *pi_data )
{
    VLC_UNUSED(p_file);
    char *p_request = (char *)_p_request;
    char **pp_data = (char **)_pp_data;
    FILE *f;

    if( ( f = vlc_fopen( p_args->file, "r" ) ) == NULL )
    {
        Callback404( p_args, pp_data, pi_data );
        return VLC_SUCCESS;
    }

    if( !p_args->b_html )
    {
        FileLoad( f, pp_data, pi_data );
    }
    else
    {
        int  i_buffer;
        char *p_buffer;

        /* first we load in a temporary buffer */
        FileLoad( f, &p_buffer, &i_buffer );

        ParseExecute( p_args, p_buffer, i_buffer, p_request, pp_data, pi_data );

        free( p_buffer );
    }

    fclose( f );

    return VLC_SUCCESS;
}
Exemple #12
0
int MultiFileLoad(int createFlags, const char *FileName, const char *Mode, EView *View) {
    char fX[MAXPATH];
    int count = 0;
    char FPath[MAXPATH];
    char FName[MAXPATH];
    FileFind *ff;
    FileInfo *fi;
    int rc;

    assert(View != 0);

    JustDirectory(FileName, fX, sizeof (fX));
    if (fX[0] == 0) strcpy(fX, ".");
    JustFileName(FileName, FName, sizeof(FName));
    if (ExpandPath(fX, FPath, sizeof(FPath)) == -1) return 0;
    Slash(FPath, 1);

    ff = new FileFind(FPath, FName, ffHIDDEN | ffFULLPATH);
    if (ff == 0)
        return 0;
    rc = ff->FindFirst(&fi);
    while (rc == 0) {
        count++;
        if (FileLoad(createFlags, fi->Name(), Mode, View) == 0) {
            delete fi;
            delete ff;
            return 0;
        }
        delete fi;
        rc = ff->FindNext(&fi);
    }
    delete ff;
    if (count == 0)
        return FileLoad(createFlags, FileName, Mode, View);
    return 1;
}
Exemple #13
0
int EMarkIndex::view(EView *aView, char *aName) {
    EMark *m = locate(aName);
    if (m) {
        EBuffer *b = m->getBuffer();
        if (b == 0) {
            if (FileLoad(0, m->getFileName(), 0, aView) == 0)
                return 0;
            if (retrieveForBuffer((EBuffer *)ActiveModel) == 0)
                return 0;
            b = (EBuffer *)ActiveModel;
        }
        aView->SwitchToModel(b);
        return b->GotoBookmark(m->getName());
    }
    return 0;
}
Exemple #14
0
void ESvnBase::ShowLine (EView *V,int line) {
    if (line>=0&&line<LineCount&&Lines[line]->File) {
        if (Lines[line]->Buf!=0) {
            V->SwitchToModel (Lines[line]->Buf);
            if (Lines[line]->Line!=-1) {
                char book[16];
                sprintf(book,"_SVN.%d",line);
                Lines[line]->Buf->GotoBookmark (book);
            }
        } else {
            char path[MAXPATH];
            strcpy (path,Directory);Slash (path,1);strcat (path,Lines[line]->File);
            if (FileLoad (0,path,0,V)==1) {
                V->SwitchToModel (ActiveModel);
                if (Lines[line]->Line!=-1) ((EBuffer *)ActiveModel)->CenterNearPosR (0,Lines[line]->Line);
            }
        }
    }
}
//////////////////////////////////////////////////////////
//
// RequiresAltTabFix
//
// Return true if there might be an alt-tab black screen problem when using gta_sa.exe
//
//////////////////////////////////////////////////////////
bool RequiresAltTabFix( void )
{
    // Exception for optimus because of better hi-perf detection when using gta_sa.exe
    if ( GetApplicationSettingInt( "nvhacks", "optimus" ) )
        return false;

    // Check for problem combo of: Windows 10 + NVidia card + full screen
    if ( IsWindows10OrGreater() && GetApplicationSettingInt( "nvhacks", "nvidia" ) )
    {
        // Slighty hacky way of checking in-game settings
        SString strCoreConfig;
        FileLoad( CalcMTASAPath( PathJoin( "mta", "config", "coreconfig.xml" ) ), strCoreConfig );
        int iWindowed        = atoi( strCoreConfig.SplitRight( "<display_windowed>" ) );
        int iFullscreenStyle = atoi( strCoreConfig.SplitRight( "<display_fullscreen_style>" ) );
        if ( iWindowed == 0 && iFullscreenStyle == 0 )   // 0=FULLSCREEN_STANDARD
            return true;        
    }
    return false;
}
Exemple #16
0
int EView::ShowVersion() {
    if (access("/usr/local/share/doc/efte/README", 0) == 0)
        FileLoad(0, "/usr/local/share/doc/efte/README", 0, this);
    else if (access("/usr/share/doc/efte/README", 0) == 0)
        FileLoad(0, "/usr/share/doc/efte/README", 0, this);
    else if (access("/efte/doc/README", 0) == 0)
        FileLoad(0, "/efte/doc/README", 0, this);
    else if (access("/efte/README", 0) == 0)
        FileLoad(0, "/efte/README", 0, this);
    else if (access("/Program Files/efte/doc/README", 0) == 0)
        FileLoad(0, "/Program Files/efte/doc/README", 0, this);
    else if (access("/Program Files (x86)/doc/README", 0) == 0)
        FileLoad(0, "/Program Files (x86)/doc/README", 0, this);
    else
        MView->Win->Choice(0, "About", 1, "O&K", PROGRAM " " VERSION " " COPYRIGHT);
    return 1;
}
Exemple #17
0
int EView::SysShowHelp(ExState &State, const char *word) {
    char options[128] = "";
    char command[1024];
    char file[MAXPATH];

    if (State.GetStrParam(this, options, sizeof(options) - 1) == 0)
        options[0] = 0;

    char wordAsk[64] = "";
    if (word == 0) {
        if (State.GetStrParam(this, wordAsk, sizeof(wordAsk) - 1) == 0)
            if (MView->Win->GetStr("Keyword",
                                   sizeof(wordAsk) - 1, wordAsk, HIST_DEFAULT) == 0)
                return 0;
        word = wordAsk;
    }

    snprintf(file, sizeof(file)-1, "/tmp/fte%d-man-%s", getpid(), word);
    snprintf(command, sizeof(command)-1, "%s %s %s >'%s' 2>&1", HelpCommand, options, word, file);

    /// !!! why is this needed ???
#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
    pid_t pid;
    int err, status;

    Msg(S_INFO, "Retrieving man page for %s, please wait", word);

    if ((pid = fork()) == 0) {
        close(1);
        SYSCALL(err = open(file, O_CREAT | O_WRONLY | O_APPEND, S_IRWXU));
	if (err != -1) {
	    close(2);
            //dup(1); // ignore error output
            close(0);
            assert(open("/dev/null", O_RDONLY) == 0);
            execlp("man", "man",
#ifndef AIX // current AIX's don't like the -a.
                   "-a",
#endif
                   word, NULL);
            // execlp("/bin/sh", "sh", "-c", command, NULL);
        }
        perror("Can't Exec Command\n");
        exit(-1);
    } else if (pid < 0) {
        perror("Can't fork");
        return 0;
    }
    SYSCALL(err = waitpid(pid, &status, 0));
    if (err == -1) {
        perror("Waitpid failed\n");
        return 0;
    }

    // int rc = system(command);

    err = FileLoad(0, file, "CATBS", this);
    unlink(file);

    if (err == 0){
        Msg(S_ERROR, "Error code %d retrieving manpage for %s", err, word);
        return 0;
    }
    return 1;
}
Exemple #18
0
int LoadDesktop(char *FileName) {
    FILE *fp;
    char line[512];
    char *p, *e;
    int FLCount = 0;

    TagClear();

    fp = fopen(FileName, "r");
    if (fp == 0)
        return 0;

    //setvbuf(fp, FileBuffer, _IOFBF, sizeof(FileBuffer));

    if (fgets(line, sizeof(line), fp) == 0 ||
            (strcmp(line, DESKTOP_VER) != 0 &&
             (strcmp(line, DESKTOP_VER1) != 0))) {
        fclose(fp);
        return 0;
    }
    while (fgets(line, sizeof(line), fp) != 0) {
        e = strchr(line, '\n');
        if (e == 0)
            break;
        *e = 0;
        if ((line[0] == 'D' || line[0] == 'F') && line[1] == '|') {
            int ModelNo = -1;
            p = line + 2;
            if (isdigit(*p)) {
                ModelNo = atoi(p);
                while (isdigit(*p)) p++;
                if (*p == '|')
                    p++;
            }

            if (line[0] == 'F') { // file
                if (FLCount > 0)
                    suspendLoads = 1;
                if (FileLoad(0, p, 0, ActiveView))
                    FLCount++;
                suspendLoads  = 0;
            } else if (line[0] == 'D') { // directory
                EModel *m = new EDirectory(0, &ActiveModel, p);
                if (m == 0 || ActiveModel == 0) {
                    ActiveView->MView->Win->Choice(GPC_ERROR, "Error", 1, "O&K",
                                                   "Could not create directory view");
                    return 0;
                }
            }

            if (ActiveModel) {
                if (ModelNo != -1) {
                    if (FindModelID(ActiveModel, ModelNo) == 0)
                        ActiveModel->ModelNo = ModelNo;
                }

                if (ActiveModel != ActiveModel->Next) {
                    suspendLoads = 1;
                    ActiveView->SelectModel(ActiveModel->Next);
                    suspendLoads  = 0;
                }
            }
        } else {
            if (line[0] == 'T' && line[1] == '|') { // tag file
                TagsAdd(line + 2);
            } else if (line[0] == 'M' && line[1] == '|') { // mark
                char *name;
                char *file;
                EPoint P;
                //long l;
                char *c;

                p = line + 2;
                P.Row = strtol(p, &c, 10);
                if (*c != '|')
                    break;
                p = c + 1;
                P.Col = strtol(p, &c, 10);
                if (*c != '|')
                    break;
                p = c + 1;
                name = p;
                while (*p && *p != '|')
                    p++;
                if (*p == '|')
                    *p++ = 0;
                else
                    break;
                file = p;

                markIndex.Insert(name, file, P);
            }
        }
    }
    fclose(fp);
    return 1;
}
Exemple #19
0
int  ArtCallback( httpd_handler_sys_t *p_args,
                          httpd_handler_t *p_handler, char *_p_url,
                          uint8_t *p_request, int i_type,
                          uint8_t *p_in, int i_in,
                          char *psz_remote_addr, char *psz_remote_host,
                          uint8_t **pp_data, int *pi_data )
{
    VLC_UNUSED(p_handler); VLC_UNUSED(_p_url); VLC_UNUSED(i_type); 
    VLC_UNUSED(p_in); VLC_UNUSED(i_in); VLC_UNUSED(psz_remote_addr); 
    VLC_UNUSED(psz_remote_host); 

    char *psz_art = NULL;
    intf_thread_t *p_intf = p_args->file.p_intf;
    intf_sys_t *p_sys = p_intf->p_sys;
    char psz_id[16];
    input_item_t *p_item = NULL;
    int i_id;

    psz_id[0] = '\0';
    if( p_request )
        ExtractURIValue( (char *)p_request, "id", psz_id, 15 );
    i_id = atoi( psz_id );
    if( i_id )
    {
        playlist_Lock( p_sys->p_playlist );
        playlist_item_t *p_pl_item = playlist_ItemGetById( p_sys->p_playlist,
                                                           i_id );
        if( p_pl_item )
            p_item = p_pl_item->p_input;
        playlist_Unlock( p_sys->p_playlist );
    }
    else
    {
        /* FIXME: Workarround a stupid assert in input_GetItem */
        if( p_sys->p_input && p_sys->p_input->p )
            p_item = input_GetItem( p_sys->p_input );
    }

    if( p_item )
    {
        psz_art = input_item_GetArtURL( p_item );
    }

    if( psz_art )
    {
        char *psz = make_path( psz_art );
        free( psz_art );
        psz_art = psz;
    }

    if( psz_art == NULL )
    {
        msg_Dbg( p_intf, "No album art found" );
        Callback404( &p_args->file, (char**)pp_data, pi_data );
        return VLC_SUCCESS;
    }

    FILE *f = vlc_fopen( psz_art, "r" );
    if( f == NULL )
    {
        msg_Dbg( p_intf, "Couldn't open album art file %s", psz_art );
        Callback404( &p_args->file, (char**)pp_data, pi_data );
        free( psz_art );
        return VLC_SUCCESS;
    }
    free( psz_art );

    char *p_data = NULL;
    int i_data;
    FileLoad( f, &p_data, &i_data );
    fclose( f );

    char *psz_ext = strrchr( psz_art, '.' );
    if( psz_ext ) psz_ext++;

#define HEADER  "Content-Type: image/%s\n" \
                "Content-Length: %d\n" \
                "\n"
    char *psz_header;
    int i_header_size = asprintf( &psz_header, HEADER, psz_ext, i_data );
#undef HEADER
    if( likely(i_header_size != -1) )
    {
        *pp_data = malloc( i_header_size + i_data );
        if( likely(*pp_data != NULL) )
        {
            *pi_data = i_header_size + i_data;
            memcpy( *pp_data, psz_header, i_header_size );
            memcpy( *pp_data+i_header_size, p_data, i_data );
        }
        free( psz_header );
    }
    free( p_data );

    return VLC_SUCCESS;
}
Exemple #20
0
wxExListViewFile::wxExListViewFile(wxWindow* parent,
  wxExFrameWithHistory* frame,
  const wxString& file,
  wxWindowID id,
  long menu_flags,
  const wxPoint& pos,
  const wxSize& size,
  long style,
  const wxValidator& validator,
  const wxString& name)
  : wxExListViewWithFrame(
      parent, 
      frame, 
      LIST_FILE, 
      id, 
      menu_flags, 
      NULL, 
      pos, 
      size, 
      style, 
      validator, 
      name)
  , wxExFile(false) // do not open files in FileLoad and Save
  , m_AddItemsDialog(NULL)
  , m_ContentsChanged(false)
  , m_TextAddFiles(_("Add files"))
  , m_TextAddFolders(_("Add folders"))
  , m_TextAddRecursive(_("Recursive"))
  , m_TextAddWhat(_("Add what"))
  , m_TextInFolder(_("In folder"))
  , m_ItemUpdated(false)
  , m_ItemNumber(0)
{
  FileLoad(file);
  
  std::vector<wxExConfigItem> v;

  v.push_back(wxExConfigItem(
    m_TextAddWhat, 
    CONFIG_COMBOBOX, 
    wxEmptyString, 
    true));

  v.push_back(wxExConfigItem(
    m_TextInFolder, 
    CONFIG_COMBOBOXDIR, 
    wxEmptyString, 
    true,
    1000));

  std::set<wxString> set;
    
  set.insert(m_TextAddFiles);
  set.insert(m_TextAddFolders);
  set.insert(m_TextAddRecursive);

  v.push_back(wxExConfigItem(set));

  m_AddItemsDialog = new wxExConfigDialog(this,
    v,
    _("Add Items"),
    0,
    1,
    wxOK | wxCANCEL,
    wxID_ADD);
}
Exemple #21
0
Fichier : http.c Projet : paa/vlc
int  ArtCallback( httpd_handler_sys_t *p_args,
                          httpd_handler_t *p_handler, char *_p_url,
                          uint8_t *p_request, int i_type,
                          uint8_t *p_in, int i_in,
                          char *psz_remote_addr, char *psz_remote_host,
                          uint8_t **pp_data, int *pi_data )
{
    VLC_UNUSED(p_handler); VLC_UNUSED(_p_url); VLC_UNUSED(i_type); 
    VLC_UNUSED(p_in); VLC_UNUSED(i_in); VLC_UNUSED(psz_remote_addr); 
    VLC_UNUSED(psz_remote_host); 
    VLC_UNUSED(p_request);

    char *psz_art = NULL;
    intf_thread_t *p_intf = p_args->file.p_intf;
    intf_sys_t *p_sys = p_intf->p_sys;
    input_item_t *p_item = NULL;
    p_sys->p_input = playlist_CurrentInput( p_sys->p_playlist );
        /* Workaround a stupid assert in input_GetItem */
        if( p_sys->p_input && p_sys->p_input->p )
            p_item = input_GetItem( p_sys->p_input );
    if( p_item )
    {
        psz_art = input_item_GetArtURL( p_item );
    }

    if( psz_art )
    {
        char *psz = make_path( psz_art );
        free( psz_art );
        psz_art = psz;
    }

    if( psz_art == NULL )
    {
        msg_Dbg( p_intf, "didn't find any art, so use default" );
        char *psz_src = var_InheritString( p_intf, "http-src" );
        if( psz_src == NULL )
        {
            char *data_path = config_GetDataDir( p_intf );
            if( asprintf( &psz_src, "%s" DIR_SEP "http", data_path ) == -1 )
                psz_src = NULL;
            free( data_path );
        }
        if( asprintf( &psz_art, "%s" DIR_SEP "images" DIR_SEP "default_album_art.png", psz_src ) == -1 )
                psz_art = NULL;
        free( psz_src );
    }

    FILE *f = vlc_fopen( psz_art, "r" );
    if( f == NULL )
    {
        Callback404( &p_args->file, (char**)pp_data, pi_data );
        free( psz_art );
        return VLC_SUCCESS;
    }
    free( psz_art );

    char *p_data = NULL;
    int i_data;
    FileLoad( f, &p_data, &i_data );
    fclose( f );

    char *psz_ext = strrchr( psz_art, '.' );
    if( psz_ext ) psz_ext++;

#define HEADER  "Content-Type: image/%s\n" \
                "Content-Length: %d\n" \
                "\n"
    char *psz_header;
    int i_header_size = asprintf( &psz_header, HEADER, psz_ext, i_data );
#undef HEADER
    if( likely(i_header_size != -1) )
    {
        *pp_data = malloc( i_header_size + i_data );
        if( likely(*pp_data != NULL) )
        {
            *pi_data = i_header_size + i_data;
            memcpy( *pp_data, psz_header, i_header_size );
            memcpy( *pp_data+i_header_size, p_data, i_data );
        }
        free( psz_header );
    }
    free( p_data );

    return VLC_SUCCESS;
}
Exemple #22
0
T_void FormLoadFromFile(T_byte8 *filename)
{
    FILE *fp, *fp2;
    T_word16 i, j;
    T_word16 objtype = 0, objid, x1, y1, x2, y2;
    T_word16 hotkey, toggletype, datatype, fieldtype, fcolor, bcolor, justify;
    T_word16 sbupID, sbdnID, sbgrID;
    T_word16 numericonly;
    T_word32 maxlength;
    T_byte8 picname[32];
    T_byte8 buttontext[256];
    T_byte8 fontname[32];
    T_byte8 tempstr[256];
    T_byte8 tempstr2[256];
    T_byte8 tempstr3[32];
    T_byte8 val;
    E_Boolean isincludedfile = FALSE;
    E_Boolean appendtext = FALSE;
    E_Boolean cursorset = FALSE;
    T_formObjectID objID;
    T_formObjectStruct *p_obj, *p_obj2;
    T_TxtfldStruct *p_txtfld;
    T_buttonStruct *p_button;
    T_buttonID buttonID, SBUbuttonID, SBDbuttonID;
    T_graphicID SBGgraphicID;
    T_sliderID sliderID;
    T_byte8 *p_includedtext;
    T_word32 size;

    DebugRoutine("FormLoadFromFile");
    DebugCheck(filename!=NULL);

    /* first, clean up the form structure and delete any previous forms */
    FormCleanUp();

    /* open up the file */
    fp = fopen(filename, "r");
    DebugCheck(fp!=NULL);
    while (feof(fp) == FALSE) {
        objtype = 0;
        /* get a line from the main file */
        fgets(tempstr, 128, fp);
        /* strip last (newline) character */
        if (tempstr[strlen(tempstr) - 1] == '\n')
            tempstr[strlen(tempstr) - 1] = '\0';

        /* append text to current object if flag is set */
        if (appendtext == TRUE) {
            if (strcmp(tempstr, "ENDOFTEXT") == 0) {
                /* turn off appendstring mode */
                TxtboxBackSpace(p_obj->objID);
                TxtboxCursTop(p_obj->objID);
                TxtboxRepaginate(p_obj->objID);
                TxtboxFirstBox();
                appendtext = FALSE;
                sprintf(tempstr, "#");
            } else if (tempstr[0] != '$' && tempstr[0] != '#') {
                /* strip last character if newline */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                TxtboxAppendString(p_obj->objID, tempstr);
                TxtboxAppendKey(p_obj->objID, 13);
                sprintf(tempstr, "#");
            }
        }

        /* check to see if we should open an included file */
        if (tempstr[0] == '$') {
            /* strip the '$' from the string */
            for (i = 1; i < strlen(tempstr); i++)
                tempstr2[i - 1] = tempstr[i];
            tempstr2[i - 1] = '\0';
            /* open an included file */
            p_includedtext = FileLoad(tempstr2, &size);
            TxtboxSetData(p_obj->objID, p_includedtext);
            TxtboxRepaginateAll(p_obj->objID);
            TxtboxCursTop(p_obj->objID);
            MemFree(p_includedtext);

//        	fp2 = fopen (tempstr2,"r");
//	        DebugCheck (fp2!=NULL);
//           isincludedfile=TRUE;

            sprintf(tempstr, "#");
        }

        /* ignore comments and blank lines */
        if (tempstr[0] != '#' && tempstr[0] != ' ') {
            sscanf(tempstr, "%d", &objtype);
            if (objtype == 1) /* add a graphic */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%s", &objtype, &objid, &x1, &y1,
                        picname);
                FormAddGraphic(x1, y1, picname, objid);
            } else if (objtype == 2) /* add a text */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &fcolor, &bcolor);
                /* get font name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", fontname);
                /* get text */
                fgets(tempstr, 128, fp);
                /* strip last (newline) character */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                /* add a text object */
                FormAddText(x1, y1, tempstr, fontname, fcolor, bcolor, objid);
            } else if (objtype == 3) /* add a button */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d,%s", &objtype, &objid, &x1,
                        &y1, &toggletype, &hotkey, picname);
                FormAddButton(x1, y1, picname, (E_Boolean)toggletype, hotkey,
                        objid);
            } else if (objtype == 4) /* add a text button */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &fcolor, &toggletype, &hotkey);
                /* get picture name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", picname);
                /* get font name */
                fgets(tempstr, 128, fp);
                sscanf(tempstr, "%s", fontname);
                /* get buttontext */
                fgets(tempstr, 128, fp);
                /* strip last (newline) character */
                if (tempstr[strlen(tempstr) - 1] == '\n')
                    tempstr[strlen(tempstr) - 1] = '\0';
                /* make a text button */
                FormAddTextButton(x1, y1, tempstr, picname, fontname, fcolor, 0,
                        (E_Boolean)toggletype, hotkey, objid);
            } else if (objtype == 5) /* add a text box */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s",
                        &objtype, &objid, &x1, &y1, &x2, &y2, &maxlength,
                        &numericonly, &justify, &fieldtype, &hotkey, &sbupID,
                        &sbdnID, &sbgrID, fontname);

                /* read in default text */
//                fgets (tempstr,128,fp);
                /* create a text box */
                /* set maximum length to highest possible value if 0 */
                if (maxlength == 0)
                    maxlength--;

                objID = FormAddTextBox(x1, y1, x2, y2, fontname, maxlength,
                        hotkey, numericonly, justify, (E_TxtboxMode)fieldtype,
                        objid);

                DebugCheck(objID != NULL);
                /* set form scroll bar stuff */
                if (sbupID != 0) {
                    SBUbuttonID = FormGetObjID(sbupID);
                    ButtonSetData(SBUbuttonID, objid);
                    ButtonSetCallbacks(SBUbuttonID, NULL, TxtboxHandleSBUp);
                    SBDbuttonID = FormGetObjID(sbdnID);
                    ButtonSetData(SBDbuttonID, objid);
                    ButtonSetCallbacks(SBDbuttonID, NULL, TxtboxHandleSBDn);
                    SBGgraphicID = FormGetObjID(sbgrID);
                    DebugCheck(SBUbuttonID != NULL);
                    DebugCheck(SBDbuttonID != NULL);
                    DebugCheck(SBGgraphicID != NULL);
                    p_obj = (T_formObjectStruct*)objID;
                    TxtboxSetScrollBarObjIDs(p_obj->objID, SBUbuttonID,
                            SBDbuttonID, SBGgraphicID);
                }

                /* set default text */
                p_obj = (T_formObjectStruct *)objID;
                appendtext = TRUE;

            } else if (objtype == 6) /* add a slider */
            {
                sscanf(tempstr, "%d,%d,%d,%d,%d", &objtype, &objid, &x1, &y1,
                        &x2);
                objID = FormAddSlider(x1, y1, x2, objid);
                DebugCheck(objID != NULL);
                p_obj = (T_formObjectStruct *)objID;
                SliderSetCallBack(p_obj->objID, FormReportSlider);
            }
        }
    }
    fclose(fp);
    DebugEnd();
}
Exemple #23
0
//============================================================================
//パラメーターの読み込み
//============================================================================
//[input]
//	pFileName:ファイル名
//===========================================================================
void CEnemy::LoadParameter( const char *pFileName )
{
	CFileLoader FileLoad( pFileName );
	
	vector< string > vecStr = CFileLoader::SplitString( FileLoad.GetStrList().at( 0 ), "," );
	
	//----------------------------------------------
	//位置の設定
	//----------------------------------------------
	SetParameter( m_vInitPos.x, vecStr.at( 0 ) );
	
	SetParameter( m_vInitPos.y, vecStr.at( 1 ) );
	
	//----------------------------------------------
	//角度の設定
	//----------------------------------------------
	SetParameter( m_InitAngle, vecStr.at( 2 ) );
	
	//----------------------------------------------
	//拡縮率の設定
	//----------------------------------------------
	SetParameter( m_fInitScale.x, vecStr.at( 3 ) );
	
	SetParameter( m_fInitScale.y, vecStr.at( 4 ) );
	
	//----------------------------------------------
	//分割数の設定
	//----------------------------------------------
	SetParameter( m_DivNum.x, vecStr.at( 5 ) );
	
	SetParameter( m_DivNum.y, vecStr.at( 6 ) );
	
	//----------------------------------------------
	//アニメーションの設定
	//----------------------------------------------
	SetParameter( m_IsAnim, vecStr.at( 7 ) );
	
	SetParameter( m_AnimTime, vecStr.at( 8 ) );
	
	//----------------------------------------------
	//ゲームの設定
	//----------------------------------------------
	SetParameter( m_Life, vecStr.at( 9 ) );
	
	SetParameter( m_Score, vecStr.at( 10 ) );
	
	//----------------------------------------------
	//パターンの設定
	//----------------------------------------------
	SetParameter( (int&)m_eMovePat, vecStr.at( 11 ) );
	
	SetParameter( (int&)m_eShotPat, vecStr.at( 12 ) );
	
	//----------------------------------------------
	//移動スピードの設定
	//----------------------------------------------
	SetParameter( m_fSpeed, vecStr.at( 13 ) );
	
	//----------------------------------------------
	//弾の設定
	//----------------------------------------------
	SetParameter( m_ShotTime, vecStr.at( 14 ) );
	
	//弾の最大数の設定
	SetParameter( m_MaxShot, vecStr.at( 15 ) );
	
	
	
	
}