[Libevent-users] [PATCH] Fix handling of EVENT_BASE_FLAG_IGNORE_ENV flag.

2009-04-25 Thread hopper
# HG changeset patch
# User Eric Hopper hop...@omnifarious.org
# Date 1240605517 25200
# Node ID 97768cd771be8ea7a4db8bd46998030dcd8c6650
# Parent  07c00814a3436ebd1d8628fa8c3c1d921523d1e5
Properly detect sense of should_check_environment and fix regression.

diff -r 07c00814a3436ebd1d8628fa8c3c1d921523d1e5 -r 
97768cd771be8ea7a4db8bd46998030dcd8c6650 event.c
--- a/event.c   Fri Apr 24 05:33:24 2009 -0700
+++ b/event.c   Fri Apr 24 13:38:37 2009 -0700
@@ -262,7 +262,7 @@
base-evbase = NULL;
 
should_check_environment =
-   cfg  (cfg-flags  EVENT_BASE_FLAG_IGNORE_ENV);
+   !(cfg  (cfg-flags  EVENT_BASE_FLAG_IGNORE_ENV));
 
for (i = 0; eventops[i]  !base-evbase; i++) {
if (cfg != NULL) {



pgpRC4WD4WL6b.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


[Libevent-users] [PATCH] Add new EVENT_DISABLED environment variable to use instead of multiple EVENT_NO flags.

2009-04-25 Thread hopper
# HG changeset patch
# User Eric Hopper hop...@omnifarious.org
# Date 1240605604 25200
# Node ID 8ca16c106804698455d97b9d40ba78ed97753907
# Parent  97768cd771be8ea7a4db8bd46998030dcd8c6650
Add check of single EVENT_DISABLED environment variable to avoid multiplying 
environmnet variables.

diff -r 97768cd771be8ea7a4db8bd46998030dcd8c6650 -r 
8ca16c106804698455d97b9d40ba78ed97753907 event.c
--- a/event.c   Fri Apr 24 13:38:37 2009 -0700
+++ b/event.c   Fri Apr 24 13:40:04 2009 -0700
@@ -225,7 +225,27 @@
evutil_snprintf(environment, sizeof(environment), EVENT_NO%s, name);
for (i = 8; environment[i] != '\0'; ++i)
environment[i] = toupper(environment[i]);
-   return (getenv(environment) != NULL);
+   if (getenv(environment) != NULL) {
+return 1;
+} else {
+const char * const disabledenv = getenv(EVENT_DISABLE);
+if (disabledenv != NULL) {
+const int namelen = strlen(name);
+const char *ptr = strstr(disabledenv, name);
+while (ptr != NULL) {
+if (((ptr == disabledenv) || (*(ptr - 1) == ',')) 
+((*(ptr + namelen) == '\0') || (*(ptr + namelen) == ',')))
+{
+return 1;
+} else if (*ptr == '\0') {
+return 0;
+} else {
+ptr = strstr(ptr + 1, name);
+}
+}
+}
+return 0;
+}
 }
 
 enum event_method_feature



pgpDxUgjyTrev.pgp
Description: PGP signature
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users


[Libevent-users] Re: function delegates

2009-04-25 Thread William Ahern
I've considerably refined my earlier approach to libevent delegates /
psuedo-lambda expressions.

I've abstracted out function pointer delegation -- delegate()  invoke() --
and then built the libevent wrapper -- event_delegate() -- around that.

Other changes:

- No more exponential pre-processor expansion (i.e. no more 2MB expansions).

- invoke() can proxy return values (ignored from libevent wrapper).

- Static detection of libevent's void(*)(int, short, void *) callback
  signature by event_delegate(); no libffi overhead. Useful for
  micro-optimizing without having to dramatically change code.

- Supporting more than 7 arguments should be a snap to add. The C99 macro
  magic has been re-written to use recursive'ish techniques.
   
GCC and libffi are, of course, still required.

Code available at:

http://25thandclement.com/~william/projects/delegate.c.html

I've been using this in a recent project and am quite happy. Only headache
is that it can be a pain to locate libffi headers, even if manually
installed.

___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users