Permalink
Browse files

Tabs to spaces

git-svn-id: http://svn.php.net/repository/pear/packages/Net_CDDB/trunk@304684 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent bf8a385 commit 571508c6999a7843826bf32078a7f1cf9136b73d @CloCkWeRX CloCkWeRX committed Oct 24, 2010
View
Oops, something went wrong.
View
Oops, something went wrong.
View
@@ -16,65 +16,65 @@
*/
class Net_CDDB_Protocol
{
- /**
- * Parse a DSN string and return the parsed array
- *
- * This function parses a DSN string and returns the parsed array. The array
- * will always contain the following elements (elements not included in the
- * DSN string will be filled with default values):
- * - scheme, The protocol used to connect (cddbp, http, etc.)
- * - host, The hostname of the remove server
- * - pass, The password for remove server access
- * - user, The username for remove server access
- * - path, The path to the script/CGI program (for HTTP)
- *
- * @param string $protocol
- * @return array
- */
- function _parseDsn($protocol)
- {
- $protocol_defaults = array(
- 'scheme' => 'cddbp', // Protocol
- 'host' => 'freedb.org', // Server
- //'port' => 8880, // Port to connect on (gets set later depending on http or cddbp)
- 'pass' => '',
- 'user' => 'unknown_user', // Username to connect with
- 'path' => '/~cddb/cddb.cgi' // Path (for HTTP only)
- );
-
- // This is for DSN strings which lack a 'host' part, we just insert a null host so we can parse it
- $protocol = str_replace(':///', '://null/', $protocol);
-
- $protocol_params = parse_url($protocol); // Parse DSN
-
- if (!isset($protocol_params['port'])) { // Default for 'port' changes depending on scheme
- if ($protocol_params['scheme'] == 'http') {
- $protocol_params['port'] = 80; // For HTTP
- } else {
- $protocol_params['port'] = 8880; // For anything else (CDDBP)
- }
- }
-
- return array_merge($protocol_defaults, $protocol_params); // Merge DSN defaults with parsed DSN
- }
-
- /**
- * Tell whether or not a protocol acts on a remote resource
- *
- * The Net_CDDB_Server command likes to know whether or not a particular
- * protocol is accessing a remote server (HTTP or CDDBP) or a local
- * version of the database. By default all protocols will inherit this field
- * and report themselves as accessing remote resources. A protocol and
- * override this method and return false to report local cddb access.
- *
- * @access public
- *
- * @return boolean
- */
- function remote()
- {
- return true;
- }
+ /**
+ * Parse a DSN string and return the parsed array
+ *
+ * This function parses a DSN string and returns the parsed array. The array
+ * will always contain the following elements (elements not included in the
+ * DSN string will be filled with default values):
+ * - scheme, The protocol used to connect (cddbp, http, etc.)
+ * - host, The hostname of the remove server
+ * - pass, The password for remove server access
+ * - user, The username for remove server access
+ * - path, The path to the script/CGI program (for HTTP)
+ *
+ * @param string $protocol
+ * @return array
+ */
+ function _parseDsn($protocol)
+ {
+ $protocol_defaults = array(
+ 'scheme' => 'cddbp', // Protocol
+ 'host' => 'freedb.org', // Server
+ //'port' => 8880, // Port to connect on (gets set later depending on http or cddbp)
+ 'pass' => '',
+ 'user' => 'unknown_user', // Username to connect with
+ 'path' => '/~cddb/cddb.cgi' // Path (for HTTP only)
+ );
+
+ // This is for DSN strings which lack a 'host' part, we just insert a null host so we can parse it
+ $protocol = str_replace(':///', '://null/', $protocol);
+
+ $protocol_params = parse_url($protocol); // Parse DSN
+
+ if (!isset($protocol_params['port'])) { // Default for 'port' changes depending on scheme
+ if ($protocol_params['scheme'] == 'http') {
+ $protocol_params['port'] = 80; // For HTTP
+ } else {
+ $protocol_params['port'] = 8880; // For anything else (CDDBP)
+ }
+ }
+
+ return array_merge($protocol_defaults, $protocol_params); // Merge DSN defaults with parsed DSN
+ }
+
+ /**
+ * Tell whether or not a protocol acts on a remote resource
+ *
+ * The Net_CDDB_Server command likes to know whether or not a particular
+ * protocol is accessing a remote server (HTTP or CDDBP) or a local
+ * version of the database. By default all protocols will inherit this field
+ * and report themselves as accessing remote resources. A protocol and
+ * override this method and return false to report local cddb access.
+ *
+ * @access public
+ *
+ * @return boolean
+ */
+ function remote()
+ {
+ return true;
+ }
}
-?>
+?>
@@ -22,41 +22,41 @@
*/
class Net_CDDB_cddiscid
{
- /**
- * Static method to obtain the track offsets and length of an audio CD
- *
- * Returns an array with each array item being the track offset in seconds,
- * and the final item being the total length of the audio disc in seconds.
- * This method uses locates and executes a 'cd-discid' binary on your
- * computer to calculate the track offsets. You need to have 'cd-discid'
- * installed and in your PATH for this to work. You can get 'cd-discid'
- * here: {@link http://lly.org/~rcw/cd-discid/}
- *
- * @static
- * @param boolean $use_sudo
- * @param string $device
- * @return array
- */
- function calcTrackOffsets($use_sudo, $device)
- {
- if ($use_sudo) {
- $sudo = 'sudo';
- } else {
- $sudo = '';
- }
-
- $cmd = trim(`which cd-discid`);
-
- if (!strlen($cmd) || substr(trim($cmd), 0, 2) == 'no') {
- return PEAR::raiseError('Net_CDDB_cddiscid could not locate the cd-discid binary. Make sure you have cd-discid installed, you can get it here: http://lly.org/~rcw/cd-discid/.');
- }
-
- $output = `$sudo $cmd $device`;
-
- $arr_tmp = explode(' ', $output);
-
- return array_slice($arr_tmp, 2);
- }
+ /**
+ * Static method to obtain the track offsets and length of an audio CD
+ *
+ * Returns an array with each array item being the track offset in seconds,
+ * and the final item being the total length of the audio disc in seconds.
+ * This method uses locates and executes a 'cd-discid' binary on your
+ * computer to calculate the track offsets. You need to have 'cd-discid'
+ * installed and in your PATH for this to work. You can get 'cd-discid'
+ * here: {@link http://lly.org/~rcw/cd-discid/}
+ *
+ * @static
+ * @param boolean $use_sudo
+ * @param string $device
+ * @return array
+ */
+ function calcTrackOffsets($use_sudo, $device)
+ {
+ if ($use_sudo) {
+ $sudo = 'sudo';
+ } else {
+ $sudo = '';
+ }
+
+ $cmd = trim(`which cd-discid`);
+
+ if (!strlen($cmd) || substr(trim($cmd), 0, 2) == 'no') {
+ return PEAR::raiseError('Net_CDDB_cddiscid could not locate the cd-discid binary. Make sure you have cd-discid installed, you can get it here: http://lly.org/~rcw/cd-discid/.');
+ }
+
+ $output = `$sudo $cmd $device`;
+
+ $arr_tmp = explode(' ', $output);
+
+ return array_slice($arr_tmp, 2);
+ }
}
-?>
+?>
@@ -19,62 +19,62 @@
*/
class Net_CDDB_cdparanoia
{
- /**
- * Static method to execute 'cdparanoia' and get track offsets from audio CD
- *
- * This static method uses the 'cdparanoia' binary to query your CD-ROM for
- * an audio CD and get the track offsets and total length of the audio CD in
- * seconds. You need to have 'cdparanoia' installed for this to work, you
- * can download and install it from here:
- * {@link http://www.xiph.org/paranoia/}
- *
- * @static
- * @param boolean $use_sudo
- * @param string $device
- * @return array
- */
- function calcTrackOffsets($use_sudo, $device)
- {
- if ($use_sudo) {
- $sudo = 'sudo';
- } else {
- $sudo = '';
- }
-
- $cmd = trim(`which cdparanoia`);
-
- if (!strlen($cmd) || substr(trim($cmd), 0, 2) == 'no') {
- return PEAR::raiseError('Net_CDDB_cdparanoia could not locate the cdparanoia binary. Make sure you have cdparanoia installed, you can get it here: http://www.xiph.org/paranoia/.');
- }
-
- $output = `$sudo $cmd -Q 2>&1`; // -d $device
-
- $offsets = array(); // Holds the array of track offsets
- $toc_start = 'Table of contents';
- $next = 1;
-
- $lines = explode("\n", $output);
- foreach ($lines as $line) {
-
- if (substr($line, 0, 4) == str_pad($next, 3, ' ', STR_PAD_LEFT) . '.') {
-
- $line = trim($line);
- while (false !== strpos($line, ' ')) {
- $line = str_replace(' ', ' ', $line);
- }
-
- $tmp = explode(' ', $line);
-
- $offsets[] = (int) $tmp[3] + 150;
- $next++;
-
- } else if (substr($line, 0, 5) == 'TOTAL') {
- $offsets[] = (int) ((((int) substr($line, 5)) + 150) / 75);
- }
- }
-
- return $offsets;
- }
+ /**
+ * Static method to execute 'cdparanoia' and get track offsets from audio CD
+ *
+ * This static method uses the 'cdparanoia' binary to query your CD-ROM for
+ * an audio CD and get the track offsets and total length of the audio CD in
+ * seconds. You need to have 'cdparanoia' installed for this to work, you
+ * can download and install it from here:
+ * {@link http://www.xiph.org/paranoia/}
+ *
+ * @static
+ * @param boolean $use_sudo
+ * @param string $device
+ * @return array
+ */
+ function calcTrackOffsets($use_sudo, $device)
+ {
+ if ($use_sudo) {
+ $sudo = 'sudo';
+ } else {
+ $sudo = '';
+ }
+
+ $cmd = trim(`which cdparanoia`);
+
+ if (!strlen($cmd) || substr(trim($cmd), 0, 2) == 'no') {
+ return PEAR::raiseError('Net_CDDB_cdparanoia could not locate the cdparanoia binary. Make sure you have cdparanoia installed, you can get it here: http://www.xiph.org/paranoia/.');
+ }
+
+ $output = `$sudo $cmd -Q 2>&1`; // -d $device
+
+ $offsets = array(); // Holds the array of track offsets
+ $toc_start = 'Table of contents';
+ $next = 1;
+
+ $lines = explode("\n", $output);
+ foreach ($lines as $line) {
+
+ if (substr($line, 0, 4) == str_pad($next, 3, ' ', STR_PAD_LEFT) . '.') {
+
+ $line = trim($line);
+ while (false !== strpos($line, ' ')) {
+ $line = str_replace(' ', ' ', $line);
+ }
+
+ $tmp = explode(' ', $line);
+
+ $offsets[] = (int) $tmp[3] + 150;
+ $next++;
+
+ } else if (substr($line, 0, 5) == 'TOTAL') {
+ $offsets[] = (int) ((((int) substr($line, 5)) + 150) / 75);
+ }
+ }
+
+ return $offsets;
+ }
}
-?>
+?>
View
@@ -16,37 +16,37 @@
*/
class Net_CDDB_Reader_test
{
- /**
- * Fakes querying the CD-ROM drive and returns fake TOC based on the device
- *
- * This class is simply used for testing, it fakes reading an audio CD from
- * your CD-ROM drive and returns different sets of track offsets/lengths
- * based on the device you pass it. You can pass it any one of these
- * devices:
- * - /dev/acd0
- * - /dev/acd1
- * - /dev/acd2
- * - /dev/acd3
- *
- * @static
- * @param boolean $use_sudo
- * @param string $device
- * @return array
- */
- function calcTrackOffsets($use_sudo, $device)
- {
- switch ($device) {
- case '/dev/acd0':
- return array(150, 15471, 34414, 43587, 55098, 65975, 83623, 92225, 105299, 116339, 129797, 2142);
- case '/dev/acd1':
- return array(150, 21052, 43715, 58057, 71430, 92865, 117600, 131987, 150625, 163292, 181490, 195685, 210197, 233230, 249257, 3541);
- case '/dev/acd2':
- return array(150, 20820, 45079, 64070, 79721, 103706, 121416, 145377, 164139, 185379, 204670, 222934, 249264, 271989, 289983, 4121);
- case '/dev/acd3': // Simulate a cd-read error by returning an empty array of track offsets
- default:
- return array();
- }
- }
+ /**
+ * Fakes querying the CD-ROM drive and returns fake TOC based on the device
+ *
+ * This class is simply used for testing, it fakes reading an audio CD from
+ * your CD-ROM drive and returns different sets of track offsets/lengths
+ * based on the device you pass it. You can pass it any one of these
+ * devices:
+ * - /dev/acd0
+ * - /dev/acd1
+ * - /dev/acd2
+ * - /dev/acd3
+ *
+ * @static
+ * @param boolean $use_sudo
+ * @param string $device
+ * @return array
+ */
+ function calcTrackOffsets($use_sudo, $device)
+ {
+ switch ($device) {
+ case '/dev/acd0':
+ return array(150, 15471, 34414, 43587, 55098, 65975, 83623, 92225, 105299, 116339, 129797, 2142);
+ case '/dev/acd1':
+ return array(150, 21052, 43715, 58057, 71430, 92865, 117600, 131987, 150625, 163292, 181490, 195685, 210197, 233230, 249257, 3541);
+ case '/dev/acd2':
+ return array(150, 20820, 45079, 64070, 79721, 103706, 121416, 145377, 164139, 185379, 204670, 222934, 249264, 271989, 289983, 4121);
+ case '/dev/acd3': // Simulate a cd-read error by returning an empty array of track offsets
+ default:
+ return array();
+ }
+ }
}
-?>
+?>
Oops, something went wrong.

0 comments on commit 571508c

Please sign in to comment.