<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */
 
  uses(
    'peer.Socket',
    'peer.URL',
    'peer.news.NntpReply',
    'peer.news.Newsgroup',
    'peer.news.Article',
    'util.Date'
  );
  
  /**
   * NNTP Connection
   *
   * Usage [retrieve newsgroup listing]:
   * <code>
   *   $c= &new NntpConnection('nntp://news.xp-framework.net');
   *   try(); {
   *     $c->connect();
   *     $groups= &$c->getGroups();
   *     $c->close();
   *   } if (catch('IOException', $e)) {
   *     $e->printStackTrace();
   *     exit();
   *   }
   *   
   *   foreach ($groups as $group) {
   *     var_dump($group->getName());
   *   }
   * </code>

   * @see      rfc://977
   * @purpose  News protocol implementation
   */
  class NntpConnection extends Object {
    var
      $url      = NULL,
      $cat      = NULL,
      $response = array();

    /**
     * Constructor
     *
     * @access  private
     * @param   &peer.URL url
     */
    function __construct(&$url) {
      $this->url= &$url;
      $this->_sock= &new Socket(
        $this->url->getHost(),
        $this->url->getPort(119)
      );
    }

    /**
     * Set a trace for debugging
     *
     * @access  public
     * @param   &util.log.LogCategory cat
     */
    function setTrace(&$cat) {
      $this->cat= &$cat;
    }
    
    /**
     * Wrapper that sends a command to the remote host.
     *
     * @access  protected  
     * @param   string format
     * @param   mixed* args
     * @return  bool success
     * @throws  ProtocolException in case the command is too long
     */
    function _sendcmd() {
      if (!$this->_sock->isConnected()) return FALSE;

      $a= func_get_args();
      $cmd= implode(' ', $a);

      // NNTP/RFC977 only allows command up to 512 (-2) chars.
      if (strlen($cmd) > 510) {
        return throw(new ProtocolException('Command too long! Max. 510 chars'));
      }
      
      $this->cat && $this->cat->debug('>>>', $cmd);
      try(); {<commit_msg>- QA: Add peer.ProtocolException to uses() - QA: Fully qualify exception name in @throws<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */
 
  uses(
    'peer.Socket',
    'peer.ProtocolException',
    'peer.URL',
    'peer.news.NntpReply',
    'peer.news.Newsgroup',
    'peer.news.Article',
    'util.Date'
  );
  
  /**
   * NNTP Connection
   *
   * Usage [retrieve newsgroup listing]:
   * <code>
   *   $c= &new NntpConnection('nntp://news.xp-framework.net');
   *   try(); {
   *     $c->connect();
   *     $groups= &$c->getGroups();
   *     $c->close();
   *   } if (catch('IOException', $e)) {
   *     $e->printStackTrace();
   *     exit();
   *   }
   *   
   *   foreach ($groups as $group) {
   *     var_dump($group->getName());
   *   }
   * </code>

   * @see      rfc://977
   * @purpose  News protocol implementation
   */
  class NntpConnection extends Object {
    var
      $url      = NULL,
      $cat      = NULL,
      $response = array();

    /**
     * Constructor
     *
     * @access  private
     * @param   &peer.URL url
     */
    function __construct(&$url) {
      $this->url= &$url;
      $this->_sock= &new Socket(
        $this->url->getHost(),
        $this->url->getPort(119)
      );
    }

    /**
     * Set a trace for debugging
     *
     * @access  public
     * @param   &util.log.LogCategory cat
     */
    function setTrace(&$cat) {
      $this->cat= &$cat;
    }
    
    /**
     * Wrapper that sends a command to the remote host.
     *
     * @access  protected  
     * @param   string format
     * @param   mixed* args
     * @return  bool success
     * @throws  peer.ProtocolException in case the command is too long
     */
    function _sendcmd() {
      if (!$this->_sock->isConnected()) return FALSE;

      $a= func_get_args();
      $cmd= implode(' ', $a);

      // NNTP/RFC977 only allows command up to 512 (-2) chars.
      if (strlen($cmd) > 510) {
        return throw(new ProtocolException('Command too long! Max. 510 chars'));
      }
      
      $this->cat && $this->cat->debug('>>>', $cmd);
      try(); {
{'fraction_non_alphanumeric': 0.16650461837627614, 'fraction_numerical': 0.009236752552260573, 'mean_word_length': 1.8576388888888888, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006894', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1376, 'n_words': 319}