View | Details | Raw Unified | Return to bug 141006
Collapse All | Expand All

(-)ocaml-event/Makefile (-10 / +10 lines)
Lines 6-13 Link Here
6
#
6
#
7
7
8
PORTNAME=	event
8
PORTNAME=	event
9
PORTVERSION=	0.5.0
9
PORTVERSION=	0.6.0
10
PORTREVISION=	7
11
CATEGORIES=	devel
10
CATEGORIES=	devel
12
MASTER_SITES=	http://www.xs4all.nl/~mmzeeman/ocaml/
11
MASTER_SITES=	http://www.xs4all.nl/~mmzeeman/ocaml/
13
PKGNAMEPREFIX=	ocaml-
12
PKGNAMEPREFIX=	ocaml-
Lines 31-46 Link Here
31
EXAMPLE_FILES=	\
30
EXAMPLE_FILES=	\
32
		Makefile \
31
		Makefile \
33
		fifo_example.ml \
32
		fifo_example.ml \
33
		http_server.ml \
34
		signal_example.ml
34
		signal_example.ml
35
LIB_FILES=	\
35
LIB_FILES=	\
36
		libevent.a \
36
		liboevent.a \
37
		libevent.cmxa \
37
		liboevent.cmxa \
38
		libmlevent.a \
38
		libmloevent.a \
39
		libevent.cma \
39
		liboevent.cma \
40
		libevent.mli \
40
		liboevent.mli \
41
		libevent.cmi
41
		liboevent.cmi
42
LIB_STUB_FILES=	\
42
LIB_STUB_FILES=	\
43
		dllmlevent.so
43
		dllmloevent.so
44
44
45
# examples to install
45
# examples to install
46
PLIST_DIRS+=	${EXAMPLESDIR:S,^${PREFIX}/,,}
46
PLIST_DIRS+=	${EXAMPLESDIR:S,^${PREFIX}/,,}
Lines 65-71 Link Here
65
		${WRKSRC}/Makefile
65
		${WRKSRC}/Makefile
66
66
67
pre-build:
67
pre-build:
68
.for file in libevent.cmi
68
.for file in liboevent.cmi
69
	@cd ${WRKSRC} && ${GMAKE} ${file}
69
	@cd ${WRKSRC} && ${GMAKE} ${file}
70
.endfor
70
.endfor
71
71
(-)ocaml-event/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
MD5 (ocaml-event-0.5.0.tar.gz) = 1c6478d39817a90faa59a353018b082d
1
MD5 (ocaml-event-0.6.0.tar.gz) = ae06ace4a05b8f32203de4641bed7c99
2
SHA256 (ocaml-event-0.5.0.tar.gz) = 0b199f5494ca7647ca70ed6b53da96a252c385b6ba3f1ff0c934e328b2e03065
2
SHA256 (ocaml-event-0.6.0.tar.gz) = 06ffb1d8621530ef3dd2ed8aa931643783586cfc91433b69a7e338931385dc8e
3
SIZE (ocaml-event-0.5.0.tar.gz) = 7040
3
SIZE (ocaml-event-0.6.0.tar.gz) = 7664
(-)ocaml-event/work/.PLIST.flattened (+25 lines)
Line 0 Link Here
1
/usr/local/share/examples/ocaml-event/Makefile
2
/usr/local/share/examples/ocaml-event/fifo_example.ml
3
/usr/local/share/examples/ocaml-event/http_server.ml
4
/usr/local/share/examples/ocaml-event/signal_example.ml
5
/usr/local/lib/ocaml/liboevent.a
6
/usr/local/lib/ocaml/liboevent.cmxa
7
/usr/local/lib/ocaml/libmloevent.a
8
/usr/local/lib/ocaml/liboevent.cma
9
/usr/local/lib/ocaml/liboevent.mli
10
/usr/local/lib/ocaml/liboevent.cmi
11
/usr/local/lib/ocaml/stublibs/dllmloevent.so
12
/usr/local/share/doc/ocaml-event/Liboevent.html
13
/usr/local/share/doc/ocaml-event/README
14
/usr/local/share/doc/ocaml-event/index.html
15
/usr/local/share/doc/ocaml-event/index_attributes.html
16
/usr/local/share/doc/ocaml-event/index_class_types.html
17
/usr/local/share/doc/ocaml-event/index_classes.html
18
/usr/local/share/doc/ocaml-event/index_exceptions.html
19
/usr/local/share/doc/ocaml-event/index_methods.html
20
/usr/local/share/doc/ocaml-event/index_module_types.html
21
/usr/local/share/doc/ocaml-event/index_modules.html
22
/usr/local/share/doc/ocaml-event/index_types.html
23
/usr/local/share/doc/ocaml-event/index_values.html
24
/usr/local/share/doc/ocaml-event/style.css
25
/usr/local/share/doc/ocaml-event/type_Liboevent.html
(-)ocaml-event/work/.PLIST.mktmp (+29 lines)
Line 0 Link Here
1
share/examples/ocaml-event/Makefile
2
share/examples/ocaml-event/fifo_example.ml
3
share/examples/ocaml-event/http_server.ml
4
share/examples/ocaml-event/signal_example.ml
5
lib/ocaml/liboevent.a
6
lib/ocaml/liboevent.cmxa
7
lib/ocaml/libmloevent.a
8
lib/ocaml/liboevent.cma
9
lib/ocaml/liboevent.mli
10
lib/ocaml/liboevent.cmi
11
lib/ocaml/stublibs/dllmloevent.so
12
@unexec rmdir %D/lib/ocaml/stublibs 2>/dev/null || true
13
@unexec rmdir %D/lib/ocaml 2>/dev/null || true
14
@dirrm share/examples/ocaml-event
15
share/doc/ocaml-event/Liboevent.html
16
share/doc/ocaml-event/README
17
share/doc/ocaml-event/index.html
18
share/doc/ocaml-event/index_attributes.html
19
share/doc/ocaml-event/index_class_types.html
20
share/doc/ocaml-event/index_classes.html
21
share/doc/ocaml-event/index_exceptions.html
22
share/doc/ocaml-event/index_methods.html
23
share/doc/ocaml-event/index_module_types.html
24
share/doc/ocaml-event/index_modules.html
25
share/doc/ocaml-event/index_types.html
26
share/doc/ocaml-event/index_values.html
27
share/doc/ocaml-event/style.css
28
share/doc/ocaml-event/type_Liboevent.html
29
@dirrm share/doc/ocaml-event
(-)ocaml-event/work/.PLIST.objdump (+40 lines)
Line 0 Link Here
1
In archive /usr/local/lib/ocaml/liboevent.a:
2
3
liboevent.o:     file format elf64-x86-64
4
5
In archive /usr/local/lib/ocaml/libmloevent.a:
6
7
event_stubs.o:     file format elf64-x86-64
8
9
10
/usr/local/lib/ocaml/stublibs/dllmloevent.so:     file format elf64-x86-64
11
12
DYNAMIC RELOCATION RECORDS
13
OFFSET           TYPE              VALUE 
14
0000000000101440 R_X86_64_RELATIVE  *ABS*+0x0000000000101440
15
0000000000101448 R_X86_64_RELATIVE  *ABS*+0x0000000000101898
16
0000000000101460 R_X86_64_RELATIVE  *ABS*+0x00000000000013a3
17
0000000000101468 R_X86_64_RELATIVE  *ABS*+0x00000000000012e3
18
0000000000101470 R_X86_64_RELATIVE  *ABS*+0x0000000000000e48
19
0000000000101478 R_X86_64_RELATIVE  *ABS*+0x0000000000000e5b
20
0000000000101940 R_X86_64_GLOB_DAT  caml_local_roots
21
0000000000101948 R_X86_64_GLOB_DAT  __cxa_finalize
22
0000000000101950 R_X86_64_GLOB_DAT  _Jv_RegisterClasses
23
00000000001018c0 R_X86_64_JUMP_SLOT  event_loop
24
00000000001018c8 R_X86_64_JUMP_SLOT  caml_callback3
25
00000000001018d0 R_X86_64_JUMP_SLOT  caml_named_value
26
00000000001018d8 R_X86_64_JUMP_SLOT  event_dispatch
27
00000000001018e0 R_X86_64_JUMP_SLOT  __cxa_finalize
28
00000000001018e8 R_X86_64_JUMP_SLOT  caml_stat_free
29
00000000001018f0 R_X86_64_JUMP_SLOT  memset
30
00000000001018f8 R_X86_64_JUMP_SLOT  caml_alloc_custom
31
0000000000101900 R_X86_64_JUMP_SLOT  event_init
32
0000000000101908 R_X86_64_JUMP_SLOT  event_add
33
0000000000101910 R_X86_64_JUMP_SLOT  caml_stat_alloc
34
0000000000101918 R_X86_64_JUMP_SLOT  event_del
35
0000000000101920 R_X86_64_JUMP_SLOT  event_pending
36
0000000000101928 R_X86_64_JUMP_SLOT  caml_invalid_argument
37
0000000000101930 R_X86_64_JUMP_SLOT  event_set
38
0000000000101938 R_X86_64_JUMP_SLOT  uerror
39
40
(-)ocaml-event/work/ocaml-event-0.6.0/LICENCE (+22 lines)
Line 0 Link Here
1
Copyright (c) 2002, 2003 by Maas-Maarten Zeeman
2
3
The package ocaml-event is copyright by Maas-Maarten Zeeman.
4
5
Permission is hereby granted, free of charge, to any person obtaining
6
a copy of this document and the ocaml-event software ("the Software"),
7
to deal in the Software without restriction, including without
8
limitation the rights to use, copy, modify, merge, publish,
9
distribute, sublicense, and/or sell copies of the Software, and to
10
permit persons to whom the Software is furnished to do so, subject to
11
the following conditions:
12
13
The above copyright notice and this permission notice shall be
14
included in all copies or substantial portions of the Software.
15
16
The Software is provided ``as is'', without warranty of any kind,
17
express or implied, including but not limited to the warranties of
18
merchantability, fitness for a particular purpose and noninfringement.
19
In no event shall Maas-Maarten Zeeman be liable for any claim, damages
20
or other liability, whether in an action of contract, tort or
21
otherwise, arising from, out of or in connection with the Software or
22
the use or other dealings in the software.
(-)ocaml-event/work/ocaml-event-0.6.0/META (+7 lines)
Line 0 Link Here
1
name = "event"
2
version = "0.5.0"
3
description = "OCaml wrapper for libevent"
4
requires = "unix"
5
archive(byte) = "libevent.cma"
6
archive(native) = "libevent.cmxa"
7
linkopts = ""
(-)ocaml-event/work/ocaml-event-0.6.0/Makefile (+100 lines)
Line 0 Link Here
1
#
2
# $Id: Makefile,v 1.2 2009-11-26 08:49:02 maas Exp $ 
3
#
4
5
# Change this to match your libevent installation.
6
EVENT_LIB=-levent
7
EVENT_LIBDIR=/usr/local/lib
8
EVENT_INCDIR=/usr/local/include
9
10
NAME=liboevent
11
OBJECTS=liboevent.cmo
12
XOBJECTS=$(OBJECTS:.cmo=.cmx)
13
C_OBJECTS=event_stubs.o
14
15
ARCHIVE=$(NAME).cma
16
XARCHIVE=$(ARCHIVE:.cma=.cmxa)
17
CARCHIVE_NAME=mloevent
18
CARCHIVE=lib$(CARCHIVE_NAME).a
19
20
# Flags for the C compiler.
21
CFLAGS=-O2 -fno-strict-aliasing -pipe -march=nocona -I$(EVENT_INCDIR)
22
23
OCAMLC=ocamlc
24
OCAMLOPT=ocamlopt
25
OCAMLDEP=ocamldep
26
OCAMLMKLIB=ocamlmklib 
27
OCAMLDOC=ocamldoc
28
OCAMLFIND=ocamlfind
29
30
.PHONY: all
31
all: $(ARCHIVE)
32
.PHONY: allopt
33
allopt:  $(XARCHIVE)
34
35
depend: *.c *.ml *.mli
36
	gcc -MM *.c > depend	
