1 | #ifndef FERESOURCE_H |
---|
2 | #define FERESOURCE_H |
---|
3 | |
---|
4 | #include <sys/param.h> |
---|
5 | |
---|
6 | #define DIR_SEP '/' |
---|
7 | #define DIR_SEPP "/" |
---|
8 | |
---|
9 | #ifndef MAXPATHLEN |
---|
10 | #define MAXPATHLEN 1024 |
---|
11 | #endif |
---|
12 | |
---|
13 | #ifdef __cplusplus |
---|
14 | /***************************************************************** |
---|
15 | * |
---|
16 | * Resource management (feResources.cc) |
---|
17 | * |
---|
18 | *****************************************************************/ |
---|
19 | typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType; |
---|
20 | |
---|
21 | typedef struct feResourceConfig_s |
---|
22 | { |
---|
23 | const char* key; // key to identify resource |
---|
24 | const char id; // char id to identify resource |
---|
25 | feResourceType type; // type of Resource |
---|
26 | const char* env; // env variable to look for |
---|
27 | const char* fmt; // format string -- see below for epxlaination |
---|
28 | char* value; // what it was set to: may be changed |
---|
29 | } feResourceConfig_s; |
---|
30 | typedef feResourceConfig_s * feResourceConfig; |
---|
31 | |
---|
32 | extern feResourceConfig_s feResourceConfigs[]; |
---|
33 | |
---|
34 | // returns value of Resource as read-only string, or NULL |
---|
35 | // if Resource not found |
---|
36 | // issues warning, if explicitely requested (warn > 0), or |
---|
37 | // if warn < 0 and Resource is gotten for the first time |
---|
38 | // Always quiet if warn == 0 |
---|
39 | char* feResource(const char id, int warn = -1); |
---|
40 | char* feResource(const char* key, int warn = -1); |
---|
41 | |
---|
42 | char* feGetResource(const char id); |
---|
43 | |
---|
44 | // char* feResourceDefault(const char id); |
---|
45 | // char* feResourceDefault(const char* key); |
---|
46 | |
---|
47 | |
---|
48 | // This needs to be called before the first call to feResource |
---|
49 | // Initializes Resources, SearchPath, and extends PATH |
---|
50 | void feInitResources(const char* argv0 = NULL); |
---|
51 | // Re-inits resources, should be called after changing env. variables |
---|
52 | void feReInitResources(); |
---|
53 | #endif /* end ifdef __cplusplus */ |
---|
54 | |
---|
55 | extern char* feArgv0; |
---|
56 | |
---|
57 | const char fePathSep = |
---|
58 | /* not really cygwin, applies to all windows systems:*/ |
---|
59 | #if (defined(CYGWIN) || defined(ix86_Win)) |
---|
60 | ';' |
---|
61 | #else |
---|
62 | ':' |
---|
63 | #endif |
---|
64 | ; |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | #endif |
---|