- char *mrl = make_URI( args[n], NULL );
- if( !mrl )
- continue;
-
- playlist_AddExt( pl_Get( p_vlc ), mrl, NULL, PLAYLIST_INSERT,
- 0, -1, i_options, ( i_options ? &args[n + 1] : NULL ),
- VLC_INPUT_OPTION_TRUSTED, true, pl_Unlocked );
- free( mrl );
- }
-}
-
-/*****************************************************************************
- * Help: print program help
- *****************************************************************************
- * Print a short inline help. Message interface is initialized at this stage.
- *****************************************************************************/
-static inline void print_help_on_full_help( void )
-{
- utf8_fprintf( stdout, "\n" );
- utf8_fprintf( stdout, "%s\n", _("To get exhaustive help, use '-H'.") );
-}
-
-static const char vlc_usage[] = N_(
- "Usage: %s [options] [stream] ..."
- "\nYou can specify multiple streams on the commandline. They will be enqueued in the playlist."
- "\nThe first item specified will be played first."
- "\n"
- "\nOptions-styles:"
- "\n --option A global option that is set for the duration of the program."
- "\n -option A single letter version of a global --option."
- "\n :option An option that only applies to the stream directly before it"
- "\n and that overrides previous settings."
- "\n"
- "\nStream MRL syntax:"
- "\n [[access][/demux]://]URL[@[title][:chapter][-[title][:chapter]]] [:option=value ...]"
- "\n"
- "\n Many of the global --options can also be used as MRL specific :options."
- "\n Multiple :option=value pairs can be specified."
- "\n"
- "\nURL syntax:"
- "\n [file://]filename Plain media file"
- "\n http://ip:port/file HTTP URL"
- "\n ftp://ip:port/file FTP URL"
- "\n mms://ip:port/file MMS URL"
- "\n screen:// Screen capture"
- "\n [dvd://][device][@raw_device] DVD device"
- "\n [vcd://][device] VCD device"
- "\n [cdda://][device] Audio CD device"
- "\n udp://[[<source address>]@[<bind address>][:<bind port>]]"
- "\n UDP stream sent by a streaming server"
- "\n vlc://pause:<seconds> Special item to pause the playlist for a certain time"
- "\n vlc://quit Special item to quit VLC"
- "\n");
-
-static void Help( libvlc_int_t *p_this, char const *psz_help_name )
-{
-#ifdef WIN32
- ShowConsole( true );
-#endif
-
- if( psz_help_name && !strcmp( psz_help_name, "help" ) )
- {
- utf8_fprintf( stdout, vlc_usage, "vlc" );
- Usage( p_this, "=help" );
- Usage( p_this, "=main" );
- print_help_on_full_help();
- }
- else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) )
- {
- utf8_fprintf( stdout, vlc_usage, "vlc" );
- Usage( p_this, NULL );
- print_help_on_full_help();
- }
- else if( psz_help_name && !strcmp( psz_help_name, "full-help" ) )
- {
- utf8_fprintf( stdout, vlc_usage, "vlc" );
- Usage( p_this, NULL );
- }
- else if( psz_help_name )
- {
- Usage( p_this, psz_help_name );
- }
-
-#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
- PauseConsole();
-#endif
- fflush( stdout );
-}
-
-/*****************************************************************************
- * Usage: print module usage
- *****************************************************************************
- * Print a short inline help. Message interface is initialized at this stage.
- *****************************************************************************/
-# define COL(x) "\033[" #x ";1m"
-# define RED COL(31)
-# define GREEN COL(32)
-# define YELLOW COL(33)
-# define BLUE COL(34)
-# define MAGENTA COL(35)
-# define CYAN COL(36)
-# define WHITE COL(0)
-# define GRAY "\033[0m"
-static void
-print_help_section( const module_t *m, const module_config_t *p_item,
- bool b_color, bool b_description )
-{
- if( !p_item ) return;
- if( b_color )
- {
- utf8_fprintf( stdout, RED" %s:\n"GRAY,
- module_gettext( m, p_item->psz_text ) );
- if( b_description && p_item->psz_longtext )
- utf8_fprintf( stdout, MAGENTA" %s\n"GRAY,
- module_gettext( m, p_item->psz_longtext ) );
- }
- else
- {
- utf8_fprintf( stdout, " %s:\n",
- module_gettext( m, p_item->psz_text ) );
- if( b_description && p_item->psz_longtext )
- utf8_fprintf( stdout, " %s\n",
- module_gettext(m, p_item->psz_longtext ) );
- }
-}
-
-static void Usage( libvlc_int_t *p_this, char const *psz_search )
-{
-#define FORMAT_STRING " %s --%s%s%s%s%s%s%s "
- /* short option ------' | | | | | | |
- * option name ------------' | | | | | |
- * <bra ---------------------' | | | | |
- * option type or "" ----------' | | | |
- * ket> -------------------------' | | |
- * padding spaces -----------------' | |
- * comment --------------------------' |
- * comment suffix ---------------------'
- *
- * The purpose of having bra and ket is that we might i18n them as well.
- */
-
-#define COLOR_FORMAT_STRING (WHITE" %s --%s"YELLOW"%s%s%s%s%s%s "GRAY)
-#define COLOR_FORMAT_STRING_BOOL (WHITE" %s --%s%s%s%s%s%s%s "GRAY)
-
-#define LINE_START 8
-#define PADDING_SPACES 25
-#ifdef WIN32
-# define OPTION_VALUE_SEP "="
-#else
-# define OPTION_VALUE_SEP " "
-#endif
- char psz_spaces_text[PADDING_SPACES+LINE_START+1];
- char psz_spaces_longtext[LINE_START+3];
- char psz_format[sizeof(COLOR_FORMAT_STRING)];
- char psz_format_bool[sizeof(COLOR_FORMAT_STRING_BOOL)];
- char psz_buffer[10000];
- char psz_short[4];
- int i_width = ConsoleWidth() - (PADDING_SPACES+LINE_START+1);
- int i_width_description = i_width + PADDING_SPACES - 1;
- bool b_advanced = var_InheritBool( p_this, "advanced" );
- bool b_description = var_InheritBool( p_this, "help-verbose" );
- bool b_description_hack;
- bool b_color = var_InheritBool( p_this, "color" );
- bool b_has_advanced = false;
- bool b_found = false;
- int i_only_advanced = 0; /* Number of modules ignored because they
- * only have advanced options */
- bool b_strict = psz_search && *psz_search == '=';
- if( b_strict ) psz_search++;
-
- memset( psz_spaces_text, ' ', PADDING_SPACES+LINE_START );
- psz_spaces_text[PADDING_SPACES+LINE_START] = '\0';
- memset( psz_spaces_longtext, ' ', LINE_START+2 );
- psz_spaces_longtext[LINE_START+2] = '\0';
-#ifndef WIN32
- if( !isatty( 1 ) )
-#endif
- b_color = false; // don't put color control codes in a .txt file
-
- if( b_color )
- {
- strcpy( psz_format, COLOR_FORMAT_STRING );
- strcpy( psz_format_bool, COLOR_FORMAT_STRING_BOOL );
- }
- else
- {
- strcpy( psz_format, FORMAT_STRING );
- strcpy( psz_format_bool, FORMAT_STRING );
- }
-
- /* List all modules */
- module_t **list = module_list_get (NULL);
- if (!list)
- return;
-
- /* Ugly hack to make sure that the help options always come first
- * (part 1) */
- if( !psz_search )
- Usage( p_this, "help" );
-
- /* Enumerate the config for each module */
- for (size_t i = 0; list[i]; i++)
- {
- bool b_help_module;
- module_t *p_parser = list[i];
- module_config_t *p_item = NULL;
- module_config_t *p_section = NULL;
- module_config_t *p_end = p_parser->p_config + p_parser->confsize;
-
- if( psz_search &&
- ( b_strict ? strcmp( psz_search, p_parser->psz_object_name )
- : !strstr( p_parser->psz_object_name, psz_search ) ) )
- {
- char *const *pp_shortcuts = p_parser->pp_shortcuts;
- unsigned i;
- for( i = 0; i < p_parser->i_shortcuts; i++ )
- {
- if( b_strict ? !strcmp( psz_search, pp_shortcuts[i] )
- : !!strstr( pp_shortcuts[i], psz_search ) )
- break;
- }
- if( i == p_parser->i_shortcuts )
- continue;
- }
-
- /* Ignore modules without config options */
- if( !p_parser->i_config_items )
- {
- continue;
- }
-
- b_help_module = !strcmp( "help", p_parser->psz_object_name );
- /* Ugly hack to make sure that the help options always come first
- * (part 2) */
- if( !psz_search && b_help_module )
- continue;
-
- /* Ignore modules with only advanced config options if requested */
- if( !b_advanced )
- {
- for( p_item = p_parser->p_config;
- p_item < p_end;
- p_item++ )
- {
- if( (p_item->i_type & CONFIG_ITEM) &&
- !p_item->b_advanced && !p_item->b_removed ) break;
- }
-
- if( p_item == p_end )
- {
- i_only_advanced++;
- continue;
- }
- }
-
- b_found = true;
-
- /* Print name of module */
- if( strcmp( "main", p_parser->psz_object_name ) )
- {
- if( b_color )
- utf8_fprintf( stdout, "\n " GREEN "%s" GRAY " (%s)\n",
- module_gettext( p_parser, p_parser->psz_longname ),
- p_parser->psz_object_name );
- else
- utf8_fprintf( stdout, "\n %s\n",
- module_gettext(p_parser, p_parser->psz_longname ) );
- }
- if( p_parser->psz_help )
- {
- if( b_color )
- utf8_fprintf( stdout, CYAN" %s\n"GRAY,
- module_gettext( p_parser, p_parser->psz_help ) );
- else
- utf8_fprintf( stdout, " %s\n",
- module_gettext( p_parser, p_parser->psz_help ) );
- }
-
- /* Print module options */
- for( p_item = p_parser->p_config;
- p_item < p_end;
- p_item++ )