Changeset 606657480ad9bf46664eea80f2a8e49aabc02d37

Show
Ignore:
Timestamp:
08/17/05 14:00:44 (3 years ago)
Author:
Christophe Massiot <massiot@videolan.org>
git-committer:
Christophe Massiot <massiot@videolan.org> 1124280044 +0000
git-parent:

[5b85463a3602cd055425c8ef0854a8ca7bee13f4]

git-author:
Christophe Massiot <massiot@videolan.org> 1124280044 +0000
Message:
  • modules/control/http.c: New RPN functions :
    • 'variable' vlc_var_type
    • 'variable' vlc_config_type
    • value 'variable' vlc_var_set (renamed from vlc_set_var for consistency)
    • 'variable' vlc_var_get
    • value 'variable' vlc_config_set
    • 'variable' vlc_config_get
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/control/http.c

    rbb137a2 r6066574  
    15891589                         char * ); 
    15901590 
    1591 static void SSPush  ( rpn_stack_t *, char * ); 
     1591static void SSPush  ( rpn_stack_t *, const char * ); 
    15921592static char *SSPop  ( rpn_stack_t * ); 
    15931593 
     
    32503250} 
    32513251 
    3252 static void SSPush( rpn_stack_t *st, char *s ) 
     3252static void SSPush( rpn_stack_t *st, const char *s ) 
    32533253{ 
    32543254    if( st->i_stack < STACK_MAX ) 
     
    37933793            free( psz_value ); 
    37943794        } 
    3795         else if( !strcmp( s, "vlc_set_var" ) ) 
    3796         { 
     3795        else if( !strcmp( s, "vlc_var_type" ) 
     3796                  || !strcmp( s, "vlc_config_type" ) ) 
     3797        { 
     3798            const char *psz_type = NULL; 
    37973799            char *psz_variable = SSPop( st ); 
    3798             char *psz_value = NULL; 
    3799             vlc_value_t val; 
     3800            vlc_object_t *p_object; 
    38003801            int i_type; 
    38013802 
     3803            if( !strcmp( s, "vlc_var_type" ) ) 
     3804            { 
     3805                p_object = VLC_OBJECT(p_sys->p_input); 
     3806                if( p_object != NULL ) 
     3807                    i_type = var_Type( p_object, psz_variable ); 
     3808            } 
     3809            else 
     3810            { 
     3811                p_object = VLC_OBJECT(p_intf); 
     3812                i_type = config_GetType( p_object, psz_variable ); 
     3813            } 
     3814 
     3815            if( p_object != NULL ) 
     3816            { 
     3817                switch( i_type & VLC_VAR_TYPE ) 
     3818                { 
     3819                case VLC_VAR_BOOL: 
     3820                    psz_type = "VLC_VAR_BOOL"; 
     3821                    break; 
     3822                case VLC_VAR_INTEGER: 
     3823                    psz_type = "VLC_VAR_INTEGER"; 
     3824                    break; 
     3825                case VLC_VAR_HOTKEY: 
     3826                    psz_type = "VLC_VAR_HOTKEY"; 
     3827                    break; 
     3828                case VLC_VAR_STRING: 
     3829                    psz_type = "VLC_VAR_STRING"; 
     3830                    break; 
     3831                case VLC_VAR_MODULE: 
     3832                    psz_type = "VLC_VAR_MODULE"; 
     3833                    break; 
     3834                case VLC_VAR_FILE: 
     3835                    psz_type = "VLC_VAR_FILE"; 
     3836                    break; 
     3837                case VLC_VAR_DIRECTORY: 
     3838                    psz_type = "VLC_VAR_DIRECTORY"; 
     3839                    break; 
     3840                case VLC_VAR_VARIABLE: 
     3841                    psz_type = "VLC_VAR_VARIABLE"; 
     3842                    break; 
     3843                case VLC_VAR_FLOAT: 
     3844                    psz_type = "VLC_VAR_FLOAT"; 
     3845                    break; 
     3846                default: 
     3847                    psz_type = "UNDEFINED"; 
     3848                } 
     3849            } 
     3850            else 
     3851                psz_type = "INVALID"; 
     3852 
     3853            SSPush( st, psz_type ); 
     3854            free( psz_variable ); 
     3855        } 
     3856        else if( !strcmp( s, "vlc_var_set" ) ) 
     3857        { 
     3858            char *psz_variable = SSPop( st ); 
     3859 
    38023860            if( p_sys->p_input != NULL ) 
    38033861            { 
     3862                vlc_bool_t b_error = VLC_FALSE; 
     3863                char *psz_value = NULL; 
     3864                vlc_value_t val; 
     3865                int i_type; 
     3866 
    38043867                i_type = var_Type( p_sys->p_input, psz_variable ); 
    38053868 
    3806                 if( (i_type & VLC_VAR_TYPE) == VLC_VAR_INTEGER
    3807                 { 
    3808                     int i_value = SSPopN( st, vars ); 
    3809                     val.i_int = i_value
     3869                switch( i_type & VLC_VAR_TYPE
     3870                { 
     3871                case VLC_VAR_BOOL: 
     3872                    val.b_bool = SSPopN( st, vars )
    38103873                    msg_Dbg( p_intf, "requested input var change: %s->%d", 
    3811                              psz_variable, i_value ); 
    3812                 } 
    3813                 else 
    3814                 { 
    3815                     psz_value = SSPop( st ); 
    3816                     val.psz_string = psz_value; 
     3874                             psz_variable, val.b_bool ); 
     3875                    break; 
     3876                case VLC_VAR_INTEGER: 
     3877                case VLC_VAR_HOTKEY: 
     3878                    val.i_int = SSPopN( st, vars ); 
     3879                    msg_Dbg( p_intf, "requested input var change: %s->%d", 
     3880                             psz_variable, val.i_int ); 
     3881                    break; 
     3882                case VLC_VAR_STRING: 
     3883                case VLC_VAR_MODULE: 
     3884                case VLC_VAR_FILE: 
     3885                case VLC_VAR_DIRECTORY: 
     3886                case VLC_VAR_VARIABLE: 
     3887                    val.psz_string = psz_value = SSPop( st ); 
    38173888                    msg_Dbg( p_intf, "requested input var change: %s->%s", 
    38183889                             psz_variable, psz_value ); 
    3819                 } 
    3820  
    3821                 var_Set( p_sys->p_input, psz_variable, val ); 
    3822             } 
    3823             if( psz_value != NULL ) 
    3824                 free( psz_value ); 
     3890                    break; 
     3891                case VLC_VAR_FLOAT: 
     3892                    psz_value = SSPop( st ); 
     3893                    val.f_float = atof( psz_value ); 
     3894                    msg_Dbg( p_intf, "requested input var change: %s->%f", 
     3895                             psz_variable, val.f_float ); 
     3896                    break; 
     3897                default: 
     3898                    msg_Warn( p_intf, "invalid variable type %d (%s)", 
     3899                              i_type & VLC_VAR_TYPE, psz_variable ); 
     3900                    b_error = VLC_TRUE; 
     3901                } 
     3902 
     3903                if( !b_error ) 
     3904                    var_Set( p_sys->p_input, psz_variable, val ); 
     3905                if( psz_value != NULL ) 
     3906                    free( psz_value ); 
     3907            } 
     3908            else 
     3909                msg_Warn( p_intf, "vlc_var_set called without an input" ); 
     3910            free( psz_variable ); 
     3911        } 
     3912        else if( !strcmp( s, "vlc_var_get" ) ) 
     3913        { 
     3914            char *psz_variable = SSPop( st ); 
     3915 
     3916            if( p_sys->p_input != NULL ) 
     3917            { 
     3918                vlc_value_t val; 
     3919                int i_type; 
     3920 
     3921                i_type = var_Type( p_sys->p_input, psz_variable ); 
     3922                var_Get( p_sys->p_input, psz_variable, &val ); 
     3923 
     3924                switch( i_type & VLC_VAR_TYPE ) 
     3925                { 
     3926                case VLC_VAR_BOOL: 
     3927                    SSPushN( st, val.b_bool ); 
     3928                    break; 
     3929                case VLC_VAR_INTEGER: 
     3930                case VLC_VAR_HOTKEY: 
     3931                    SSPushN( st, val.i_int ); 
     3932                    break; 
     3933                case VLC_VAR_STRING: 
     3934                case VLC_VAR_MODULE: 
     3935                case VLC_VAR_FILE: 
     3936                case VLC_VAR_DIRECTORY: 
     3937                case VLC_VAR_VARIABLE: 
     3938                    SSPush( st, val.psz_string ); 
     3939                    free( val.psz_string ); 
     3940                    break; 
     3941                case VLC_VAR_FLOAT: 
     3942                { 
     3943                    char psz_value[20]; 
     3944                    snprintf( psz_value, sizeof(psz_value), "%f", val.f_float ); 
     3945                    SSPush( st, psz_value ); 
     3946                    break; 
     3947                } 
     3948                default: 
     3949                    msg_Warn( p_intf, "invalid variable type %d (%s)", 
     3950                              i_type & VLC_VAR_TYPE, psz_variable ); 
     3951                    SSPush( st, "" ); 
     3952                } 
     3953            } 
     3954            else 
     3955            { 
     3956                msg_Warn( p_intf, "vlc_var_get called without an input" ); 
     3957                SSPush( st, "" ); 
     3958            } 
     3959            free( psz_variable ); 
     3960        } 
     3961        else if( !strcmp( s, "vlc_config_set" ) ) 
     3962        { 
     3963            char *psz_variable = SSPop( st ); 
     3964            int i_type = config_GetType( p_intf, psz_variable ); 
     3965 
     3966            switch( i_type & VLC_VAR_TYPE ) 
     3967            { 
     3968            case VLC_VAR_BOOL: 
     3969            case VLC_VAR_INTEGER: 
     3970                config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) ); 
     3971                break; 
     3972            case VLC_VAR_STRING: 
     3973            case VLC_VAR_MODULE: 
     3974            case VLC_VAR_FILE: 
     3975            case VLC_VAR_DIRECTORY: 
     3976            { 
     3977                char *psz_string = SSPop( st ); 
     3978                config_PutPsz( p_intf, psz_variable, psz_string ); 
     3979                free( psz_string ); 
     3980                break; 
     3981            } 
     3982            case VLC_VAR_FLOAT: 
     3983            { 
     3984                char *psz_string = SSPop( st ); 
     3985                config_PutFloat( p_intf, psz_variable, atof(psz_string) ); 
     3986                free( psz_string ); 
     3987                break; 
     3988            } 
     3989            default: 
     3990                msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)", 
     3991                          psz_variable ); 
     3992            } 
     3993            free( psz_variable ); 
     3994        } 
     3995        else if( !strcmp( s, "vlc_config_get" ) ) 
     3996        { 
     3997            char *psz_variable = SSPop( st ); 
     3998            int i_type = config_GetType( p_intf, psz_variable ); 
     3999 
     4000            switch( i_type & VLC_VAR_TYPE ) 
     4001            { 
     4002            case VLC_VAR_BOOL: 
     4003            case VLC_VAR_INTEGER: 
     4004                SSPushN( st, config_GetInt( p_intf, psz_variable ) ); 
     4005                break; 
     4006            case VLC_VAR_STRING: 
     4007            case VLC_VAR_MODULE: 
     4008            case VLC_VAR_FILE: 
     4009            case VLC_VAR_DIRECTORY: 
     4010            { 
     4011                char *psz_string = config_GetPsz( p_intf, psz_variable ); 
     4012                SSPush( st, psz_string ); 
     4013                free( psz_string ); 
     4014                break; 
     4015            } 
     4016            case VLC_VAR_FLOAT: 
     4017            { 
     4018                char psz_string[20]; 
     4019                snprintf( psz_string, sizeof(psz_string), "%f", 
     4020                          config_GetFloat( p_intf, psz_variable ) ); 
     4021                SSPush( st, psz_string ); 
     4022                break; 
     4023            } 
     4024            default: 
     4025                msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)", 
     4026                          psz_variable ); 
     4027            } 
    38254028            free( psz_variable ); 
    38264029        }