net-proto 1.0.6 → 1.1.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.
@@ -1,2 +0,0 @@
1
- /* version.h - there can be only one */
2
- #define NET_PROTO_VERSION "1.0.6"
@@ -1,86 +0,0 @@
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
- * Examples:
21
- *
22
- * Net::Proto.getprotobyname("tcp") # => 6
23
- * Net::Proto.getprotobyname("bogus") # => nil
24
- */
25
- static VALUE np_getprotobyname(VALUE klass, VALUE rbProtoName){
26
- struct protoent* p;
27
- VALUE v_proto_num = Qnil;
28
-
29
- SafeStringValue(rbProtoName);
30
- p = getprotobyname(StringValuePtr(rbProtoName));
31
-
32
- if(p)
33
- v_proto_num = INT2FIX(p->p_proto);
34
-
35
- return v_proto_num;
36
- }
37
-
38
- /*
39
- * call-seq:
40
- * Proto.getprotobynumber(num)
41
- *
42
- * Given a protocol number, returns the corresponding string, or nil if not
43
- * found.
44
- *
45
- * Examples:
46
- *
47
- * Net::Proto.getprotobynumber(6) # => "tcp"
48
- * Net::Proto.getprotobynumber(999) # => nil
49
- */
50
- static VALUE np_getprotobynumber(VALUE klass, VALUE v_proto_num)
51
- {
52
- struct protoent* p;
53
- VALUE v_proto_name = Qnil;
54
-
55
- p = getprotobynumber(NUM2INT(v_proto_num));
56
-
57
- if(p)
58
- v_proto_name = rb_str_new2(p->p_name);
59
-
60
- return v_proto_name;
61
- }
62
-
63
- void Init_proto()
64
- {
65
- VALUE mNet, cProto;
66
-
67
- /* The Net module serves only as a namespace */
68
- mNet = rb_define_module("Net");
69
-
70
- /* The Proto class encapsulates network protocol information */
71
- cProto = rb_define_class_under(mNet, "Proto", rb_cObject);
72
-
73
- /* Class Methods */
74
- rb_define_singleton_method(cProto,"getprotobyname",np_getprotobyname,1);
75
- rb_define_singleton_method(cProto,"getprotobynumber",np_getprotobynumber,1);
76
-
77
- /* There is no constructor */
78
- rb_funcall(cProto, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
79
-
80
- /* 1.0.4: The version of this library. This is a string, not a number */
81
- rb_define_const(cProto, "VERSION", rb_str_new2(NET_PROTO_VERSION));
82
- }
83
-
84
- #ifdef __cplusplus
85
- }
86
- #endif