From e5ec54b175b604c6145c67e1e6a067205c7168ea Mon Sep 17 00:00:00 2001 From: ygrek Date: Tue, 19 May 2015 00:21:16 -0700 Subject: [PATCH] update README and copyrights, cleanup comments --- LICENCE | 1 + Makefile | 8 +++----- README | 14 +++++++------- event_stubs.c | 35 +++++++++++++++++------------------ libevent.ml | 17 ++++++++--------- libevent.mli | 24 ++++++++++++------------ unittest.ml | 2 -- 7 files changed, 48 insertions(+), 53 deletions(-) diff --git a/LICENCE b/LICENCE index 49a952b..1098aa5 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,5 @@ Copyright (c) 2002, 2003 by Maas-Maarten Zeeman +Copyright (c) 2010 ygrek The package ocaml-event is copyright by Maas-Maarten Zeeman. diff --git a/Makefile b/Makefile index 8388a6f..404c504 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,4 @@ # -# $Id: Makefile,v 1.2 2009-11-26 08:49:02 maas Exp $ -# # Change this to match your libevent installation. EVENT_LIB=-levent @@ -23,7 +21,7 @@ CFLAGS=-DFULL_UNROLL -Wall -O2 -I$(EVENT_INCDIR) OCAMLC=ocamlc OCAMLOPT=ocamlopt OCAMLDEP=ocamldep -OCAMLMKLIB=ocamlmklib +OCAMLMKLIB=ocamlmklib OCAMLDOC=ocamldoc OCAMLFIND=ocamlfind @@ -36,7 +34,7 @@ all: $(ARCHIVE) allopt: $(XARCHIVE) depend: *.c *.ml *.mli - gcc -MM *.c > depend + gcc -MM *.c > depend $(OCAMLDEP) *.mli *.ml >> depend ## Library creation @@ -64,7 +62,7 @@ uninstall: ## Documentation .PHONY: doc doc: FORCE - cd doc; $(OCAMLDOC) -html -I .. ../$(NAME).mli + cd doc; $(OCAMLDOC) -html -I .. ../*.mli ## Testing .PHONY: test diff --git a/README b/README index 08a031b..d93ccfa 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ Overview - Ocaml-Expat is a wrapper for the libevent API. The libevent API + ocaml-event is a wrapper for the libevent API. The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals @@ -14,13 +14,13 @@ Overview Installation - - Download, compile, and install libevent. - See http://www.monkey.org/~provos/libevent/ + - Download, compile, and install libevent. + See http://libevent.org - Edit the variables at the beginning of the Makefile to reflect the - location where libevent is installed on your system. + location where libevent is installed on your system. - - Do make depend; make all + - Do make depend; make all - If the Objective Caml native-code compiler is available on your platform (look for the "ocamlopt" executable), do "make allopt". @@ -36,11 +36,11 @@ Installation - Become super-user if necessary and do "make install". This installs the library in the standard Objective Caml library directory. - + Documentation See the HTML documentation in doc/index.html References - libevent:: + libevent:: diff --git a/event_stubs.c b/event_stubs.c index 7079b42..59100e9 100644 --- a/event_stubs.c +++ b/event_stubs.c @@ -1,12 +1,11 @@ /************************************************************************/ -/* The OcamlEvent library */ +/* The ocaml-event library */ /* */ /* Copyright 2002, 2003, 2004 Maas-Maarten Zeeman. All rights reserved. */ +/* Copyright 2010 ygrek */ /* See LICENCE for details. */ /************************************************************************/ -/* $Id: event_stubs.c,v 1.2 2009-11-26 08:41:10 maas Exp $ */ - /* Stub code to interface Ocaml with libevent */ #include @@ -126,21 +125,21 @@ get_struct_event_base_val(value v) return base; } -/* +/* * This callback calls the ocaml event callback, which will in turn * call the real ocaml callback. */ static void -event_cb(int fd, short type, void *arg) +event_cb(int fd, short type, void *arg) { caml_leave_blocking_section(); - callback3(*event_cb_closure, + callback3(*event_cb_closure, Val_long((long) arg), Val_int(fd), Val_int(type)); caml_enter_blocking_section(); } static void -set_struct_timeval(struct timeval *tv, value vfloat) +set_struct_timeval(struct timeval *tv, value vfloat) { double timeout = Double_val(vfloat); tv->tv_sec = (int) timeout; @@ -175,24 +174,24 @@ oc_event_fd(value vevent) CAMLreturn(Val_long(EVENT_FD(struct_event_val(vevent)))); } -CAMLprim value +CAMLprim value oc_event_set(value vbase, value vevent, value fd, value vevent_flag) -{ +{ CAMLparam4(vbase, vevent, fd, vevent_flag); - struct event *event = struct_event_val(vevent); + struct event *event = struct_event_val(vevent); struct event_base* base = get_struct_event_base_val(vbase); - event_set(event, Int_val(fd), Int_val(vevent_flag), - &event_cb, event); + event_set(event, Int_val(fd), Int_val(vevent_flag), + &event_cb, event); if (0 != event_base_set(base, event)) { raise_error("event_set", "event_base_set"); } - CAMLreturn(Val_unit); -} + CAMLreturn(Val_unit); +} CAMLprim value oc_event_add(value vevent, value vfloat_option) @@ -215,10 +214,10 @@ oc_event_add(value vevent, value vfloat_option) } CAMLprim value -oc_event_del(value vevent) +oc_event_del(value vevent) { CAMLparam0(); - struct event *event = struct_event_val(vevent); + struct event *event = struct_event_val(vevent); event_del(event); @@ -229,7 +228,7 @@ CAMLprim value oc_event_pending(value vevent, value vtype) { CAMLparam2(vevent, vtype); - struct event *event = struct_event_val(vevent); + struct event *event = struct_event_val(vevent); int r = 0; r = event_pending(event, Int_val(vtype), NULL); @@ -270,7 +269,7 @@ oc_event_base_loop(value vbase, value vloop_flag) CAMLprim value -oc_event_base_dispatch(value vbase) +oc_event_base_dispatch(value vbase) { CAMLparam1(vbase); struct event_base* base = get_struct_event_base_val(vbase); diff --git a/libevent.ml b/libevent.ml index dc13e7b..1c74503 100644 --- a/libevent.ml +++ b/libevent.ml @@ -1,19 +1,19 @@ (***********************************************************************) -(* The OcamlEvent library *) +(* The ocaml-event library *) (* *) -(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. See *) -(* LICENCE for details. *) +(* Copyright 2002, 2003 Maas-Maarten Zeeman. All rights reserved. *) +(* Copyright 2010 ygrek *) +(* See LICENCE for details. *) (***********************************************************************) -(* $Id: liboevent.ml,v 1.1 2009-11-26 08:49:02 maas Exp $ *) type event type event_base type event_flags = - TIMEOUT - | READ + TIMEOUT + | READ | WRITE - | SIGNAL + | SIGNAL let int_of_event_type = function TIMEOUT -> 0x01 @@ -107,7 +107,7 @@ external init : unit -> event_base = "oc_event_base_init" external reinit : event_base -> unit = "oc_event_base_reinit" external free : event_base -> unit = "oc_event_base_free" -let () = +let () = Callback.register "event_cb" event_cb (** Compatibility *) @@ -121,4 +121,3 @@ let dispatch () = dispatch base let loop = loop base end - diff --git a/libevent.mli b/libevent.mli index bdef81d..3a8a6ee 100644 --- a/libevent.mli +++ b/libevent.mli @@ -1,8 +1,9 @@ (***********************************************************************) -(* The Ocaml Libevent library *) +(* The ocaml-event library *) (* *) -(* Copyright 2002, 2003, 2004 Maas-Maarten Zeeman. All rights *) -(* reserved. See LICENCE for details. *) +(* Copyright 2002, 2003, 2004 Maas-Maarten Zeeman. All rights reserved *) +(* Copyright 2010 ygrek *) +(* See LICENCE for details. *) (***********************************************************************) @@ -14,12 +15,12 @@ This library is a wrapper of the libevent API made by Nils Provos. For more information about this library see: - http://www.monkey.org/~provos/libevent. + http://libevent.org Currently, libevent supports kqueue(2), select(2), poll(2) and epoll(4). Support for /dev/poll is planned. - @author Maas-Maarten Zeeman + @author Maas-Maarten Zeeman *) (** The type of events *) @@ -29,7 +30,7 @@ type event type event_base (** The possible event types *) -type event_flags = +type event_flags = TIMEOUT (** A timeout occurred. *) | READ (** A read is possible. *) | WRITE (** A write operation is possible. *) @@ -49,7 +50,7 @@ val fd : event -> Unix.file_descr val signal : event -> int (** [signal event] returns the signal associated with the event *) -val set : event_base -> event -> +val set : event_base -> event -> Unix.file_descr -> event_flags list -> persist:bool -> event_callback -> unit (** [set events event fd type persist callback] initializes the event for use with [events]. The flag [persist] makes an event persitent until {!Libevent.del} is @@ -70,11 +71,11 @@ val add : event -> float option -> unit of the function specified with {!Libevent.set}, or in at least the time specified in the [timeout]. If [timeout] is [None], no timeout occures, and the function will only be called if a - matching event occurs on the file descriptor. Addition of the already + matching event occurs on the file descriptor. Addition of the already scheduled (added) event will reschedule the timeout. *) val del : event -> unit -(** Delete the event. After event was deleted it should be first +(** Delete the event. After event was deleted it should be first reinitialized with [set] before next [add]. *) val pending : event -> event_flags list -> bool @@ -88,8 +89,8 @@ val activate : event -> event_flags list -> unit (** {5 Process Events} *) val dispatch : event_base -> unit -(** In order to process events, an application needs to call dispatch. This - * function only returns on error, and should replace the event core of the +(** In order to process events, an application needs to call dispatch. This + * function only returns on error, and should replace the event core of the * application *) @@ -119,4 +120,3 @@ val dispatch : unit -> unit val loop : loop_flags -> unit end - diff --git a/unittest.ml b/unittest.ml index b933cde..049f5ef 100644 --- a/unittest.ml +++ b/unittest.ml @@ -5,8 +5,6 @@ (* LICENCE for details. *) (***********************************************************************) -(* $Id: unittest.ml,v 1.3 2009-11-26 09:10:37 maas Exp $ *) - open OUnit open Libevent -- 2.11.4.GIT