37
	$(OCAMLDEP) *.mli *.ml >> depend
38
39
## Library creation
40
$(CARCHIVE): $(C_OBJECTS)
41
	$(OCAMLMKLIB) -oc $(CARCHIVE_NAME) $(C_OBJECTS) \
42
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
43
$(ARCHIVE): $(CARCHIVE) $(OBJECTS)
44
	$(OCAMLMKLIB) -o $(NAME) $(OBJECTS) -oc $(CARCHIVE_NAME) \
45
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
46
$(XARCHIVE): $(CARCHIVE) $(XOBJECTS)
47
	$(OCAMLMKLIB) -o $(NAME) $(XOBJECTS) -oc $(CARCHIVE_NAME) \
48
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
49
50
## Installation
51
.PHONY: install
52
install: all
53
	{ test ! -f $(XARCHIVE) || extra="$(XARCHIVE) $(NAME).a"; }; \
54
	$(OCAMLFIND) install $(NAME) META $(NAME).cmi $(NAME).mli $(ARCHIVE) \
55
	dll$(CARCHIVE_NAME).so lib$(CARCHIVE_NAME).a $$extra
56
57
.PHONY: uninstall
58
uninstall:
59
	$(OCAMLFIND) remove $(NAME)
60
61
## Documentation
62
.PHONY: doc
63
doc: FORCE
64
	cd doc; $(OCAMLDOC) -html -I .. ../$(NAME).mli
65
66
## Testing
67
.PHONY: testall
68
testall: test testopt
69
.PHONY: test
70
test: unittest 	
71
	./unittest
72
.PHONY: testopt
73
testopt: unittest.opt
74
	./unittest.opt
75
unittest: all unittest.ml
76
	$(OCAMLFIND) ocamlc -o unittest -package oUnit -cclib -L. -linkpkg \
77
	$(ARCHIVE) unittest.ml
78
unittest.opt: allopt unittest.ml
79
	$(OCAMLFIND) ocamlopt -o unittest.opt -package oUnit -cclib -L. -linkpkg \
80
	$(XARCHIVE) unittest.ml
