clucumber 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +4 -9
  3. data/lib/clucumber/clucumber-bootstrap.lisp +32 -0
  4. data/lib/clucumber/vendor/cl-interpol/alias.lisp +55 -0
  5. data/lib/clucumber/vendor/cl-interpol/cl-interpol.asd +56 -0
  6. data/lib/clucumber/vendor/cl-interpol/load.lisp +53 -0
  7. data/lib/clucumber/vendor/cl-interpol/packages.lisp +40 -0
  8. data/lib/clucumber/vendor/cl-interpol/read.lisp +716 -0
  9. data/lib/clucumber/vendor/cl-interpol/specials.lisp +113 -0
  10. data/lib/clucumber/vendor/cl-interpol/test/packages.lisp +34 -0
  11. data/lib/clucumber/vendor/cl-interpol/test/tests.lisp +128 -0
  12. data/lib/clucumber/vendor/cl-interpol/test.lisp +177 -0
  13. data/lib/clucumber/vendor/cl-interpol/test2.lisp +6254 -0
  14. data/lib/clucumber/vendor/cl-interpol/unicode.lisp +13912 -0
  15. data/lib/clucumber/vendor/cl-interpol/util.lisp +122 -0
  16. data/lib/clucumber/vendor/cl-ppcre/api.lisp +1262 -0
  17. data/lib/clucumber/vendor/cl-ppcre/charmap.lisp +152 -0
  18. data/lib/clucumber/vendor/cl-ppcre/charset.lisp +242 -0
  19. data/lib/clucumber/vendor/cl-ppcre/chartest.lisp +98 -0
  20. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-test.asd +34 -0
  21. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/packages.lisp +38 -0
  22. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode/resolver.lisp +61 -0
  23. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre-unicode.asd +58 -0
  24. data/lib/clucumber/vendor/cl-ppcre/cl-ppcre.asd +79 -0
  25. data/lib/clucumber/vendor/cl-ppcre/closures.lisp +471 -0
  26. data/lib/clucumber/vendor/cl-ppcre/convert.lisp +875 -0
  27. data/lib/clucumber/vendor/cl-ppcre/errors.lisp +84 -0
  28. data/lib/clucumber/vendor/cl-ppcre/lexer.lisp +737 -0
  29. data/lib/clucumber/vendor/cl-ppcre/lispworks-defsystem.lisp +57 -0
  30. data/lib/clucumber/vendor/cl-ppcre/load.lisp +67 -0
  31. data/lib/clucumber/vendor/cl-ppcre/optimize.lisp +578 -0
  32. data/lib/clucumber/vendor/cl-ppcre/packages.lisp +68 -0
  33. data/lib/clucumber/vendor/cl-ppcre/parser.lisp +319 -0
  34. data/lib/clucumber/vendor/cl-ppcre/ppcre-tests.lisp +269 -0
  35. data/lib/clucumber/vendor/cl-ppcre/regex-class-util.lisp +555 -0
  36. data/lib/clucumber/vendor/cl-ppcre/regex-class.lisp +259 -0
  37. data/lib/clucumber/vendor/cl-ppcre/repetition-closures.lisp +833 -0
  38. data/lib/clucumber/vendor/cl-ppcre/scanner.lisp +506 -0
  39. data/lib/clucumber/vendor/cl-ppcre/specials.lisp +172 -0
  40. data/lib/clucumber/vendor/cl-ppcre/test/packages.lisp +37 -0
  41. data/lib/clucumber/vendor/cl-ppcre/test/perl-tests.lisp +150 -0
  42. data/lib/clucumber/vendor/cl-ppcre/test/tests.lisp +159 -0
  43. data/lib/clucumber/vendor/cl-ppcre/test/unicode-tests.lisp +80 -0
  44. data/lib/clucumber/vendor/cl-ppcre/util.lisp +201 -0
  45. data/lib/clucumber/vendor/cl-unicode/alias.lisp +135 -0
  46. data/lib/clucumber/vendor/cl-unicode/api.lisp +412 -0
  47. data/lib/clucumber/vendor/cl-unicode/build/char-info.lisp +133 -0
  48. data/lib/clucumber/vendor/cl-unicode/build/dump.lisp +239 -0
  49. data/lib/clucumber/vendor/cl-unicode/build/read.lisp +280 -0
  50. data/lib/clucumber/vendor/cl-unicode/build/util.lisp +182 -0
  51. data/lib/clucumber/vendor/cl-unicode/cl-unicode.asd +90 -0
  52. data/lib/clucumber/vendor/cl-unicode/conditions.lisp +54 -0
  53. data/lib/clucumber/vendor/cl-unicode/derived.lisp +120 -0
  54. data/lib/clucumber/vendor/cl-unicode/hash-tables.lisp +20 -0
  55. data/lib/clucumber/vendor/cl-unicode/lists.lisp +10 -0
  56. data/lib/clucumber/vendor/cl-unicode/methods.lisp +15 -0
  57. data/lib/clucumber/vendor/cl-unicode/packages.lisp +76 -0
  58. data/lib/clucumber/vendor/cl-unicode/specials.lisp +135 -0
  59. data/lib/clucumber/vendor/cl-unicode/test/packages.lisp +34 -0
  60. data/lib/clucumber/vendor/cl-unicode/test/tests.lisp +150 -0
  61. data/lib/clucumber/vendor/cl-unicode/test-functions.lisp +94 -0
  62. data/lib/clucumber/vendor/cl-unicode/util.lisp +274 -0
  63. data/lib/clucumber/vendor/lift/compare/fiveam-tests.lisp +14 -0
  64. data/lib/clucumber/vendor/lift/compare/lift-tests.lisp +13 -0
  65. data/lib/clucumber/vendor/lift/compare/rt-tests.lisp +16 -0
  66. data/lib/clucumber/vendor/lift/compare/xlunit-tests.lisp +15 -0
  67. data/lib/clucumber/vendor/lift/dev/changes.lisp +61 -0
  68. data/lib/clucumber/vendor/lift/dev/config.lisp +354 -0
  69. data/lib/clucumber/vendor/lift/dev/copy-file.lisp +117 -0
  70. data/lib/clucumber/vendor/lift/dev/introspection.lisp +232 -0
  71. data/lib/clucumber/vendor/lift/dev/lift-interface.lisp +56 -0
  72. data/lib/clucumber/vendor/lift/dev/lift-notes.lisp +202 -0
  73. data/lib/clucumber/vendor/lift/dev/lift-randomized.lisp +45 -0
  74. data/lib/clucumber/vendor/lift/dev/lift.lisp +2383 -0
  75. data/lib/clucumber/vendor/lift/dev/macros.lisp +229 -0
  76. data/lib/clucumber/vendor/lift/dev/measuring.lisp +156 -0
  77. data/lib/clucumber/vendor/lift/dev/packages.lisp +161 -0
  78. data/lib/clucumber/vendor/lift/dev/port.lisp +151 -0
  79. data/lib/clucumber/vendor/lift/dev/prototypes.lisp +282 -0
  80. data/lib/clucumber/vendor/lift/dev/random-testing.lisp +124 -0
  81. data/lib/clucumber/vendor/lift/dev/report-locations.lisp +13 -0
  82. data/lib/clucumber/vendor/lift/dev/reports.lisp +916 -0
  83. data/lib/clucumber/vendor/lift/dev/utilities.lisp +242 -0
  84. data/lib/clucumber/vendor/lift/docs/package.lisp +6 -0
  85. data/lib/clucumber/vendor/lift/docs/setup.lisp +17 -0
  86. data/lib/clucumber/vendor/lift/examples/basic-examples.lisp +289 -0
  87. data/lib/clucumber/vendor/lift/examples/random-testing.lisp +32 -0
  88. data/lib/clucumber/vendor/lift/lift-documentation.asd +28 -0
  89. data/lib/clucumber/vendor/lift/lift-test.asd +35 -0
  90. data/lib/clucumber/vendor/lift/lift.asd +77 -0
  91. data/lib/clucumber/vendor/lift/test/equality-tests.lisp +40 -0
  92. data/lib/clucumber/vendor/lift/test/finding-tests.lisp +32 -0
  93. data/lib/clucumber/vendor/lift/test/lift-test.lisp +783 -0
  94. data/lib/clucumber/vendor/lift/test/order-of-operations.lisp +54 -0
  95. data/lib/clucumber/vendor/lift/test/packages.lisp +17 -0
  96. data/lib/clucumber/vendor/lift/test/test-config-files.lisp +20 -0
  97. data/lib/clucumber/vendor/lift/test/test-dynamic-variables.lisp +57 -0
  98. data/lib/clucumber/vendor/lift/test/test-maximum-problems.lisp +74 -0
  99. data/lib/clucumber/vendor/lift/test/test-prototypes.lisp +278 -0
  100. data/lib/clucumber/vendor/lift/test/test-timeout.lisp +37 -0
  101. data/lib/clucumber/vendor/lift/test/tests-in-progress.lisp +62 -0
  102. data/lib/clucumber/vendor/lift/test/testsuite-expects.lisp +60 -0
  103. data/lib/clucumber/vendor/lift/timeout/package.lisp +13 -0
  104. data/lib/clucumber/vendor/lift/timeout/with-timeout.lisp +123 -0
  105. data/lib/clucumber/vendor/lift/website/stuff/Temp.lisp +34 -0
  106. data/lib/clucumber/vendor/st-json/st-json.asd +3 -0
  107. data/lib/clucumber/vendor/st-json/st-json.lisp +310 -0
  108. data/lib/clucumber/vendor/trivial-backtrace/dev/backtrace.lisp +127 -0
  109. data/lib/clucumber/vendor/trivial-backtrace/dev/fallback.lisp +10 -0
  110. data/lib/clucumber/vendor/trivial-backtrace/dev/map-backtrace.lisp +103 -0
  111. data/lib/clucumber/vendor/trivial-backtrace/dev/mucking.lisp +75 -0
  112. data/lib/clucumber/vendor/trivial-backtrace/dev/packages.lisp +13 -0
  113. data/lib/clucumber/vendor/trivial-backtrace/dev/utilities.lisp +104 -0
  114. data/lib/clucumber/vendor/trivial-backtrace/test/packages.lisp +5 -0
  115. data/lib/clucumber/vendor/trivial-backtrace/test/test-setup.lisp +4 -0
  116. data/lib/clucumber/vendor/trivial-backtrace/test/tests.lisp +16 -0
  117. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace-test.asd +22 -0
  118. data/lib/clucumber/vendor/trivial-backtrace/trivial-backtrace.asd +35 -0
  119. data/lib/clucumber/vendor/usocket/backend/allegro.lisp +199 -0
  120. data/lib/clucumber/vendor/usocket/backend/armedbear.lisp +491 -0
  121. data/lib/clucumber/vendor/usocket/backend/clisp.lisp +260 -0
  122. data/lib/clucumber/vendor/usocket/backend/cmucl.lisp +266 -0
  123. data/lib/clucumber/vendor/usocket/backend/lispworks.lisp +741 -0
  124. data/lib/clucumber/vendor/usocket/backend/mcl.lisp +369 -0
  125. data/lib/clucumber/vendor/usocket/backend/openmcl.lisp +206 -0
  126. data/lib/clucumber/vendor/usocket/backend/sbcl.lisp +424 -0
  127. data/lib/clucumber/vendor/usocket/backend/scl.lisp +261 -0
  128. data/lib/clucumber/vendor/usocket/condition.lisp +227 -0
  129. data/lib/clucumber/vendor/usocket/package.lisp +82 -0
  130. data/lib/clucumber/vendor/usocket/server.lisp +45 -0
  131. data/lib/clucumber/vendor/usocket/test/package.lisp +13 -0
  132. data/lib/clucumber/vendor/usocket/test/test-usocket.lisp +166 -0
  133. data/lib/clucumber/vendor/usocket/usocket-test.asd +26 -0
  134. data/lib/clucumber/vendor/usocket/usocket.asd +37 -0
  135. data/lib/clucumber/vendor/usocket/usocket.lisp +542 -0
  136. data/lib/clucumber/vendor/usocket/vendor/kqueue.lisp +1 -0
  137. data/lib/clucumber/vendor/usocket/vendor/split-sequence.lisp +245 -0
  138. data/lib/clucumber.rb +29 -7
  139. metadata +151 -5
