net-proto 1.0.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,84 @@
1
+ == 1.0.3 - 13-Aug-2007
2
+ * Fix for OS X (whining about malloced pointer).
3
+ * Added a Rakefile along with tasks for installation and testing.
4
+ * Major internal reorganization.
5
+ * Fixed Proto::VERSION test.
6
+
7
+ == 1.0.2 - 18-Nov-2006
8
+ * Updated the README, gemspec and netproto.txt files.
9
+ * No code changes.
10
+
11
+ == 1.0.1 - 30-Jun-2006
12
+ * Added rdoc to the source files.
13
+ * Added a gemspec.
14
+
15
+ == 1.0.0 - 14-Jul-2005
16
+ * Moved project to RubyForge.
17
+ * Minor directory layout change.
18
+ * Minor changes to the extconf.rb file.
19
+ * Officially bumped VERSION to 1.0.0.
20
+
21
+ == 0.2.5 - 18-Apr-2005
22
+ * The Unix versions now call setprotoent(0) and endprotoent() internally
23
+ before each call.
24
+
25
+ == 0.2.4 - 12-Apr-2005
26
+ * Added internal taint checking for the Proto.getprotobyname method.
27
+ * Removed the INSTALL file. Installation instructions are now in the README.
28
+ * Moved the sample script into the 'examples' directory.
29
+ * General code cleanup.
30
+ * Minor test suite changes and additions.
31
+ * Removed the netproto.rd and netproto.html files. The netproto.txt file is
32
+ now rdoc friendly.
33
+
34
+ == 0.2.3 - 13-Sep-2004
35
+ * Replaced all instances of the deprecated STR2CSTR() function with the
36
+ StringValuePtr() function. That means that, as of this release, this
37
+ package requires Ruby 1.8.0 or later.
38
+ * Minor documentation corrections.
39
+
40
+ == 0.2.2 - 10-Apr-2004
41
+ * No longer returns an Array in block form. Only the non-block form returns
42
+ an array. The block form returns nil.
43
+ * Updated the documentation, warranty information included, license changed
44
+ back to "Ruby's".
45
+ * Modified extconf.rb. It is now assumed that you have TestUnit installed.
46
+ * Changed "tc_all.rb" to "tc_netproto.rb".
47
+ * Changed "netproto.rd2" to "netproto.rd".
48
+
49
+ == 0.2.1 - 29-Jul-2003
50
+ * Code cleanup (-Wall warnings on Linux)
51
+ * Removed VERSION() class method. Use the constant instead
52
+ * The getprotoent() method now returns an array of structs in non-block form
53
+ * Added README file
54
+ * Added generic test script under test/
55
+ * Modified extconf.rb to use generic test script for those who don't have
56
+ TestUnit installed, instead of dynamically generating one
57
+ * Fixed up TestUnit test suite
58
+
59
+ == 0.2.0 - 26-Feb-2003
60
+ * Added MS Windows support (except 'getprotoent()' - see docs)
61
+ * For protocols that aren't defined, nil is now returned instead
62
+ of crashing (always a good thing)
63
+ * Removed sys-uname requirement
64
+ * Added a test suite (for those with testunit installed)
65
+ * Some internal layout changes (doc, lib, test dirs)
66
+ * Added a VERSION constant and class method
67
+ * RD2 documentation now separated from source
68
+ * Installation instructions modified
69
+ * Lots of changes to extconf.rb
70
+ * Changelog now CHANGES
71
+ * Manifest now MANIFEST
72
+ * Package name changed to lower case
73
+
74
+ == 0.1.0 - 13-Aug-2002
75
+ * Fixed bug with getprotoent_r function for Linux
76
+ * Added a 'generic' source file that uses the non-reentrant functions for
77
+ those platforms that are not specifically supported.
78
+ * Added FreeBSD support
79
+ * Modified test script slightly
80
+ * Added a changelog :)
81
+ * Added a manifest
82
+
83
+ == 0.0.1 - 12-Aug-2002
84
+ * Initial release (though written earlier)
@@ -0,0 +1,13 @@
1
+ * CHANGES
2
+ * MANIFEST
3
+ * README
4
+ * Rakefile
5
+ * net-proto.gemspec
6
+ * doc/netproto.txt
7
+ * examples/test_proto.rb
8
+ * ext/version.h
9
+ * ext/generic/generic.c
10
+ * ext/linux/linux.c
11
+ * ext/sunos/sunos.c
12
+ * ext/windows/windows.c
13
+ * test/tc_netproto.rb
data/README ADDED
@@ -0,0 +1,30 @@
1
+ == Description
2
+ The net-proto package provides a way to get protocol information.
3
+
4
+ This is really just a wrapper for the getprotobyname(), getprotobynumber() and
5
+ the getprotoent() functions.
6
+
7
+ == Prerequisites
8
+ Ruby 1.8.0 or later.
9
+
10
+ == Installation
11
+ rake test (optional)
12
+ rake install (non-gem) OR rake install_gem (gem)
13
+
14
+ == Notes
15
+ The net-proto package uses reentrant code for sunos and linux. Otherwise, the
16
+ generic form of the functions are used (which may be reentrant by default
17
+ anway - check the man pages on your platform).
18
+
19
+ The Proto.getprotoent method is not supported on MS Windows because the
20
+ underlying function isn't supported by the MS Windows API.
21
+
22
+ == Why should I use this?
23
+ Ruby has a predefined set of constants in socket.c in the general form of
24
+ IPPROTO_XXX, Y. However, using constants in this fashion can be unreliable
25
+ because it's easy to define your own protocols (I set 'echo' to 7, for
26
+ example), or to modify/delete entries in /etc/protocols.
27
+
28
+ == Further Documentation
29
+ See the 'netproto.txt' file under the 'doc' directory for more details. There
30
+ is also an example under the 'examples' directory.
@@ -0,0 +1,82 @@
1
+ == Description
2
+ Net::Proto - An interface for the 'getproto' family of functions.
3
+
4
+ == Synopsis
5
+ require "net/proto"
6
+ include Net
7
+
8
+ Proto.getprotobyname("tcp") # -> 6
9
+ Proto.getprotobynumber(1) # -> "icmp"
10
+
11
+ # Block form
12
+ Proto.getprotoent{ |p|
13
+ puts p.name
14
+ puts p.aliases
15
+ puts p.proto
16
+ }
17
+
18
+ # Non-block form
19
+ a = Proto.getprotoent
20
+
21
+ == Constants
22
+ VERSION
23
+ The current version number of this package, returned as a String.
24
+
25
+ == Class Methods
26
+ Proto.getprotobyname(name)
27
+ Given a protocol string, returns the corresponding number, or nil if not
28
+ found.
29
+
30
+ Proto.getprotobynumber(num)
31
+ Given a protocol number, returns the corresponding string, or nil if not
32
+ found.
33
+
34
+ Proto.getprotoent
35
+ Proto.getprotoent{ |struct| ... }
36
+ In block form, yields each entry from /etc/protocols as a struct of type
37
+ Proto::ProtoStruct. In non-block form, returns an array of
38
+ Proto::ProtoStruct objects.
39
+
40
+ The fields are 'name' (a String), 'aliases' (an Array of String's,
41
+ though often only one element), and 'proto' (a Fixnum).
42
+
43
+ This method is NOT supported on MS Windows.
44
+
45
+ == Notes
46
+ This module uses the reentrant (i.e. thread safe) functions on those
47
+ platforms that support them. In some cases, e.g. FreeBSD and HP-UX, the
48
+ standard function names are reentrant by default (i.e. there is no '_r'
49
+ version, or it's not needed), so you will not see specific .c files for
50
+ all platforms.
51
+
52
+ The 'setprotoent()' and 'endprotoent()' functions are not implemented as
53
+ separate method calls. Rather, these are called internally by the various
54
+ methods, except on Windows, which does not support them.
55
+
56
+ The 'getprotoent()' method is not supported on the MS Windows platform.
57
+ It's not part of the API as of Windows XP.
58
+
59
+ == Known Bugs
60
+ None that I'm aware of. Please log any bug reports on the project page
61
+ at http://ruby-netutils.sf.net.
62
+
63
+ == Future Plans
64
+ Use the asynchronous calls (WSAAsyncGetProtoByName and
65
+ WSAAsyncGetProtoByNumber) on MS Windows systems.
66
+
67
+ == Copyright
68
+ (C) 2003-2007 Daniel J. Berger
69
+ All rights reserved.
70
+
71
+ == Warranty
72
+ This package is provided "as is" and without any express or
73
+ implied warranties, including, without limitation, the implied
74
+ warranties of merchantability and fitness for a particular purpose.
75
+
76
+ == License
77
+ Ruby's
78
+
79
+ == Author
80
+ Daniel J. Berger
81
+ djberg96 at gmail dot com
82
+ imperator on IRC (Freenode)
@@ -0,0 +1,73 @@
1
+ /***********************
2
+ * proto.c (windows.c)
3
+ ***********************/
4
+ #include <ruby.h>
5
+ #include <version.h>
6
+ #include <windows.h>
7
+
8
+ #ifdef __cplusplus
9
+ extern "C"
10
+ {
11
+ #endif
12
+
13
+ /*
14
+ * call-seq:
15
+ * Proto.getprotobyname(name)
16
+ *
17
+ * Given a protocol string, returns the corresponding number, or nil if not
18
+ * found.
19
+ */
20
+ static VALUE np_getprotobyname(VALUE klass, VALUE rbProtoName){
21
+ struct protoent* p;
22
+ VALUE v_proto_num = Qnil;
23
+
24
+ SafeStringValue(rbProtoName);
25
+ p = getprotobyname(StringValuePtr(rbProtoName));
26
+
27
+ if(p)
28
+ v_proto_num = INT2FIX(p->p_proto);
29
+
30
+ return v_proto_num;
31
+ }
32
+
33
+ /*
34
+ * call-seq:
35
+ * Proto.getprotobynumber(num)
36
+ *
37
+ * Given a protocol number, returns the corresponding string, or nil if not
38
+ * found.
39
+ */
40
+ static VALUE np_getprotobynumber(VALUE klass, VALUE v_proto_num)
41
+ {
42
+ struct protoent* p;
43
+ VALUE v_proto_name = Qnil;
44
+
45
+ p = getprotobynumber(NUM2INT(v_proto_num));
46
+
47
+ if(p)
48
+ v_proto_name = rb_str_new2(p->p_name);
49
+
50
+ return v_proto_name;
51
+ }
52
+
53
+ void Init_proto()
54
+ {
55
+ VALUE mNet, cProto;
56
+
57
+ /* The Net module serves only as a namespace */
58
+ mNet = rb_define_module("Net");
59
+
60
+ /* The Proto class encapsulates network protocol information */
61
+ cProto = rb_define_class_under(mNet, "Proto", rb_cObject);
62
+
63
+ /* Class Methods */
64
+ rb_define_singleton_method(cProto,"getprotobyname",np_getprotobyname,1);
65
+ rb_define_singleton_method(cProto,"getprotobynumber",np_getprotobynumber,1);
66
+
67
+ /* 1.0.3: The version of this package. This is a string, not a number */
68
+ rb_define_const(cProto, "VERSION", rb_str_new2(NET_PROTO_VERSION));
69
+ }
70
+
71
+ #ifdef __cplusplus
72
+ }
73
+ #endif
Binary file
@@ -0,0 +1,71 @@
1
+ ###########################################################################
2
+ # tc_netproto.rb
3
+ #
4
+ # Test suite for net-proto - all platforms. This test suite should be run
5
+ # via the 'rake test' task.
6
+ ###########################################################################
7
+ require "net/proto"
8
+ require "test/unit"
9
+ include Net
10
+
11
+ class TC_Net_Proto < Test::Unit::TestCase
12
+ # These were the protocols listed in my
13
+ # own /etc/protocols file on Solaris 9.
14
+ def setup
15
+ @protocols = %w/
16
+ ip icmp igmp ggp ipip tcp cbt egp igp pup udp mux hmp
17
+ xns-idp rdp idpr idpr-cmtp sdrp idrp rsvp gre
18
+ mobile ospf pim ipcomp vrrp sctp hopopt ipv6
19
+ ipv6-route ipv6-frag esp ah ipv6-icmp ipv6-nonxt ipv6-opts
20
+ /
21
+ end
22
+
23
+ def test_version
24
+ assert_equal("1.0.3", Proto::VERSION)
25
+ end
26
+
27
+ def test_getprotobynumber
28
+ assert_respond_to(Proto, :getprotobynumber)
29
+ assert_raises(TypeError){ Proto.getprotobynumber("foo") }
30
+ assert_raises(TypeError){ Proto.getprotobynumber(nil) }
31
+ assert_equal(nil, Proto.getprotobynumber(9999999))
32
+ assert_equal("tcp", Proto.getprotobynumber(6))
33
+ assert_nothing_raised{
34
+ 0.upto(132){ |n| Proto.getprotobynumber(n) }
35
+ }
36
+ end
37
+
38
+ def test_getprotobyname
39
+ assert_respond_to(Proto, :getprotobyname)
40
+ assert_raises(TypeError){ Proto.getprotobyname(1) }
41
+ assert_raises(TypeError){ Proto.getprotobyname(nil) }
42
+ assert_equal(nil, Proto.getprotobyname("foo"))
43
+ assert_equal(6, Proto.getprotobyname("tcp"))
44
+ @protocols.each{ |prot|
45
+ assert_nothing_raised{ Proto.getprotobyname(prot) }
46
+ }
47
+ end
48
+
49
+ def test_getprotoent
50
+ if File::ALT_SEPARATOR
51
+ msg = "The getprotoent() function is not supported on this "
52
+ msg += "platform - test skipped"
53
+ STDERR.puts msg
54
+ else
55
+ assert_respond_to(Proto, :getprotoent)
56
+ p = Proto.getprotoent.first
57
+ assert_kind_of(Struct::ProtoStruct, p)
58
+ assert_equal(%w/name aliases proto/,p.members)
59
+ assert_kind_of(String, p.name, "Bad type for name")
60
+ assert_kind_of(Array, p.aliases, "Bad type for aliases")
61
+ assert_kind_of(Integer, p.proto, "Bad type for proto")
62
+ p.aliases.each{ |a|
63
+ assert_kind_of(String, a, "Bad type for aliases member")
64
+ }
65
+ end
66
+ end
67
+
68
+ def teardown
69
+ @protocols = nil
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: net-proto
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: x86-mswin32-60
6
+ authors:
7
+ - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-07 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: The net-proto package provides the getprotobyname(), getprotobynumber() and the getprotoent() methods for Ruby.
17
+ email: djberg96@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGES
24
+ - README
25
+ - MANIFEST
26
+ - doc/netproto.txt
27
+ - ext/windows/windows.c
28
+ files:
29
+ - doc/netproto.txt
30
+ - test/tc_netproto.rb
31
+ - lib/net
32
+ - lib/net/proto.so
33
+ - ext/windows/windows.c
34
+ - CHANGES
35
+ - README
36
+ - MANIFEST
37
+ has_rdoc: true
38
+ homepage: http://www.rubyforge.org/projects/sysutils
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 1.8.0
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project: sysutils
59
+ rubygems_version: 1.1.1
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: The net-proto package provides the getprotobyname(), getprotobynumber() and the getprotoent() methods for Ruby.
63
+ test_files:
64
+ - test/tc_netproto.rb