81
82
## Cleaning up
83
.PHONY: clean
84
clean::
85
	rm -f *~ *.cm* *.o *.a *.so doc/*.html doc/*.css depend \
86
	unittest unittest.opt
87
88
FORCE:
89
90
.SUFFIXES: .ml .mli .cmo .cmi .cmx
91
92
.mli.cmi:
93
	$(OCAMLC) -c $(COMPFLAGS) $<
94
.ml.cmo:
95
	$(OCAMLC) -c $(COMPLAGS) -nolabels $<
96
.ml.cmx:
97
	$(OCAMLOPT) -c $(COMPFLAGS) -nolabels $<
98
.c.o:
99
	$(OCAMLC) -c -ccopt "$(CFLAGS)" $<
100
(-)ocaml-event/work/ocaml-event-0.6.0/Makefile.bak (+100 lines)
Line 0 Link Here
1
#
2
# $Id: Makefile,v 1.2 2009-11-26 08:49:02 maas Exp $ 
3
#
4
5
# Change this to match your libevent installation.
6
EVENT_LIB=-levent
7
EVENT_LIBDIR=/usr/local/lib
8
EVENT_INCDIR=/usr/local/include
9
10
NAME=liboevent
11
OBJECTS=liboevent.cmo
12
XOBJECTS=$(OBJECTS:.cmo=.cmx)
13
C_OBJECTS=event_stubs.o
14
15
ARCHIVE=$(NAME).cma
16
XARCHIVE=$(ARCHIVE:.cma=.cmxa)
17
CARCHIVE_NAME=mloevent
18
CARCHIVE=lib$(CARCHIVE_NAME).a
19
20
# Flags for the C compiler.
21
CFLAGS=-DFULL_UNROLL -O2 -I$(EVENT_INCDIR)
22
23
OCAMLC=ocamlc
24
OCAMLOPT=ocamlopt
25
OCAMLDEP=ocamldep
26
OCAMLMKLIB=ocamlmklib 
27
OCAMLDOC=ocamldoc
28
OCAMLFIND=ocamlfind
29
30
.PHONY: all
31
all: $(ARCHIVE)
32
.PHONY: allopt
33
allopt:  $(XARCHIVE)
34
35
depend: *.c *.ml *.mli
36
	gcc -MM *.c > depend	
37
	$(OCAMLDEP) *.mli *.ml >> depend
38
39
## Library creation
40
$(CARCHIVE): $(C_OBJECTS)
41
	$(OCAMLMKLIB) -oc $(CARCHIVE_NAME) $(C_OBJECTS) \
42
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
43
$(ARCHIVE): $(CARCHIVE) $(OBJECTS)
44
	$(OCAMLMKLIB) -o $(NAME) $(OBJECTS) -oc $(CARCHIVE_NAME) \
45
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
46
$(XARCHIVE): $(CARCHIVE) $(XOBJECTS)
47
	$(OCAMLMKLIB) -o $(NAME) $(XOBJECTS) -oc $(CARCHIVE_NAME) \
48
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
49
50
## Installation
51
.PHONY: install
52
install: all
53
	{ test ! -f $(XARCHIVE) || extra="$(XARCHIVE) $(NAME).a"; }; \
54
	$(OCAMLFIND) install $(NAME) META $(NAME).cmi $(NAME).mli $(ARCHIVE) \
55
	dll$(CARCHIVE_NAME).so lib$(CARCHIVE_NAME).a $$extra
56
57
.PHONY: uninstall
58
uninstall:
59
	$(OCAMLFIND) remove $(NAME)
60
61
## Documentation
62
.PHONY: doc
63
doc: FORCE
64
	cd doc; $(OCAMLDOC) -html -I .. ../$(NAME).mli
65
66
## Testing
67
.PHONY: testall
68
testall: test testopt
69
.PHONY: test
70
test: unittest 	
71
	./unittest
72
.PHONY: testopt
73
testopt: unittest.opt
74
	./unittest.opt
75
unittest: all unittest.ml
76
	$(OCAMLFIND) ocamlc -o unittest -package oUnit -cclib -L. -linkpkg \
77
	$(ARCHIVE) unittest.ml
78
unittest.opt: allopt unittest.ml
79
	$(OCAMLFIND) ocamlopt -o unittest.opt -package oUnit -cclib -L. -linkpkg \
80
	$(XARCHIVE) unittest.ml
81
82
## Cleaning up
83
.PHONY: clean
84
clean::
85
	rm -f *~ *.cm* *.o *.a *.so doc/*.html doc/*.css depend \
86
	unittest unittest.opt
87
88
FORCE:
89
90
.SUFFIXES: .ml .mli .cmo .cmi .cmx
91
92
.mli.cmi:
93
	$(OCAMLC) -c $(COMPFLAGS) $<
94
.ml.cmo:
95
	$(OCAMLC) -c $(COMPLAGS) -nolabels $<
96
.ml.cmx:
97
	$(OCAMLOPT) -c $(COMPFLAGS) -nolabels $<
98
.c.o:
99
	$(OCAMLC) -c -ccopt "$(CFLAGS)" $<
100
(-)ocaml-event/work/ocaml-event-0.6.0/Makefile.orig (+101 lines)
Line 0 Link Here
1
#
2
# $Id: Makefile,v 1.2 2009-11-26 08:49:02 maas Exp $ 
3
#
4
5
# Change this to match your libevent installation.
6
EVENT_LIB=-levent
7
EVENT_LIBDIR=/usr/local/lib
8
EVENT_INCDIR=/usr/local/include
9
10
NAME=liboevent
11
OBJECTS=liboevent.cmo
12
XOBJECTS=$(OBJECTS:.cmo=.cmx)
13
C_OBJECTS=event_stubs.o
14
15
ARCHIVE=$(NAME).cma
16
XARCHIVE=$(ARCHIVE:.cma=.cmxa)
17
CARCHIVE_NAME=mloevent
18
CARCHIVE=lib$(CARCHIVE_NAME).a
19
20
# Flags for the C compiler.
21
CFLAGS=-DFULL_UNROLL -O2 -I$(EVENT_INCDIR)
22
23
OCAMLC=ocamlc
24
OCAMLOPT=ocamlopt
25
OCAMLDEP=ocamldep
26
OCAMLMKLIB=ocamlmklib 
27
OCAMLDOC=ocamldoc
28
OCAMLFIND=ocamlfind
29
30
.PHONY: all
31
all: $(ARCHIVE)
32
.PHONY: allopt
33
allopt:  $(XARCHIVE)
34
35
depend: *.c *.ml *.mli
36
	gcc -MM *.c > depend	
37
	$(OCAMLDEP) *.mli *.ml >> depend
38
39
## Library creation
40
$(CARCHIVE): $(C_OBJECTS)
41
	$(OCAMLMKLIB) -oc $(CARCHIVE_NAME) $(C_OBJECTS) \
42
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
43
$(ARCHIVE): $(CARCHIVE) $(OBJECTS)
44
	$(OCAMLMKLIB) -o $(NAME) $(OBJECTS) -oc $(CARCHIVE_NAME) \
45
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
46
$(XARCHIVE): $(CARCHIVE) $(XOBJECTS)
47
	$(OCAMLMKLIB) -o $(NAME) $(XOBJECTS) -oc $(CARCHIVE_NAME) \
48
	-L$(EVENT_LIBDIR) $(EVENT_LIB)
49
50
## Installation
51
.PHONY: install
52
install: all
53
	{ test ! -f $(XARCHIVE) || extra="$(XARCHIVE) $(NAME).a"; }; \
54
	$(OCAMLFIND) install $(NAME) META $(NAME).cmi $(NAME).mli $(ARCHIVE) \
55
	dll$(CARCHIVE_NAME).so lib$(CARCHIVE_NAME).a $$extra
56
57
.PHONY: uninstall
58
uninstall:
59
	$(OCAMLFIND) remove $(NAME)
60
61
## Documentation
62
.PHONY: doc
63
doc: FORCE
64
	cd doc; $(OCAMLDOC) -html -I .. ../$(NAME).mli
65
66
## Testing
67
.PHONY: testall
68
testall: test testopt
69
.PHONY: test
70
test: unittest 	
71
	./unittest
72
.PHONY: testopt
73
testopt: unittest.opt
74
	./unittest.opt
75
unittest: all unittest.ml
76
	$(OCAMLFIND) ocamlc -o unittest -package oUnit -cclib -L. -linkpkg \
77
	$(ARCHIVE) unittest.ml
78
unittest.opt: allopt unittest.ml
79
	$(OCAMLFIND) ocamlopt -o unittest.opt -package oUnit -cclib -L. -linkpkg \
80
	$(XARCHIVE) unittest.ml
81
82
## Cleaning up
83
.PHONY: clean
84
clean::
85
	rm -f *~ *.cm* *.o *.a *.so doc/*.html doc/*.css depend \
86
	unittest unittest.opt
87
88
FORCE:
89
90
.SUFFIXES: .ml .mli .cmo .cmi .cmx
91
92
.mli.cmi:
93
	$(OCAMLC) -c $(COMPFLAGS) $<
94
.ml.cmo:
95
	$(OCAMLC) -c $(COMPLAGS) -nolabels $<
96
.ml.cmx:
97
	$(OCAMLOPT) -c $(COMPFLAGS) -nolabels $<
98
.c.o:
99
	$(OCAMLC) -c -ccopt "$(CFLAGS)" $<
100
101
include depend
(-)ocaml-event/work/ocaml-event-0.6.0/README (+46 lines)
Line 0 Link Here
1
		       The ocaml-event library
2
3
Overview
4
5
  Ocaml-Expat is a wrapper for the libevent API. The libevent API
6
  provides a mechanism to execute a callback function when a specific
7
  event occurs on a file descriptor or after a timeout has been
8
  reached. Furthermore, libevent also support callbacks due to signals
9
  or regular timeouts. Libevent is meant to replace the event loop
10
  found in event driven network servers. An application just needs to
11
  call event_dispatch() and then adds or removes events dynamically
12
  without having to change the event loop. This wrapper makes the
13
  libevent library available for ocaml programmers.
14
15
Installation
16
17
  - Download, compile, and install libevent. 
18
    See http://www.monkey.org/~provos/libevent/
19
20
  - Edit the variables at the beginning of the Makefile to reflect the
21
    location where libevent is installed on your system. 
22
23
  - Do make depend; make all	
24
25
  - If the Objective Caml native-code compiler is available on your
26
    platform (look for the "ocamlopt" executable), do "make allopt".
27
28
  - To generate the documentation, do "make doc"
29
30
  - (Optional) To test the library, do "make test". This requires the
31
    installation of OUnit.
32
33
  - (Optional) To test the library compiled with ocamlopt and ocamlc,
34
    do "make testall". This requires the installation of OUnit.
35
36
  - Become super-user if necessary and do "make install".  This
37
    installs the library in the standard Objective Caml library
38
    directory.
39
  
40
Documentation
41
42
  See the HTML documentation in doc/index.html
43
44
References
45
46
  libevent::<http://www.monkey.org/~provos/libevent>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/Liboevent.html (+141 lines)
Line 0 Link Here
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="style.css" type="text/css">
5
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
6
<link rel="Start" href="index.html">
7
<link rel="Up" href="index.html">
8
<link title="Index of types" rel=Appendix href="index_types.html">
9
<link title="Index of values" rel=Appendix href="index_values.html">
10
<link title="Index of modules" rel=Appendix href="index_modules.html">
11
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><link title="Basic Libevent Operations" rel="Section" href="#5_BasicLibeventOperations">
12
<link title="Process Events" rel="Section" href="#5_ProcessEvents">
13
<title>Liboevent</title>
14
</head>
15
<body>
16
<div class="navbar">&nbsp;<a href="index.html">Up</a>
17
&nbsp;</div>
18
<center><h1>Module <a href="type_Liboevent.html">Liboevent</a></h1></center>
19
<br>
20
<pre><span class="keyword">module</span> Liboevent: <code class="code">sig</code> <a href="Liboevent.html">..</a> <code class="code">end</code></pre>The Ocaml Event library provides an interface to the event API.
21
<p>
22
23
    The event API provides a mechanism to execute a function when a
24
    specific event on a file descriptor occurs or after a given time
25
    has passed.
26
<p>
27
28
    This library is a wrapper of the libevent API made by Nils
29
    Provos. For more information about this library see:
30
    http://www.monkey.org/~provos/libevent. 
31
<p>
32
33
    Currently, libevent supports kqueue(2), select(2), poll(2) and
34
    epoll(4). Support for /dev/poll is planned.<br>
35
<b>Author(s):</b> Maas-Maarten Zeeman<br>
36
<hr width="100%">
37
<pre><span class="keyword">type</span> <a name="TYPEevent"></a><code class="type"></code>event </pre>
38
<div class="info">
39
The type of events<br>
40
</div>
41
42
<br><code><span class="keyword">type</span> <a name="TYPEevent_flags"></a><code class="type"></code>event_flags = </code><table class="typetable">
43
<tr>
44
<td align="left" valign="top" >
45
<code><span class="keyword">|</span></code></td>
46
<td align="left" valign="top" >
47
<code><span class="constructor">TIMEOUT</span></code></td>
48
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A timeout occurred.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
49
</tr>
50
<tr>
51
<td align="left" valign="top" >
52
<code><span class="keyword">|</span></code></td>
53
<td align="left" valign="top" >
54
<code><span class="constructor">READ</span></code></td>
55
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A read is possible.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
56
</tr>
57
<tr>
58
<td align="left" valign="top" >
59
<code><span class="keyword">|</span></code></td>
60
<td align="left" valign="top" >
61
<code><span class="constructor">WRITE</span></code></td>
62
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A write operation is possible.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
63
</tr>
64
<tr>
65
<td align="left" valign="top" >
66
<code><span class="keyword">|</span></code></td>
67
<td align="left" valign="top" >
68
<code><span class="constructor">SIGNAL</span></code></td>
69
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A signal occurred.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
70
</tr></table>
71
72
<div class="info">
73
The possible event types<br>
74
</div>
75
76
<pre><span class="keyword">type</span> <a name="TYPEevent_callback"></a><code class="type"></code>event_callback = <code class="type">Unix.file_descr -> <a href="Liboevent.html#TYPEevent_flags">event_flags</a> -> unit</code> </pre>
77
<div class="info">
78
The type of event callbacks<br>
79
</div>
80
81
<br>
82
<a name="5_BasicLibeventOperations"></a>
83
<h5>Basic Libevent Operations</h5><br>
84
<pre><span class="keyword">val</span> <a name="VALcreate"></a>create : <code class="type">unit -> <a href="Liboevent.html#TYPEevent">event</a></code></pre><div class="info">
85
Create a new empty event<br>
86
</div>
87
<pre><span class="keyword">val</span> <a name="VALfd"></a>fd : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> Unix.file_descr</code></pre><div class="info">
88
<code class="code">fd event</code> returns the file descriptor associated with the event<br>
89
</div>
90
<pre><span class="keyword">val</span> <a name="VALsignal"></a>signal : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> int</code></pre><div class="info">
91
<code class="code">signal event</code> returns the signal associated with the event<br>
92
</div>
93
<pre><span class="keyword">val</span> <a name="VALset"></a>set : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -><br>       Unix.file_descr -><br>       <a href="Liboevent.html#TYPEevent_flags">event_flags</a> list -><br>       persist:bool -> <a href="Liboevent.html#TYPEevent_callback">event_callback</a> -> unit</code></pre><div class="info">
94
<code class="code">set event fd type persist callback</code> initializes the event. The
95
    flag <code class="code">persist</code> makes an event persitent until <code class="code">Libevent.del</code> is
96
    called.<br>
97
</div>
98
<pre><span class="keyword">val</span> <a name="VALset_signal"></a>set_signal : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -><br>       signal:int -> persist:bool -> <a href="Liboevent.html#TYPEevent_callback">event_callback</a> -> unit</code></pre><div class="info">
99
<code class="code">set_signal event signal persist callback</code> initializes the event. The
100
    flag <code class="code">persist</code> makes an event persistent unit <code class="code">Libevent.del</code> is
101
    called.<br>
102
</div>
103
<pre><span class="keyword">val</span> <a name="VALadd"></a>add : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> float option -> unit</code></pre><div class="info">
104
<code class="code">add event timeout</code> adds the <code class="code">event</code> and schedules the execution
105
    of the function specified with <code class="code">Libevent.set</code>, or in at least the
106
    time specified in the <code class="code">timeout</code>. If <code class="code">timeout</code> is <code class="code">None</code>, no
107
    timeout occures, and the function will only be called if a
108
    matching event occurs on the file descriptor.<br>
109
</div>
110
<pre><span class="keyword">val</span> <a name="VALdel"></a>del : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> unit</code></pre><div class="info">
111
Del the event<br>
112
</div>
113
<pre><span class="keyword">val</span> <a name="VALpending"></a>pending : <code class="type"><a href="Liboevent.html#TYPEevent">event</a> -> <a href="Liboevent.html#TYPEevent_flags">event_flags</a> list -> bool</code></pre><br>
114
<a name="5_ProcessEvents"></a>
115
<h5>Process Events</h5><br>
116
<pre><span class="keyword">val</span> <a name="VALdispatch"></a>dispatch : <code class="type">unit -> unit</code></pre><div class="info">
117
In order to process events, an application needs to call dispatch. This 
118
 *  function only returns on error, and should replace the event core of the 
119
 *  application<br>
120
</div>
121
<br><code><span class="keyword">type</span> <a name="TYPEloop_flags"></a><code class="type"></code>loop_flags = </code><table class="typetable">
122
<tr>
123
<td align="left" valign="top" >
124
<code><span class="keyword">|</span></code></td>
125
<td align="left" valign="top" >
126
<code><span class="constructor">ONCE</span></code></td>
127
128
</tr>
129
<tr>
130
<td align="left" valign="top" >
131
<code><span class="keyword">|</span></code></td>
132
<td align="left" valign="top" >
133
<code><span class="constructor">NONBLOCK</span></code></td>
134
135
</tr></table>
136
137
138
<pre><span class="keyword">val</span> <a name="VALloop"></a>loop : <code class="type"><a href="Liboevent.html#TYPEloop_flags">loop_flags</a> -> unit</code></pre><div class="info">
139
Provides an interface for single pass execution of pending events<br>
140
</div>
141
</body></html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/README (+1 lines)
Line 0 Link Here
1
To create the documentation run 'make doc'
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index.html (+25 lines)
Line 0 Link Here
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html>
3
<head>
4
<link rel="stylesheet" href="style.css" type="text/css">
5
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
6
<link rel="Start" href="index.html">
7
<link title="Index of types" rel=Appendix href="index_types.html">
8
<link title="Index of values" rel=Appendix href="index_values.html">
9
<link title="Index of modules" rel=Appendix href="index_modules.html">
10
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title></title>
11
</head>
12
<body>
13
<center><h1></h1></center>
14
<a href="index_types.html">Index of types</a><br>
15
<a href="index_values.html">Index of values</a><br>
16
<a href="index_modules.html">Index of modules</a><br>
17
<br/><br>
18
<table class="indextable">
19
<tr><td><a href="Liboevent.html">Liboevent</a></td><td><div class="info">
20
The Ocaml Event library provides an interface to the event API.
21
</div>
22
</td></tr>
23
</table>
24
</body>
25
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_attributes.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of class attributes</title>
10
</head>
11
<body>
12
<center><h1>Index of class attributes</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_class_types.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of class types</title>
10
</head>
11
<body>
12
<center><h1>Index of class types</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_classes.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of classes</title>
10
</head>
11
<body>
12
<center><h1>Index of classes</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_exceptions.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of exceptions</title>
10
</head>
11
<body>
12
<center><h1>Index of exceptions</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_methods.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of class methods</title>
10
</head>
11
<body>
12
<center><h1>Index of class methods</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_module_types.html (+16 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of module types</title>
10
</head>
11
<body>
12
<center><h1>Index of module types</h1></center>
13
<table>
14
</table><br>
15
</body>
16
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_modules.html (+22 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of modules</title>
10
</head>
11
<body>
12
<center><h1>Index of modules</h1></center>
13
<table>
14
<tr><td align="left"><br>L</td></tr>
15
<tr><td><a href="Liboevent.html">Liboevent</a> </td>
16
<td><div class="info">
17
The Ocaml Event library provides an interface to the event API.
18
</div>
19
</td></tr>
20
</table><br>
21
</body>
22
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_types.html (+35 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of types</title>
10
</head>
11
<body>
12
<center><h1>Index of types</h1></center>
13
<table>
14
<tr><td align="left"><br>E</td></tr>
15
<tr><td><a href="Liboevent.html#TYPEevent">event</a> [<a href="Liboevent.html">Liboevent</a>]</td>
16
<td><div class="info">
17
The type of events
18
</div>
19
</td></tr>
20
<tr><td><a href="Liboevent.html#TYPEevent_callback">event_callback</a> [<a href="Liboevent.html">Liboevent</a>]</td>
21
<td><div class="info">
22
The type of event callbacks
23
</div>
24
</td></tr>
25
<tr><td><a href="Liboevent.html#TYPEevent_flags">event_flags</a> [<a href="Liboevent.html">Liboevent</a>]</td>
26
<td><div class="info">
27
The possible event types
28
</div>
29
</td></tr>
30
<tr><td align="left"><br>L</td></tr>
31
<tr><td><a href="Liboevent.html#TYPEloop_flags">loop_flags</a> [<a href="Liboevent.html">Liboevent</a>]</td>
32
<td></td></tr>
33
</table><br>
34
</body>
35
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/index_values.html (+72 lines)
Line 0 Link Here
1
<html>
2
<head>
3
<link rel="stylesheet" href="style.css" type="text/css">
4
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
5
<link rel="Start" href="index.html">
6
<link title="Index of types" rel=Appendix href="index_types.html">
7
<link title="Index of values" rel=Appendix href="index_values.html">
8
<link title="Index of modules" rel=Appendix href="index_modules.html">
9
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Index of values</title>
10
</head>
11
<body>
12
<center><h1>Index of values</h1></center>
13
<table>
14
<tr><td align="left"><br>A</td></tr>
15
<tr><td><a href="Liboevent.html#VALadd">add</a> [<a href="Liboevent.html">Liboevent</a>]</td>
16
<td><div class="info">
17
<code class="code">add event timeout</code> adds the <code class="code">event</code> and schedules the execution
18
    of the function specified with <code class="code">Libevent.set</code>, or in at least the
19
    time specified in the <code class="code">timeout</code>.
20
</div>
21
</td></tr>
22
<tr><td align="left"><br>C</td></tr>
23
<tr><td><a href="Liboevent.html#VALcreate">create</a> [<a href="Liboevent.html">Liboevent</a>]</td>
24
<td><div class="info">
25
Create a new empty event
26
</div>
27
</td></tr>
28
<tr><td align="left"><br>D</td></tr>
29
<tr><td><a href="Liboevent.html#VALdel">del</a> [<a href="Liboevent.html">Liboevent</a>]</td>
30
<td><div class="info">
31
Del the event
32
</div>
33
</td></tr>
34
<tr><td><a href="Liboevent.html#VALdispatch">dispatch</a> [<a href="Liboevent.html">Liboevent</a>]</td>
35
<td><div class="info">
36
In order to process events, an application needs to call dispatch.
37
</div>
38
</td></tr>
39
<tr><td align="left"><br>F</td></tr>
40
<tr><td><a href="Liboevent.html#VALfd">fd</a> [<a href="Liboevent.html">Liboevent</a>]</td>
41
<td><div class="info">
42
<code class="code">fd event</code> returns the file descriptor associated with the event
43
</div>
44
</td></tr>
45
<tr><td align="left"><br>L</td></tr>
46
<tr><td><a href="Liboevent.html#VALloop">loop</a> [<a href="Liboevent.html">Liboevent</a>]</td>
47
<td><div class="info">
48
Provides an interface for single pass execution of pending events
49
</div>
50
</td></tr>
51
<tr><td align="left"><br>P</td></tr>
52
<tr><td><a href="Liboevent.html#VALpending">pending</a> [<a href="Liboevent.html">Liboevent</a>]</td>
53
<td></td></tr>
54
<tr><td align="left"><br>S</td></tr>
55
<tr><td><a href="Liboevent.html#VALset">set</a> [<a href="Liboevent.html">Liboevent</a>]</td>
56
<td><div class="info">
57
<code class="code">set event fd type persist callback</code> initializes the event.
58
</div>
59
</td></tr>
60
<tr><td><a href="Liboevent.html#VALset_signal">set_signal</a> [<a href="Liboevent.html">Liboevent</a>]</td>
61
<td><div class="info">
62
<code class="code">set_signal event signal persist callback</code> initializes the event.
63
</div>
64
</td></tr>
65
<tr><td><a href="Liboevent.html#VALsignal">signal</a> [<a href="Liboevent.html">Liboevent</a>]</td>
66
<td><div class="info">
67
<code class="code">signal event</code> returns the signal associated with the event
68
</div>
69
</td></tr>
70
</table><br>
71
</body>
72
</html>
(-)ocaml-event/work/ocaml-event-0.6.0/doc/style.css (+33 lines)
Line 0 Link Here
1
a:visited {color : #416DFF; text-decoration : none; }
2
a:link {color : #416DFF; text-decoration : none;}
3
a:hover {color : Red; text-decoration : none; background-color: #5FFF88}
4
a:active {color : Red; text-decoration : underline; }
5
.keyword { font-weight : bold ; color : Red }
6
.keywordsign { color : #C04600 }
7
.superscript { font-size : 4 }
8
.subscript { font-size : 4 }
9
.comment { color : Green }
10
.constructor { color : Blue }
11
.type { color : #5C6585 }
12
.string { color : Maroon }
13
.warning { color : Red ; font-weight : bold }
14
.info { margin-left : 3em; margin-right : 3em }
15
.param_info { margin-top: 4px; margin-left : 3em; margin-right : 3em }
16
.code { color : #465F91 ; }
17
h1 { font-size : 20pt ; text-align: center; }
18
h2 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ;padding: 2px; }
19
h3 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90DDFF ;padding: 2px; }
20
h4 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90EDFF ;padding: 2px; }
21
h5 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90FDFF ;padding: 2px; }
22
h6 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #C0FFFF ; padding: 2px; }
23
div.h7 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #E0FFFF ; padding: 2px; }
24
div.h8 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #F0FFFF ; padding: 2px; }
25
div.h9 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #FFFFFF ; padding: 2px; }
26
.typetable { border-style : hidden }
27
.indextable { border-style : hidden }
28
.paramstable { border-style : hidden ; padding: 5pt 5pt}
29
body { background-color : White }
30
tr { background-color : White }
31
td.typefieldcomment { background-color : #FFFFFF ; font-size: smaller ;}
32
pre { margin-bottom: 4px }
33
div.sig_block {margin-left: 2em}
(-)ocaml-event/work/ocaml-event-0.6.0/doc/type_Liboevent.html (+32 lines)
Line 0 Link Here
1
<html><head>
2
<link rel="stylesheet" href="style.css" type="text/css">
3
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
4
<link rel="Start" href="index.html">
5
<link title="Index of types" rel=Appendix href="index_types.html">
6
<link title="Index of values" rel=Appendix href="index_values.html">
7
<link title="Index of modules" rel=Appendix href="index_modules.html">
8
<link title="Liboevent" rel="Chapter" href="Liboevent.html"><title>Liboevent</title>
9
</head>
10
<body>
11
<code class="code"><span class="keyword">sig</span><br>
12
&nbsp;&nbsp;<span class="keyword">type</span>&nbsp;event<br>
13
&nbsp;&nbsp;<span class="keyword">type</span>&nbsp;event_flags&nbsp;=&nbsp;<span class="constructor">TIMEOUT</span>&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="constructor">READ</span>&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="constructor">WRITE</span>&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="constructor">SIGNAL</span><br>
14
&nbsp;&nbsp;<span class="keyword">type</span>&nbsp;event_callback&nbsp;=&nbsp;<span class="constructor">Unix</span>.file_descr&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Liboevent</span>.event_flags&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
15
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;create&nbsp;:&nbsp;unit&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Liboevent</span>.event<br>
16
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;fd&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Unix</span>.file_descr<br>
17
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;signal&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;int<br>
18
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;set&nbsp;:<br>
19
&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span><br>
20
&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Unix</span>.file_descr&nbsp;<span class="keywordsign">-&gt;</span><br>
21
&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Liboevent</span>.event_flags&nbsp;list&nbsp;<span class="keywordsign">-&gt;</span><br>
22
&nbsp;&nbsp;&nbsp;&nbsp;persist:bool&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Liboevent</span>.event_callback&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
23
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;set_signal&nbsp;:<br>
24
&nbsp;&nbsp;&nbsp;&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span><br>
25
&nbsp;&nbsp;&nbsp;&nbsp;signal:int&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;persist:bool&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Liboevent</span>.event_callback&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
26
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;add&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;float&nbsp;option&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
27
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;del&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
28
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;pending&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.event&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;<span class="constructor">Liboevent</span>.event_flags&nbsp;list&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;bool<br>
29
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;dispatch&nbsp;:&nbsp;unit&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
30
&nbsp;&nbsp;<span class="keyword">type</span>&nbsp;loop_flags&nbsp;=&nbsp;<span class="constructor">ONCE</span>&nbsp;<span class="keywordsign">|</span>&nbsp;<span class="constructor">NONBLOCK</span><br>
31
&nbsp;&nbsp;<span class="keyword">val</span>&nbsp;loop&nbsp;:&nbsp;<span class="constructor">Liboevent</span>.loop_flags&nbsp;<span class="keywordsign">-&gt;</span>&nbsp;unit<br>
32
<span class="keyword">end</span></code></body></html>
(-)ocaml-event/work/ocaml-event-0.6.0/event_stubs.c (+223 lines)
Line 0 Link Here
1
/************************************************************************/
2
/* The OcamlEvent library                                               */
3
/*                                                                      */
4
/* Copyright 2002, 2003, 2004 Maas-Maarten Zeeman. All rights reserved. */
5
/* See LICENCE for details.                                             */
6
/************************************************************************/
7
8
/* $Id: event_stubs.c,v 1.2 2009-11-26 08:41:10 maas Exp $ */
9
10
/* Stub code to interface Ocaml with libevent */
11
12
#include <sys/time.h>
13
#include <stdlib.h>
14
#include <event.h>
15
#include <string.h>
16
17
#include <caml/mlvalues.h>
18
#include <caml/custom.h>
19
#include <caml/alloc.h>
20
#include <caml/memory.h>
21
#include <caml/callback.h>
22
#include <caml/fail.h>
23
24
#define struct_event_val(v) (*(struct event**) Data_custom_val(v))
25
#define Is_some(v) (Is_block(v))
26
27
static value * event_cb_closure = NULL;
28
29
/* use the error function from the Unix library */
30
extern void uerror (char * cmdname, value arg) Noreturn;
31
32
static void
33
struct_event_finalize(value ve) 
34
{
35
  struct event *ev = struct_event_val(ve);
36
  
37
  if (event_initialized(ev)) {
38
    event_del(ev);
39
  }
40
41
  stat_free(struct_event_val(ve));
42
}
43
44
static int 
45
struct_event_compare(value v1, value v2) 
46
{ 
47
  struct event *p1 = struct_event_val(v1);
48
  struct event *p2 = struct_event_val(v2);
49
  if(p1 == p2) return 0;
50
  if(p1 < p2) return -1; 
51
  return 1;
52
}
53
54
static long
55
struct_event_hash(value v)
56
{
57
  return (long) struct_event_val(v);
58
}
59
60
static struct custom_operations struct_event_ops = {
61
  "struct event",
62
  struct_event_finalize,
63
  struct_event_compare,
64
  struct_event_hash,
65
  custom_serialize_default,
66
  custom_deserialize_default
67
};
68
69
/* 
70
 * This callback calls the ocaml event callback, which will in turn
71
 * call the real ocaml callback.  
72
 */
73
static void
74
event_cb(int fd, short type, void *arg) 
75
{
76
  callback3(*event_cb_closure, 
77
	    Val_long((long) arg), Val_int(fd), Val_int(type));
78
}
79
80
static void
81
set_struct_timeval(struct timeval *tv, value vfloat) 
82
{
83
  double timeout = Double_val(vfloat);
84
  tv->tv_sec = (int) timeout;
85
  tv->tv_usec = (int) (1e6 * (timeout - tv->tv_sec));
86
}
87
88
CAMLprim value
89
oc_create_event(value unit) 
90
{
91
  CAMLparam0();
92
  CAMLlocal1(ve);
93
  struct event* ev = caml_stat_alloc(sizeof(struct event));
94
  memset(ev, 0, sizeof(*ev));
95
96
  ve = alloc_custom(&struct_event_ops, sizeof(struct event*), 0, 1);
97
  *(struct event**) Data_custom_val(ve) = ev;
98
99
  CAMLreturn(ve);
100
}
101
102
CAMLprim value
103
oc_event_id(value vevent)
104
{
105
  CAMLparam0();
106
  CAMLreturn(Val_long((long) struct_event_val(vevent)));
107
}
108
109
CAMLprim value
110
oc_event_fd(value vevent)
111
{
112
  CAMLparam1(vevent);
113
  CAMLreturn(Val_long(EVENT_FD(struct_event_val(vevent))));
114
}
115
116
CAMLprim value 
117
oc_event_set(value vevent, value fd, value vevent_flag) 
118
{ 
119
  CAMLparam3(vevent, fd, vevent_flag); 
120
121
  struct event *event = struct_event_val(vevent); 
122
123
  event_set(event, Int_val(fd), Int_val(vevent_flag), 
124
	    &event_cb, event); 
125
126
  CAMLreturn(Val_unit); 
127
} 
128
129
CAMLprim value
130
oc_event_add(value vevent, value vfloat_option) 
131
{
132
  CAMLparam2(vevent, vfloat_option);
133
  struct event *event = struct_event_val(vevent); 
134
  struct timeval timeval;
135
  struct timeval *tv = NULL;
136
137
  if Is_some(vfloat_option) {
138
    set_struct_timeval(&timeval, Field(vfloat_option, 0));
139
    tv = &timeval;
140
  } 
141
  
142
  if((0 != event_add(event, tv))) {
143
    uerror("event_add", vevent);
144
  }
145
146
  CAMLreturn(Val_unit);
147
}
148
149
CAMLprim value
150
oc_event_del(value vevent) 
151
{
152
  CAMLparam0();
153
  struct event *event = struct_event_val(vevent); 
154
155
  event_del(event);
156
157
  CAMLreturn(Val_unit);
158
}
159
160
CAMLprim value
161
oc_event_pending(value vevent, value vtype, value vfloat_option) 
162
{
163
  CAMLparam3(vevent, vtype, vfloat_option);
164
  struct event *event = struct_event_val(vevent); 
165
  struct timeval timeval;
166
  struct timeval *tv = NULL;
167
  
168
  if Is_some(vfloat_option) {
169
    set_struct_timeval(&timeval, Field(vfloat_option, 0));
170
    tv = &timeval;
171
  } 
172
173
  event_pending(event, Int_val(vtype), tv);
174
175
  CAMLreturn(Val_unit);
176
}
177
178
CAMLprim value
179
oc_event_loop(value vloop_flag)
180
{
181
  CAMLparam1(vloop_flag);
182
183
  if((-1 == event_loop(Int_val(vloop_flag)))) {
184
    uerror("event_dispatch", vloop_flag);
185
  }
186
  
187
  CAMLreturn(Val_unit);
188
}
189
190
191
CAMLprim value
192
oc_event_dispatch(value unit) 
193
{
194
  CAMLparam1(unit);
195
196
  if((-1 == event_dispatch())) {
197
    uerror("event_dispatch", unit);
198
  }
199
200
  CAMLreturn(Val_unit);
201
}
202
203
/*
204
 * Initialize the event library
205
 */
