⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vlmshell.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 4 页
字号:
        {            vlm_MessageAdd( p_msg_instance, vlm_MessageNew( "playlistindex",                            psz_tmp ) );            free( psz_tmp );        }    }    return p_msg;}static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,                                vlm_schedule_sys_t *schedule,                                const char *psz_filter ){    if( media != NULL )    {        vlm_message_t *p_msg = vlm_MessageNew( "show", vlm_NULL );        if( p_msg )            vlm_MessageAdd( p_msg, vlm_ShowMedia( media ) );        return p_msg;    }    else if( schedule != NULL )    {        int i;        vlm_message_t *msg;        vlm_message_t *msg_schedule;        vlm_message_t *msg_child;        char buffer[100];        msg = vlm_MessageNew( "show", vlm_NULL );        msg_schedule =            vlm_MessageAdd( msg, vlm_MessageNew( schedule->psz_name, vlm_NULL ) );        vlm_MessageAdd( msg_schedule, vlm_MessageNew("type", "schedule") );        vlm_MessageAdd( msg_schedule,                        vlm_MessageNew( "enabled", schedule->b_enabled ?                                        "yes" : "no" ) );        if( schedule->i_date != 0 )        {            struct tm date;            time_t i_time = (time_t)( schedule->i_date / 1000000 );            char *psz_date;            localtime_r( &i_time, &date);            if( asprintf( &psz_date, "%d/%d/%d-%d:%d:%d",                          date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,                          date.tm_hour, date.tm_min, date.tm_sec ) != -1 )            {                 vlm_MessageAdd( msg_schedule,                                 vlm_MessageNew( "date", psz_date ) );                 free( psz_date );            }        }        else            vlm_MessageAdd( msg_schedule, vlm_MessageNew("date", "now") );        if( schedule->i_period != 0 )        {            time_t i_time = (time_t) ( schedule->i_period / 1000000 );            struct tm date;            date.tm_sec = (int)( i_time % 60 );            i_time = i_time / 60;            date.tm_min = (int)( i_time % 60 );            i_time = i_time / 60;            date.tm_hour = (int)( i_time % 24 );            i_time = i_time / 24;            date.tm_mday = (int)( i_time % 30 );            i_time = i_time / 30;            /* okay, okay, months are not always 30 days long */            date.tm_mon = (int)( i_time % 12 );            i_time = i_time / 12;            date.tm_year = (int)i_time;            sprintf( buffer, "%d/%d/%d-%d:%d:%d", date.tm_year, date.tm_mon,                     date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec);            vlm_MessageAdd( msg_schedule, vlm_MessageNew("period", buffer) );        }        else            vlm_MessageAdd( msg_schedule, vlm_MessageNew("period", "0") );        sprintf( buffer, "%d", schedule->i_repeat );        vlm_MessageAdd( msg_schedule, vlm_MessageNew( "repeat", buffer ) );        msg_child =            vlm_MessageAdd( msg_schedule, vlm_MessageNew("commands", vlm_NULL ) );        for( i = 0; i < schedule->i_command; i++ )        {           vlm_MessageAdd( msg_child,                           vlm_MessageNew( schedule->command[i], vlm_NULL ) );        }        return msg;    }    else if( psz_filter && !strcmp( psz_filter, "media" ) )    {        vlm_message_t *p_msg;        vlm_message_t *p_msg_child;        int i_vod = 0, i_broadcast = 0;        int i;        char *psz_count;        for( i = 0; i < vlm->i_media; i++ )        {            if( vlm->media[i]->cfg.b_vod )                i_vod++;            else                i_broadcast++;        }        if( asprintf( &psz_count, "( %d broadcast - %d vod )", i_broadcast,                      i_vod) == -1 )            return NULL;        p_msg = vlm_MessageNew( "show", vlm_NULL );        p_msg_child = vlm_MessageAdd( p_msg, vlm_MessageNew( "media", psz_count ) );        free( psz_count );        for( i = 0; i < vlm->i_media; i++ )            vlm_MessageAdd( p_msg_child, vlm_ShowMedia( vlm->media[i] ) );        return p_msg;    }    else if( psz_filter && !strcmp( psz_filter, "schedule" ) )    {        int i;        vlm_message_t *msg;        vlm_message_t *msg_child;        msg = vlm_MessageNew( "show", vlm_NULL );        msg_child = vlm_MessageAdd( msg, vlm_MessageNew( "schedule", vlm_NULL ) );        for( i = 0; i < vlm->i_schedule; i++ )        {            vlm_schedule_sys_t *s = vlm->schedule[i];            vlm_message_t *msg_schedule;            mtime_t i_time, i_next_date;            msg_schedule = vlm_MessageAdd( msg_child,                                           vlm_MessageNew( s->psz_name, vlm_NULL ) );            vlm_MessageAdd( msg_schedule,                            vlm_MessageNew( "enabled", s->b_enabled ?                                            "yes" : "no" ) );            /* calculate next date */            i_time = vlm_Date();            i_next_date = s->i_date;            if( s->i_period != 0 )            {                int j = 0;                while( s->i_date + j * s->i_period <= i_time &&                       s->i_repeat > j )                {                    j++;                }                i_next_date = s->i_date + j * s->i_period;            }            if( i_next_date > i_time )            {                time_t i_date = (time_t) (i_next_date / 1000000) ;#if !defined( UNDER_CE )#ifdef HAVE_CTIME_R                char psz_date[500];                ctime_r( &i_date, psz_date );#else                char *psz_date = ctime( &i_date );#endif                vlm_MessageAdd( msg_schedule,                                vlm_MessageNew( "next launch", psz_date ) );#endif            }        }        return msg;    }    else if( ( psz_filter == NULL ) && ( media == NULL ) && ( schedule == NULL ) )    {        vlm_message_t *show1 = vlm_Show( vlm, NULL, NULL, "media" );        vlm_message_t *show2 = vlm_Show( vlm, NULL, NULL, "schedule" );        vlm_MessageAdd( show1, show2->child[0] );        /* We must destroy the parent node "show" of show2         * and not the children */        free( show2->psz_name );        free( show2 );        return show1;    }    else    {        return vlm_MessageNew( "show", vlm_NULL );    }}/***************************************************************************** * Config handling functions *****************************************************************************/static int Load( vlm_t *vlm, char *file ){    char *pf = file;    int  i_line = 1;    while( *pf != '\0' )    {        vlm_message_t *message = NULL;        int i_end = 0;        while( pf[i_end] != '\n' && pf[i_end] != '\0' && pf[i_end] != '\r' )        {            i_end++;        }        if( pf[i_end] == '\r' || pf[i_end] == '\n' )        {            pf[i_end] = '\0';            i_end++;            if( pf[i_end] == '\n' ) i_end++;        }        if( *pf && ExecuteCommand( vlm, pf, &message ) )        {            if( message )            {                if( message->psz_value )                    msg_Err( vlm, "Load error on line %d: %s: %s",                             i_line, message->psz_name, message->psz_value );                vlm_MessageDelete( message );            }            return 1;        }        if( message ) vlm_MessageDelete( message );        pf += i_end;        i_line++;    }    return 0;}static char *Save( vlm_t *vlm ){    char *save = NULL;    char psz_header[] = "\n"                        "# VLC media player VLM command batch\n"                        "# http://www.videolan.org/vlc/\n\n" ;    char *p;    int i,j;    int i_length = strlen( psz_header );    for( i = 0; i < vlm->i_media; i++ )    {        vlm_media_sys_t *media = vlm->media[i];        vlm_media_t *p_cfg = &media->cfg;        if( p_cfg->b_vod )            i_length += strlen( "new * vod " ) + strlen(p_cfg->psz_name);        else            i_length += strlen( "new * broadcast " ) + strlen(p_cfg->psz_name);        if( p_cfg->b_enabled == true )            i_length += strlen( "enabled" );        else            i_length += strlen( "disabled" );        if( !p_cfg->b_vod && p_cfg->broadcast.b_loop == true )            i_length += strlen( " loop\n" );        else            i_length += strlen( "\n" );        for( j = 0; j < p_cfg->i_input; j++ )            i_length += strlen( "setup * input \"\"\n" ) + strlen( p_cfg->psz_name ) + strlen( p_cfg->ppsz_input[j] );        if( p_cfg->psz_output != NULL )            i_length += strlen( "setup * output \n" ) + strlen(p_cfg->psz_name) + strlen(p_cfg->psz_output);        for( j = 0; j < p_cfg->i_option; j++ )            i_length += strlen("setup * option \n") + strlen(p_cfg->psz_name) + strlen(p_cfg->ppsz_option[j]);        if( p_cfg->b_vod && p_cfg->vod.psz_mux )            i_length += strlen("setup * mux \n") + strlen(p_cfg->psz_name) + strlen(p_cfg->vod.psz_mux);    }    for( i = 0; i < vlm->i_schedule; i++ )    {        vlm_schedule_sys_t *schedule = vlm->schedule[i];        i_length += strlen( "new  schedule " ) + strlen( schedule->psz_name );        if( schedule->b_enabled == true )        {            i_length += strlen( "date //-:: enabled\n" ) + 14;        }        else        {            i_length += strlen( "date //-:: disabled\n" ) + 14;        }        if( schedule->i_period != 0 )        {            i_length += strlen( "setup  " ) + strlen( schedule->psz_name ) +                strlen( "period //-::\n" ) + 14;        }        if( schedule->i_repeat >= 0 )        {            char buffer[12];            sprintf( buffer, "%d", schedule->i_repeat );            i_length += strlen( "setup  repeat \n" ) +                strlen( schedule->psz_name ) + strlen( buffer );        }        else        {            i_length++;        }        for( j = 0; j < schedule->i_command; j++ )        {            i_length += strlen( "setup  append \n" ) +                strlen( schedule->psz_name ) + strlen( schedule->command[j] );        }    }    /* Don't forget the '\0' */    i_length++;    /* now we have the length of save */    p = save = malloc( i_length );    if( !save ) return NULL;    *save = '\0';    p += sprintf( p, "%s", psz_header );    /* finally we can write in it */    for( i = 0; i < vlm->i_media; i++ )    {        vlm_media_sys_t *media = vlm->media[i];        vlm_media_t *p_cfg = &media->cfg;        if( p_cfg->b_vod )            p += sprintf( p, "new %s vod ", p_cfg->psz_name );        else            p += sprintf( p, "new %s broadcast ", p_cfg->psz_name );        if( p_cfg->b_enabled )            p += sprintf( p, "enabled" );        else            p += sprintf( p, "disabled" );        if( !p_cfg->b_vod && p_cfg->broadcast.b_loop )            p += sprintf( p, " loop\n" );        else            p += sprintf( p, "\n" );        for( j = 0; j < p_cfg->i_input; j++ )            p += sprintf( p, "setup %s input \"%s\"\n", p_cfg->psz_name, p_cfg->ppsz_input[j] );        if( p_cfg->psz_output )            p += sprintf( p, "setup %s output %s\n", p_cfg->psz_name, p_cfg->psz_output );        for( j = 0; j < p_cfg->i_option; j++ )            p += sprintf( p, "setup %s option %s\n", p_cfg->psz_name, p_cfg->ppsz_option[j] );        if( p_cfg->b_vod && p_cfg->vod.psz_mux )            p += sprintf( p, "setup %s mux %s\n", p_cfg->psz_name, p_cfg->vod.psz_mux );    }    /* and now, the schedule scripts */    for( i = 0; i < vlm->i_schedule; i++ )    {        vlm_schedule_sys_t *schedule = vlm->schedule[i];        struct tm date;        time_t i_time = (time_t) ( schedule->i_date / 1000000 );        localtime_r( &i_time, &date);        p += sprintf( p, "new %s schedule ", schedule->psz_name);        if( schedule->b_enabled == true )        {            p += sprintf( p, "date %d/%d/%d-%d:%d:%d enabled\n",                          date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,                          date.tm_hour, date.tm_min, date.tm_sec );        }        else        {            p += sprintf( p, "date %d/%d/%d-%d:%d:%d disabled\n",                          date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,                          date.tm_hour, date.tm_min, date.tm_sec);        }        if( schedule->i_period != 0 )        {            p += sprintf( p, "setup %s ", schedule->psz_name );            i_time = (time_t) ( schedule->i_period / 1000000 );            date.tm_sec = (int)( i_time % 60 );            i_time = i_time / 60;            date.tm_min = (int)( i_time % 60 );            i_time = i_time / 60;            date.tm_hour = (int)( i_time % 24 );            i_time = i_time / 24;            date.tm_mday = (int)( i_time % 30 );            i_time = i_time / 30;            /* okay, okay, months are not always 30 days long */            date.tm_mon = (int)( i_time % 12 );            i_time = i_time / 12;            date.tm_year = (int)i_time;            p += sprintf( p, "period %d/%d/%d-%d:%d:%d\n",                          date.tm_year, date.tm_mon, date.tm_mday,                          date.tm_hour, date.tm_min, date.tm_sec);        }        if( schedule->i_repeat >= 0 )        {            p += sprintf( p, "setup %s repeat %d\n",                          schedule->psz_name, schedule->i_repeat );        }        else        {            p += sprintf( p, "\n" );        }        for( j = 0; j < schedule->i_command; j++ )        {            p += sprintf( p, "setup %s append %s\n",                          schedule->psz_name, schedule->command[j] );        }    }    return save;}#endif /* ENABLE_VLM */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -