rstyx 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +482 -0
- data/ChangeLog +4 -0
- data/Manifest.txt +17 -0
- data/NEWS +2 -0
- data/README +41 -0
- data/Rakefile +55 -0
- data/examples/readstyxfile.rb +48 -0
- data/lib/rstyx/authmodules.rb +90 -0
- data/lib/rstyx/client.rb +709 -693
- data/lib/rstyx/common.rb +71 -0
- data/lib/rstyx/errors.rb +35 -2
- data/lib/rstyx/messages.rb +377 -1113
- data/lib/rstyx/server.rb +1305 -0
- data/lib/rstyx/version.rb +2 -2
- data/lib/rstyx.rb +11 -4
- data/tests/tc_client.rb +260 -45
- data/tests/tc_message.rb +245 -388
- data/tests/tc_styxservproto.rb +596 -0
- metadata +51 -26
data/lib/rstyx/common.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005-2007 Rafael Sevilla
|
4
|
+
# This file is part of RStyx
|
5
|
+
#
|
6
|
+
# RStyx is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as
|
8
|
+
# published by the Free Software Foundation; either version 2.1
|
9
|
+
# of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# RStyx is distributed in the hope that it will be useful, but
|
12
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with RStyx; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA
|
19
|
+
# 02110-1301 USA.
|
20
|
+
#
|
21
|
+
# Common code and defined constants
|
22
|
+
#
|
23
|
+
# Author:: Rafael R. Sevilla (mailto:dido@imperium.ph)
|
24
|
+
# Copyright:: Copyright (c) 2005,2006 Rafael R. Sevilla
|
25
|
+
# License:: GNU Lesser General Public License
|
26
|
+
#
|
27
|
+
# $Id: common.rb 218 2007-07-04 06:24:33Z dido $
|
28
|
+
#
|
29
|
+
module RStyx
|
30
|
+
# File access modes in Styx
|
31
|
+
OREAD = 0
|
32
|
+
OWRITE = 1
|
33
|
+
ORDWR = 2
|
34
|
+
OEXEC = 3
|
35
|
+
OTRUNC = 0x10
|
36
|
+
ORCLOSE = 0x40
|
37
|
+
|
38
|
+
# Constants related to the file type
|
39
|
+
DMDIR = 0x80000000 # directory
|
40
|
+
DMAPPEND = 0x40000000 # append-only file
|
41
|
+
DMEXCL = 0x20000000 # exclusive use file
|
42
|
+
DMAUTH = 0x8000000 # file used for authentication
|
43
|
+
|
44
|
+
# Maximum FID numbers and the NOFID constant.
|
45
|
+
MAX_FID = 0xfffffffe
|
46
|
+
NOFID = 0xffffffff
|
47
|
+
|
48
|
+
# Maximum tag number
|
49
|
+
MAX_TAG = 0xffff
|
50
|
+
|
51
|
+
# Seek mode constants
|
52
|
+
SEEK_SET = 0
|
53
|
+
SEEK_CUR = 1
|
54
|
+
SEEK_END = 2
|
55
|
+
|
56
|
+
# Maximum number of path elements
|
57
|
+
MAXWELEM = 16
|
58
|
+
|
59
|
+
#
|
60
|
+
# Debugging
|
61
|
+
# Debug levels:
|
62
|
+
# 0 = no debugging output
|
63
|
+
# 1 = Show dumps of all messages sent and received
|
64
|
+
# 2 = In addition to dumps of messages, also the byte strings sent and
|
65
|
+
# received
|
66
|
+
#
|
67
|
+
DEBUG = 0
|
68
|
+
|
69
|
+
# Limits of unsigned quanitities
|
70
|
+
MAXUINT = 0xffffffff
|
71
|
+
end
|
data/lib/rstyx/errors.rb
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
# Copyright:: Copyright (c) 2005 Rafael R. Sevilla
|
25
25
|
# License:: GNU Lesser General Public License
|
26
26
|
#
|
27
|
-
# $Id: errors.rb
|
27
|
+
# $Id: errors.rb 230 2007-08-10 08:20:19Z dido $
|
28
28
|
#
|
29
29
|
|
30
30
|
module RStyx
|
@@ -34,7 +34,40 @@ module RStyx
|
|
34
34
|
# class for now, but here so we can distinguish Styx errors and
|
35
35
|
# for later extension.
|
36
36
|
#
|
37
|
-
class StyxException <
|
37
|
+
class StyxException < RuntimeError
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Raised when a FID not in use is referenced.
|
42
|
+
#
|
43
|
+
class FidNotFoundException < StyxException
|
44
|
+
attr_accessor :fid
|
45
|
+
|
46
|
+
def initialize(fid)
|
47
|
+
@fid = fid
|
48
|
+
end
|
49
|
+
|
50
|
+
def message
|
51
|
+
return("FID #{@fid} is already in use.")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Tag in use exception, raised when a tag already in use is reallocated.
|
57
|
+
#
|
58
|
+
class TagInUseException < StyxException
|
59
|
+
attr_accessor :tag
|
60
|
+
|
61
|
+
def initialize(tag)
|
62
|
+
@tag = tag
|
63
|
+
end
|
64
|
+
|
65
|
+
def message
|
66
|
+
return("Tag #{@tag} is already in use.")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class FileExists < StyxException
|
38
71
|
end
|
39
72
|
|
40
73
|
end
|