206
CAMLprim value
207
oc_event_init(value unit)
208
{
209
  CAMLparam1(unit);
210
  
211
  /* setup the event callback closure if needed */
212
  if(event_cb_closure == NULL) {
213
    event_cb_closure = caml_named_value("event_cb");
214
    if(event_cb_closure == NULL) {
215
      invalid_argument("Callback event_cv not initialized.");
216
    }
217
  }
218
219
  /* and don't forget to initialize libevent */
220
  event_init();
221
222
  CAMLreturn(Val_unit);
223
}
(-)ocaml-event/work/ocaml-event-0.6.0/examples/Makefile (+23 lines)
Line 0 Link Here
1
#
2
# Simple makefile to build the example programs. The event library
3
# must be installed first.
4
#
5
6
all: fifo_example signal_example http_server
7
8
fifo_example: fifo_example.ml
9
	ocamlfind ocamlc -o fifo_example -package libevent -linkpkg \
10
	fifo_example.ml
11
12
signal_example: signal_example.ml
13
	ocamlfind ocamlc -o signal_example -package libevent -linkpkg \
14
	signal_example.ml
15
16
http_server: http_server.ml
17
	ocamlfind ocamlc -o http_server -package libevent -linkpkg \
18
	http_server.ml
19
20
.PHONY: clean
21
clean::
22
	rm -f *~ *.cm* *.o fifo_example signal_example http_server
