Commit 0caf8ce6 authored by Simon Latapie's avatar Simon Latapie

* http.c : added parsing of options in Add MRL option. In http.c is a the

            parse_MRL function which perhaps should be somewhere else
            (playlist ?).
 * Makefile.am : forgoten style.css
 * index.html : little fixes
 * intf-http.txt : updated doc
parent 4dcb355c
...@@ -110,6 +110,11 @@ pop them backs. It's used with the little RPN evaluator. ...@@ -110,6 +110,11 @@ pop them backs. It's used with the little RPN evaluator.
- url_param : 1 if url_value isn't empty else 0 - url_param : 1 if url_value isn't empty else 0
- version : the VLC version - version : the VLC version
- copyright : the VLC copyright - copyright : the VLC copyright
- stream_position : current position of the VLC in the stream (percentage)
- stream_time : current position of the VLC in the stream (in seconds)
- stream_length : total length of the current stream (in seconds)
- volume : current volume level
- stream_state : current state of the VLC (playing, paused, stop)
Variables could have fields, just use . to access them. Variables could have fields, just use . to access them.
Ex: var.field, var.field.subfield, ... Ex: var.field, var.field.subfield, ...
...@@ -171,6 +176,8 @@ You have access to : ...@@ -171,6 +176,8 @@ You have access to :
* string: * string:
strcat : push the result of 'ST(1)ST(2)' strcat : push the result of 'ST(1)ST(2)'
strcmp : compare ST(1) and ST(2), push -1, 0, or 1 strcmp : compare ST(1) and ST(2), push -1, 0, or 1
strncmp : compare the ST(3) first characters of ST(1) and ST(2),
push -1, 0, or 1
strlen : push the length of ST(1) strlen : push the length of ST(1)
* stack manipulation * stack manipulation
dup : duplicate ST(1) on the stack dup : duplicate ST(1) on the stack
...@@ -199,23 +206,39 @@ commands will work. ...@@ -199,23 +206,39 @@ commands will work.
Url commands are : Url commands are :
| Name | argument | | Name | arguments |
----------------------------------------------------------------- -------------------------------------------------------------------------------
| play | item(integer)| Play the specified item | play | item(integer)| Play the specified item
| stop | | Stop | stop | | Stop
| pause | | Pause | pause | | Pause
| next | | Go to the next playlist element | next | | Go to the next playlist element
| previous | | Got to the previous playlist element | previous | | Got to the previous playlist element
| add | mrl(string) | Add a mrl to the playlist | fullscreen | | toggle fullscreen
| delete | item(integer)| Deletes an (list of) element of the playlist | volume | value(string)| set volume level (absolute or relative)
| empty | | Empty the playlist | seek | seek_value | c.f. notes
| close | id(hexa) | Close a specific connection | add | mrl(string) | Add a mrl to the playlist (with its options)
| shutdown | | Quit vlc | delete | item(integer)| Deletes an (list of) element of the playlist
| keep | item(integer)| Deletes all but (list of) element of the playlist
| sort | type,order | c.f. notes
| empty | | Empty the playlist
| close | id(hexa) | Close a specific connection
| shutdown | | Quit vlc
For example, you can restrict the execution of the shutdown command to For example, you can restrict the execution of the shutdown command to
protected pages (through a .access) using the control macro in all pages protected pages (through a .access) using the control macro in all pages
unprotected. unprotected.
Notes:
Seek: The seek command is used to seek in current playing stream. the
seek_value argument is a string which represents a relative or absolute
position in the stream: a percentage, or a time.
For examples "+12min 42sec", "01:13:43", "-12%", "42%", or
"1 hour 12 minutes" are valid argument values.
Sort: sorts the playlist by type (string), and with the order (integer).
If order is "0", it is normal order. Otherwise it is reverse order. The
type can be "title", "group", "author".
2. Macro "get" 2. Macro "get"
-------------- --------------
...@@ -285,7 +308,7 @@ variable will be displayed (instead of it name). ...@@ -285,7 +308,7 @@ variable will be displayed (instead of it name).
a set of integer. The stack element should be a string like: a set of integer. The stack element should be a string like:
first:last[:step][,first2:last2[:step2][,...] first:last[:step][,first2:last2[:step2][,...]
Ex: 1:5:2,6:8:1 will be expanded into 1,3,5,6,7,8 Ex: 1:5:2,6:8:1 will be expanded into 1,3,5,6,7,8
- "directory" : take the first element of the stack as the base - "directory" : take the first element of the stack as the base
directory and construct a set of filename and directly in it. directory and construct a set of filename and directly in it.
Each element has the following fields: Each element has the following fields:
...@@ -331,7 +354,7 @@ variable will be displayed (instead of it name). ...@@ -331,7 +354,7 @@ variable will be displayed (instead of it name).
- ip : - ip :
- url: - url:
- status: HTTP error code. - status: HTTP error code.
- the name of a foreach variable if it's a set of set of value. - the name of a foreach variable if it's a set of set of value.
Ex : Ex :
<vlc id="foreach" param1="cat" param2="informations" /> <vlc id="foreach" param1="cat" param2="informations" />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: http.c,v 1.31 2003/11/09 05:22:56 garf Exp $ * $Id: http.c,v 1.32 2003/11/12 02:43:33 garf Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -124,6 +124,10 @@ static char *uri_extract_value( char *psz_uri, char *psz_name, ...@@ -124,6 +124,10 @@ static char *uri_extract_value( char *psz_uri, char *psz_name,
char *psz_value, int i_value_max ); char *psz_value, int i_value_max );
static void uri_decode_url_encoded( char *psz ); static void uri_decode_url_encoded( char *psz );
static char *Find_end_MRL( char *psz );
static playlist_item_t * parse_MRL( char *psz );
/***************************************************************************** /*****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
...@@ -1627,7 +1631,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1627,7 +1631,7 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
case TIME_REL_FOR: case TIME_REL_FOR:
{ {
var_Get( p_sys->p_input, "time", &val ); var_Get( p_sys->p_input, "time", &val );
if( (uint64_t)( i_value ) * 1000 + val.i_time <= i_length ) if( (uint64_t)( i_value ) * 1000000 + val.i_time <= i_length )
{ {
val.i_time = ((uint64_t)( i_value ) * 1000000) + val.i_time; val.i_time = ((uint64_t)( i_value ) * 1000000) + val.i_time;
} else } else
...@@ -1741,11 +1745,22 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1741,11 +1745,22 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
case MVLC_ADD: case MVLC_ADD:
{ {
char mrl[512]; char mrl[512];
playlist_item_t * p_item;
uri_extract_value( p_request, "mrl", mrl, 512 ); uri_extract_value( p_request, "mrl", mrl, 512 );
uri_decode_url_encoded( mrl ); uri_decode_url_encoded( mrl );
playlist_Add( p_sys->p_playlist, mrl, NULL, 0, p_item = parse_MRL( mrl );
PLAYLIST_APPEND, PLAYLIST_END );
msg_Dbg( p_intf, "requested playlist add: %s", mrl ); if( p_item == NULL )
{
msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
} else
{
playlist_AddItem( p_sys->p_playlist , p_item ,
PLAYLIST_APPEND, PLAYLIST_END );
msg_Dbg( p_intf, "requested mrl add: %s", mrl );
}
break; break;
} }
case MVLC_DEL: case MVLC_DEL:
...@@ -2297,9 +2312,9 @@ static int http_get( httpd_file_callback_args_t *p_args, ...@@ -2297,9 +2312,9 @@ static int http_get( httpd_file_callback_args_t *p_args,
var_Get( p_sys->p_input, "position", &val); var_Get( p_sys->p_input, "position", &val);
sprintf( position, "%d" , (int)((val.f_float) * 100.0)); sprintf( position, "%d" , (int)((val.f_float) * 100.0));
var_Get( p_sys->p_input, "time", &val); var_Get( p_sys->p_input, "time", &val);
sprintf( time, "%d" , (int)(val.i_time / 1000) ); sprintf( time, "%d" , (int)(val.i_time / 1000000) );
var_Get( p_sys->p_input, "length", &val); var_Get( p_sys->p_input, "length", &val);
sprintf( length, "%d" , (int)(val.i_time / 1000) ); sprintf( length, "%d" , (int)(val.i_time / 1000000) );
var_Get( p_sys->p_input, "state", &val ); var_Get( p_sys->p_input, "state", &val );
if( val.i_int == PLAYING_S ) if( val.i_int == PLAYING_S )
...@@ -2667,6 +2682,16 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2667,6 +2682,16 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
free( s1 ); free( s1 );
free( s2 ); free( s2 );
} }
else if( !strcmp( s, "strncmp" ) )
{
char *s1 = SSPop( st );
char *s2 = SSPop( st );
int n = SSPopN( st, vars );
SSPushN( st, strncmp( s1, s2 , n ) );
free( s1 );
free( s2 );
}
else if( !strcmp( s, "strlen" ) ) else if( !strcmp( s, "strlen" ) )
{ {
char *str = SSPop( st ); char *str = SSPop( st );
...@@ -2736,3 +2761,213 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2736,3 +2761,213 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
} }
} }
/**********************************************************************
* Find_end_MRL: Find the end of the sentence :
* this function parses the string psz and find the end of the item
* and/or option with detecting the " and ' problems.
* returns NULL if an error is detected, otherwise, returns a pointer
* of the end of the sentence (after the last character)
**********************************************************************/
static char *Find_end_MRL( char *psz )
{
char *s_sent = psz;
switch( *s_sent )
{
case '\"':
{
s_sent++;
while( ( *s_sent != '\"' ) && ( *s_sent != '\0' ) )
{
if( *s_sent == '\'' )
{
s_sent = Find_end_MRL( s_sent );
if( s_sent == NULL )
{
return NULL;
}
} else
{
s_sent++;
}
}
if( *s_sent == '\"' )
{
s_sent++;
return s_sent;
} else /* *s_sent == '\0' , which means the number of " is incorrect */
{
return NULL;
}
break;
}
case '\'':
{
s_sent++;
while( ( *s_sent != '\'' ) && ( *s_sent != '\0' ) )
{
if( *s_sent == '\"' )
{
s_sent = Find_end_MRL( s_sent );
if( s_sent == NULL )
{
return NULL;
}
} else
{
s_sent++;
}
}
if( *s_sent == '\'' )
{
s_sent++;
return s_sent;
} else /* *s_sent == '\0' , which means the number of ' is incorrect */
{
return NULL;
}
break;
}
default: /* now we can look for spaces */
{
while( ( *s_sent != ' ' ) && ( *s_sent != '\0' ) )
{
if( ( *s_sent == '\'' ) || ( *s_sent == '\"' ) )
{
s_sent = Find_end_MRL( s_sent );
} else
{
s_sent++;
}
}
return s_sent;
}
}
}
/**********************************************************************
* parse_MRL: parse the MRL, find the mrl string and the options,
* create an item with all informations in it, and return the item.
* return NULL if there is an error.
**********************************************************************/
playlist_item_t * parse_MRL( char *psz )
{
char **ppsz_options = NULL;
char *mrl;
char *s_mrl = psz;
int i_error = 0;
char *s_temp;
int i = 0;
int i_options = 0;
playlist_item_t * p_item;
/* In case there is spaces before the mrl */
while( ( *s_mrl == ' ' ) && ( *s_mrl != '\0' ) )
{
s_mrl++;
}
/* extract the mrl */
s_temp = Find_end_MRL( s_mrl );
if( s_temp == NULL )
{
return NULL;
}
/* if the mrl is between " or ', we must remove them */
if( (*s_mrl == '\'') || (*s_mrl == '\"') )
{
mrl = (char *)malloc( (s_temp - s_mrl - 1) * sizeof( char ) );
strncpy( mrl , (s_mrl + 1) , s_temp - s_mrl - 2 );
mrl[ s_temp - s_mrl - 2 ] = '\0';
} else
{
mrl = (char *)malloc( (s_temp - s_mrl + 1) * sizeof( char ) );
strncpy( mrl , s_mrl , s_temp - s_mrl );
mrl[ s_temp - s_mrl ] = '\0';
}
s_mrl = s_temp;
/* now we can take care of the options */
while( (*s_mrl != '\0') && (i_error == 0) )
{
switch( *s_mrl )
{
case ' ':
{
s_mrl++;
break;
}
case ':': /* an option */
{
s_temp = Find_end_MRL( s_mrl );
if( s_temp == NULL )
{
i_error = 1;
} else
{
i_options++;
ppsz_options = (char **)realloc( ppsz_options , i_options * sizeof(char *) );
ppsz_options[ i_options - 1 ] = (char *)malloc( (s_temp - s_mrl + 1) * sizeof( char ) );
strncpy( ppsz_options[ i_options - 1 ] , s_mrl , s_temp - s_mrl );
/* don't forget to finish the string with a '\0' */
(ppsz_options[ i_options - 1 ])[ s_temp - s_mrl ] = '\0';
s_mrl = s_temp;
}
break;
}
default:
{
i_error = 1;
break;
}
}
}
if( i_error != 0 )
{
free( mrl );
for( i = 0 ; i < i_options ; i++ )
{
free( ppsz_options[i] );
}
free( ppsz_options );
return NULL;
} else
{
/* now create an item */
p_item = malloc( sizeof( playlist_item_t ) );
p_item->psz_name = mrl;
p_item->psz_uri = mrl;
p_item->psz_author = strdup( "" );
p_item->i_duration = -1;
p_item->i_type = 0;
p_item->i_status = 0;
p_item->b_autodeletion = VLC_FALSE;
p_item->b_enabled = VLC_TRUE;
p_item->i_group = PLAYLIST_TYPE_MANUAL;
p_item->ppsz_options = NULL;
p_item->i_options = i_options;
if( i_options )
{
p_item->ppsz_options = ppsz_options;
}
return p_item;
}
}
...@@ -133,4 +133,5 @@ DIST_http = \ ...@@ -133,4 +133,5 @@ DIST_http = \
http/admin/index.html \ http/admin/index.html \
http/admin/browse.html \ http/admin/browse.html \
http/admin/.access \ http/admin/.access \
http/style.css \
$(NULL) $(NULL)
...@@ -20,13 +20,12 @@ ...@@ -20,13 +20,12 @@
<div class="section"> <div class="section">
<table class="add"> <table class="add">
<tr> <tr>
<td colspan="1">Current State: <vlc id="value" param1="stream_state" /></td> <td nowrap="1">Current State: <vlc id="value" param1="stream_state" /></td>
<td colspan="0" align="right"><a href="info.html">Information</a> <a href="admin/">Administration</a></td> <td align="right"><a href="info.html">Information</a> <a href="admin/">Administration</a></td>
</tr> </tr>
<tr><td> </td></tr>
<tr> <tr>
<form method="get" action=""> <form method="get" action="">
<td colspan="5"> <td nowrap="1">
<input type="submit" name="control" value="stop" /> <input type="submit" name="control" value="stop" />
<input type="submit" name="control" value="pause" /> <input type="submit" name="control" value="pause" />
<input type="submit" name="control" value="previous" /> <input type="submit" name="control" value="previous" />
...@@ -35,15 +34,30 @@ ...@@ -35,15 +34,30 @@
</td> </td>
</form> </form>
<form> <form>
<td colspan="0" align="right"> <td align="right" nowrap="1">
Current Volume: <vlc id="value" param1="volume" /> <input type="text" name="value" size="5"><input type="hidden" name="control" value="volume"><input type="submit" name="Set" value="Set"> Current Volume: <vlc id="value" param1="volume" /> <input type="text" name="value" size="5"><input type="hidden" name="control" value="volume"><input type="submit" name="Set" value="Set">
</td> </td>
</form> </form>
</tr> </tr>
<tr> <tr>
<form> <td colspan="2">
<td colspan="8"><input type="submit" name="seek_value" value="-1min"><input type="text" name="seek_value" size="12"><input type="hidden" name="control" value="seek"><input type="submit" name="seek_value" value="+1min"> ( Seek Textbox: for example "+12min 42sec", "01:13:43", "-12%" etc... )</td> <table>
</form> <tr>
<form>
<td><input type="submit" name="seek_value" value="-1min"><input type="hidden" name="control" value="seek"></td>
</form>
<form>
<td><input type="text" name="seek_value" size="14"><input type="hidden" name="control" value="seek"></td>
</form>
<form>
<td><input type="submit" name="seek_value" value="+1min"><input type="hidden" name="control" value="seek"></td>
</form>
<td>
( Seek Textbox: for example "+12min 42sec", "01:13:43", "-12%" etc... )
</td>
</tr>
</table>
</td>
</tr> </tr>
</table> </table>
</div> </div>
...@@ -62,44 +76,45 @@ ...@@ -62,44 +76,45 @@
</table> </table>
</form> </form>
</div> </div>
<div class="sectitle">VLC Playlist</div>
<div class="section">
<form method="get" action=""> <div class="sectitle">VLC Playlist</div>
<table> <div class="section">
<vlc id="foreach" param1="pl" param2="playlist" /> <tr>
<tr class="<vlc id="if" param1="2 pl.index % 0 =" />ligne1<vlc id="else" />ligne2<vlc id="end" />"> <td>
<td> <form>
<input type=checkbox name="item" value="<vlc id="value" param1="pl.index" />"> <input type="submit" name="control" value="sort" /> by
<vlc id="if" param1="pl.current" /> <select name="type">
<b> <option value="title">title
<vlc id="end" /> <option value="group">group
<a href="?control=play&item=<vlc id="value" param1="pl.index" />"><vlc id="value" param1="pl.index" /> - <vlc id="value" param1="pl.name" /></a> <vlc id="if" param1="pl.current" /> <option value="author">author
</b> </select> with
<vlc id="end" /> <select name="order">
</td></tr> <option value="0">normal order
<vlc id="end" /> <option value="1">reverse order
</table> </select>
<td><input type="submit" name="control" value="delete" /></td> </form>
<td><input type="submit" name="control" value="keep" /></td> </td>
</form> </tr>
<tr> <form method="get" action="">
<td> <table>
<form> <vlc id="foreach" param1="pl" param2="playlist" />
<input type="submit" name="control" value="sort" /> by <tr class="<vlc id="if" param1="2 pl.index % 0 =" />ligne1<vlc id="else" />ligne2<vlc id="end" />">
<select name="type"> <td>
<option value="title">title <input type=checkbox name="item" value="<vlc id="value" param1="pl.index" />">
<option value="group">group <vlc id="if" param1="pl.current" />
<option value="author">author <b>
</select> with <vlc id="end" />
<select name="order"> <a href="?control=play&item=<vlc id="value" param1="pl.index" />"><vlc id="value" param1="pl.index" /> - <vlc id="value" param1="pl.name" /></a>
<option value="0">normal order <vlc id="if" param1="pl.current" />
<option value="1">reverse order </b>
</select> <vlc id="end" />
</form> </td>
</td> </tr>
</tr> <vlc id="end" />
</table>
<td><input type="submit" name="control" value="delete" /></td>
<td><input type="submit" name="control" value="keep" /></td>
</form>
</div> </div>
<hr/> <hr/>
<p> <vlc id="value" param1="copyright" /> </p> <p> <vlc id="value" param1="copyright" /> </p>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment