blob: b96d14b9bcddb6995092eb64e72c98d0db1da5be [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/types/buffers.h
3 Buffer management definitions, macros and inline functions.
4
5 Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _TYPES_BUFFERS_H
23#define _TYPES_BUFFERS_H
24
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020025#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020026#include <common/memory.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020027
Willy Tarreau54469402006-07-29 16:59:06 +020028#include <stdint.h>
29
30/* The BF_* macros designate Buffer Flags, which may be ORed in the bit field
31 * member 'flags' in struct buffer.
32 */
33#define BF_SHUTR_PENDING 1
34#define BF_SHUTR_DONE 2
35#define BF_SHUTW_PENDING 4
36#define BF_SHUTW_DONE 8
Willy Tarreau0f9f5052006-07-29 17:39:25 +020037
Willy Tarreau54469402006-07-29 16:59:06 +020038#define BF_PARTIAL_READ 16
39#define BF_COMPLETE_READ 32
40#define BF_READ_ERROR 64
Willy Tarreau0f9f5052006-07-29 17:39:25 +020041#define BF_READ_NULL 128
42#define BF_READ_STATUS (BF_PARTIAL_READ|BF_COMPLETE_READ|BF_READ_ERROR|BF_READ_NULL)
43#define BF_CLEAR_READ (~BF_READ_STATUS)
Willy Tarreau54469402006-07-29 16:59:06 +020044
Willy Tarreau0f9f5052006-07-29 17:39:25 +020045#define BF_PARTIAL_WRITE 256
46#define BF_COMPLETE_WRITE 512
47#define BF_WRITE_ERROR 1024
48#define BF_WRITE_NULL 2048
49#define BF_WRITE_STATUS (BF_PARTIAL_WRITE|BF_COMPLETE_WRITE|BF_WRITE_ERROR|BF_WRITE_NULL)
50#define BF_CLEAR_WRITE (~BF_WRITE_STATUS)
Willy Tarreau54469402006-07-29 16:59:06 +020051
52
Willy Tarreau0f9f5052006-07-29 17:39:25 +020053
Willy Tarreaubaaee002006-06-26 02:48:02 +020054/* describes a chunk of string */
55struct chunk {
56 char *str; /* beginning of the string itself. Might not be 0-terminated */
57 int len; /* size of the string from first to last char. <0 = uninit. */
58};
59
60struct buffer {
Willy Tarreau0f9f5052006-07-29 17:39:25 +020061 u_int32_t flags; /* BF_* */
Willy Tarreaud7971282006-07-29 18:36:34 +020062 struct timeval rex; /* expiration date for a read */
63 struct timeval wex; /* expiration date for a write */
64 struct timeval cex; /* expiration date for a connect */
65 int rto; /* read timeout */
66 int wto; /* write timeout */
67 int cto; /* connect timeout */
Willy Tarreaubaaee002006-06-26 02:48:02 +020068 unsigned int l; /* data length */
69 char *r, *w, *h, *lr; /* read ptr, write ptr, last header ptr, last read */
70 char *rlim; /* read limit, used for header rewriting */
71 unsigned long long total; /* total data read */
72 char data[BUFSIZE];
73};
74
75#define sizeof_buffer sizeof(struct buffer)
76extern void **pool_buffer;
77
78
79#endif /* _TYPES_BUFFERS_H */
80
81/*
82 * Local variables:
83 * c-indent-level: 8
84 * c-basic-offset: 8
85 * End:
86 */