23
(-)ocaml-event/work/ocaml-event-0.6.0/examples/fifo_example.ml (+38 lines)
Line 0 Link Here
1
(*
2
 * Small example program
3
 *)
4
5
open Libevent
6
7
let fifo_read event fd event_type =
8
  let buflen = 255 in
9
  let buf = String.create buflen in 
10
  match Unix.read fd buf 0 buflen with
11
    0 -> 
12
      Printf.printf "Connection closed\n";
13
      flush stdout
14
  | n -> 
15
      Printf.printf "Read: %s\n" (String.sub buf 0 n);
16
      flush stdout;
17
18
      (* Reschedule this event *)
19
      add event None
20
21
let _ =
22
  let fifo = "event.fifo" in
23
24
  Unix.unlink fifo; 
25
  Unix.mkfifo fifo 0o600;
26
27
  let fifo_fd = Unix.openfile fifo [ Unix.O_RDWR; Unix.O_NONBLOCK ] 0 in
28
  let evfifo = create () in
29
30
  Printf.printf "Write date to: %s\n" fifo;
31
  flush stdout;
32
  
33
  set evfifo fifo_fd [READ] false (fifo_read evfifo);
34
  add evfifo None;
35
36
  dispatch ()
37
    
38
(-)ocaml-event/work/ocaml-event-0.6.0/examples/http_server.ml (+64 lines)
Line 0 Link Here
1
(* 
2
 * Simple but fast HTTP Server 
3
 *)
