File: HTTPCacheMacros.h

package info (click to toggle)
libdap 3.20.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 24,568 kB
  • sloc: cpp: 50,809; sh: 41,536; xml: 23,511; ansic: 20,030; yacc: 2,508; exp: 1,544; makefile: 990; lex: 309; perl: 52; fortran: 8
file content (71 lines) | stat: -rw-r--r-- 1,704 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * HTTPCacheMacros.h
 *
 *  Created on: Dec 28, 2011
 *      Author: jimg
 */

#ifndef HTTPCACHEMACROS_H_
#define HTTPCACHEMACROS_H_

#ifdef WIN32
#include <direct.h>
#include <time.h>
#include <fcntl.h>
#define MKDIR(a,b) _mkdir((a))
#define UMASK(a) _umask((a))

#if 0
#define REMOVE(a) do { \
        int s = remove((a)); \
        if (s != 0) \
            throw InternalErr(__FILE__, __LINE__, "Cache error; could not remove file: " + long_to_string(s)); \
    } while(0)
#endif

#define REMOVE_BOOL(a) remove((a))
#define REMOVE(a) ((void)remove((a)))
#define MKSTEMP(a) _open(_mktemp((a)),_O_CREAT,_S_IREAD|_S_IWRITE)
#define DIR_SEPARATOR_CHAR '\\'
#define DIR_SEPARATOR_STR "\\"

#else
#include <cerrno>
#define MKDIR(a,b) mkdir((a), (b))
#define UMASK(a) umask((a))

#if 0
// Replaced this with something that signals errors. jhrg 12/28/2011
// A great idea, but it breaks things in ways that complicate
// testing. Push this change forward to H 1.9. jhrg 12/28/2011
#define REMOVE(a) do { \
        errno = 0; \
        int s = remove((a)); \
        if (s != 0) \
            throw InternalErr(__FILE__, __LINE__, "Cache error; could not remove file: " + long_to_string(errno)); \
    } while(0)
#endif

#define REMOVE_BOOL(a) remove((a))
#define REMOVE(a) ((void)remove((a)))

#define MKSTEMP(a) mkstemp((a))
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STR "/"
#endif

#ifdef WIN32
#define CACHE_LOCATION "\\tmp\\"
#define CACHE_ROOT "dods-cache\\"
#else
#define CACHE_LOCATION "/tmp/"
#define CACHE_ROOT "dods-cache/"
#endif

#define CACHE_INDEX ".index"
#define CACHE_LOCK ".lock"
#define CACHE_META ".meta"
#define CACHE_EMPTY_ETAG "@cache@"


#endif /* HTTPCACHEMACROS_H_ */