1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file glimits.h
19 ///
20 
21 #ifndef G_LIMITS_H__
22 #define G_LIMITS_H__
23 
24 #include "gdef.h"
25 
26 /// \namespace G
27 namespace G
28 {
29 	class limits ;
30 }
31 
32 /// \class G::limits
33 /// A scoping structure for a set of buffer sizes.
34 /// Intended to be used to reduce memory requirements in
35 /// embedded environments.
36 ///
37 class G::limits
38 {
39 public:
40 
41  #ifndef G_SMALL
42 	enum { path = 10000 } ; // cf. MAX_PATH, PATH_MAX, MAXPATHLEN
43 	enum { log = 1000 } ; // log line limit
44 	enum { file_buffer = 102400 } ; // cf. BUFSIZ
45 	enum { pipe_buffer = 4096 } ; // one-off read from a pipe
46 	enum { get_pwnam_r_buffer = 200 } ; // approx line length in /etc/passwd
47 	enum { net_buffer = 20000 } ; // best if bigger than the TLS maximum block size of 16k
48 	enum { net_line_limit = 1000000 } ; // denial of service limit
49 	enum { net_hostname = 1024 } ;
50 	enum { net_listen_queue = 3 } ;
51 	enum { net_certificate_cache_size = 50 } ;
52 	enum { win32_subclass_limit = 80 } ;
53 	enum { win32_classname_buffer = 256 } ;
54 	enum { ssl_max_cache_entries = 10 } ; // libnss3 SSL_ConfigServerSessionIDCache()
55  #else
56 	enum { path = 256 } ;
57 	enum { log = 120 } ;
58 	enum { file_buffer = 128 } ;
59 	enum { pipe_buffer = 128 } ;
60 	enum { get_pwnam_r_buffer = 1024 } ; // if no sysconf() value
61 	enum { net_buffer = 512 } ;
62 	enum { net_line_limit = 2000 } ;
63 	enum { net_hostname = 128 } ;
64 	enum { net_listen_queue = 20 } ;
65 	enum { net_certificate_cache_size = 2 } ;
66 	enum { win32_subclass_limit = 2 } ;
67 	enum { win32_classname_buffer = 128 } ;
68 	enum { ssl_max_cache_entries = 0 } ;
69  #endif
70 
71 private:
72 	limits() ; // not implemented
73 } ;
74 
75 #endif
76