4
5
let accept fd = 
6
  let client_fd, client_addr = Unix.accept fd in  
7
    Unix.set_nonblock client_fd;
8
    client_fd, client_addr
9
10
let http_server_cb buffer buflen fd event_type =
11
  let client_fd, client_addr = accept fd in
12
13
  let read_event = Libevent.create () in
14
  let write_event = Libevent.create () in
15
      
16
  (* The http connection callback *)
17
  let http_read_cb fd event_type =
18
    let len = Unix.read fd buffer 0 buflen in
19
20
    (* HTTP Request not parsed, does not even have to be complete yet.*)
21
    let http_write_cb fd event_type = 
22
      let response = "HTTP/1.0 200 OK\n\r" ^
23
	"Server: Caml 1.0\r\n" ^
24
	"\r\n" ^
25
	"<html><h1>Hi There</h1>" ^
26
	"<pre>" ^ (String.sub buffer 0 len) ^ "</pre>" ^ 
27
        "</html"
28
      in
29
      let l = Unix.write fd response 0 (String.length response) in
30
	Unix.close fd
31
    in
32
      Libevent.set write_event fd [Libevent.WRITE] false http_write_cb;
33
      Libevent.add write_event None
34
35
  in
36
    Libevent.set read_event client_fd [Libevent.READ] false http_read_cb;
37
    Libevent.add read_event None
38
  
39
let bind_server port = 
40
  let fd = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
41
    Unix.set_nonblock fd; 
42
    Unix.setsockopt fd Unix.SO_REUSEADDR true;
43
    Unix.bind fd (Unix.ADDR_INET (Unix.inet_addr_any, port));
44
    Unix.listen fd 5;
45
    fd
46
47
let _ =
48
  Unix.set_nonblock Unix.stdout;
49
  Unix.set_nonblock Unix.stderr;
50
51
  let server_event = Libevent.create () in
52
  let stdout_event = Libevent.create () in
53
  let stderr_event = Libevent.create () in
54
55
  let server_fd = bind_server 8080 in
56
    
57
  let buflen = 10240 in
58
  let buffer = String.create buflen in 
59
60
    Libevent.set server_event server_fd [Libevent.READ] true 
61
      (http_server_cb buffer buflen);
62
    Libevent.add server_event None;
63
64
    Libevent.dispatch ();
(-)ocaml-event/work/ocaml-event-0.6.0/examples/signal_example.ml (+32 lines)
Line 0 Link Here
1
(*
2
 * Small example program
3
 *)
4
5
let signal_callback event called fd event_type =
6
  (* Print information on the signal we received *)
7
  Printf.printf "Got signal: %d\n" (Libevent.signal event);
8
  flush stdout;
9
 
10
  called := !called - 1;
11
12
  if !called <= 0 then
13
    Libevent.del event
14
15
let _ =
16
  let sigint = 2 in  
17
18
  (* Create an event *)
19
  let signal_event = Libevent.create () in
20
21
  (* Set the sigint signal *)
22
  Libevent.set_signal signal_event sigint true
23
    (signal_callback signal_event (ref 2));
24
25
  (* Add the signal to the event library *)
26
  Libevent.add signal_event None;
27
28
  Printf.printf "SIGINT me please!\n";
29
  flush stdout;
30
31
  (* Start the event dispatching mainloop *)
32
  Libevent.dispatch ()
(-)ocaml-event/work/ocaml-event-0.6.0/liboevent.ml (+108 lines)
Line 0 Link Here
1
(***********************************************************************)
2
(* The OcamlEvent library                                              *)
3
(*                                                                     *)
4
(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. See  *) 
5
(* LICENCE for details.                                                *)
6
(***********************************************************************)
7
8
(* $Id: liboevent.ml,v 1.1 2009-11-26 08:49:02 maas Exp $ *)
9
type event
10
11
type event_flags =
12
    TIMEOUT 
13
  | READ 
14
  | WRITE
15
  | SIGNAL 
16
17
let int_of_event_type = function
18
    TIMEOUT -> 0x01
19
  | READ -> 0x02
20
  | WRITE -> 0x04
21
  | SIGNAL -> 0x08
22
23
let event_type_of_int = function
24
  | 1 -> TIMEOUT
25
  | 2 -> READ
26
  | 4 -> WRITE
27
  | 8 -> SIGNAL
28
  | _ -> raise (Invalid_argument "event_type")
29
30
type event_callback = Unix.file_descr -> event_flags -> unit
31
32
(* Use an internal hashtable to store the ocaml callbacks with the
33
   event *)
34
let table = Hashtbl.create 0
35
36
(* Called by the c-stub, locate, and call the ocaml callback *)
37
let event_cb event_id fd etype =
38
  (Hashtbl.find table event_id) fd (event_type_of_int etype)
39
  
