summaryrefslogtreecommitdiff
path: root/lib/net/protocol.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-12 06:04:40 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-12 06:04:40 +0000
commitbeffb7f8357091b17d5783d6f1b921c4d8727250 (patch)
tree62ab3effac982be552d42e7da2709d7356d91e9d /lib/net/protocol.rb
parent960676a2de16f046be01f0ef54ec4efe93ce612d (diff)
aamine
* lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.26. * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: add module Net::NetPrivate and its inner classes {Read,Write}Adapter, Command, Socket, SMTPCommand, POP3Command, APOPCommand, HTTPCommand git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/protocol.rb')
-rw-r--r--lib/net/protocol.rb145
1 files changed, 76 insertions, 69 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 10bc8b0..b351c26 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -1,6 +1,6 @@
=begin
-= net/protocol.rb
+= net/protocol.rb version 1.1.27
written by Minero Aoki <aamine@dp.u-netsurf.ne.jp>
@@ -64,7 +64,7 @@ module Net
class Protocol
- Version = '1.1.26'
+ Version = '1.1.27'
class << self
@@ -137,7 +137,7 @@ module Net
protocol_param :port, 'nil'
protocol_param :command_type, 'nil'
- protocol_param :socket_type, '::Net::Socket'
+ protocol_param :socket_type, '::Net::NetPrivate::Socket'
def initialize( addr = nil, port = nil )
@@ -220,72 +220,6 @@ module Net
- class Command
-
- def initialize( sock )
- @socket = sock
- @last_reply = nil
- @critical = false
- end
-
- attr_accessor :socket
- attr_reader :last_reply
-
- def inspect
- "#<#{type}>"
- end
-
- # abstract quit
-
-
- private
-
- # abstract get_reply()
-
- def check_reply( *oks )
- @last_reply = get_reply
- reply_must( @last_reply, *oks )
- end
-
- def reply_must( rep, *oks )
- oks.each do |i|
- if i === rep then
- return rep
- end
- end
- rep.error!
- end
-
- def getok( line, ok = SuccessCode )
- @socket.writeline line
- check_reply ok
- end
-
-
- def critical
- return if @critical
- @critical = true
- r = yield
- @critical = false
- r
- end
-
- def critical?
- @critical
- end
-
- def begin_critical
- ret = @critical
- @critical = true
- not ret
- end
-
- def end_critical
- @critical = false
- end
-
- end
-
class Response
@@ -379,6 +313,9 @@ module Net
+ module NetPrivate
+
+
class WriteAdapter
def initialize( sock, mid )
@@ -414,6 +351,73 @@ module Net
end
+ class Command
+
+ def initialize( sock )
+ @socket = sock
+ @last_reply = nil
+ @critical = false
+ end
+
+ attr_accessor :socket
+ attr_reader :last_reply
+
+ def inspect
+ "#<#{type}>"
+ end
+
+ # abstract quit
+
+
+ private
+
+ # abstract get_reply()
+
+ def check_reply( *oks )
+ @last_reply = get_reply
+ reply_must( @last_reply, *oks )
+ end
+
+ def reply_must( rep, *oks )
+ oks.each do |i|
+ if i === rep then
+ return rep
+ end
+ end
+ rep.error!
+ end
+
+ def getok( line, ok = SuccessCode )
+ @socket.writeline line
+ check_reply ok
+ end
+
+
+ def critical
+ return if @critical
+ @critical = true
+ r = yield
+ @critical = false
+ r
+ end
+
+ def critical?
+ @critical
+ end
+
+ def begin_critical
+ ret = @critical
+ @critical = true
+ not ret
+ end
+
+ def end_critical
+ @critical = false
+ end
+
+ end
+
+
class Socket
def initialize( addr, port, pipe = nil )
@@ -756,6 +760,9 @@ module Net
end
+ end # module Net::NetPrivate
+
+
def Net.quote( str )
str = str.gsub( "\n", '\\n' )
str.gsub!( "\r", '\\r' )