goinfre/libs/libevent/events.c

goinfre/libs/libevent/events.c

  _____________________________________________________________________________ 
 /   / Index / Goinfre / Resume / Links / Contact / Sitemap /    .: v0.6.1.0 |^|
|\__/-------+         +--------+-------+---------+---------+-----------------+#|
|  1| /goinfre/libs/libevent/events.c                                        |#|
|  2| ==========================================                             |#|
|  3|                                                                        |#|
|  4|                                                   [ raw ] [ download ] |#|
|  5|                                             ` `` ````````````````````` |#|
|  6|                                                                        |#|
|  7| /**                                                                    |#|
|  8|  * libevent/events.c                                                   |#|
|  9|  *                                                                     |#|
| 10|  * Copyright (c) Manfred Touron 2008                                   |#|
| 11|  */                                                                    |#|
| 12|                                                                        |#|
| 13| #include <stdlib.h>                                                    |#|
| 14| #include <unistd.h>                                                    |#|
| 15| #include <stdio.h>                                                     |#|
| 16| #include <string.h>                                                    |#|
| 17|                                                                        |#|
| 18| #include <liblc/liblc.h>                                               |#|
| 19|                                                                        |#|
| 20| #include "core.h"                                                      |#|
| 21|                                                                        |#|
| 22| lc      events = NULL;                                                 |#|
| 23|                                                                        |#|
| 24| int      events_init(void)                                             |#|
| 25| {                                                                      |#|
| 26|   static int      inited = 0;                                          |#|
| 27|                                                                        |#|
| 28|   if (!inited)                                                         |#|
| 29|     {                                                                  |#|
| 30|       events = lc_new();                                               |#|
| 31|       inited = 1;                                                      |#|
| 32|     }                                                                  |#|
| 33|   return (1);                                                          |#|
| 34| }                                                                      |#|
| 35|                                                                        |#|
| 36| int      events_event_cmpfn(void *a, void *b)                          |#|
| 37| {                                                                      |#|
| 38|   event      e;                                                        |#|
| 39|                                                                        |#|
| 40|   e = (event)a;                                                        |#|
| 41|   return (strcmp(e->name, b));                                         |#|
| 42| }                                                                      |#|
| 43|                                                                        |#|
| 44| int      events_event_exists(event e)                                  |#|
| 45| {                                                                      |#|
| 46|   return (events_find(e->name) != NULL);                               |#|
| 47| }                                                                      |#|
| 48|                                                                        |#|
| 49| event      events_add(event e)                                         |#|
| 50| {                                                                      |#|
| 51|   events_init();                                                       | |
| 52|   lc_push(events, e);                                                  | |
| 53|   return (e);                                                          | |
| 54| }                                                                      | |
| 55|                                                                        | |
| 56| void      event_unset(event e)                                         | |
| 57| {                                                                      | |
| 58|   lc_remove_ptr(events, e);                                            | |
| 59|   free(e);                                                             | |
| 60|   return ;                                                             | |
| 61| }                                                                      | |
| 62|                                                                        | |
| 63| void      events_debug(void)                                           | |
| 64| {                                                                      | |
| 65|   lc_walk(events, event_e_debug);                                      | |
| 66| }                                                                      | |
| 67|                                                                        | |
| 68| event      events_find(const char *name)                               | |
| 69| {                                                                      | |
| 70|   events_init();                                                       | |
| 71|   return ((lc_find_cmpfn(events, (void *)name,                         | |
| 72|                    events_event_cmpfn)));                              | |
| 73| }                                                                      | |
| 74|                                                                        | |
+---+                                                                        | |
\_   \______ mo5.so - normal - 1337.so - rev.so - video_r.so +---------------+ |
  |__       \_____   plain.so - color.so - comment.so       /  moul 2008 (c) |V|
     \-----\______\________________________________________/-----------------+-+