cvs: pear(MAINT_1_2) /Net_NNTP/NNTP/Protocol Client.php

From: Date: Sun, 13 Mar 2005 17:55:00 +0000
Subject: cvs: pear(MAINT_1_2) /Net_NNTP/NNTP/Protocol Client.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-30248@lists.php.net to get a copy of this message
heino Sun Mar 13 12:55:00 2005 EDT Modified files: (Branch: MAINT_1_2) /pear/Net_NNTP/NNTP/Protocol Client.php Log: add cmdStat(), cmdNext() and cmdStat() http://cvs.php.net/diff.php/pear/Net_NNTP/NNTP/Protocol/Client.php?r1=1.3&r2=1.3.4.1&ty=u Index: pear/Net_NNTP/NNTP/Protocol/Client.php diff -u pear/Net_NNTP/NNTP/Protocol/Client.php:1.3 pear/Net_NNTP/NNTP/Protocol/Client.php:1.3.4.1 --- pear/Net_NNTP/NNTP/Protocol/Client.php:1.3 Fri Jan 14 10:29:08 2005 +++ pear/Net_NNTP/NNTP/Protocol/Client.php Sun Mar 13 12:55:00 2005 @@ -58,7 +58,7 @@ // | been changes or removed. | // | | // +-----------------------------------------------------------------------+ -// $Id: Client.php,v 1.3 2005/01/14 15:29:08 heino Exp $ +// $Id: Client.php,v 1.3.4.1 2005/03/13 17:55:00 heino Exp $ require_once 'PEAR.php'; require_once 'Net/Socket.php'; @@ -78,7 +78,7 @@ * @category Net * @package Net_NNTP * @author Heino H. Gehlsen <heino@gehlsen.dk> - * @version $Id: Client.php,v 1.3 2005/01/14 15:29:08 heino Exp $ + * @version $Id: Client.php,v 1.3.4.1 2005/03/13 17:55:00 heino Exp $ * @access public * @see Net_NNTP_Client * @since Class available since Release 0.11.0 @@ -328,6 +328,166 @@ } // }}} + // {{{ cmdNext() + + /** + * + * + * @return + * @access public + */ + function cmdNext($x = 1) + { + // + $response = $this->_sendCommand('NEXT'); + if (PEAR::isError($response)) { + return $response; + } + + switch ($response) { + case 223: // RFC977: 'n a article retrieved - request text separately (n = article number, a = unique article id)' + $response_arr = split(' ', trim($this->currentStatusResponse())); + + switch ($x) { +/* + case 0: + $data = array(); + $data['number'] = $response_arr[0]; + $data['id'] = $response_arr[1]; + return $data; + break; +*/ + case 1: + return (int) $response_arr[0]; + break; + case 2: + return (string) $response_arr[1]; + break; + } + break; + case 412: // RFC977: 'no newsgroup selected' + return PEAR::throwError('No newsgroup has been selected', $response, $this->currentStatusResponse()); + break; + case 420: // RFC977: 'no current article has been selected' + return PEAR::throwError('No current article has been selected', $response, $this->currentStatusResponse()); + break; + case 421: // RFC977: 'no next article in this group' + return PEAR::throwError('No next article in this group', $response, $this->currentStatusResponse()); + break; + default: + return PEAR::throwError('Unidentified response code', $response, $this->currentStatusResponse()); + } + } + + // }}} + // {{{ cmdLast() + + /** + * + * + * @return + * @access public + */ + function cmdLast($x = 1) + { + // + $response = $this->_sendCommand('LAST'); + if (PEAR::isError($response)) { + return $response; + } + + switch ($response) { + case 223: // RFC977: 'n a article retrieved - request text separately (n = article number, a = unique article id)' + $response_arr = split(' ', trim($this->currentStatusResponse())); + + switch ($x) { +/* + case 0: + $data = array(); + $data['number'] = $response_arr[0]; + $data['id'] = $response_arr[1]; + return $data; + break; +*/ + case 1: + return (int) $response_arr[0]; + break; + case 2: + return (string) $response_arr[1]; + break; + } + break; + case 412: // RFC977: 'no newsgroup selected' + return PEAR::throwError('No newsgroup has been selected', $response, $this->currentStatusResponse()); + break; + case 420: // RFC977: 'no current article has been selected' + return PEAR::throwError('No current article has been selected', $response, $this->currentStatusResponse()); + break; + case 422: // RFC977: 'no previous article in this group' + return PEAR::throwError('No previous article in this group', $response, $this->currentStatusResponse()); + break; + default: + return PEAR::throwError('Unidentified response code', $response, $this->currentStatusResponse()); + } + } + + // }}} + // {{{ cmdStat + + /** + * + * + * @param mixed $article + * + * @return mixed (???) ??? on success or (object) pear_error on failure + * @access public + */ + function cmdStat($article) + { + // tell the newsserver we want an article + $response = $this->_sendCommand('STAT '.$article); + if (PEAR::isError($response)) { + return $response; + } + + switch ($response) { + case 223: // RFC977: 'n <a> article retrieved - request text separately' (actually not documented, but copied from the ARTICLE command) + $response_arr = split(' ', trim($this->currentStatusResponse())); + + switch (2) { +/* + case 0: + $data = array(); + $data['number'] = $response_arr[0]; + $data['id'] = $response_arr[1]; + return $data; + break; + case 1: + return (int) $response_arr[0]; + break; + default: +*/ + case 2: + return (string) $response_arr[1]; + break; + } + + break; + case 412: // RFC977: 'no newsgroup has been selected' (actually not documented, but copied from the ARTICLE command) + return PEAR::throwError('No newsgroup has been selected', $response, $this->currentStatusResponse()); + break; + case 423: // RFC977: 'no such article number in this group' (actually not documented, but copied from the ARTICLE command) + return PEAR::throwError('No such article number in this group', $response, $this->currentStatusResponse()); + break; + case 430: // RFC977: 'no such article found' (actually not documented, but copied from the ARTICLE command) + return PEAR::throwError('No such article found', $response, $this->currentStatusResponse()); + break; + default: + return PEAR::throwError('Unidentified response code', $response, $this->currentStatusResponse()); + } + } + + // }}} // {{{ cmdArticle() /**

« previous php.pear.cvs (#30248) next »