Permalink
Browse files

Change around names in test directory - sorry bert

  • Loading branch information...
1 parent 7ce2cb8 commit 5304a18002d9348ae6bbde936452a117ab0702dc @ry ry committed Mar 31, 2011
Showing with 34 additions and 18 deletions.
  1. +3 −2 .gitignore
  2. +6 −3 Makefile
  3. +15 −0 test/echo-demo.c
  4. +7 −13 test/{echo-server.c → echo.c}
  5. +3 −0 test/echo.h
View
@@ -17,8 +17,9 @@ ev/config.log
ev/config.status
ev/libtool
ev/stamp-h1
-test/echo-server
ev/autom4te.cache
/ipch/
/Debug/
-/Release/
+/Release/
+
+test/echo-demo
View
@@ -1,11 +1,14 @@
-test/echo-server: test/echo-server.c ol.a
- $(CC) -ansi -g -o test/echo-server test/echo-server.c ol.a -lm
+test/echo-demo: test/echo-demo.c test/echo.o ol.a
+ $(CC) -ansi -g -o test/echo-demo test/echo-demo.c test/echo.o ol.a -lm
ol.a: ol-unix.o ev/ev.o
$(AR) rcs ol.a ol-unix.o ev/ev.o
ol-unix.o: ol-unix.c ol.h ol-unix.h
- $(CC) -ansi -g -c ol-unix.c -o ol-unix.o -lm
+ $(CC) -ansi -g -c ol-unix.c -o ol-unix.o
+
+test/echo.o: test/echo.c test/echo.h
+ $(CC) -ansi -g -c test/echo.c -o test/echo.o
ev/ev.o: ev/config.h ev/ev.c
$(MAKE) -C ev
View
@@ -0,0 +1,15 @@
+#include "../ol.h"
+#include "echo.h"
+
+int main(int argc, char** argv) {
+ ol_init();
+
+ int r = echo_start(8000);
+ if (r) {
+ return r;
+ }
+
+ ol_run();
+
+ return 0;
+}
@@ -66,7 +66,7 @@ void on_accept(ol_handle* server, ol_handle* new_client) {
new_client->close_cb = on_close;
- p = (peer_t*)malloc(sizeof(peer_t));
+ p = (peer_t*)malloc(sizeof(peer_t));
p->handle = new_client;
p->buf.base = p->read_buffer;
p->buf.len = BUFSIZE;
@@ -82,31 +82,25 @@ void on_accept(ol_handle* server, ol_handle* new_client) {
}
-int main(int argc, char** argv) {
- ol_handle* server;
- struct sockaddr_in addr;
- int r;
-
- ol_init();
+int echo_start(int port) {
+ ol_handle* server = ol_tcp_handle_new(on_close, NULL);
- server = ol_tcp_handle_new(on_close, NULL);
+ struct sockaddr_in addr = ol_ip4_addr("0.0.0.0", port);
- addr = ol_ip4_addr("0.0.0.0", 8000);
-
- r = ol_bind(server, (struct sockaddr*) &addr);
+ int r = ol_bind(server, (struct sockaddr*) &addr);
if (r) {
+ /* TODO: Error codes */
fprintf(stderr, "Bind error\n");
return 1;
}
r = ol_listen(server, 128, on_accept);
if (r) {
+ /* TODO: Error codes */
fprintf(stderr, "Listen error\n");
return 1;
}
- ol_run();
-
return 0;
}
View
@@ -0,0 +1,3 @@
+#include "../ol.h"
+
+int echo_start(int port);

0 comments on commit 5304a18

Please sign in to comment.