Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / event2 / bufferevent_struct.h @ 14

History | View | Annotate | Download (4.16 KB)

1
/*        $NetBSD: bufferevent_struct.h,v 1.1.1.2 2015/01/29 06:38:26 spz Exp $        */
2
/*        $NetBSD: bufferevent_struct.h,v 1.1.1.2 2015/01/29 06:38:26 spz Exp $        */
3
/*
4
 * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
5
 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. The name of the author may not be used to endorse or promote products
16
 *    derived from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
#ifndef _EVENT2_BUFFEREVENT_STRUCT_H_
30
#define _EVENT2_BUFFEREVENT_STRUCT_H_
31

    
32
/** @file event2/bufferevent_struct.h
33

34
  Data structures for bufferevents.  Using these structures may hurt forward
35
  compatibility with later versions of Libevent: be careful!
36

37
  @deprecated Use of bufferevent_struct.h is completely deprecated; these
38
    structures are only exposed for backward compatibility with programs
39
    written before Libevent 2.0 that used them.
40
 */
41

    
42
#ifdef __cplusplus
43
extern "C" {
44
#endif
45

    
46
#include <event2/event-config.h>
47
#ifdef _EVENT_HAVE_SYS_TYPES_H
48
#include <sys/types.h>
49
#endif
50
#ifdef _EVENT_HAVE_SYS_TIME_H
51
#include <sys/time.h>
52
#endif
53

    
54
/* For int types. */
55
#include <event2/util.h>
56
/* For struct event */
57
#include <event2/event_struct.h>
58

    
59
struct event_watermark {
60
        size_t low;
61
        size_t high;
62
};
63

    
64
/**
65
  Shared implementation of a bufferevent.
66

67
  This type is exposed only because it was exposed in previous versions,
68
  and some people's code may rely on manipulating it.  Otherwise, you
69
  should really not rely on the layout, size, or contents of this structure:
70
  it is fairly volatile, and WILL change in future versions of the code.
71
**/
72
struct bufferevent {
73
        /** Event base for which this bufferevent was created. */
74
        struct event_base *ev_base;
75
        /** Pointer to a table of function pointers to set up how this
76
            bufferevent behaves. */
77
        const struct bufferevent_ops *be_ops;
78

    
79
        /** A read event that triggers when a timeout has happened or a socket
80
            is ready to read data.  Only used by some subtypes of
81
            bufferevent. */
82
        struct event ev_read;
83
        /** A write event that triggers when a timeout has happened or a socket
84
            is ready to write data.  Only used by some subtypes of
85
            bufferevent. */
86
        struct event ev_write;
87

    
88
        /** An input buffer. Only the bufferevent is allowed to add data to
89
            this buffer, though the user is allowed to drain it. */
90
        struct evbuffer *input;
91

    
92
        /** An input buffer. Only the bufferevent is allowed to drain data
93
            from this buffer, though the user is allowed to add it. */
94
        struct evbuffer *output;
95

    
96
        struct event_watermark wm_read;
97
        struct event_watermark wm_write;
98

    
99
        bufferevent_data_cb readcb;
100
        bufferevent_data_cb writecb;
101
        /* This should be called 'eventcb', but renaming it would break
102
         * backward compatibility */
103
        bufferevent_event_cb errorcb;
104
        void *cbarg;
105

    
106
        struct timeval timeout_read;
107
        struct timeval timeout_write;
108

    
109
        /** Events that are currently enabled: currently EV_READ and EV_WRITE
110
            are supported. */
111
        short enabled;
112
};
113

    
114
#ifdef __cplusplus
115
}
116
#endif
117

    
118
#endif /* _EVENT2_BUFFEREVENT_STRUCT_H_ */