roundcubemail/program/lib/Roundcube/rcube_imap_generic.php
protected function parseResult($string, $err_prefix = '')
    {
        if (preg_match('/^[a-z0-9*]+ (OK|NO|BAD|BYE)(.*)$/i', trim($string), $matches)) {
            $res = strtoupper($matches[1]);
            $str = trim($matches[2]);

            if ($res == 'OK') {
                $this->errornum = self::ERROR_OK;
            }
            else if ($res == 'NO') {
                $this->errornum = self::ERROR_NO;
            }
            else if ($res == 'BAD') {
                $this->errornum = self::ERROR_BAD;
            }
            else if ($res == 'BYE') {
                $this->closeSocket();
                $this->errornum = self::ERROR_BYE;
            }

            if ($str) {
                $str = trim($str);
                // get response string and code (RFC5530)
                if (preg_match("/^\[([a-z-]+)\]/i", $str, $m)) {
                    $this->resultcode = strtoupper($m[1]);
                    $str = trim(substr($str, strlen($m[1]) + 2));
                }
                else {
                    $this->resultcode = null;
                    // parse response for [APPENDUID 1204196876 3456]
                    if (preg_match("/^\[APPENDUID [0-9]+ ([0-9]+)\]/i", $str, $m)) {
                        $this->data['APPENDUID'] = $m[1];
                    }
                    // parse response for [COPYUID 1204196876 3456:3457 123:124]
                    else if (preg_match("/^\[COPYUID [0-9]+ ([0-9,:]+) ([0-9,:]+)\]/i", $str, $m)) {
                        $this->data['COPYUID'] = array($m[1], $m[2]);
                    }
                }

                $this->result = $str;

                if ($this->errornum != self::ERROR_OK) {
                    $this->error = $err_prefix ? $err_prefix.$str : $str;
                }
            }

            return $this->errornum;
        }

        return self::ERROR_UNKNOWN;
    }
protected function parseResult($string, $err_prefix = '')
    {
        if (preg_match('/^[a-z0-9*]+ (OK|NO|BAD|BYE)(.*)$/i', trim($string), $matches)) {
            $res = strtoupper($matches[1]);
            $str = trim($matches[2]);

            if ($res == 'OK') {
                $this->errornum = self::ERROR_OK;
            }
            else if ($res == 'NO') {
                $this->errornum = self::ERROR_NO;
            }
            else if ($res == 'BAD') {
                $this->errornum = self::ERROR_BAD;
            }
            else if ($res == 'BYE') {
                $this->closeSocket();
                $this->errornum = self::ERROR_BYE;
            }

            if ($str) {
                $str = trim($str);
                // get response string and code (RFC5530)
                if (preg_match("/^\[([a-z-]+)\]/i", $str, $m)) {
                    $this->resultcode = strtoupper($m[1]);
                    $str = trim(substr($str, strlen($m[1]) + 2));
                }
                else {
                    $this->resultcode = null;
                    // parse response for [APPENDUID 1204196876 3456]
                    if (preg_match("/^\[APPENDUID [0-9]+ ([0-9]+)\]/i", $str, $m)) {
                        $this->data['APPENDUID'] = $m[1];
                    }
                    // parse response for [COPYUID 1204196876 3456:3457 123:124]
                    else if (preg_match("/^\[COPYUID [0-9]+ ([0-9,:]+) ([0-9,:]+)\]/i", $str, $m)) {
                        $this->data['COPYUID'] = array($m[1], $m[2]);
                    }
                }

                $this->result = $str;

                if ($this->errornum != self::ERROR_OK) {
                    $this->error = $err_prefix ? $err_prefix.$str : $str;
                }
            }

            return $this->errornum;
        }

        return self::ERROR_UNKNOWN;
    }
protected function parseResult ( $ string , $ err_prefix = '' ) { if ( preg_match ( '/^[a-z0-9*]+ (OK|NO|BAD|BYE)(.*)$/i' , trim ( $ string ) , $ matches ) ) { $ res = strtoupper ( $ matches [ 1 ] ) ; $ str = trim ( $ matches [ 2 ] ) ; if ( $ res == 'OK' ) { $ this -> errornum = self :: ERROR_OK ; } else if ( $ res == 'NO' ) { $ this -> errornum = self :: ERROR_NO ; } else if ( $ res == 'BAD' ) { $ this -> errornum = self :: ERROR_BAD ; } else if ( $ res == 'BYE' ) { $ this -> closeSocket ( ) ; $ this -> errornum = self :: ERROR_BYE ; } if ( $ str ) { $ str = trim ( $ str ) ; // get response string and code (RFC5530) if ( preg_match ( "/^\[([a-z-]+)\]/i" , $ str , $ m ) ) { $ this -> resultcode = strtoupper ( $ m [ 1 ] ) ; $ str = trim ( substr ( $ str , strlen ( $ m [ 1 ] ) + 2 ) ) ; } else { $ this -> resultcode = null ; // parse response for [APPENDUID 1204196876 3456] if ( preg_match ( "/^\[APPENDUID [0-9]+ ([0-9]+)\]/i" , $ str , $ m ) ) { $ this -> data [ 'APPENDUID' ] = $ m [ 1 ] ; } // parse response for [COPYUID 1204196876 3456:3457 123:124] else if ( preg_match ( "/^\[COPYUID [0-9]+ ([0-9,:]+) ([0-9,:]+)\]/i" , $ str , $ m ) ) { $ this -> data [ 'COPYUID' ] = array ( $ m [ 1 ] , $ m [ 2 ] ) ; } } $ this -> result = $ str ; if ( $ this -> errornum != self :: ERROR_OK ) { $ this -> error = $ err_prefix ? $ err_prefix . $ str : $ str ; } } return $ this -> errornum ; } return self :: ERROR_UNKNOWN ; }
Response parser.

@param string $string     Response text
@param string $err_prefix Error message prefix

@return int Response status
Response parser .