cvs: pear /XMMS xmms.c xmms.php
| From: | Rasmus Lerdorf | Date: | Mon, 13 Aug 2001 10:00:29 +0000 |
| Subject: | cvs: pear /XMMS xmms.c xmms.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-489@lists.php.net to get a copy of this message | ||
rasmus Mon Aug 13 06:00:29 2001 EDT
Modified files:
/pear/XMMS xmms.c xmms.php
Log:
- Check for out-of-bounds on playlist ranges
- Quicker 0-param handling
Index: pear/XMMS/xmms.c
diff -u pear/XMMS/xmms.c:1.10 pear/XMMS/xmms.c:1.11
--- pear/XMMS/xmms.c:1.10 Sun Aug 12 22:01:02 2001
+++ pear/XMMS/xmms.c Mon Aug 13 06:00:26 2001
@@ -164,8 +164,9 @@
pid_t pid;
char *av[] = { "xmms",NULL };
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
/* Ok, this is pretty weird, but hey, why not? */
@@ -194,8 +195,9 @@
Check if XMMS is running */
PHP_FUNCTION(xmms_is_running)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
RETURN_BOOL(xmms_remote_is_running(XG(session))?1:0);
}
@@ -205,8 +207,9 @@
Get the number of songs in the playlist */
PHP_FUNCTION(xmms_playlist_length)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -221,8 +224,9 @@
Get current playlist position */
PHP_FUNCTION(xmms_playlist_pos)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -280,9 +284,14 @@
add_assoc_double(return_value, "time",
xmms_remote_get_playlist_time(XG(session),pos)/1000.0);
} else {
/* We were passed an array of playlist positions to get info on */
+ len = xmms_remote_get_playlist_length(XG(session));
zend_hash_internal_pointer_reset(Z_ARRVAL_P(var));
while (zend_hash_get_current_data(Z_ARRVAL_P(var), (void **)&tmp) == SUCCESS) {
convert_to_long_ex(tmp);
+ if(Z_LVAL_PP(tmp)<0 || Z_LVAL_PP(tmp)>=len) {
+ zend_hash_move_forward(Z_ARRVAL_P(var));
+ continue;
+ }
MAKE_STD_ZVAL(tmp_arr);
array_init(tmp_arr);
title = xmms_remote_get_playlist_title(XG(session),Z_LVAL_PP(tmp));
@@ -322,8 +331,9 @@
Stop playing current song */
PHP_FUNCTION(xmms_stop)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -337,8 +347,9 @@
Pause current song (toggle) */
PHP_FUNCTION(xmms_pause)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -352,8 +363,9 @@
Force XMMS to terminate */
PHP_FUNCTION(xmms_quit)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -368,18 +380,16 @@
Get the XMMS version */
PHP_FUNCTION(xmms_version)
{
- int version;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
RETURN_FALSE;
}
- version = xmms_remote_get_version(XG(session));
- RETURN_LONG(version);
+ RETURN_LONG(xmms_remote_get_version(XG(session)));
}
/* }}} */
@@ -387,8 +397,9 @@
Go to next song in playlist */
PHP_FUNCTION(xmms_next)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -403,8 +414,9 @@
Go to previous song in playlist */
PHP_FUNCTION(xmms_prev)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -421,8 +433,9 @@
{
int playing, paused;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -448,8 +461,9 @@
Get repeat setting */
PHP_FUNCTION(xmms_is_repeat)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -496,8 +510,9 @@
Get shuffle setting */
PHP_FUNCTION(xmms_is_shuffle)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -580,8 +595,9 @@
Clear playlist */
PHP_FUNCTION(xmms_clear)
{
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
@@ -602,8 +618,9 @@
int playing, paused, repeat, shuffle;
char status[10];
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
- return;
+ if(ZEND_NUM_ARGS() != 0) {
+ WRONG_PARAM_COUNT;
+ }
if(!xmms_remote_is_running(XG(session))) {
php_error(E_WARNING, "XMMS is not running");
Index: pear/XMMS/xmms.php
diff -u pear/XMMS/xmms.php:1.5 pear/XMMS/xmms.php:1.6
--- pear/XMMS/xmms.php:1.5 Sun Aug 12 15:58:28 2001
+++ pear/XMMS/xmms.php Mon Aug 13 06:00:27 2001
@@ -17,6 +17,10 @@
xmms_shuffle(empty($shuffle)?false:true);
xmms_repeat(empty($repeat)?false:true);
}
+if(!xmms_is_running()) {
+ echo "XMMS is currently disabled\n";
+ exit;
+}
switch($action) {
case 'play':
xmms_play();