eventmachine 0.7.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +44 -265
- data/GNU +281 -0
- data/LEGAL +25 -0
- data/README +5 -3
- data/RELEASE_NOTES +7 -2
- data/ext/binder.cpp +8 -15
- data/ext/binder.h +8 -15
- data/ext/cmain.cpp +29 -15
- data/ext/ed.cpp +36 -43
- data/ext/ed.h +8 -15
- data/ext/em.cpp +116 -21
- data/ext/em.h +11 -16
- data/ext/emwin.cpp +9 -16
- data/ext/emwin.h +9 -16
- data/ext/eventmachine.h +9 -14
- data/ext/extconf.rb +9 -17
- data/ext/files.cpp +7 -14
- data/ext/files.h +7 -14
- data/ext/page.cpp +8 -15
- data/ext/page.h +8 -15
- data/ext/project.h +15 -15
- data/ext/rubymain.cpp +37 -16
- data/ext/sigs.cpp +8 -15
- data/ext/sigs.h +8 -15
- data/ext/ssl.cpp +8 -15
- data/ext/ssl.h +8 -15
- data/lib/em/deferrable.rb +40 -27
- data/lib/em/eventable.rb +12 -23
- data/lib/em/future.rb +62 -0
- data/lib/eventmachine.rb +156 -66
- data/lib/eventmachine_version.rb +12 -23
- data/lib/evma.rb +15 -18
- data/lib/evma/callback.rb +16 -19
- data/lib/evma/container.rb +17 -19
- data/lib/evma/factory.rb +16 -19
- data/lib/evma/protocol.rb +17 -19
- data/lib/evma/reactor.rb +17 -19
- data/lib/pr_eventmachine.rb +12 -23
- data/lib/protocols/buftok.rb +121 -0
- data/lib/protocols/header_and_content.rb +12 -23
- data/lib/protocols/httpclient.rb +44 -31
- data/lib/protocols/line_and_text.rb +97 -118
- data/lib/protocols/tcptest.rb +12 -22
- data/tests/test_basic.rb +14 -24
- data/tests/test_eventables.rb +14 -24
- data/tests/test_exc.rb +57 -0
- data/tests/test_futures.rb +136 -0
- data/tests/test_hc.rb +14 -24
- data/tests/test_httpclient.rb +106 -25
- data/tests/test_ltp.rb +14 -23
- data/tests/test_timers.rb +109 -0
- data/tests/test_ud.rb +14 -24
- metadata +11 -2
data/ext/em.h
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: em.h
|
3
|
+
$Id: em.h 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
|
-
File:
|
5
|
+
File: em.h
|
6
6
|
Date: 06Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
15
|
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
@@ -72,6 +65,7 @@ class EventMachine_t
|
|
72
65
|
void SignalLoopBreaker();
|
73
66
|
const char *InstallOneshotTimer (int);
|
74
67
|
const char *ConnectToServer (const char *, int);
|
68
|
+
const char *ConnectToUnixServer (const char *);
|
75
69
|
const char *CreateTcpServer (const char *, int);
|
76
70
|
const char *OpenDatagramSocket (const char *, int);
|
77
71
|
const char *CreateUnixDomainServer (const char*);
|
@@ -80,6 +74,7 @@ class EventMachine_t
|
|
80
74
|
void Add (EventableDescriptor*);
|
81
75
|
|
82
76
|
void SetTimerQuantum (int);
|
77
|
+
static void SetuidString (const char*);
|
83
78
|
|
84
79
|
public:
|
85
80
|
enum { // Event names
|
@@ -101,7 +96,7 @@ class EventMachine_t
|
|
101
96
|
|
102
97
|
private:
|
103
98
|
enum {
|
104
|
-
MaxOutstandingTimers =
|
99
|
+
MaxOutstandingTimers = 1000,
|
105
100
|
HeartbeatInterval = 2
|
106
101
|
};
|
107
102
|
void (*EventCallback)(const char*, int, const char*, int);
|
data/ext/emwin.cpp
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: emwin.cpp
|
3
|
+
$Id: emwin.cpp 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
|
-
File:
|
5
|
+
File: emwin.cpp
|
6
6
|
Date: 05May06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/emwin.h
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: emwin.h
|
3
|
+
$Id: emwin.h 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
|
-
File:
|
5
|
+
File: emwin.h
|
6
6
|
Date: 05May06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/eventmachine.h
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: eventmachine.h
|
3
|
+
$Id: eventmachine.h 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
5
|
File: eventmachine.h
|
6
6
|
Date: 15Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
15
|
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
@@ -36,6 +29,7 @@ extern "C" {
|
|
36
29
|
void evma_release_library();
|
37
30
|
const char *evma_install_oneshot_timer (int seconds);
|
38
31
|
const char *evma_connect_to_server (const char *server, int port);
|
32
|
+
const char *evma_connect_to_unix_server (const char *server);
|
39
33
|
const char *evma_create_tcp_server (const char *address, int port);
|
40
34
|
const char *evma_create_unix_domain_server (const char *filename);
|
41
35
|
const char *evma_open_datagram_socket (const char *server, int port);
|
@@ -48,6 +42,7 @@ extern "C" {
|
|
48
42
|
void evma_close_connection (const char *binding, int after_writing);
|
49
43
|
void evma_signal_loopbreak();
|
50
44
|
void evma_set_timer_quantum (int);
|
45
|
+
void evma_setuid_string (const char *username);
|
51
46
|
void evma_stop_machine();
|
52
47
|
|
53
48
|
const char *evma__write_file (const char *filename);
|
data/ext/extconf.rb
CHANGED
@@ -1,24 +1,16 @@
|
|
1
|
-
# $Id: extconf.rb
|
1
|
+
# $Id: extconf.rb 318 2007-05-22 22:06:24Z blackhedd $
|
2
2
|
#
|
3
3
|
#----------------------------------------------------------------------------
|
4
4
|
#
|
5
|
-
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
5
|
+
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
6
|
+
# Gmail: blackhedd
|
7
|
+
#
|
9
8
|
# This program is free software; you can redistribute it and/or modify
|
10
|
-
# it under the terms of the GNU General Public License
|
11
|
-
# the Free Software Foundation; either version 2 of the
|
12
|
-
# (at your option) any later version.
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
-
# GNU General Public License for more details.
|
18
|
-
#
|
19
|
-
# You should have received a copy of the GNU General Public License
|
20
|
-
# along with this program; if not, write to the Free Software
|
21
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
9
|
+
# it under the terms of either: 1) the GNU General Public License
|
10
|
+
# as published by the Free Software Foundation; either version 2 of the
|
11
|
+
# License, or (at your option) any later version; or 2) Ruby's License.
|
12
|
+
#
|
13
|
+
# See the file COPYING for complete licensing information.
|
22
14
|
#
|
23
15
|
#---------------------------------------------------------------------------
|
24
16
|
#
|
data/ext/files.cpp
CHANGED
@@ -5,22 +5,15 @@ $Id: ed.cpp 250 2006-08-25 02:17:58Z blackhedd $
|
|
5
5
|
File: files.cpp
|
6
6
|
Date: 26Aug06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/files.h
CHANGED
@@ -5,22 +5,15 @@ $Id: ed.h 243 2006-08-23 02:00:10Z blackhedd $
|
|
5
5
|
File: files.h
|
6
6
|
Date: 26Aug06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/page.cpp
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: page.cpp
|
3
|
+
$Id: page.cpp 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
5
|
File: page.cpp
|
6
6
|
Date: 30Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/page.h
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: page.h
|
3
|
+
$Id: page.h 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
5
|
File: page.h
|
6
6
|
Date: 30Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
15
|
-
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
data/ext/project.h
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: project.h
|
3
|
+
$Id: project.h 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
5
|
File: project.h
|
6
6
|
Date: 06Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
15
|
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
@@ -55,12 +48,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
55
48
|
#include <netinet/in.h>
|
56
49
|
#include <netinet/tcp.h>
|
57
50
|
#include <arpa/inet.h>
|
51
|
+
#include <pwd.h>
|
58
52
|
typedef int SOCKET;
|
59
53
|
#define closesocket close
|
60
54
|
#define INVALID_SOCKET -1
|
61
55
|
#define SOCKET_ERROR -1
|
62
56
|
#ifdef OS_SOLARIS8
|
63
|
-
#
|
57
|
+
#include <strings.h>
|
58
|
+
#include <sys/un.h>
|
59
|
+
#ifndef AF_LOCAL
|
60
|
+
#define AF_LOCAL AF_UNIX
|
61
|
+
#endif
|
62
|
+
// The ff is superfluous on Solaris > 7. Thanks to Brett Eisenberg.
|
63
|
+
//#define INADDR_NONE ((unsigned long)-1)
|
64
64
|
#endif
|
65
65
|
#endif
|
66
66
|
|
data/ext/rubymain.cpp
CHANGED
@@ -1,26 +1,19 @@
|
|
1
1
|
/*****************************************************************************
|
2
2
|
|
3
|
-
$Id: rubymain.cpp
|
3
|
+
$Id: rubymain.cpp 318 2007-05-22 22:06:24Z blackhedd $
|
4
4
|
|
5
|
-
File:
|
5
|
+
File: rubymain.cpp
|
6
6
|
Date: 06Apr06
|
7
7
|
|
8
|
-
Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail:
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
10
|
|
11
11
|
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of the GNU General Public License
|
13
|
-
the Free Software Foundation; either version 2 of the
|
14
|
-
(at your option) any later version.
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
15
|
|
16
|
-
|
17
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19
|
-
GNU General Public License for more details.
|
20
|
-
|
21
|
-
You should have received a copy of the GNU General Public License
|
22
|
-
along with this program; if not, write to the Free Software
|
23
|
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
See the file COPYING for complete licensing information.
|
24
17
|
|
25
18
|
*****************************************************************************/
|
26
19
|
|
@@ -200,7 +193,23 @@ t_connect_server
|
|
200
193
|
|
201
194
|
static VALUE t_connect_server (VALUE self, VALUE server, VALUE port)
|
202
195
|
{
|
203
|
-
|
196
|
+
// Avoid FIX2INT in this case, because it doesn't deal with type errors properly.
|
197
|
+
// Specifically, if the value of port comes in as a string rather than an integer,
|
198
|
+
// NUM2INT will throw a type error, but FIX2INT will generate garbage.
|
199
|
+
|
200
|
+
const char *f = evma_connect_to_server (StringValuePtr(server), NUM2INT(port));
|
201
|
+
if (!f || !*f)
|
202
|
+
rb_raise (rb_eRuntimeError, "no connection");
|
203
|
+
return rb_str_new2 (f);
|
204
|
+
}
|
205
|
+
|
206
|
+
/*********************
|
207
|
+
t_connect_unix_server
|
208
|
+
*********************/
|
209
|
+
|
210
|
+
static VALUE t_connect_unix_server (VALUE self, VALUE serversocket)
|
211
|
+
{
|
212
|
+
const char *f = evma_connect_to_unix_server (StringValuePtr(serversocket));
|
204
213
|
if (!f || !*f)
|
205
214
|
rb_raise (rb_eRuntimeError, "no connection");
|
206
215
|
return rb_str_new2 (f);
|
@@ -272,6 +281,16 @@ static VALUE t_set_timer_quantum (VALUE self, VALUE interval)
|
|
272
281
|
return Qnil;
|
273
282
|
}
|
274
283
|
|
284
|
+
/***************
|
285
|
+
t_setuid_string
|
286
|
+
***************/
|
287
|
+
|
288
|
+
static VALUE t_setuid_string (VALUE self, VALUE username)
|
289
|
+
{
|
290
|
+
evma_setuid_string (StringValuePtr (username));
|
291
|
+
return Qnil;
|
292
|
+
}
|
293
|
+
|
275
294
|
|
276
295
|
|
277
296
|
/*************
|
@@ -308,12 +327,14 @@ extern "C" void Init_rubyeventmachine()
|
|
308
327
|
rb_define_module_function (EmModule, "send_datagram", (VALUE(*)(...))t_send_datagram, 5);
|
309
328
|
rb_define_module_function (EmModule, "close_connection", (VALUE(*)(...))t_close_connection, 2);
|
310
329
|
rb_define_module_function (EmModule, "connect_server", (VALUE(*)(...))t_connect_server, 2);
|
330
|
+
rb_define_module_function (EmModule, "connect_unix_server", (VALUE(*)(...))t_connect_unix_server, 1);
|
311
331
|
rb_define_module_function (EmModule, "open_udp_socket", (VALUE(*)(...))t_open_udp_socket, 2);
|
312
332
|
rb_define_module_function (EmModule, "release_machine", (VALUE(*)(...))t_release_machine, 0);
|
313
333
|
rb_define_module_function (EmModule, "stop", (VALUE(*)(...))t_stop, 0);
|
314
334
|
rb_define_module_function (EmModule, "signal_loopbreak", (VALUE(*)(...))t_signal_loopbreak, 0);
|
315
335
|
rb_define_module_function (EmModule, "library_type", (VALUE(*)(...))t_library_type, 0);
|
316
336
|
rb_define_module_function (EmModule, "set_timer_quantum", (VALUE(*)(...))t_set_timer_quantum, 1);
|
337
|
+
rb_define_module_function (EmModule, "setuid_string", (VALUE(*)(...))t_setuid_string, 1);
|
317
338
|
|
318
339
|
// Provisional:
|
319
340
|
rb_define_module_function (EmModule, "_write_file", (VALUE(*)(...))t__write_file, 1);
|