author | Mikael Hallendal <micke@imendio.com> |
Thu, 10 Apr 2008 14:57:41 +0200 | |
changeset 377 | 52b0968e0235 |
parent 376 | d54d6310c136 |
child 378 | f757ef1a9d72 |
permissions | -rw-r--r-- |
374
6fb30156b968
Added files for LmSSL and LmProxy to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1 |
#include "rblm.h" |
6fb30156b968
Added files for LmSSL and LmProxy to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
2 |
|
375
1f0f637e3ae8
Added LmProxyType to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
374
diff
changeset
|
3 |
VALUE lm_cProxy; |
1f0f637e3ae8
Added LmProxyType to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
374
diff
changeset
|
4 |
|
376
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
5 |
static LmProxy * |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
6 |
rb_lm_proxy_from_ruby_object (VALUE obj) |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
7 |
{ |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
8 |
LmProxy *proxy; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
9 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
10 |
if (!rb_lm__is_kind_of (obj, lm_cProxy)) { |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
11 |
rb_raise (rb_eTypeError, "no a LmProxy"); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
12 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
13 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
14 |
Data_Get_Struct (obj, LmProxy, proxy); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
15 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
16 |
return proxy; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
17 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
18 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
19 |
void |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
20 |
proxy_free (LmProxy *proxy) |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
21 |
{ |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
22 |
lm_proxy_unref (proxy); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
23 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
24 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
25 |
VALUE |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
26 |
proxy_allocate (VALUE klass) |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
27 |
{ |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
28 |
return Data_Wrap_Struct (klass, NULL, proxy_free, NULL); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
29 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
30 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
31 |
VALUE |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
32 |
proxy_initialize (int argc, VALUE *argv, VALUE self) |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
33 |
{ |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
34 |
LmProxy *proxy; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
35 |
VALUE type, server, port; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
36 |
char *server_str = NULL; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
37 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
38 |
rb_scan_args (argc, argv, "12", &type, &server, &port); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
39 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
40 |
proxy = lm_proxy_new (FIX2INT (type)); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
41 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
42 |
if (!NIL_P (server)) { |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
43 |
if (!rb_respond_to (server, rb_intern ("to_s"))) { |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
44 |
rb_raise (rb_eArgError, "server should respond to to_s"); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
45 |
} else { |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
46 |
VALUE str_val = rb_funcall (server, rb_intern ("to_s"), 0); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
47 |
lm_proxy_set_server (proxy, StringValuePtr (str_val)); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
48 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
49 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
50 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
51 |
if (!NIL_P (port)) { |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
52 |
lm_proxy_set_port (proxy, NUM2UINT (port)); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
53 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
54 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
55 |
DATA_PTR (self) = proxy; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
56 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
57 |
return self; |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
58 |
} |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
59 |
|
377
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
60 |
VALUE |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
61 |
proxy_get_type (VALUE self) |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
62 |
{ |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
63 |
LmProxy *proxy = rb_lm_proxy_from_ruby_object (self); |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
64 |
|
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
65 |
return INT2FIX (lm_proxy_get_type (proxy)); |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
66 |
} |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
67 |
|
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
68 |
VALUE |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
69 |
proxy_set_type (VALUE self, VALUE type) |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
70 |
{ |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
71 |
LmProxy *proxy = rb_lm_proxy_from_ruby_object (self); |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
72 |
|
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
73 |
lm_proxy_set_type (proxy, FIX2INT (type)); |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
74 |
|
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
75 |
return Qnil; |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
76 |
} |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
77 |
|
374
6fb30156b968
Added files for LmSSL and LmProxy to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
78 |
extern void |
6fb30156b968
Added files for LmSSL and LmProxy to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
79 |
Init_lm_proxy (VALUE lm_mLM) |
375
1f0f637e3ae8
Added LmProxyType to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
374
diff
changeset
|
80 |
{ |
1f0f637e3ae8
Added LmProxyType to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
374
diff
changeset
|
81 |
lm_cProxy = rb_define_class_under (lm_mLM, "Proxy", rb_cObject); |
376
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
82 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
83 |
rb_define_alloc_func (lm_cProxy, proxy_allocate); |
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
84 |
|
d54d6310c136
Implemented allocate and initialize for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
375
diff
changeset
|
85 |
rb_define_method (lm_cProxy, "initialize", proxy_initialize, -1); |
377
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
86 |
rb_define_method (lm_cProxy, "type", proxy_get_type, 0); |
52b0968e0235
Added type and type= for LmProxy in the ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
376
diff
changeset
|
87 |
rb_define_method (lm_cProxy, "type=", proxy_set_type, 1); |
375
1f0f637e3ae8
Added LmProxyType to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
374
diff
changeset
|
88 |
} |
374
6fb30156b968
Added files for LmSSL and LmProxy to ruby bindings
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
89 |