@@ -0,0 +1,227 @@
1
+ ;;;; $Id: condition.lisp 500 2009-09-17 07:01:50Z hhubner $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/condition.lisp $
3
+
4
+ ;;;; See LICENSE for licensing information.
5
+
6
+ (in-package :usocket)
7
+
8
+ ;; Condition signalled by operations with unsupported arguments
9
+ ;; For trivial-sockets compatibility.
10
+
11
+ (define-condition insufficient-implementation (error)
12
+ ((feature :initarg :feature :reader feature)
13
+ (context :initarg :context :reader context
14
+ :documentation "String designator of the public API function which
15
+ the feature belongs to."))
16
+ (:documentation "The ancestor of all errors usocket may generate
17
+ because of insufficient support from the underlying implementation
18
+ with respect to the arguments given to `function'.
19
+
20
+ One call may signal several errors, if the caller allows processing
21
+ to continue.
22
+ "))
23
+
24
+ (define-condition unsupported (insufficient-implementation)
25
+ ((minimum :initarg :minimum :reader minimum
26
+ :documentation "Indicates the minimal version of the
27
+ implementation required to support the requested feature."))
28
+ (:report (lambda (c stream)
29
+ (format stream "~A in ~A is unsupported."
30
+ (feature c) (context c))
31
+ (when (minimum c)
32
+ (format stream " Minimum version (~A) is required."
33
+ (minimum c)))))
34
+ (:documentation "Signalled when the underlying implementation
35
+ doesn't allow supporting the requested feature.
36
+
37
+ When you see this error, go bug your vendor/implementation developer!"))
38
+
39
+ (define-condition unimplemented (insufficient-implementation)
40
+ ()
41
+ (:report (lambda (c stream)
42
+ (format stream "~A in ~A is unimplemented."
43
+ (feature c) (context c))))
44
+ (:documentation "Signalled if a certain feature might be implemented,
45
+ based on the features of the underlying implementation, but hasn't
46
+ been implemented yet."))
47
+
48
+ ;; Conditions raised by sockets operations
49
+
50
+ (define-condition socket-condition (condition)
51
+ ((socket :initarg :socket
52
+ :accessor usocket-socket))
53
+ ;;###FIXME: no slots (yet); should at least be the affected usocket...
54
+ (:documentation "Parent condition for all socket related conditions."))
55
+
56
+ (define-condition socket-error (socket-condition error)
57
+ () ;; no slots (yet)
58
+ (:documentation "Parent error for all socket related errors"))
59
+
60
+ (define-condition ns-condition (condition)
61
+ ((host-or-ip :initarg :host-or-ip
62
+ :accessor host-or-ip))
63
+ (:documentation "Parent condition for all name resolution conditions."))
64
+
65
+ (define-condition ns-error (ns-condition error)
66
+ ()
67
+ (:documentation "Parent error for all name resolution errors."))
68
+
69
+ (eval-when (:compile-toplevel :load-toplevel :execute)
70
+ (defun define-usocket-condition-class (class &rest parents)
71
+ `(progn
72
+ (define-condition ,class ,parents ())
73
+ (export ',class))))
74
+
75
+ (defmacro define-usocket-condition-classes (class-list parents)
76
+ `(progn ,@(mapcar #'(lambda (x)
77
+ (apply #'define-usocket-condition-class
78
+ x parents))
79
+ class-list)))
80
+
81
+ ;; Mass define and export our conditions
82
+ (define-usocket-condition-classes
83
+ (interrupted-condition)
84
+ (socket-condition))
85
+
86
+ (define-condition unknown-condition (socket-condition)
87
+ ((real-condition :initarg :real-condition
88
+ :accessor usocket-real-condition))
89
+ (:documentation "Condition raised when there's no other - more applicable -
90
+ condition available."))
91
+
92
+
93
+ ;; Mass define and export our errors
94
+ (define-usocket-condition-classes
95
+ (address-in-use-error
96
+ address-not-available-error
97
+ bad-file-descriptor-error
98
+ connection-refused-error
99
+ connection-aborted-error
100
+ connection-reset-error
101
+ invalid-argument-error
102
+ no-buffers-error
103
+ operation-not-supported-error
104
+ operation-not-permitted-error
105
+ protocol-not-supported-error
106
+ socket-type-not-supported-error
107
+ network-unreachable-error
108
+ network-down-error
109
+ network-reset-error
110
+ host-down-error
111
+ host-unreachable-error
112
+ shutdown-error
113
+ timeout-error
114
+ deadline-timeout-error
115
+ invalid-socket-error
116
+ invalid-socket-stream-error)
117
+ (socket-error))
118
+
119
+ (define-condition unknown-error (socket-error)
120
+ ((real-error :initarg :real-error
121
+ :accessor usocket-real-error))
122
+ (:report (lambda (c stream)
123
+ (typecase c
124
+ (simple-condition
125
+ (format stream
126
+ (simple-condition-format-control (usocket-real-error c))
127
+ (simple-condition-format-arguments (usocket-real-error c))))
128
+ (otherwise
129
+ (format stream "The condition ~A occurred." (usocket-real-error c))))))
130
+ (:documentation "Error raised when there's no other - more applicable -
131
+ error available."))
132
+
133
+ (define-usocket-condition-classes
134
+ (ns-try-again)
135
+ (ns-condition))
136
+
137
+ (define-condition ns-unknown-condition (ns-condition)
138
+ ((real-error :initarg :real-condition
139
+ :accessor ns-real-condition))
140
+ (:documentation "Condition raised when there's no other - more applicable -
141
+ condition available."))
142
+
143
+ (define-usocket-condition-classes
144
+ ;; the no-data error code in the Unix 98 api
145
+ ;; isn't really an error: there's just no data to return.
146
+ ;; with lisp, we just return NIL (indicating no data) instead of
147
+ ;; raising an exception...
148
+ (ns-host-not-found-error
149
+ ns-no-recovery-error)
150
+ (ns-error))
151
+
152
+ (define-condition ns-unknown-error (ns-error)
153
+ ((real-error :initarg :real-error
154
+ :accessor ns-real-error))
155
+ (:report (lambda (c stream)
156
+ (typecase c
157
+ (simple-condition
158
+ (format stream
159
+ (simple-condition-format-control (usocket-real-error c))
160
+ (simple-condition-format-arguments (usocket-real-error c))))
161
+ (otherwise
162
+ (format stream "The condition ~A occurred." (usocket-real-error c))))))
163
+ (:documentation "Error raised when there's no other - more applicable -
164
+ error available."))
165
+
166
+ (defmacro with-mapped-conditions ((&optional socket) &body body)
167
+ `(handler-bind ((condition #'(lambda (c) (handle-condition c ,socket))))
168
+ ,@body))
169
+
170
+ (defparameter +unix-errno-condition-map+
171
+ `(((11) . retry-condition) ;; EAGAIN
172
+ ((35) . retry-condition) ;; EDEADLCK
173
+ ((4) . interrupted-condition))) ;; EINTR
174
+
175
+ (defparameter +unix-errno-error-map+
176
+ ;;### the first column is for non-(linux or srv4) systems
177
+ ;; the second for linux
178
+ ;; the third for srv4
179
+ ;;###FIXME: How do I determine on which Unix we're running
180
+ ;; (at least in clisp and sbcl; I know about cmucl...)
181
+ ;; The table below works under the assumption we'll *only* see
182
+ ;; socket associated errors...
183
+ `(((48 98) . address-in-use-error)
184
+ ((49 99) . address-not-available-error)
185
+ ((9) . bad-file-descriptor-error)
186
+ ((61 111) . connection-refused-error)
187
+ ((54 104) . connection-reset-error)
188
+ ((53 103) . connection-aborted-error)
189
+ ((22) . invalid-argument-error)
190
+ ((55 105) . no-buffers-error)
191
+ ((12) . out-of-memory-error)
192
+ ((45 95) . operation-not-supported-error)
193
+ ((1) . operation-not-permitted-error)
194
+ ((43 92) . protocol-not-supported-error)
195
+ ((44 93) . socket-type-not-supported-error)
196
+ ((51 101) . network-unreachable-error)
197
+ ((50 100) . network-down-error)
198
+ ((52 102) . network-reset-error)
199
+ ((58 108) . already-shutdown-error)
200
+ ((60 110) . timeout-error)
201
+ ((64 112) . host-down-error)
202
+ ((65 113) . host-unreachable-error)))
203
+
204
+
205
+ (defun map-errno-condition (errno)
206
+ (cdr (assoc errno +unix-errno-error-map+ :test #'member)))
207
+
208
+
209
+ (defun map-errno-error (errno)
210
+ (cdr (assoc errno +unix-errno-error-map+ :test #'member)))
211
+
212
+
213
+ (defparameter +unix-ns-error-map+
214
+ `((1 . ns-host-not-found-error)
215
+ (2 . ns-try-again-condition)
216
+ (3 . ns-no-recovery-error)))
217
+
218
+
219
+
220
+ (defmacro unsupported (feature context &key minimum)
221
+ `(cerror "Ignore it and continue" 'unsupported
222
+ :feature ,feature
223
+ :context ,context
224
+ :minimum ,minimum))
225
+
226
+ (defmacro unimplemented (feature context)
227
+ `(signal 'unimplemented :feature ,feature :context ,context))
@@ -0,0 +1,82 @@
1
+ ;;;; $Id: package.lisp 515 2010-01-07 18:26:06Z ctian $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/package.lisp $
3
+
4
+ ;;;; See the LICENSE file for licensing information.
5
+
6
+ (in-package :usocket-system)
7
+
8
+ #+lispworks
9
+ (eval-when (:compile-toplevel :load-toplevel :execute)
10
+ (require "comm"))
11
+
12
+ (defpackage :usocket
13
+ (:use :common-lisp)
14
+ (:export #:*wildcard-host*
15
+ #:*auto-port*
16
+
17
+ #:*remote-host* ; special variables (udp)
18
+ #:*remote-port*
19
+
20
+ #:socket-connect ; socket constructors and methods
21
+ #:socket-listen
22
+ #:socket-accept
23
+ #:socket-close
24
+ #:get-local-address
25
+ #:get-peer-address
26
+ #:get-local-port
27
+ #:get-peer-port
28
+ #:get-local-name
29
+ #:get-peer-name
30
+
31
+ #:socket-send ; udp function (send)
32
+ #:socket-receive ; udp function (receive)
33
+ #:socket-server ; udp server
34
+
35
+ #:wait-for-input ; waiting for input-ready state (select() like)
36
+ #:make-wait-list
37
+ #:add-waiter
38
+ #:remove-waiter
39
+ #:remove-all-waiters
40
+
41
+ #:with-connected-socket ; convenience macros
42
+ #:with-server-socket
43
+ #:with-client-socket
44
+ #:with-socket-listener
45
+
46
+ #:usocket ; socket object and accessors
47
+ #:stream-usocket
48
+ #:stream-server-usocket
49
+ #:socket
50
+ #:socket-stream
51
+ #:datagram-usocket
52
+
53
+ #:host-byte-order ; IP(v4) utility functions
54
+ #:hbo-to-dotted-quad
55
+ #:hbo-to-vector-quad
56
+ #:vector-quad-to-dotted-quad
57
+ #:dotted-quad-to-vector-quad
58
+ #:ip=
59
+ #:ip/=
60
+
61
+ #:integer-to-octet-buffer ; Network utility functions
62
+ #:octet-buffer-to-integer
63
+ #:port-to-octet-buffer
64
+ #:port-from-octet-buffer
65
+ #:ip-to-octet-buffer
66
+ #:ip-from-octet-buffer
67
+
68
+ #:with-mapped-conditions
69
+
70
+ #:socket-condition ; conditions
71
+ #:ns-condition
72
+ #:socket-error ; errors
73
+ #:ns-error
74
+ #:unknown-condition
75
+ #:ns-unknown-condition
76
+ #:unknown-error
77
+ #:ns-unknown-error
78
+ #:socket-warning ; warnings (udp)
79
+
80
+ #:insufficient-implementation ; conditions regarding usocket support level
81
+ #:unsupported
82
+ #:unimplemented))
@@ -0,0 +1,45 @@
1
+ ;;;; $Id: server.lisp 515 2010-01-07 18:26:06Z ctian $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/server.lisp $
3
+
4
+ (in-package :usocket)
5
+
6
+ (defvar *remote-host*)
7
+ (defvar *remote-port*)
8
+
9
+ (defun socket-server (host port function &optional arguments
10
+ &key (timeout 1)
11
+ (max-buffer-size +max-datagram-packet-size+))
12
+ (let ((socket (socket-connect nil nil
13
+ :protocol :datagram
14
+ :local-host host
15
+ :local-port port))
16
+ (buffer (make-array max-buffer-size
17
+ :element-type '(unsigned-byte 8)
18
+ :initial-element 0)))
19
+ (unwind-protect
20
+ (loop (progn
21
+ (multiple-value-bind (sockets real-time)
22
+ (wait-for-input socket :timeout timeout)
23
+ (declare (ignore sockets))
24
+ (when real-time
25
+ (multiple-value-bind (recv n *remote-host* *remote-port*)
26
+ (socket-receive socket buffer max-buffer-size)
27
+ (declare (ignore recv))
28
+ (if (plusp n)
29
+ (progn
30
+ (let ((reply
31
+ (apply function
32
+ (cons (subseq buffer 0 n) arguments))))
33
+ (when reply
34
+ (replace buffer reply)
35
+ (let ((n (socket-send socket buffer (length reply)
36
+ :host *remote-host*
37
+ :port *remote-port*)))
38
+ (when (minusp n)
39
+ (error "send error: ~A~%" n))))))
40
+ (error "receive error: ~A" n))))
41
+ #+scl (when thread:*quitting-lisp*
42
+ (return))
43
+ #+(and cmu mp) (mp:process-yield))))
44
+ (socket-close socket)
45
+ (values))))
@@ -0,0 +1,13 @@
1
+ ;;;; $Id: package.lisp 57 2006-02-07 19:39:46Z ehuelsmann $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/test/package.lisp $
3
+
4
+ ;;;; See the LICENSE file for licensing information.
5
+
6
+ (in-package :cl-user)
7
+
8
+ (eval-when (:execute :load-toplevel :compile-toplevel)
9
+ (defpackage :usocket-test
10
+ (:use :cl :regression-test)
11
+ (:nicknames :usoct)
12
+ (:export :do-tests :run-usocket-tests)))
13
+
@@ -0,0 +1,166 @@
1
+ ;;;; $Id: test-usocket.lisp 510 2010-01-04 07:49:39Z ctian $
2
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/test/test-usocket.lisp $
3
+
4
+ ;;;; See LICENSE for licensing information.
5
+
6
+ (in-package :usocket-test)
7
+
8
+ ;; The parameters below may need adjustments to match the system
9
+ ;; the tests are run on.
10
+ (defparameter +non-existing-host+ "192.168.1.199")
11
+ (defparameter +unused-local-port+ 15213)
12
+ (defparameter *soc1* (usocket::make-stream-socket :socket :my-socket
13
+ :stream :my-stream))
14
+ (eval-when (:compile-toplevel :load-toplevel :execute)
15
+ (defparameter +local-ip+ #(192 168 1 25))
16
+ (defparameter +common-lisp-net+
17
+ #+ignore #(80 68 86 115) ;; common-lisp.net IP (not valid as of 2010-01-03
18
+ (first (usocket::get-hosts-by-name "common-lisp.net"))))
19
+
20
+ (defmacro with-caught-conditions ((expect throw) &body body)
21
+ `(catch 'caught-error
22
+ (handler-case
23
+ (progn ,@body)
24
+ (usocket:unknown-error (c) (if (typep c ,expect)
25
+ (throw 'caught-error ,throw)
26
+ (progn
27
+ (describe c)
28
+ (describe
29
+ (usocket::usocket-real-error c))
30
+ c)))
31
+ (error (c) (if (typep c ,expect)
32
+ (throw 'caught-error ,throw)
33
+ (progn
34
+ (describe c)
35
+ c)))
36
+ (usocket:unknown-condition (c) (if (typep c ,expect)
37
+ (throw 'caught-error ,throw)
38
+ (progn
39
+ (describe c)
40
+ (describe
41
+ (usocket::usocket-real-condition c))
42
+ c)))
43
+ (condition (c) (if (typep c ,expect)
44
+ (throw 'caught-error ,throw)
45
+ (progn
46
+ (describe c)
47
+ c))))))
48
+
49
+ (deftest make-socket.1 (usocket:socket *soc1*) :my-socket)
50
+ (deftest make-socket.2 (usocket:socket-stream *soc1*) :my-stream)
51
+
52
+ (deftest socket-no-connect.1
53
+ (with-caught-conditions ('usocket:socket-error nil)
54
+ (usocket:socket-connect "127.0.0.0" +unused-local-port+ :timeout 0)
55
+ t)
56
+ nil)
57
+ (deftest socket-no-connect.2
58
+ (with-caught-conditions ('usocket:socket-error nil)
59
+ (usocket:socket-connect #(127 0 0 0) +unused-local-port+ :timeout 0)
60
+ t)
61
+ nil)
62
+ (deftest socket-no-connect.3
63
+ (with-caught-conditions ('usocket:socket-error nil)
64
+ (usocket:socket-connect 2130706432 +unused-local-port+ :timeout 0) ;; == #(127 0 0 0)
65
+ t)
66
+ nil)
67
+
68
+ (deftest socket-failure.1
69
+ (with-caught-conditions (#-(or cmu lispworks armedbear openmcl mcl)
70
+ 'usocket:network-unreachable-error
71
+ #+(or cmu lispworks armedbear)
72
+ 'usocket:unknown-error
73
+ #+(or openmcl mcl)
74
+ 'usocket:timeout-error
75
+ nil)
76
+ (usocket:socket-connect 2130706432 +unused-local-port+ :timeout 0) ;; == #(127 0 0 0)
77
+ :unreach)
78
+ nil)
79
+ (deftest socket-failure.2
80
+ (with-caught-conditions (#+(or lispworks armedbear)
81
+ 'usocket:unknown-error
82
+ #+cmu
83
+ 'usocket:network-unreachable-error
84
+ #+(or openmcl mcl)
85
+ 'usocket:timeout-error
86
+ #-(or lispworks armedbear cmu openmcl mcl)
87
+ 'usocket:host-unreachable-error
88
+ nil)
89
+ (usocket:socket-connect +non-existing-host+ 80 :timeout 0) ;; 80 = just a port
90
+ :unreach)
91
+ nil)
92
+
93
+
94
+ ;; let's hope c-l.net doesn't move soon, or that people start to
95
+ ;; test usocket like crazy..
96
+ (deftest socket-connect.1
97
+ (with-caught-conditions (nil nil)
98
+ (let ((sock (usocket:socket-connect "common-lisp.net" 80)))
99
+ (unwind-protect
100
+ (when (typep sock 'usocket:usocket) t)
101
+ (usocket:socket-close sock))))
102
+ t)
103
+ (deftest socket-connect.2
104
+ (with-caught-conditions (nil nil)
105
+ (let ((sock (usocket:socket-connect +common-lisp-net+ 80)))
106
+ (unwind-protect
107
+ (when (typep sock 'usocket:usocket) t)
108
+ (usocket:socket-close sock))))
109
+ t)
110
+ (deftest socket-connect.3
111
+ (with-caught-conditions (nil nil)
112
+ (let ((sock (usocket:socket-connect (usocket::host-byte-order +common-lisp-net+) 80)))
113
+ (unwind-protect
114
+ (when (typep sock 'usocket:usocket) t)
115
+ (usocket:socket-close sock))))
116
+ t)
117
+
118
+ ;; let's hope c-l.net doesn't change its software any time soon
119
+ (deftest socket-stream.1
120
+ (with-caught-conditions (nil nil)
121
+ (let ((sock (usocket:socket-connect "common-lisp.net" 80)))
122
+ (unwind-protect
123
+ (progn
124
+ (format (usocket:socket-stream sock)
125
+ "GET / HTTP/1.0~c~c~c~c"
126
+ #\Return #\linefeed #\Return #\linefeed)
127
+ (force-output (usocket:socket-stream sock))
128
+ (read-line (usocket:socket-stream sock)))
129
+ (usocket:socket-close sock))))
130
+ #+(or mcl clisp) "HTTP/1.1 200 OK"
131
+ #-(or clisp mcl) #.(format nil "HTTP/1.1 200 OK~A" #\Return) nil)
132
+
133
+ (deftest socket-name.1
134
+ (with-caught-conditions (nil nil)
135
+ (let ((sock (usocket:socket-connect +common-lisp-net+ 80)))
136
+ (unwind-protect
137
+ (usocket::get-peer-address sock)
138
+ (usocket:socket-close sock))))
139
+ #.+common-lisp-net+)
140
+ (deftest socket-name.2
141
+ (with-caught-conditions (nil nil)
142
+ (let ((sock (usocket:socket-connect +common-lisp-net+ 80)))
143
+ (unwind-protect
144
+ (usocket::get-peer-port sock)
145
+ (usocket:socket-close sock))))
146
+ 80)
147
+ (deftest socket-name.3
148
+ (with-caught-conditions (nil nil)
149
+ (let ((sock (usocket:socket-connect +common-lisp-net+ 80)))
150
+ (unwind-protect
151
+ (usocket::get-peer-name sock)
152
+ (usocket:socket-close sock))))
153
+ #.+common-lisp-net+ 80)
154
+ (deftest socket-name.4
155
+ (with-caught-conditions (nil nil)
156
+ (let ((sock (usocket:socket-connect +common-lisp-net+ 80)))
157
+ (unwind-protect
158
+ (usocket::get-local-address sock)
159
+ (usocket:socket-close sock))))
160
+ #.+local-ip+)
161
+
162
+
163
+ (defun run-usocket-tests ()
164
+ (do-tests))
165
+
166
+ ;;; (usoct::run-usocket-tests )
@@ -0,0 +1,26 @@
1
+ ;;;; -*- Mode: Lisp -*-
2
+ ;;;; $Id: usocket-test.asd 46 2006-02-06 20:50:07Z ehuelsmann $
3
+ ;;;; $URL: svn+ssh://common-lisp.net/project/usocket/svn/usocket/trunk/test/usocket-test.asd $
4
+
5
+ ;;;; See the LICENSE file for licensing information.
6
+
7
+ (in-package :cl-user)
8
+
9
+ (unless (find-package ':usocket-system)
10
+ (make-package ':usocket-system
11
+ :use '(:cl :asdf)))
12
+
13
+ (in-package :usocket-system)
14
+
15
+ (defsystem usocket-test
16
+ :name "usocket test"
17
+ :author "Erik Enge"
18
+ :version "0.1.0"
19
+ :licence "MIT"
20
+ :description "Tests for usocket"
21
+ :depends-on (:usocket
22
+ :rt)
23
+ :components ((:module "test"
24
+ :components ((:file "package")
25
+ (:file "test-usocket"
26
+ :depends-on ("package"))))))
@@ -0,0 +1,37 @@
1
+ ;;;; -*- Mode: Lisp -*-
2
+ ;;;; $Id: usocket.asd 519 2010-01-13 09:48:05Z ctian $
3
+ ;;;; $URL: svn://common-lisp.net/project/usocket/svn/usocket/trunk/usocket.asd $
4
+
5
+ ;;;; See the LICENSE file for licensing information.
6
+
7
+ (in-package #:cl-user)
8
+
9
+ (defpackage #:usocket-system
10
+ (:use #:cl #:asdf))
11
+
12
+ (in-package #:usocket-system)
13
+
14
+ (defsystem usocket
15
+ :name "usocket"
16
+ :author "Erik Enge & Erik Huelsmann"
17
+ :version "0.5.0"
18
+ :licence "MIT"
19
+ :description "Universal socket library for Common Lisp"
20
+ :depends-on (#+sbcl :sb-bsd-sockets)
21
+ :components ((:file "package")
22
+ (:module "vendor" :depends-on ("package")
23
+ :components ((:file "split-sequence")
24
+ #+mcl (:file "kqueue")))
25
+ (:file "usocket" :depends-on ("vendor"))
26
+ (:file "condition" :depends-on ("usocket"))
27
+ (:module "backend" :depends-on ("condition")
28
+ :components (#+clisp (:file "clisp")
29
+ #+cmu (:file "cmucl")
30
+ #+scl (:file "scl")
31
+ #+(or sbcl ecl) (:file "sbcl")
32
+ #+lispworks (:file "lispworks")
33
+ #+mcl (:file "mcl")
34
+ #+openmcl (:file "openmcl")
35
+ #+allegro (:file "allegro")
36
+ #+armedbear (:file "armedbear")))
37
+ (:file "server" :depends-on ("backend"))))