source: branches/help/CORE/arb_pathlen.h

Last change on this file was 18730, checked in by westram, 3 years ago
  • remove trailing whitespace from c source.
File size: 1.7 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : arb_pathlen.h                                     //
4//   Purpose   : stop PATH_MAX and accomplices driving me crazy    //
5//                                                                 //
6//   Coded by Ralf Westram (coder@reallysoft.de) in October 2013   //
7//   Institute of Microbiology (Technical University Munich)       //
8//   http://www.arb-home.de/                                       //
9//                                                                 //
10// =============================================================== //
11
12#ifndef ARB_PATHLEN_H
13#define ARB_PATHLEN_H
14
15#ifndef STATIC_ASSERT_H
16#include <static_assert.h>
17#endif
18#ifndef _GLIBCXX_CLIMITS
19#include <climits>
20#endif
21#ifndef _GLIBCXX_CSTDIO
22#include <cstdio>
23#endif
24
25#define ARB_PATH_LOWER_LIMIT 256
26#define ARB_PATH_UPPER_LIMIT 10000 // ought to be enough for anybody ;-)
27
28#ifdef PATH_MAX
29#define ARB_PATH_MAX PATH_MAX
30#else
31#define ARB_PATH_MAX 4096 // use a reasonable amout if PATH_MAX is undefined (i.e. if there is NO limit)
32#endif
33
34#ifndef ARB_PATH_MAX
35#error Failed to detect useable allowed size for filenames (ARB_PATH_MAX)
36#endif
37#ifndef FILENAME_MAX
38#error FILENAME_MAX is undefined
39#endif
40
41STATIC_ASSERT(FILENAME_MAX>=ARB_PATH_MAX); // if this fails, either PATH_MAX lies or the reasonable amount set above is too high
42STATIC_ASSERT(ARB_PATH_MAX>=ARB_PATH_LOWER_LIMIT);
43STATIC_ASSERT(ARB_PATH_UPPER_LIMIT>=ARB_PATH_LOWER_LIMIT);
44
45#if (ARB_PATH_MAX > ARB_PATH_UPPER_LIMIT)
46#undef ARB_PATH_MAX
47#define ARB_PATH_MAX ARB_PATH_UPPER_LIMIT
48#endif
49
50#else
51#error arb_pathlen.h included twice
52#endif // ARB_PATHLEN_H
Note: See TracBrowser for help on using the repository browser.