Exemple #1
0
static int		move_to_dir(t_env *env, char *path)
{
	char	*oldpwd;
	char	*pwd;
	char	buffer[256];

	pwd = getcwd(buffer, 256);
	if (!pwd)
	{
		permission_denied("cd", path);
		return (1);
	}
	oldpwd = ft_strdup(pwd);
	if (chdir(path) == 0)
	{
		pwd = getcwd(buffer, 256);
		move_old_and_pwd(env, oldpwd, pwd);
		ft_memdel((void**)&oldpwd);
		return (0);
	}
	else
	{
		no_such_file(path);
		ft_memdel((void**)&oldpwd);
		return (-1);
	}
}
Exemple #2
0
bool
SkFontManager::openPreDataRead( SkStream ** preData )
{
    SkStream * stream = openReadStream( SYSTEM_DL_PREDATA_FILE );

    if( !stream )
    {
        if( permission_denied() )
            goto SKIP_ERROR0;

        if( !no_such_file() )
            goto ERROR0;

        goto SKIP_ERROR0;
    }

    *preData = stream;
    return true;

SKIP_ERROR0:
    return false;

ERROR0:
    if( stream )
        SkDELETE( stream );
    return false;
}
Exemple #3
0
/* 10123
* report statistics for server commands.
*/
static HANDLER(histogram)
{
    unsigned long  count = 0;
    double  bytes = 0;
    int     l;

    (void) pkt;
    (void) len;
    CHECK_USER_CLASS("histogram");
    if(con->user->level < LEVEL_MODERATOR )
    {
        permission_denied(con);
        return;
    }
    for (l = 0; l < Protocol_Size; l++)
    {
        if(Protocol[l].count != 0)
            send_cmd(con, tag, "%d %u %.0f", Protocol[l].message, Protocol[l].count, Protocol[l].bytes);
        count += Protocol[l].count;
        bytes += Protocol[l].bytes;
    }
    send_cmd(con, MSG_SERVER_HISTOGRAM, "%d %u %.0f %lu %.0f", unknown_numeric.message, unknown_numeric.count, unknown_numeric.bytes, count, bytes);
}
Exemple #4
0
/* 10125
* report statistics for outging commands.
*/
static HANDLER(shistogram) 
{
    LIST    *list;
    histogram_t *h;
    unsigned long count = 0;
    double   bytes = 0;

    (void) pkt;
    (void) len;
    CHECK_USER_CLASS("shistogram");
    if(con->user->level < LEVEL_MODERATOR ) 
	{
        permission_denied(con);
        return;
    }
    for (list = global.histOutList; list; list = list->next) 
	{
        h = list->data;
        send_cmd(con, tag, "%d %u %u %s", h->tag, h->count, h->len, tag2hrf(h->tag) );
        count += h->count;
        bytes += h->len;
    }
    send_cmd(con, MSG_SERVER_SHISTOGRAM, "%lu %.0f", count, bytes );
}
Exemple #5
0
bool
SkFontManager::savePreData()
{
    SkStream * inStream = openReadStream( SYSTEM_DL_PREDATA_FILE );
    SkFILEWStream * outStream = NULL;
    preDataHeader header = { 1, __key(), 0 };
    SkString permission;

    if( !inStream )
    {
        setUpdateVersion( 2 );
        header.updateVersion++;
        header.count = mDownloadFonts.numFonts();
        goto SAVE0;
    }
    else
    {
        inStream->read( &header, SYSTEM_DL_PREDATA_HEADER_LEN );

        if( header.tag != __key() )
        {
            header.updateVersion = 1;
            header.tag = __key();
            header.count = mDownloadFonts.numFonts();
            goto SAVE1;
        }

        header.count = mDownloadFonts.numFonts();
        header.updateVersion++;
        if( header.updateVersion >= 0xFFFFFFFE )
            header.updateVersion = 2;
    }

SAVE1:
    SkDELETE( inStream );
    inStream = NULL;

SAVE0:
    outStream = openWriteStream( SYSTEM_DL_PREDATA_FILE );

    if( !outStream )
    {
        if( permission_denied() )
            goto SKIP_ERROR0;
        HyLogef( "outStream is null" );
        goto ERROR0;
    }

    outStream->write( &header, SYSTEM_DL_PREDATA_HEADER_LEN );

    for( uint32_t n = 0 ; n < header.count ; n++ )
    {
        SkFontData * font = mDownloadFonts.getFont( n );
        font->writePreData( outStream );
    }

    SkDELETE( outStream );
    outStream = NULL;

    //setUpdateVersion( header.updateVersion );

    permission.set( SYSTEM_FONT_PERMISSION_SET );
    permission.append( SYSTEM_DL_PREDATA_FILE );
    system( permission.c_str() );

    HyLogi( "Font Configuration Data (%d), saved.", header.updateVersion );
    return true;

SKIP_ERROR0:
    return false;

ERROR0:
    if( outStream )
        SkDELETE( outStream );
    return false;
}
Exemple #6
0
LoadState
SkFontManager::loadPreData( uint32_t * newFontIndex, bool boot )
{
    LoadState state = load_true;
    preDataHeader header = { 0, 0, 0 };
    uint32_t curFontIndex = ( boot == true ? readFontConfig() : getCurrentFontIndex() );
    uint32_t curNewFontIndex = curFontIndex;
    uint32_t numEmbeddedFonts = mEmbeddedFonts.numFonts();
    bool statePass = ( curFontIndex < numEmbeddedFonts ? true : false );
    bool system = ( newFontIndex != NULL ? true : false );
    SkStream * stream = NULL;

    if( openPreDataRead( &stream ) == false )
    {
        if( no_such_file() || permission_denied() )
            goto SKIP_ERROR0;

        HyLogef( "openPreDataRead(%s (%d))", strerror( errno ), errno );
        goto ERROR0;
    }

    stream->read( &header, SYSTEM_DL_PREDATA_HEADER_LEN );

    if( header.tag != __key() )
    {
        HyLogef( "Wrong tag" );
        goto ERROR0;
    }

LOAD_START:
    if( getUpdateVersion() == 0 ) // Boot Load & reload.
    {
        setUpdateVersion( header.updateVersion );

        if( header.count == 0 )
            goto SUCCEED0;

        for( uint32_t n = 0 ; n < header.count ; n++ )
        {
            SkFontData * font = SkNEW( SkFontData );

            if( font )
            {
                font->readPreData( stream );

                if( font->checkCertify( system ) == true )
                {
                    font->loadFont();
                    mDownloadFonts.addFonts( font );
                }
                else
                {
                    if( ( system == true ) && ( statePass == false ) )
                    {
                        if( state != load_restart )
                        {
                            if( ( numEmbeddedFonts + n ) == curFontIndex )
                            {
                                state = load_restart;
                            }
                            else
                            {
                                state = load_change;
                                if( ( numEmbeddedFonts + n ) < curFontIndex )
                                    curNewFontIndex--;
                            }
                        }
                    }
                    else
                    {
                        state = load_change;
                    }

                    font->deleteFiles();
                    SkDELETE( font );
                    font = NULL;
                }
            }
            else
            {
                HyLogef( "SkNEW( SkFontData )" );
                continue;
            }
        }
    }
    else // Fonts change
    {
        if( getUpdateVersion() == header.updateVersion )
        {
            goto SUCCEED0;
        }
        else
        {
            mDownloadFonts.resetFonts();
            setUpdateVersion( 0 );
            goto LOAD_START;
        }
    }

SUCCEED0:
    if( ( system == true ) && ( statePass == false ) )
    {
        switch( state )
        {
        case load_change:
            *newFontIndex = curNewFontIndex;
            break;
        case load_restart:
            *newFontIndex = SYSTEM_DEFAULT_FAMILY_INDEX;
            break;
        default:
            *newFontIndex = curFontIndex;
            break;
        }
    }
    else if( ( system == true ) && ( statePass == true ) )
    {
        *newFontIndex = curFontIndex;
    }

    if( stream )
        SkDELETE( stream );
    return state;

SKIP_ERROR0:
    return load_false;

ERROR0:
    if( stream )
        SkDELETE( stream );
    return load_false;
}