40
(* Create an event *)
41
external create : unit -> event = "oc_create_event"
42
43
(* Return the id of an event *)
44
external event_id : event -> int = "oc_event_id"
45
46
(* Return the signal associated with the event *)
47
external signal : event -> int = "oc_event_fd"
48
49
(* Return the fd associated with the event *)
50
external fd : event -> Unix.file_descr = "oc_event_fd"
51
52
(* Set an event (not exported) *)
53
external cset_fd : event -> Unix.file_descr -> int -> unit = "oc_event_set"
54
external cset_int : event -> int -> int -> unit = "oc_event_set"
55
56
(* Event set *)
57
let set event fd etype persist (cb : event_callback) =
58
  let rec int_of_event_type_list flag = function
59
      h::t -> int_of_event_type_list (flag lor (int_of_event_type h)) t
60
    | [] -> flag
61
  in
62
  let flag = 
63
    let f = int_of_event_type_list 0 etype in
64
    if persist then
65
      f lor 0x10
66
    else
67
      f
68
  in
69
  Hashtbl.add table (event_id event) cb;
70
  cset_fd event fd flag
71
72
let set_signal event signal persist (cb : event_callback) =
73
  let signal_flag = (int_of_event_type SIGNAL) in
74
  let flag = if persist then
75
    signal_flag lor 0x10
76
  else
77
    signal_flag
78
  in
79
  Hashtbl.add table (event_id event) cb;
80
  cset_int event signal flag
81
82
(* Add an event *)
83
external add : event -> float option -> unit = "oc_event_add"
84
85
(* Del an event  *)
86
external cdel : event -> unit = "oc_event_del"
87
let del event =
88
  Hashtbl.remove table (event_id event);
89
  cdel event
90
91
(* *)
92
(* Not fully implemented yet *)
93
external pending : event -> event_flags list -> bool = "oc_event_pending"
94
95
(* Process events *)
96
external dispatch : unit -> unit = "oc_event_dispatch"
97
98
type loop_flags = ONCE | NONBLOCK
99
external loop : loop_flags -> unit = "oc_event_loop"
100
101
(* Initialize the event library *)
102
external init : unit -> unit = "oc_event_init"
103
let _ = 
104
  Callback.register "event_cb" event_cb;
105
  init ()
106
107
108
(-)ocaml-event/work/ocaml-event-0.6.0/liboevent.mli (+88 lines)
Line 0 Link Here
1
(***********************************************************************)
2
(* The Ocaml Libevent library                                          *)
3
(*                                                                     *)
4
(* Copyright 2002, 2003, 2004 Maas-Maarten Zeeman. All rights          *) 
5
(* reserved. See LICENCE for details.                                  *)       
6
(***********************************************************************)
7
8
9
(** The Ocaml Event library provides an interface to the event API.
10
11
    The event API provides a mechanism to execute a function when a
12
    specific event on a file descriptor occurs or after a given time
13
    has passed.
14
15
    This library is a wrapper of the libevent API made by Nils
16
    Provos. For more information about this library see:
17
    http://www.monkey.org/~provos/libevent. 
18
19
    Currently, libevent supports kqueue(2), select(2), poll(2) and
20
    epoll(4). Support for /dev/poll is planned.
21
22
    @author Maas-Maarten Zeeman 
23
*)
24
25
(** The type of events *)
26
type event
27
28
(** The possible event types *)
29
type event_flags = 
30
    TIMEOUT (** A timeout occurred. *)
31
  | READ    (** A read is possible. *)
32
  | WRITE   (** A write operation is possible. *)
33
  | SIGNAL  (** A signal occurred. *)
34
35
type event_callback = Unix.file_descr -> event_flags -> unit
36
(** The type of event callbacks *)
37
38
(** {5 Basic Libevent Operations} *)
39
40
val create : unit -> event
41
(** Create a new empty event *)
42
43
val fd : event -> Unix.file_descr
44
(** [fd event] returns the file descriptor associated with the event *)
45
46
val signal : event -> int
47
(** [signal event] returns the signal associated with the event *)
48
49
val set : event -> 
50
  Unix.file_descr -> event_flags list -> persist:bool -> event_callback -> unit
51
(** [set event fd type persist callback] initializes the event. The
52
    flag [persist] makes an event persitent until {!Libevent.del} is
53
    called. *)
54
55
val set_signal : event ->
56
  signal:int -> persist:bool -> event_callback -> unit
57
(** [set_signal event signal persist callback] initializes the event. The
58
    flag [persist] makes an event persistent unit {!Libevent.del} is
59
    called. *)
60
61
val add : event -> float option -> unit
62
(** [add event timeout] adds the [event] and schedules the execution
63
    of the function specified with {!Libevent.set}, or in at least the
64
    time specified in the [timeout]. If [timeout] is [None], no
65
    timeout occures, and the function will only be called if a
66
    matching event occurs on the file descriptor. *)
67
68
val del : event -> unit
69
(** Del the event *)
70
71
val pending : event -> event_flags list -> bool 
72
73
(** {5 Process Events} *)
74
75
val dispatch : unit -> unit
76
(** In order to process events, an application needs to call dispatch. This 
77
 *  function only returns on error, and should replace the event core of the 
78
 *  application
79
 *)
80
81
type loop_flags =
82
    ONCE            
83
  | NONBLOCK        
84
val loop : loop_flags -> unit
85
(** Provides an interface for single pass execution of pending events *)
86
87
88
(-)ocaml-event/work/ocaml-event-0.6.0/unittest.ml (+80 lines)
Line 0 Link Here
1
(***********************************************************************)
2
(* The OcamlEvent library                                              *)
3
(*                                                                     *)
4
(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. See  *) 
5
(* LICENCE for details.                                                *)
6
(***********************************************************************)
7
8
(* $Id: unittest.ml,v 1.3 2009-11-26 09:10:37 maas Exp $ *)
9
10
open OUnit
11
12
let create_event = Liboevent.create 
13
14
(* Tests the creation of new events *)
15
let test_create_event _ =
16
  let e1 = create_event () in
17
  let e2 = create_event () in 
18
  "Events should be different" @? (e1 <> e2)
19
20
(* Tests if pending can be called with and without the optional float *)
21
let test_pending _ =
22
  let e = create_event () in
23
  ignore(Liboevent.pending e [])
24
25
(* Test eof on a read callback *)
26
let test_read_eof _ =
27
  let test_string = "This is a test string\n\n\n" in
28
  let buflen = 512 in
29
  let buf = String.create buflen in
30
  let read_count = ref 0 in 
31
  let evt = create_event () in
32
  let read_cb fd event_type = 
33
    (* read data from the fd *)
34
    let len = Unix.read fd buf 0 buflen in
35
    (* when 0 bytes are read this is the EOF, and we are done. *)
36
    if len <> 0 then
37
      begin
38
	read_count := !read_count + len;
39
	Liboevent.add evt None
40
      end
41
  in
42
43
  (* Create a socket pair for testing *)
44
  let s1, s2 = Unix.socketpair Unix.PF_UNIX Unix.SOCK_STREAM 0 in
45
  let _ = Unix.write s1 test_string 0 (String.length test_string) in
46
47
  (* A shutdown_send will cause an EOF on the reading end *)
48
  Unix.shutdown s1 Unix.SHUTDOWN_SEND;
49
50
  (* Setup the event *)
51
  Liboevent.set evt s2 [Liboevent.READ] false read_cb;
52
  Liboevent.add evt None;
53
  Liboevent.dispatch ();
54
55
  (* Now its time to check some things *)
56
  assert_equal (String.length test_string) ! read_count
57
58
(* This is not really a test (yet) *)
59
let call_set _ =
60
  let do_nothing _ _ =
61
    ()
62
  in  
63
  let e1 = Liboevent.create () in
64
  Liboevent.set e1 Unix.stderr [Liboevent.WRITE] false do_nothing;
65
  Liboevent.set e1 Unix.stdout [Liboevent.WRITE] false do_nothing;
66
  Liboevent.set e1 Unix.stdin [Liboevent.READ] false do_nothing;
67
  Liboevent.add e1 (Some 0.1);
68
  Liboevent.loop(Liboevent.ONCE)
69
 
70
(* Construct the test suite *)
71
let suite = "event" >::: 
72
  ["create_event" >:: test_create_event;
73
   "test_pending" >:: test_pending;
74
   "test_read_eof" >:: test_read_eof;
75
   "call_set" >:: call_set;
76
 ] 
77
78
(* Run the tests in the test suite *)
79
let _ = 
80
  run_test_tt_main suite

Return to bug 141006