cvs: pecl /id3 id3.c php_id3.h
| From: | Carsten Lucke | Date: | Mon, 23 Aug 2004 23:09:47 +0000 |
| Subject: | cvs: pecl /id3 id3.c php_id3.h | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-1718@lists.php.net to get a copy of this message | ||
luckec Mon Aug 23 19:09:47 2004 EDT
Modified files:
/pecl/id3 id3.c php_id3.h
Log:
added switch into id3_get_tag() to distinguish between id3v1 and v2 functions
http://cvs.php.net/diff.php/pecl/id3/id3.c?r1=1.9&r2=1.10&ty=u
Index: pecl/id3/id3.c
diff -u pecl/id3/id3.c:1.9 pecl/id3/id3.c:1.10
--- pecl/id3/id3.c:1.9 Mon Aug 23 18:39:08 2004
+++ pecl/id3/id3.c Mon Aug 23 19:09:46 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: id3.c,v 1.9 2004/08/23 22:39:08 schst Exp $ */
+/* $Id: id3.c,v 1.10 2004/08/23 23:09:46 luckec Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -113,7 +113,7 @@
{
zval *arg;
php_stream *stream;
- int version = ID3_V1_0;
+ int version = ID3_V2_4;
int opened = 0;
char tag[4];
@@ -124,7 +124,8 @@
/**
* v2.0 will be implemented at later point
*/
- if (version != ID3_V1_0 && version != ID3_V1_1) {
+ //if (version != ID3_V1_0 && version != ID3_V1_1) {
+ if (!(version == ID3_V1_0 || version == ID3_V1_1 || version == ID3_V2_1 || version == ID3_V2_2 ||
version == ID3_V2_3 || version == ID3_V2_4)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "id3_get_tag(): Unsupported version
given");
return;
}
@@ -161,9 +162,14 @@
return;
}
+ /* initialize associative return array */
array_init(return_value);
-
- _php_id3v1_get_tag(stream, return_value TSRMLS_CC);
+ /* call function to fill return-array depending on version */
+ if (version == ID3_V1_0 || version == ID3_V1_1) {
+ _php_id3v1_get_tag(stream, return_value, version TSRMLS_CC);
+ } else {
+ _php_id3v2_get_tag(stream, return_value, version TSRMLS_CC);
+ }
if (opened == 1) {
php_stream_close(stream);
@@ -174,11 +180,10 @@
/* {{{ proto zval* _php_id3v1_get_tag(php_stream *stream , zval* return_value TSRMLS_DC)
Set an array containg all information from the id3v1 tag */
-void _php_id3v1_get_tag(php_stream *stream , zval* return_value TSRMLS_DC)
+void _php_id3v1_get_tag(php_stream *stream , zval* return_value, int version TSRMLS_DC)
{
unsigned char genre;
unsigned int bytes_read;
- int version = ID3_V1_0;
char title[31],
artist[31],
album[31],
@@ -245,6 +250,14 @@
/* genre */
php_stream_read(stream, &genre, 1);
add_assoc_long(return_value, "genre", (long)genre);
+}
+/* }}} */
+
+/* {{{ proto zval* _php_id3v1_get_tag(php_stream *stream , zval* return_value TSRMLS_DC)
+ Set an array containg all information from the id3v1 tag */
+void _php_id3v2_get_tag(php_stream *stream , zval* return_value, int version TSRMLS_DC)
+{
+ zend_printf("Sorry, not implemented yet");
}
/* }}} */
http://cvs.php.net/diff.php/pecl/id3/php_id3.h?r1=1.4&r2=1.5&ty=u
Index: pecl/id3/php_id3.h
diff -u pecl/id3/php_id3.h:1.4 pecl/id3/php_id3.h:1.5
--- pecl/id3/php_id3.h:1.4 Mon Aug 23 18:10:23 2004
+++ pecl/id3/php_id3.h Mon Aug 23 19:09:46 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_id3.h,v 1.4 2004/08/23 22:10:23 luckec Exp $ */
+/* $Id: php_id3.h,v 1.5 2004/08/23 23:09:46 luckec Exp $ */
#ifndef PHP_ID3_H
#define PHP_ID3_H
@@ -61,7 +61,8 @@
struct id3v2HdrFlags _php_id3v2_get_hdrFlags(php_stream *stream TSRMLS_DC);
int _php_id3v2_get_tagLength(php_stream *stream TSRMLS_DC);
int _php_bigEndian_to_Int(char* byteword, int bytewordlen, int synchsafe);
-void _php_id3v1_get_tag(php_stream *stream , zval* retval TSRMLS_DC);
+void _php_id3v1_get_tag(php_stream *stream , zval* return_value, int version TSRMLS_DC);
+void _php_id3v2_get_tag(php_stream *stream , zval* return_value, int version TSRMLS_DC);
static int _php_id3_get_version(php_stream *stream TSRMLS_DC);
static int _php_id3_write_padded(php_stream *stream, zval **data, int length TSRMLS_DC);
@@ -97,7 +98,7 @@
"Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
"Vocal", "Jazz+Funk", "Fusion", "Trance",
"Classical", "Instrumental", "Acid",
"House", "Game", "Sound Clip", "Gospel",
"Noise", "Alternative Rock", "Bass", "Soul",
"Punk", "Space", "Meditative", "Instrumental Pop",
"Instrumental Rock", "Ethnic", "Gothic", "Darkwave",
"Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance",
"Dream", "Southern Rock",
- "Comedy", "Cult", "Gangsta", "Top 40", "Christian
Rap", "Pop/Funk", "Jungle", "Native US", "Cabaret",
"New Wave", "Psychadelic", "Rave",
+ "Comedy", "Cult", "Gangsta", "Top 40", "Christian
Rap", "Pop/Funk", "Jungle", "Native US", "Cabaret",
"New Wave", "Psychedelic", "Rave",
"Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid
Punk", "Acid Jazz", "Polka", "Retro", "Musical",
"Rock & Roll", "Hard Rock", "Folk",
"Folk-Rock", "National Folk", "Swing", "Fast Fusion",
"Bebob", "Latin", "Revival", "Celtic",
"Bluegrass", "Avantgarde", "Gothic Rock",
"Progressive Rock", "Psychedelic Rock", "Symphonic Rock",
"Slow Rock", "Big Band", "Chorus", "Easy Listening",
"Acoustic", "Humour",