Add licenses, remove dependency on OpenSSL.
[shibboleth/cpp-opensaml.git] / saml / internal.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /*
18  *  internal.h - internally visible classes
19  */
20
21 #ifndef __saml_internal_h__
22 #define __saml_internal_h__
23
24 #ifdef WIN32
25 # define _CRT_SECURE_NO_DEPRECATE 1
26 # define _CRT_NONSTDC_NO_DEPRECATE 1
27 #endif
28
29 // Export public APIs
30 #define SAML_EXPORTS
31
32 // eventually we might be able to support autoconf via cygwin...
33 #if defined (_MSC_VER) || defined(__BORLANDC__)
34 # include "config_win32.h"
35 #else
36 # include "config.h"
37 #endif
38
39 #include "base.h"
40 #include "SAMLConfig.h"
41
42 #include <limits.h>
43
44 using namespace xercesc;
45
46 // C99 defines LLONG_MIN, LLONG_MAX and ULLONG_MAX, but this part of
47 // C99 is not yet included into the C++ standard.
48 // GCC defines LONG_LONG_MIN, LONG_LONG_MAX and ULONG_LONG_MAX.
49 // Some compilers (such as Comeau C++ up to and including version 4.3.3)
50 // define nothing.  In this last case we make a reasonable guess.
51 #ifndef LLONG_MIN
52 #if defined(LONG_LONG_MIN)
53 #define LLONG_MIN LONG_LONG_MIN
54 #elif SIZEOF_LONG_LONG == 8
55 #define LLONG_MIN 0x8000000000000000LL
56 #endif
57 #endif
58  
59 #ifndef LLONG_MAX
60 #if defined(LONG_LONG_MAX)
61 #define LLONG_MAX LONG_LONG_MAX
62 #elif SIZEOF_LONG_LONG == 8
63 #define LLONG_MAX 0x7fffffffffffffffLL
64 #endif
65 #endif
66  
67 #ifndef ULLONG_MAX
68 #if defined(ULONG_LONG_MAX)
69 #define ULLONG_MAX ULONG_LONG_MAX
70 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
71 #define ULLONG_MAX 0xffffffffffffffffULL
72 #endif
73 #endif
74
75 #if SIZEOF_TIME_T == 8
76 # define SAMLTIME_MAX LLONG_MAX
77 #elif SIZEOF_TIME_T == 4
78 # define SAMLTIME_MAX LONG_MAX
79 #endif
80
81 #define SAML_LOGCAT "OpenSAML"
82
83 namespace opensaml {
84     
85     /// @cond OFF
86     class SAMLInternalConfig : public SAMLConfig
87     {
88     public:
89         SAMLInternalConfig() {}
90
91         static SAMLInternalConfig& getInternalConfig();
92
93         // global per-process setup and shutdown of runtime
94         bool init(bool initXMLTooling=true);
95         void term(bool termXMLTooling=true);
96
97         void generateRandomBytes(void* buf, unsigned int len);
98         void generateRandomBytes(std::string& buf, unsigned int len);
99         XMLCh* generateIdentifier();
100         std::string hashSHA1(const char* data, bool toHex=false);
101     private:
102     };
103     /// @endcond
104
105 };
106
107 #endif /* __saml_internal_h__ */