~ubuntu-branches/ubuntu/karmic/psi/karmic

« back to all changes in this revision

Viewing changes to third-party/qca/qca/src/botantools/botan/botan/libstate.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 1999-2007 The Botan Project. All rights reserved.
 
3
 
 
4
Redistribution and use in source and binary forms, for any use, with or without
 
5
modification, is permitted provided that the following conditions are met:
 
6
 
 
7
1. Redistributions of source code must retain the above copyright notice, this
 
8
list of conditions, and the following disclaimer.
 
9
 
 
10
2. Redistributions in binary form must reproduce the above copyright notice,
 
11
this list of conditions, and the following disclaimer in the documentation
 
12
and/or other materials provided with the distribution.
 
13
 
 
14
THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED
 
15
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 
16
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
 
17
 
 
18
IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT,
 
19
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 
20
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
21
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
22
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 
23
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 
24
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
25
*/
 
26
// LICENSEHEADER_END
 
27
namespace QCA { // WRAPNS_LINE
 
28
/*************************************************
 
29
* Library Internal/Global State Header File      *
 
30
* (C) 1999-2007 The Botan Project                *
 
31
*************************************************/
 
32
 
 
33
#ifndef BOTAN_LIB_STATE_H__
 
34
#define BOTAN_LIB_STATE_H__
 
35
 
 
36
#ifdef BOTAN_TOOLS_ONLY
 
37
} // WRAPNS_LINE
 
38
#include <botan/allocate.h>
 
39
namespace QCA { // WRAPNS_LINE
 
40
#else
 
41
} // WRAPNS_LINE
 
42
#include <botan/base.h>
 
43
namespace QCA { // WRAPNS_LINE
 
44
} // WRAPNS_LINE
 
45
#include <botan/enums.h>
 
46
namespace QCA { // WRAPNS_LINE
 
47
} // WRAPNS_LINE
 
48
#include <botan/ui.h>
 
49
namespace QCA { // WRAPNS_LINE
 
50
#endif
 
51
} // WRAPNS_LINE
 
52
#include <string>
 
53
namespace QCA { // WRAPNS_LINE
 
54
} // WRAPNS_LINE
 
55
#include <vector>
 
56
namespace QCA { // WRAPNS_LINE
 
57
} // WRAPNS_LINE
 
58
#include <map>
 
59
namespace QCA { // WRAPNS_LINE
 
60
 
 
61
namespace Botan {
 
62
 
 
63
/*************************************************
 
64
* Global State Container Base                    *
 
65
*************************************************/
 
66
class Library_State
 
67
   {
 
68
   public:
 
69
#ifndef BOTAN_TOOLS_ONLY
 
70
      class Engine_Iterator
 
71
         {
 
72
         public:
 
73
            class Engine* next();
 
74
            Engine_Iterator(const Library_State& l) : lib(l) { n = 0; }
 
75
         private:
 
76
            const Library_State& lib;
 
77
            u32bit n;
 
78
         };
 
79
      friend class Engine_Iterator;
 
80
 
 
81
      class UI
 
82
         {
 
83
         public:
 
84
            virtual void pulse(Pulse_Type) {}
 
85
            virtual ~UI() {}
 
86
         };
 
87
#endif
 
88
 
 
89
      int prealloc_size;
 
90
      Allocator* get_allocator(const std::string& = "") const;
 
91
      void add_allocator(Allocator*);
 
92
#ifdef BOTAN_TOOLS_ONLY
 
93
      void set_default_allocator(const std::string&);
 
94
#else
 
95
      void set_default_allocator(const std::string&) const;
 
96
#endif
 
97
 
 
98
#ifndef BOTAN_TOOLS_ONLY
 
99
      bool rng_is_seeded() const { return rng->is_seeded(); }
 
100
      void randomize(byte[], u32bit);
 
101
 
 
102
      void set_prng(RandomNumberGenerator*);
 
103
      void add_entropy_source(EntropySource*, bool = true);
 
104
      void add_entropy(const byte[], u32bit);
 
105
      void add_entropy(EntropySource&, bool);
 
106
      u32bit seed_prng(bool, u32bit);
 
107
#endif
 
108
 
 
109
      void load(class Modules&);
 
110
 
 
111
#ifndef BOTAN_TOOLS_ONLY
 
112
      void set_timer(class Timer*);
 
113
      u64bit system_clock() const;
 
114
 
 
115
      class Config& config() const;
 
116
 
 
117
      void add_engine(class Engine*);
 
118
#endif
 
119
 
 
120
      class Mutex* get_mutex() const;
 
121
      class Mutex* get_named_mutex(const std::string&);
 
122
 
 
123
#ifndef BOTAN_TOOLS_ONLY
 
124
      void set_x509_state(class X509_GlobalState*);
 
125
      class X509_GlobalState& x509_state();
 
126
 
 
127
      void pulse(Pulse_Type) const;
 
128
      void set_ui(UI*);
 
129
 
 
130
      void set_transcoder(class Charset_Transcoder*);
 
131
      std::string transcode(const std::string,
 
132
                            Character_Set, Character_Set) const;
 
133
#endif
 
134
 
 
135
      Library_State(class Mutex_Factory*);
 
136
      ~Library_State();
 
137
   private:
 
138
      Library_State(const Library_State&) {}
 
139
      Library_State& operator=(const Library_State&) { return (*this); }
 
140
 
 
141
#ifndef BOTAN_TOOLS_ONLY
 
142
      class Engine* get_engine_n(u32bit) const;
 
143
#endif
 
144
 
 
145
      class Mutex_Factory* mutex_factory;
 
146
#ifndef BOTAN_TOOLS_ONLY
 
147
      class Timer* timer;
 
148
      class Config* config_obj;
 
149
      class X509_GlobalState* x509_state_obj;
 
150
#endif
 
151
 
 
152
      std::map<std::string, class Mutex*> locks;
 
153
      std::map<std::string, Allocator*> alloc_factory;
 
154
      mutable Allocator* cached_default_allocator;
 
155
#ifdef BOTAN_TOOLS_ONLY
 
156
      std::string default_allocator_type;
 
157
#endif
 
158
 
 
159
#ifndef BOTAN_TOOLS_ONLY
 
160
      UI* ui;
 
161
      class Charset_Transcoder* transcoder;
 
162
      RandomNumberGenerator* rng;
 
163
#endif
 
164
      std::vector<Allocator*> allocators;
 
165
#ifndef BOTAN_TOOLS_ONLY
 
166
      std::vector<EntropySource*> entropy_sources;
 
167
      std::vector<class Engine*> engines;
 
168
#endif
 
169
   };
 
170
 
 
171
/*************************************************
 
172
* Global State                                   *
 
173
*************************************************/
 
174
Library_State& global_state();
 
175
void set_global_state(Library_State*);
 
176
Library_State* swap_global_state(Library_State*);
 
177
 
 
178
}
 
179
 
 
180
#endif
 
181
} // WRAPNS_LINE