tevent: Add a utility function tevent_find_ops_byname().
authorJeremy Allison <jra@samba.org>
Mon, 11 Feb 2013 18:56:58 +0000 (10:56 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 14 Feb 2013 18:19:38 +0000 (10:19 -0800)
Returns an event ops struct given a string name. Not
yet used, but will be part of the new "standard" fallback
code.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tevent/tevent.c
lib/tevent/tevent_internal.h

index e307dba3d7952412508fb7758dd2e19b21df6838..63524710da5c4167986c031876938cd3d36ad320 100644 (file)
@@ -121,6 +121,28 @@ static void tevent_backend_init(void)
        tevent_standard_init();
 }
 
+_PRIVATE_ const struct tevent_ops *tevent_find_ops_byname(const char *name)
+{
+       struct tevent_ops_list *e;
+
+       tevent_backend_init();
+
+       if (name == NULL) {
+               name = tevent_default_backend;
+       }
+       if (name == NULL) {
+               name = "standard";
+       }
+
+       for (e = tevent_backends; e != NULL; e = e->next) {
+               if (0 == strcmp(e->name, name)) {
+                       return e->ops;
+               }
+       }
+
+       return NULL;
+}
+
 /*
   list available backends
 */
index 4e9cd69213dd6bbd058afbb7e1fea9cd8abd0ecb..fa6652cfa13656d9289acff8f6cd9b69e41b1d10 100644 (file)
@@ -265,6 +265,7 @@ struct tevent_context {
        } tracing;
 };
 
+const struct tevent_ops *tevent_find_ops_byname(const char *name);
 
 int tevent_common_context_destructor(struct tevent_context *ev);
 int tevent_common_loop_wait(struct tevent_context *ev,