Annotation of embedaddon/trafshow/events.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     Copyright (c) 2003 Rinet Corp., Novosibirsk, Russia
        !             3:  *
        !             4:  * Redistribution and use in source forms, with and without modification,
        !             5:  * are permitted provided that this entire comment appears intact.
        !             6:  *
        !             7:  * THIS SOURCE CODE IS PROVIDED ``AS IS'' WITHOUT ANY WARRANTIES OF ANY KIND.
        !             8:  */
        !             9: 
        !            10: #ifndef        _EVENTS_H_
        !            11: #define        _EVENTS_H_
        !            12: 
        !            13: #include <sys/types.h>
        !            14: #include <sys/time.h>
        !            15: 
        !            16: /*
        !            17:  * Event scheduler.
        !            18:  */
        !            19: 
        !            20: typedef struct event_ent {
        !            21:        struct timeval tv;      /* system time in [micro]seconds from UTC */
        !            22:        void (*func)(void *);   /* function to call at the time */
        !            23:        void *arg;              /* function argument pointer */
        !            24: 
        !            25:         struct event_ent *next;
        !            26: } EVENT;
        !            27: 
        !            28: /*
        !            29:  * Subtract or add two timeval structs:
        !            30:  * out = out - in
        !            31:  * out = out + in
        !            32:  * result always greater 0.
        !            33:  */
        !            34: void tv_sub(struct timeval *out, const struct timeval *in);
        !            35: void tv_add(struct timeval *out, const struct timeval *in);
        !            36: 
        !            37: /*
        !            38:  * Round timeval to seconds.
        !            39:  */
        !            40: u_long tv_round(const struct timeval *tvp);
        !            41: 
        !            42: /*
        !            43:  * Return difference of time in milliseconds.
        !            44:  */
        !            45: u_long tv_diff(const struct timeval *tvp1, const struct timeval *tvp2);
        !            46: 
        !            47: /*
        !            48:  * Shift the time to be sharp at (12am + N * period), local time.
        !            49:  */
        !            50: void tv_sharp(struct timeval *tvp, int period);
        !            51: 
        !            52: /*
        !            53:  * Execute pending event and schedule the next nearest.
        !            54:  * Return 0 if timeval was modified.
        !            55:  */
        !            56: int select_event(struct timeval *tvp);
        !            57: 
        !            58: /*
        !            59:  * Add the new system event (or modify) to be executed at the given time.
        !            60:  * Return 0 on success, -1 for error.
        !            61:  */
        !            62: int add_event(struct timeval *tvp, void (*func)(void *), void *arg);
        !            63: 
        !            64: /*
        !            65:  * Remove system event from queue if any.
        !            66:  * Null func pointer may be used as wildcard ANY.
        !            67:  * Return number of removed events.
        !            68:  */
        !            69: int remove_event(void (*func)(void *), void *arg);
        !            70: 
        !            71: /*
        !            72:  * Modify existing system event in queue for the new function argument.
        !            73:  * Null func pointer may be used as wildcard ANY.
        !            74:  * Return number of removed events.
        !            75:  */
        !            76: int change_event(void (*func)(void *), void *arg, void *new_arg);
        !            77: 
        !            78: EVENT *find_event(void (*func)(void *), void *arg);
        !            79: 
        !            80: /*
        !            81:  * Clear/free all system events.
        !            82:  */
        !            83: void free_events();
        !            84: 
        !            85: #endif /* _EVENTS_H_ */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>