~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to third-party/qca/qca/src/botantools/botantools.diff

  • 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
diff -ur a/include/bigint.h b/include/bigint.h
 
2
--- a/include/bigint.h  2007-03-24 11:51:37.000000000 -0700
 
3
+++ b/include/bigint.h  2007-06-26 11:31:40.000000000 -0700
 
4
@@ -6,7 +6,13 @@
 
5
 #ifndef BOTAN_BIGINT_H__
 
6
 #define BOTAN_BIGINT_H__
 
7
 
 
8
-#include <botan/base.h>
 
9
+#ifdef BOTAN_MINIMAL_BIGINT
 
10
+# include <botan/secmem.h>
 
11
+# include <botan/exceptn.h>
 
12
+#else
 
13
+# include <botan/base.h>
 
14
+#endif
 
15
+
 
16
 #include <botan/mp_types.h>
 
17
 #include <iosfwd>
 
18
 
 
19
@@ -82,7 +88,9 @@
 
20
       word operator[](u32bit index) const { return reg[index]; }
 
21
       void clear() { reg.clear(); }
 
22
 
 
23
+#ifndef BOTAN_MINIMAL_BIGINT
 
24
       void randomize(u32bit = 0);
 
25
+#endif
 
26
 
 
27
       void binary_encode(byte[]) const;
 
28
       void binary_decode(const byte[], u32bit);
 
29
@@ -102,7 +110,9 @@
 
30
       BigInt(const std::string&);
 
31
       BigInt(const byte[], u32bit, Base = Binary);
 
32
       BigInt(Sign, u32bit);
 
33
+#ifndef BOTAN_MINIMAL_BIGINT
 
34
       BigInt(NumberType, u32bit);
 
35
+#endif
 
36
    private:
 
37
       void grow_to(u32bit) const;
 
38
       SecureVector<word> reg;
 
39
@@ -140,15 +150,19 @@
 
40
 /*************************************************
 
41
 * I/O Operators                                  *
 
42
 *************************************************/
 
43
+#ifndef BOTAN_MINIMAL_BIGINT
 
44
 std::ostream& operator<<(std::ostream&, const BigInt&);
 
45
 std::istream& operator>>(std::istream&, BigInt&);
 
46
+#endif
 
47
 
 
48
 }
 
49
 
 
50
+#ifndef BOTAN_MINIMAL_BIGINT
 
51
 namespace std {
 
52
 
 
53
 inline void swap(Botan::BigInt& a, Botan::BigInt& b) { a.swap(b); }
 
54
 
 
55
 }
 
56
+#endif
 
57
 
 
58
 #endif
 
59
diff -ur a/include/charset.h b/include/charset.h
 
60
--- a/include/charset.h 2007-03-24 11:51:37.000000000 -0700
 
61
+++ b/include/charset.h 2007-06-26 11:31:40.000000000 -0700
 
62
@@ -7,7 +7,9 @@
 
63
 #define BOTAN_CHARSET_H__
 
64
 
 
65
 #include <botan/types.h>
 
66
+#ifndef BOTAN_TOOLS_ONLY
 
67
 #include <botan/enums.h>
 
68
+#endif
 
69
 #include <string>
 
70
 
 
71
 namespace Botan {
 
72
@@ -15,6 +17,7 @@
 
73
 /*************************************************
 
74
 * Character Set Transcoder Interface             *
 
75
 *************************************************/
 
76
+#ifndef BOTAN_TOOLS_ONLY
 
77
 class Charset_Transcoder
 
78
    {
 
79
    public:
 
80
@@ -23,13 +26,16 @@
 
81
 
 
82
       virtual ~Charset_Transcoder() {}
 
83
    };
 
84
+#endif
 
85
 
 
86
 namespace Charset {
 
87
 
 
88
 /*************************************************
 
89
 * Character Set Handling                         *
 
90
 *************************************************/
 
91
+#ifndef BOTAN_TOOLS_ONLY
 
92
 std::string transcode(const std::string&, Character_Set, Character_Set);
 
93
+#endif
 
94
 
 
95
 bool is_digit(char);
 
96
 bool is_space(char);
 
97
diff -ur a/include/libstate.h b/include/libstate.h
 
98
--- a/include/libstate.h        2007-03-24 11:51:37.000000000 -0700
 
99
+++ b/include/libstate.h        2007-06-26 11:31:40.000000000 -0700
 
100
@@ -6,9 +6,13 @@
 
101
 #ifndef BOTAN_LIB_STATE_H__
 
102
 #define BOTAN_LIB_STATE_H__
 
103
 
 
104
+#ifdef BOTAN_TOOLS_ONLY
 
105
+#include <botan/allocate.h>
 
106
+#else
 
107
 #include <botan/base.h>
 
108
 #include <botan/enums.h>
 
109
 #include <botan/ui.h>
 
110
+#endif
 
111
 #include <string>
 
112
 #include <vector>
 
113
 #include <map>
 
114
@@ -21,6 +25,7 @@
 
115
 class Library_State
 
116
    {
 
117
    public:
 
118
+#ifndef BOTAN_TOOLS_ONLY
 
119
       class Engine_Iterator
 
120
          {
 
121
          public:
 
122
@@ -38,11 +43,18 @@
 
123
             virtual void pulse(Pulse_Type) {}
 
124
             virtual ~UI() {}
 
125
          };
 
126
+#endif
 
127
 
 
128
+      int prealloc_size;
 
129
       Allocator* get_allocator(const std::string& = "") const;
 
130
       void add_allocator(Allocator*);
 
131
+#ifdef BOTAN_TOOLS_ONLY
 
132
+      void set_default_allocator(const std::string&);
 
133
+#else
 
134
       void set_default_allocator(const std::string&) const;
 
135
+#endif
 
136
 
 
137
+#ifndef BOTAN_TOOLS_ONLY
 
138
       bool rng_is_seeded() const { return rng->is_seeded(); }
 
139
       void randomize(byte[], u32bit);
 
140
 
 
141
@@ -51,19 +63,23 @@
 
142
       void add_entropy(const byte[], u32bit);
 
143
       void add_entropy(EntropySource&, bool);
 
144
       u32bit seed_prng(bool, u32bit);
 
145
+#endif
 
146
 
 
147
       void load(class Modules&);
 
148
 
 
149
+#ifndef BOTAN_TOOLS_ONLY
 
150
       void set_timer(class Timer*);
 
151
       u64bit system_clock() const;
 
152
 
 
153
       class Config& config() const;
 
154
 
 
155
       void add_engine(class Engine*);
 
156
+#endif
 
157
 
 
158
       class Mutex* get_mutex() const;
 
159
       class Mutex* get_named_mutex(const std::string&);
 
160
 
 
161
+#ifndef BOTAN_TOOLS_ONLY
 
162
       void set_x509_state(class X509_GlobalState*);
 
163
       class X509_GlobalState& x509_state();
 
164
 
 
165
@@ -73,6 +89,7 @@
 
166
       void set_transcoder(class Charset_Transcoder*);
 
167
       std::string transcode(const std::string,
 
168
                             Character_Set, Character_Set) const;
 
169
+#endif
 
170
 
 
171
       Library_State(class Mutex_Factory*);
 
172
       ~Library_State();
 
173
@@ -80,23 +97,34 @@
 
174
       Library_State(const Library_State&) {}
 
175
       Library_State& operator=(const Library_State&) { return (*this); }
 
176
 
 
177
+#ifndef BOTAN_TOOLS_ONLY
 
178
       class Engine* get_engine_n(u32bit) const;
 
179
+#endif
 
180
 
 
181
       class Mutex_Factory* mutex_factory;
 
182
+#ifndef BOTAN_TOOLS_ONLY
 
183
       class Timer* timer;
 
184
       class Config* config_obj;
 
185
       class X509_GlobalState* x509_state_obj;
 
186
+#endif
 
187
 
 
188
       std::map<std::string, class Mutex*> locks;
 
189
       std::map<std::string, Allocator*> alloc_factory;
 
190
       mutable Allocator* cached_default_allocator;
 
191
+#ifdef BOTAN_TOOLS_ONLY
 
192
+      std::string default_allocator_type;
 
193
+#endif
 
194
 
 
195
+#ifndef BOTAN_TOOLS_ONLY
 
196
       UI* ui;
 
197
       class Charset_Transcoder* transcoder;
 
198
       RandomNumberGenerator* rng;
 
199
+#endif
 
200
       std::vector<Allocator*> allocators;
 
201
+#ifndef BOTAN_TOOLS_ONLY
 
202
       std::vector<EntropySource*> entropy_sources;
 
203
       std::vector<class Engine*> engines;
 
204
+#endif
 
205
    };
 
206
 
 
207
 /*************************************************
 
208
diff -ur a/include/mem_ops.h b/include/mem_ops.h
 
209
--- a/include/mem_ops.h 2007-03-24 11:51:37.000000000 -0700
 
210
+++ b/include/mem_ops.h 2007-06-26 11:31:40.000000000 -0700
 
211
@@ -8,6 +8,7 @@
 
212
 
 
213
 #include <botan/types.h>
 
214
 #include <cstring>
 
215
+#include <string.h>
 
216
 
 
217
 namespace Botan {
 
218
 
 
219
@@ -15,16 +16,16 @@
 
220
 * Memory Manipulation Functions                  *
 
221
 *************************************************/
 
222
 template<typename T> inline void copy_mem(T* out, const T* in, u32bit n)
 
223
-   { std::memmove(out, in, sizeof(T)*n); }
 
224
+   { memmove(out, in, sizeof(T)*n); }
 
225
 
 
226
 template<typename T> inline void clear_mem(T* ptr, u32bit n)
 
227
-   { std::memset(ptr, 0, sizeof(T)*n); }
 
228
+   { memset(ptr, 0, sizeof(T)*n); }
 
229
 
 
230
 template<typename T> inline void set_mem(T* ptr, u32bit n, byte val)
 
231
-   { std::memset(ptr, val, sizeof(T)*n); }
 
232
+   { memset(ptr, val, sizeof(T)*n); }
 
233
 
 
234
 template<typename T> inline bool same_mem(const T* p1, const T* p2, u32bit n)
 
235
-   { return (std::memcmp(p1, p2, sizeof(T)*n) == 0); }
 
236
+   { return (memcmp(p1, p2, sizeof(T)*n) == 0); }
 
237
 
 
238
 }
 
239
 
 
240
diff -ur a/include/mem_pool.h b/include/mem_pool.h
 
241
--- a/include/mem_pool.h        2007-03-24 11:51:37.000000000 -0700
 
242
+++ b/include/mem_pool.h        2007-06-26 11:31:40.000000000 -0700
 
243
@@ -46,13 +46,17 @@
 
244
             byte* alloc(u32bit) throw();
 
245
             void free(void*, u32bit) throw();
 
246
 
 
247
-            bool operator<(const void*) const;
 
248
             bool operator<(const Memory_Block& other) const
 
249
-               { return (buffer < other.buffer); }
 
250
+               {
 
251
+               if(buffer < other.buffer && other.buffer < buffer_end)
 
252
+                  return false;
 
253
+               return (buffer < other.buffer);
 
254
+               }
 
255
+
 
256
          private:
 
257
             typedef u64bit bitmap_type;
 
258
-            static const u32bit BITMAP_SIZE = 8 * sizeof(bitmap_type);
 
259
-            static const u32bit BLOCK_SIZE = 64;
 
260
+            static const u32bit BITMAP_SIZE;
 
261
+            static const u32bit BLOCK_SIZE;
 
262
 
 
263
             bitmap_type bitmap;
 
264
             byte* buffer, *buffer_end;
 
265
Only in b/include: mmap_mem.h
 
266
diff -ur a/include/modules.h b/include/modules.h
 
267
--- a/include/modules.h 2007-03-24 11:51:37.000000000 -0700
 
268
+++ b/include/modules.h 2007-06-26 11:31:40.000000000 -0700
 
269
@@ -6,7 +6,9 @@
 
270
 #ifndef BOTAN_MODULE_FACTORIES_H__
 
271
 #define BOTAN_MODULE_FACTORIES_H__
 
272
 
 
273
+#ifndef BOTAN_TOOLS_ONLY
 
274
 #include <botan/init.h>
 
275
+#endif
 
276
 #include <string>
 
277
 #include <vector>
 
278
 
 
279
@@ -19,14 +21,18 @@
 
280
    {
 
281
    public:
 
282
       virtual class Mutex_Factory* mutex_factory() const = 0;
 
283
+#ifndef BOTAN_TOOLS_ONLY
 
284
       virtual class Timer* timer() const = 0;
 
285
       virtual class Charset_Transcoder* transcoder() const = 0;
 
286
+#endif
 
287
 
 
288
       virtual std::string default_allocator() const = 0;
 
289
 
 
290
       virtual std::vector<class Allocator*> allocators() const = 0;
 
291
+#ifndef BOTAN_TOOLS_ONLY
 
292
       virtual std::vector<class EntropySource*> entropy_sources() const = 0;
 
293
       virtual std::vector<class Engine*> engines() const = 0;
 
294
+#endif
 
295
 
 
296
       virtual ~Modules() {}
 
297
    };
 
298
@@ -38,18 +44,30 @@
 
299
    {
 
300
    public:
 
301
       class Mutex_Factory* mutex_factory() const;
 
302
+#ifndef BOTAN_TOOLS_ONLY
 
303
       class Timer* timer() const;
 
304
       class Charset_Transcoder* transcoder() const;
 
305
+#endif
 
306
 
 
307
       std::string default_allocator() const;
 
308
 
 
309
       std::vector<class Allocator*> allocators() const;
 
310
+#ifndef BOTAN_TOOLS_ONLY
 
311
       std::vector<class EntropySource*> entropy_sources() const;
 
312
       std::vector<class Engine*> engines() const;
 
313
+#endif
 
314
 
 
315
+#ifdef BOTAN_TOOLS_ONLY
 
316
+      Builtin_Modules();
 
317
+#else
 
318
       Builtin_Modules(const InitializerOptions&);
 
319
+#endif
 
320
    private:
 
321
+#ifdef BOTAN_TOOLS_ONLY
 
322
+      const bool should_lock;
 
323
+#else
 
324
       const bool should_lock, use_engines;
 
325
+#endif
 
326
    };
 
327
 
 
328
 }
 
329
diff -ur a/include/mutex.h b/include/mutex.h
 
330
--- a/include/mutex.h   2007-03-24 11:51:37.000000000 -0700
 
331
+++ b/include/mutex.h   2007-06-26 11:31:40.000000000 -0700
 
332
@@ -55,6 +55,7 @@
 
333
 /*************************************************
 
334
 * Named Mutex Holder                             *
 
335
 *************************************************/
 
336
+#ifndef BOTAN_NO_LIBSTATE
 
337
 class Named_Mutex_Holder
 
338
    {
 
339
    public:
 
340
@@ -63,6 +64,7 @@
 
341
    private:
 
342
       const std::string mutex_name;
 
343
    };
 
344
+#endif
 
345
 
 
346
 }
 
347
 
 
348
Only in b/include: mux_qt.h
 
349
diff -ur a/include/numthry.h b/include/numthry.h
 
350
--- a/include/numthry.h 2007-03-24 11:51:37.000000000 -0700
 
351
+++ b/include/numthry.h 2007-06-26 11:31:40.000000000 -0700
 
352
@@ -7,11 +7,14 @@
 
353
 #define BOTAN_NUMBTHRY_H__
 
354
 
 
355
 #include <botan/bigint.h>
 
356
+#ifndef BOTAN_MINIMAL_BIGINT
 
357
 #include <botan/reducer.h>
 
358
 #include <botan/pow_mod.h>
 
359
+#endif
 
360
 
 
361
 namespace Botan {
 
362
 
 
363
+#ifndef BOTAN_MINIMAL_BIGINT
 
364
 /*************************************************
 
365
 * Fused Arithmetic Operations                    *
 
366
 *************************************************/
 
367
@@ -22,9 +25,11 @@
 
368
 * Number Theory Functions                        *
 
369
 *************************************************/
 
370
 inline BigInt abs(const BigInt& n) { return n.abs(); }
 
371
+#endif
 
372
 
 
373
 void divide(const BigInt&, const BigInt&, BigInt&, BigInt&);
 
374
 
 
375
+#ifndef BOTAN_MINIMAL_BIGINT
 
376
 BigInt gcd(const BigInt&, const BigInt&);
 
377
 BigInt lcm(const BigInt&, const BigInt&);
 
378
 
 
379
@@ -85,6 +90,7 @@
 
380
       Fixed_Exponent_Power_Mod pow_mod;
 
381
       Modular_Reducer reducer;
 
382
    };
 
383
+#endif
 
384
 
 
385
 }
 
386
 
 
387
diff -ur a/include/parsing.h b/include/parsing.h
 
388
--- a/include/parsing.h 2007-03-24 11:51:37.000000000 -0700
 
389
+++ b/include/parsing.h 2007-06-26 11:31:40.000000000 -0700
 
390
@@ -15,17 +15,21 @@
 
391
 /*************************************************
 
392
 * String Parsing Functions                       *
 
393
 *************************************************/
 
394
+#ifndef BOTAN_TOOLS_ONLY
 
395
 std::vector<std::string> parse_algorithm_name(const std::string&);
 
396
 std::vector<std::string> split_on(const std::string&, char);
 
397
 std::vector<u32bit> parse_asn1_oid(const std::string&);
 
398
 bool x500_name_cmp(const std::string&, const std::string&);
 
399
 u32bit parse_expr(const std::string&);
 
400
+#endif
 
401
 
 
402
 /*************************************************
 
403
 * String/Integer Conversions                     *
 
404
 *************************************************/
 
405
 std::string to_string(u64bit, u32bit = 0);
 
406
+#ifndef BOTAN_TOOLS_ONLY
 
407
 u32bit to_u32bit(const std::string&);
 
408
+#endif
 
409
 
 
410
 }
 
411
 
 
412
diff -ur a/include/types.h b/include/types.h
 
413
--- a/include/types.h   2007-03-24 11:51:37.000000000 -0700
 
414
+++ b/include/types.h   2007-06-26 11:31:40.000000000 -0700
 
415
@@ -6,10 +6,24 @@
 
416
 #ifndef BOTAN_TYPES_H__
 
417
 #define BOTAN_TYPES_H__
 
418
 
 
419
+#ifdef BOTAN_TYPES_QT
 
420
+#include <QtGlobal>
 
421
+#else
 
422
 #include <botan/build.h>
 
423
+#endif
 
424
 
 
425
 namespace Botan {
 
426
 
 
427
+#ifdef BOTAN_TYPES_QT
 
428
+
 
429
+typedef quint8 byte;
 
430
+typedef quint16 u16bit;
 
431
+typedef quint32 u32bit;
 
432
+typedef qint32 s32bit;
 
433
+typedef quint64 u64bit;
 
434
+
 
435
+#else
 
436
+
 
437
 typedef unsigned char byte;
 
438
 typedef unsigned short u16bit;
 
439
 typedef unsigned int u32bit;
 
440
@@ -26,6 +40,8 @@
 
441
    typedef unsigned long long u64bit;
 
442
 #endif
 
443
 
 
444
+#endif // BOTAN_TYPES_QT
 
445
+
 
446
 }
 
447
 
 
448
 namespace Botan_types {
 
449
diff -ur a/include/util.h b/include/util.h
 
450
--- a/include/util.h    2007-03-24 11:51:37.000000000 -0700
 
451
+++ b/include/util.h    2007-06-26 11:31:40.000000000 -0700
 
452
@@ -13,8 +13,10 @@
 
453
 /*************************************************
 
454
 * Timer Access Functions                         *
 
455
 *************************************************/
 
456
+#ifndef BOTAN_TOOLS_ONLY
 
457
 u64bit system_time();
 
458
 u64bit system_clock();
 
459
+#endif
 
460
 
 
461
 /*************************************************
 
462
 * Memory Locking Functions                       *
 
463
@@ -27,13 +29,17 @@
 
464
 *************************************************/
 
465
 u32bit round_up(u32bit, u32bit);
 
466
 u32bit round_down(u32bit, u32bit);
 
467
+#ifndef BOTAN_TOOLS_ONLY
 
468
 u64bit combine_timers(u32bit, u32bit, u32bit);
 
469
+#endif
 
470
 
 
471
 /*************************************************
 
472
 * Work Factor Estimates                          *
 
473
 *************************************************/
 
474
+#ifndef BOTAN_TOOLS_ONLY
 
475
 u32bit entropy_estimate(const byte[], u32bit);
 
476
 u32bit dl_work_factor(u32bit);
 
477
+#endif
 
478
 
 
479
 }
 
480
 
 
481
diff -ur a/modules/alloc_mmap/mmap_mem.cpp b/modules/alloc_mmap/mmap_mem.cpp
 
482
--- a/modules/alloc_mmap/mmap_mem.cpp   2007-03-24 11:51:37.000000000 -0700
 
483
+++ b/modules/alloc_mmap/mmap_mem.cpp   2007-08-20 07:51:08.000000000 -0700
 
484
@@ -102,6 +102,11 @@
 
485
 void MemoryMapping_Allocator::dealloc_block(void* ptr, u32bit n)
 
486
    {
 
487
    if(ptr == 0) return;
 
488
+#ifdef MLOCK_NOT_VOID_PTR
 
489
+# define MLOCK_TYPE_CAST (char *)
 
490
+#else
 
491
+# define MLOCK_TYPE_CAST
 
492
+#endif
 
493
 
 
494
    const u32bit OVERWRITE_PASSES = 12;
 
495
    const byte PATTERNS[] = { 0x00, 0xFF, 0xAA, 0x55, 0x73, 0x8C, 0x5F, 0xA0,
 
496
@@ -110,14 +115,14 @@
 
497
    for(u32bit j = 0; j != OVERWRITE_PASSES; j++)
 
498
       {
 
499
       std::memset(ptr, PATTERNS[j % sizeof(PATTERNS)], n);
 
500
-      if(msync(ptr, n, MS_SYNC))
 
501
+      if(msync(MLOCK_TYPE_CAST ptr, n, MS_SYNC))
 
502
          throw MemoryMapping_Failed("Sync operation failed");
 
503
       }
 
504
    std::memset(ptr, 0, n);
 
505
-   if(msync(ptr, n, MS_SYNC))
 
506
+   if(msync(MLOCK_TYPE_CAST ptr, n, MS_SYNC))
 
507
       throw MemoryMapping_Failed("Sync operation failed");
 
508
 
 
509
-   if(munmap(ptr, n))
 
510
+   if(munmap(MLOCK_TYPE_CAST ptr, n))
 
511
       throw MemoryMapping_Failed("Could not unmap file");
 
512
    }
 
513
 
 
514
diff -ur a/modules/mux_qt/mux_qt.cpp b/modules/mux_qt/mux_qt.cpp
 
515
--- a/modules/mux_qt/mux_qt.cpp 2007-03-24 11:51:37.000000000 -0700
 
516
+++ b/modules/mux_qt/mux_qt.cpp 2007-06-26 11:32:30.000000000 -0700
 
517
@@ -6,7 +6,7 @@
 
518
 #include <botan/mux_qt.h>
 
519
 #include <qmutex.h>
 
520
 
 
521
-#if !defined(QT_THREAD_SUPPORT)
 
522
+#if QT_VERSION <= 0x040000 && !defined(QT_THREAD_SUPPORT)
 
523
    #error Your version of Qt does not support threads or mutexes
 
524
 #endif
 
525
 
 
526
diff -ur a/src/big_code.cpp b/src/big_code.cpp
 
527
--- a/src/big_code.cpp  2007-03-24 11:51:37.000000000 -0700
 
528
+++ b/src/big_code.cpp  2007-06-26 11:31:30.000000000 -0700
 
529
@@ -6,7 +6,9 @@
 
530
 #include <botan/bigint.h>
 
531
 #include <botan/numthry.h>
 
532
 #include <botan/charset.h>
 
533
+#ifndef BOTAN_MINIMAL_BIGINT
 
534
 #include <botan/hex.h>
 
535
+#endif
 
536
 
 
537
 namespace Botan {
 
538
 
 
539
@@ -17,6 +19,7 @@
 
540
    {
 
541
    if(base == Binary)
 
542
       n.binary_encode(output);
 
543
+#ifndef BOTAN_MINIMAL_BIGINT
 
544
    else if(base == Hexadecimal)
 
545
       {
 
546
       SecureVector<byte> binary(n.encoded_size(Binary));
 
547
@@ -24,6 +27,7 @@
 
548
       for(u32bit j = 0; j != binary.size(); ++j)
 
549
          Hex_Encoder::encode(binary[j], output + 2*j);
 
550
       }
 
551
+#endif
 
552
    else if(base == Octal)
 
553
       {
 
554
       BigInt copy = n;
 
555
@@ -46,7 +50,15 @@
 
556
          output[output_size - 1 - j] =
 
557
             Charset::digit2char(remainder.word_at(0));
 
558
          if(copy.is_zero())
 
559
+            {
 
560
+            if(j < output_size - 1)
 
561
+               {
 
562
+               int extra = output_size - 1 - j;
 
563
+               memmove(output, output + extra, output_size - extra);
 
564
+               memset(output + output_size - extra, 0, extra);
 
565
+               }
 
566
             break;
 
567
+            }
 
568
          }
 
569
       }
 
570
    else
 
571
@@ -99,6 +111,7 @@
 
572
    BigInt r;
 
573
    if(base == Binary)
 
574
       r.binary_decode(buf, length);
 
575
+#ifndef BOTAN_MINIMAL_BIGINT
 
576
    else if(base == Hexadecimal)
 
577
       {
 
578
       SecureVector<byte> hex;
 
579
@@ -119,6 +132,7 @@
 
580
          binary[j] = Hex_Decoder::decode(hex+2*j-offset);
 
581
       r.binary_decode(binary, binary.size());
 
582
       }
 
583
+#endif
 
584
    else if(base == Decimal || base == Octal)
 
585
       {
 
586
       const u32bit RADIX = ((base == Decimal) ? 10 : 8);
 
587
diff -ur a/src/big_io.cpp b/src/big_io.cpp
 
588
--- a/src/big_io.cpp    2007-03-24 11:51:37.000000000 -0700
 
589
+++ b/src/big_io.cpp    2007-06-26 11:31:30.000000000 -0700
 
590
@@ -8,6 +8,8 @@
 
591
 
 
592
 namespace Botan {
 
593
 
 
594
+#ifndef BOTAN_MINIMAL_BIGINT
 
595
+
 
596
 /*************************************************
 
597
 * Write the BigInt into a stream                 *
 
598
 *************************************************/
 
599
@@ -49,4 +51,6 @@
 
600
    return stream;
 
601
    }
 
602
 
 
603
+#endif
 
604
+
 
605
 }
 
606
diff -ur a/src/big_ops2.cpp b/src/big_ops2.cpp
 
607
--- a/src/big_ops2.cpp  2007-03-24 11:51:37.000000000 -0700
 
608
+++ b/src/big_ops2.cpp  2007-06-26 11:31:30.000000000 -0700
 
609
@@ -19,7 +19,11 @@
 
610
    {
 
611
    const u32bit x_sw = sig_words(), y_sw = y.sig_words();
 
612
 
 
613
+#ifdef BOTAN_TYPES_QT
 
614
+   const u32bit reg_size = qMax(x_sw, y_sw) + 1;
 
615
+#else
 
616
    const u32bit reg_size = std::max(x_sw, y_sw) + 1;
 
617
+#endif
 
618
    grow_to(reg_size);
 
619
 
 
620
    if((sign() == y.sign()))
 
621
@@ -56,7 +60,11 @@
 
622
 
 
623
    s32bit relative_size = bigint_cmp(data(), x_sw, y.data(), y_sw);
 
624
 
 
625
+#ifdef BOTAN_TYPES_QT
 
626
+   const u32bit reg_size = qMax(x_sw, y_sw) + 1;
 
627
+#else
 
628
    const u32bit reg_size = std::max(x_sw, y_sw) + 1;
 
629
+#endif
 
630
    grow_to(reg_size);
 
631
 
 
632
    if(relative_size < 0)
 
633
diff -ur a/src/big_ops3.cpp b/src/big_ops3.cpp
 
634
--- a/src/big_ops3.cpp  2007-03-24 11:51:37.000000000 -0700
 
635
+++ b/src/big_ops3.cpp  2007-06-26 11:31:30.000000000 -0700
 
636
@@ -18,7 +18,11 @@
 
637
    {
 
638
    const u32bit x_sw = x.sig_words(), y_sw = y.sig_words();
 
639
 
 
640
+#ifdef BOTAN_TYPES_QT
 
641
+   BigInt z(x.sign(), qMax(x_sw, y_sw) + 1);
 
642
+#else
 
643
    BigInt z(x.sign(), std::max(x_sw, y_sw) + 1);
 
644
+#endif
 
645
 
 
646
    if((x.sign() == y.sign()))
 
647
       bigint_add3(z.get_reg(), x.data(), x_sw, y.data(), y_sw);
 
648
@@ -49,7 +53,11 @@
 
649
 
 
650
    s32bit relative_size = bigint_cmp(x.data(), x_sw, y.data(), y_sw);
 
651
 
 
652
+#ifdef BOTAN_TYPES_QT
 
653
+   BigInt z(BigInt::Positive, qMax(x_sw, y_sw) + 1);
 
654
+#else
 
655
    BigInt z(BigInt::Positive, std::max(x_sw, y_sw) + 1);
 
656
+#endif
 
657
 
 
658
    if(relative_size < 0)
 
659
       {
 
660
diff -ur a/src/charset.cpp b/src/charset.cpp
 
661
--- a/src/charset.cpp   2007-03-24 11:51:37.000000000 -0700
 
662
+++ b/src/charset.cpp   2007-06-26 11:31:30.000000000 -0700
 
663
@@ -4,10 +4,15 @@
 
664
 *************************************************/
 
665
 
 
666
 #include <botan/charset.h>
 
667
+#ifdef BOTAN_TOOLS_ONLY
 
668
+#include <botan/exceptn.h>
 
669
+#else
 
670
 #include <botan/hex.h>
 
671
 #include <botan/base64.h>
 
672
+#endif
 
673
 #include <botan/libstate.h>
 
674
 #include <cctype>
 
675
+#include <ctype.h>
 
676
 
 
677
 namespace Botan {
 
678
 
 
679
@@ -16,11 +21,13 @@
 
680
 /*************************************************
 
681
 * Perform character set transcoding              *
 
682
 *************************************************/
 
683
+#ifndef BOTAN_TOOLS_ONLY
 
684
 std::string transcode(const std::string& str,
 
685
                       Character_Set to, Character_Set from)
 
686
    {
 
687
    return global_state().transcode(str, to, from);
 
688
    }
 
689
+#endif
 
690
 
 
691
 /*************************************************
 
692
 * Check if a character represents a digit        *
 
693
@@ -92,11 +99,13 @@
 
694
 *************************************************/
 
695
 bool caseless_cmp(char a, char b)
 
696
    {
 
697
-   return (std::tolower((unsigned char)a) == std::tolower((unsigned char)b));
 
698
+   return (tolower((unsigned char)a) == tolower((unsigned char)b));
 
699
    }
 
700
 
 
701
 }
 
702
 
 
703
+#ifndef BOTAN_TOOLS_ONLY
 
704
+
 
705
 /*************************************************
 
706
 * Hex Encoder Lookup Tables                      *
 
707
 *************************************************/
 
708
@@ -168,4 +177,6 @@
 
709
 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
 
710
 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
 
711
 
 
712
+#endif
 
713
+
 
714
 }
 
715
diff -ur a/src/defalloc.cpp b/src/defalloc.cpp
 
716
--- a/src/defalloc.cpp  2007-03-24 11:51:37.000000000 -0700
 
717
+++ b/src/defalloc.cpp  2007-06-26 11:31:30.000000000 -0700
 
718
@@ -8,6 +8,8 @@
 
719
 #include <botan/util.h>
 
720
 #include <cstdlib>
 
721
 #include <cstring>
 
722
+#include <stdlib.h>
 
723
+#include <string.h>
 
724
 
 
725
 namespace Botan {
 
726
 
 
727
@@ -18,7 +20,7 @@
 
728
 *************************************************/
 
729
 void* do_malloc(u32bit n, bool do_lock)
 
730
    {
 
731
-   void* ptr = std::malloc(n);
 
732
+   void* ptr = malloc(n);
 
733
 
 
734
    if(!ptr)
 
735
       return 0;
 
736
@@ -26,7 +28,7 @@
 
737
    if(do_lock)
 
738
       lock_mem(ptr, n);
 
739
 
 
740
-   std::memset(ptr, 0, n);
 
741
+   memset(ptr, 0, n);
 
742
    return ptr;
 
743
    }
 
744
 
 
745
@@ -38,11 +40,11 @@
 
746
    if(!ptr)
 
747
       return;
 
748
 
 
749
-   std::memset(ptr, 0, n);
 
750
+   memset(ptr, 0, n);
 
751
    if(do_lock)
 
752
       unlock_mem(ptr, n);
 
753
 
 
754
-   std::free(ptr);
 
755
+   free(ptr);
 
756
    }
 
757
 
 
758
 }
 
759
diff -ur a/src/libstate.cpp b/src/libstate.cpp
 
760
--- a/src/libstate.cpp  2007-03-24 11:51:37.000000000 -0700
 
761
+++ b/src/libstate.cpp  2007-06-26 11:31:30.000000000 -0700
 
762
@@ -4,14 +4,20 @@
 
763
 *************************************************/
 
764
 
 
765
 #include <botan/libstate.h>
 
766
+#ifndef BOTAN_TOOLS_ONLY
 
767
 #include <botan/config.h>
 
768
+#endif
 
769
 #include <botan/modules.h>
 
770
+#ifndef BOTAN_TOOLS_ONLY
 
771
 #include <botan/engine.h>
 
772
 #include <botan/x509stat.h>
 
773
+#endif
 
774
 #include <botan/stl_util.h>
 
775
 #include <botan/mutex.h>
 
776
+#ifndef BOTAN_TOOLS_ONLY
 
777
 #include <botan/timers.h>
 
778
 #include <botan/charset.h>
 
779
+#endif
 
780
 #include <algorithm>
 
781
 
 
782
 namespace Botan {
 
783
@@ -56,10 +62,12 @@
 
784
 /*************************************************
 
785
 * Increment the Engine iterator                  *
 
786
 *************************************************/
 
787
+#ifndef BOTAN_TOOLS_ONLY
 
788
 Engine* Library_State::Engine_Iterator::next()
 
789
    {
 
790
    return lib.get_engine_n(n++);
 
791
    }
 
792
+#endif
 
793
 
 
794
 /*************************************************
 
795
 * Get a new mutex object                         *
 
796
@@ -92,8 +100,11 @@
 
797
 
 
798
    if(!cached_default_allocator)
 
799
       {
 
800
+#ifdef BOTAN_TOOLS_ONLY
 
801
+      std::string chosen = default_allocator_type;
 
802
+#else
 
803
       std::string chosen = config().option("base/default_allocator");
 
804
-
 
805
+#endif
 
806
       if(chosen == "")
 
807
          chosen = "malloc";
 
808
 
 
809
@@ -120,17 +131,26 @@
 
810
 /*************************************************
 
811
 * Set the default allocator type                 *
 
812
 *************************************************/
 
813
+#ifdef BOTAN_TOOLS_ONLY
 
814
+void Library_State::set_default_allocator(const std::string& type)
 
815
+#else
 
816
 void Library_State::set_default_allocator(const std::string& type) const
 
817
+#endif
 
818
    {
 
819
    Named_Mutex_Holder lock("allocator");
 
820
 
 
821
    if(type == "")
 
822
       return;
 
823
 
 
824
+#ifdef BOTAN_TOOLS_ONLY
 
825
+   default_allocator_type = type;
 
826
+#else
 
827
    config().set("conf", "base/default_allocator", type);
 
828
+#endif
 
829
    cached_default_allocator = 0;
 
830
    }
 
831
 
 
832
+#ifndef BOTAN_TOOLS_ONLY
 
833
 /*************************************************
 
834
 * Set the high resolution clock implementation   *
 
835
 *************************************************/
 
836
@@ -317,13 +337,17 @@
 
837
    return (*config_obj);
 
838
    }
 
839
 
 
840
+#endif
 
841
+
 
842
 /*************************************************
 
843
 * Load modules                                   *
 
844
 *************************************************/
 
845
 void Library_State::load(Modules& modules)
 
846
    {
 
847
+#ifndef BOTAN_TOOLS_ONLY
 
848
    set_timer(modules.timer());
 
849
    set_transcoder(modules.transcoder());
 
850
+#endif
 
851
 
 
852
    std::vector<Allocator*> mod_allocs = modules.allocators();
 
853
    for(u32bit j = 0; j != mod_allocs.size(); j++)
 
854
@@ -331,6 +355,7 @@
 
855
 
 
856
    set_default_allocator(modules.default_allocator());
 
857
 
 
858
+#ifndef BOTAN_TOOLS_ONLY
 
859
    std::vector<Engine*> mod_engines = modules.engines();
 
860
    for(u32bit j = 0; j != mod_engines.size(); ++j)
 
861
       {
 
862
@@ -341,6 +366,7 @@
 
863
    std::vector<EntropySource*> sources = modules.entropy_sources();
 
864
    for(u32bit j = 0; j != sources.size(); ++j)
 
865
       add_entropy_source(sources[j]);
 
866
+#endif
 
867
    }
 
868
 
 
869
 /*************************************************
 
870
@@ -352,25 +378,39 @@
 
871
       throw Exception("Library_State: no mutex found");
 
872
 
 
873
    this->mutex_factory = mutex_factory;
 
874
+#ifndef BOTAN_TOOLS_ONLY
 
875
    this->timer = new Timer();
 
876
    this->transcoder = 0;
 
877
    this->config_obj = new Config();
 
878
+#endif
 
879
 
 
880
+#ifndef BOTAN_TOOLS_ONLY
 
881
    locks["settings"] = get_mutex();
 
882
+#endif
 
883
    locks["allocator"] = get_mutex();
 
884
+#ifndef BOTAN_TOOLS_ONLY
 
885
    locks["rng"] = get_mutex();
 
886
    locks["engine"] = get_mutex();
 
887
    rng = 0;
 
888
+#endif
 
889
    cached_default_allocator = 0;
 
890
+#ifndef BOTAN_TOOLS_ONLY
 
891
    x509_state_obj = 0;
 
892
    ui = 0;
 
893
+#endif
 
894
    }
 
895
 
 
896
 /*************************************************
 
897
 * Library_State Destructor                       *
 
898
 *************************************************/
 
899
+static void delete_lock(std::pair<const std::string, Mutex*> &pair)
 
900
+   {
 
901
+   delete pair.second;
 
902
+   }
 
903
+
 
904
 Library_State::~Library_State()
 
905
    {
 
906
+#ifndef BOTAN_TOOLS_ONLY
 
907
    delete x509_state_obj;
 
908
    delete transcoder;
 
909
    delete rng;
 
910
@@ -381,6 +421,7 @@
 
911
    std::for_each(entropy_sources.begin(), entropy_sources.end(),
 
912
                  del_fun<EntropySource>());
 
913
    std::for_each(engines.begin(), engines.end(), del_fun<Engine>());
 
914
+#endif
 
915
 
 
916
    cached_default_allocator = 0;
 
917
 
 
918
@@ -390,8 +431,7 @@
 
919
       delete allocators[j];
 
920
       }
 
921
 
 
922
-   std::for_each(locks.begin(), locks.end(),
 
923
-                 delete2nd<std::map<std::string, Mutex*>::value_type>);
 
924
+   std::for_each(locks.begin(), locks.end(), delete_lock);
 
925
 
 
926
    delete mutex_factory;
 
927
    }
 
928
diff -ur a/src/mem_pool.cpp b/src/mem_pool.cpp
 
929
--- a/src/mem_pool.cpp  2007-03-24 11:51:37.000000000 -0700
 
930
+++ b/src/mem_pool.cpp  2007-06-26 11:31:30.000000000 -0700
 
931
@@ -5,8 +5,12 @@
 
932
 
 
933
 #include <botan/mem_pool.h>
 
934
 #include <botan/libstate.h>
 
935
+#ifdef BOTAN_TOOLS_ONLY
 
936
+#include <botan/mem_ops.h>
 
937
+#else
 
938
 #include <botan/config.h>
 
939
 #include <botan/bit_ops.h>
 
940
+#endif
 
941
 #include <botan/util.h>
 
942
 #include <algorithm>
 
943
 
 
944
@@ -22,7 +26,11 @@
 
945
    if(provided)
 
946
       return provided;
 
947
 
 
948
+#ifdef BOTAN_TOOLS_ONLY
 
949
+   u32bit result = (u32bit)global_state().prealloc_size;
 
950
+#else
 
951
    u32bit result = global_config().option_as_u32bit("base/memory_chunk");
 
952
+#endif
 
953
    if(result)
 
954
       return result;
 
955
 
 
956
@@ -42,16 +50,6 @@
 
957
    }
 
958
 
 
959
 /*************************************************
 
960
-* Compare a Memory_Block with a void pointer     *
 
961
-*************************************************/
 
962
-inline bool Pooling_Allocator::Memory_Block::operator<(const void* other) const
 
963
-   {
 
964
-   if(buffer <= other && other < buffer_end)
 
965
-      return false;
 
966
-   return (buffer < other);
 
967
-   }
 
968
-
 
969
-/*************************************************
 
970
 * See if ptr is contained by this block          *
 
971
 *************************************************/
 
972
 bool Pooling_Allocator::Memory_Block::contains(void* ptr,
 
973
@@ -207,7 +205,7 @@
 
974
       const u32bit block_no = round_up(n, BLOCK_SIZE) / BLOCK_SIZE;
 
975
 
 
976
       std::vector<Memory_Block>::iterator i =
 
977
-         std::lower_bound(blocks.begin(), blocks.end(), ptr);
 
978
+         std::lower_bound(blocks.begin(), blocks.end(), Memory_Block(ptr));
 
979
 
 
980
       if(i == blocks.end() || !i->contains(ptr, block_no))
 
981
          throw Invalid_State("Pointer released to the wrong allocator");
 
982
@@ -270,7 +268,10 @@
 
983
       }
 
984
 
 
985
    std::sort(blocks.begin(), blocks.end());
 
986
-   last_used = std::lower_bound(blocks.begin(), blocks.end(), ptr);
 
987
+   last_used = std::lower_bound(blocks.begin(), blocks.end(), Memory_Block(ptr));
 
988
    }
 
989
 
 
990
+const u32bit Pooling_Allocator::Memory_Block::BITMAP_SIZE = 8 * sizeof(Pooling_Allocator::Memory_Block::bitmap_type);
 
991
+const u32bit Pooling_Allocator::Memory_Block::BLOCK_SIZE = 64;
 
992
+
 
993
 }
 
994
diff -ur a/src/modules.cpp b/src/modules.cpp
 
995
--- a/src/modules.cpp   2007-03-24 11:51:37.000000000 -0700
 
996
+++ b/src/modules.cpp   2007-06-26 11:31:30.000000000 -0700
 
997
@@ -5,71 +5,77 @@
 
998
 
 
999
 #include <botan/modules.h>
 
1000
 #include <botan/defalloc.h>
 
1001
+#ifndef BOTAN_TOOLS_ONLY
 
1002
 #include <botan/def_char.h>
 
1003
 #include <botan/eng_def.h>
 
1004
 #include <botan/es_file.h>
 
1005
 #include <botan/timers.h>
 
1006
+#endif
 
1007
 
 
1008
 #if defined(BOTAN_EXT_MUTEX_PTHREAD)
 
1009
-  #include <botan/mux_pthr.h>
 
1010
+#  include <botan/mux_pthr.h>
 
1011
 #elif defined(BOTAN_EXT_MUTEX_WIN32)
 
1012
-  #include <botan/mux_win32.h>
 
1013
+#  include <botan/mux_win32.h>
 
1014
 #elif defined(BOTAN_EXT_MUTEX_QT)
 
1015
-  #include <botan/mux_qt.h>
 
1016
+#  include <botan/mux_qt.h>
 
1017
 #endif
 
1018
 
 
1019
 #if defined(BOTAN_EXT_ALLOC_MMAP)
 
1020
-  #include <botan/mmap_mem.h>
 
1021
+#  include <botan/mmap_mem.h>
 
1022
 #endif
 
1023
 
 
1024
+#ifndef BOTAN_TOOLS_ONLY
 
1025
+
 
1026
 #if defined(BOTAN_EXT_TIMER_HARDWARE)
 
1027
-  #include <botan/tm_hard.h>
 
1028
+#  include <botan/tm_hard.h>
 
1029
 #elif defined(BOTAN_EXT_TIMER_POSIX)
 
1030
-  #include <botan/tm_posix.h>
 
1031
+#  include <botan/tm_posix.h>
 
1032
 #elif defined(BOTAN_EXT_TIMER_UNIX)
 
1033
-  #include <botan/tm_unix.h>
 
1034
+#  include <botan/tm_unix.h>
 
1035
 #elif defined(BOTAN_EXT_TIMER_WIN32)
 
1036
-  #include <botan/tm_win32.h>
 
1037
+#  include <botan/tm_win32.h>
 
1038
 #endif
 
1039
 
 
1040
 #if defined(BOTAN_EXT_ENGINE_AEP)
 
1041
-  #include <botan/eng_aep.h>
 
1042
+#  include <botan/eng_aep.h>
 
1043
 #endif
 
1044
 
 
1045
 #if defined(BOTAN_EXT_ENGINE_GNU_MP)
 
1046
-  #include <botan/eng_gmp.h>
 
1047
+#  include <botan/eng_gmp.h>
 
1048
 #endif
 
1049
 
 
1050
 #if defined(BOTAN_EXT_ENGINE_OPENSSL)
 
1051
-  #include <botan/eng_ossl.h>
 
1052
+#  include <botan/eng_ossl.h>
 
1053
 #endif
 
1054
 
 
1055
 #if defined(BOTAN_EXT_ENTROPY_SRC_AEP)
 
1056
-  #include <botan/es_aep.h>
 
1057
+#  include <botan/es_aep.h>
 
1058
 #endif
 
1059
 
 
1060
 #if defined(BOTAN_EXT_ENTROPY_SRC_EGD)
 
1061
-  #include <botan/es_egd.h>
 
1062
+#  include <botan/es_egd.h>
 
1063
 #endif
 
1064
 
 
1065
 #if defined(BOTAN_EXT_ENTROPY_SRC_UNIX)
 
1066
-  #include <botan/es_unix.h>
 
1067
+#  include <botan/es_unix.h>
 
1068
 #endif
 
1069
 
 
1070
 #if defined(BOTAN_EXT_ENTROPY_SRC_BEOS)
 
1071
-  #include <botan/es_beos.h>
 
1072
+#  include <botan/es_beos.h>
 
1073
 #endif
 
1074
 
 
1075
 #if defined(BOTAN_EXT_ENTROPY_SRC_CAPI)
 
1076
-  #include <botan/es_capi.h>
 
1077
+#  include <botan/es_capi.h>
 
1078
 #endif
 
1079
 
 
1080
 #if defined(BOTAN_EXT_ENTROPY_SRC_WIN32)
 
1081
-  #include <botan/es_win32.h>
 
1082
+#  include <botan/es_win32.h>
 
1083
 #endif
 
1084
 
 
1085
 #if defined(BOTAN_EXT_ENTROPY_SRC_FTW)
 
1086
-  #include <botan/es_ftw.h>
 
1087
+#  include <botan/es_ftw.h>
 
1088
+#endif
 
1089
+
 
1090
 #endif
 
1091
 
 
1092
 namespace Botan {
 
1093
@@ -93,6 +99,7 @@
 
1094
 /*************************************************
 
1095
 * Find a high resolution timer, if possible      *
 
1096
 *************************************************/
 
1097
+#ifndef BOTAN_TOOLS_ONLY
 
1098
 Timer* Builtin_Modules::timer() const
 
1099
    {
 
1100
 #if defined(BOTAN_EXT_TIMER_HARDWARE)
 
1101
@@ -107,6 +114,7 @@
 
1102
    return new Timer;
 
1103
 #endif
 
1104
    }
 
1105
+#endif
 
1106
 
 
1107
 /*************************************************
 
1108
 * Find any usable allocators                     *
 
1109
@@ -142,6 +150,8 @@
 
1110
       return "malloc";
 
1111
    }
 
1112
 
 
1113
+#ifndef BOTAN_TOOLS_ONLY
 
1114
+
 
1115
 /*************************************************
 
1116
 * Register any usable entropy sources            *
 
1117
 *************************************************/
 
1118
@@ -217,13 +227,22 @@
 
1119
    return new Default_Charset_Transcoder;
 
1120
    }
 
1121
 
 
1122
+#endif
 
1123
+
 
1124
 /*************************************************
 
1125
 * Builtin_Modules Constructor                    *
 
1126
 *************************************************/
 
1127
+#ifdef BOTAN_TOOLS_ONLY
 
1128
+Builtin_Modules::Builtin_Modules() :
 
1129
+   should_lock(true)
 
1130
+   {
 
1131
+   }
 
1132
+#else
 
1133
 Builtin_Modules::Builtin_Modules(const InitializerOptions& args) :
 
1134
    should_lock(args.secure_memory()),
 
1135
    use_engines(args.use_engines())
 
1136
    {
 
1137
    }
 
1138
+#endif
 
1139
 
 
1140
 }
 
1141
diff -ur a/src/mp_asm.cpp b/src/mp_asm.cpp
 
1142
--- a/src/mp_asm.cpp    2007-03-24 11:51:37.000000000 -0700
 
1143
+++ b/src/mp_asm.cpp    2007-06-26 11:31:30.000000000 -0700
 
1144
@@ -174,6 +174,7 @@
 
1145
 /*************************************************
 
1146
 * Montgomery Reduction Algorithm                 *
 
1147
 *************************************************/
 
1148
+#ifndef BOTAN_MINIMAL_BIGINT
 
1149
 void bigint_monty_redc(word z[], u32bit z_size,
 
1150
                        const word x[], u32bit x_size, word u)
 
1151
    {
 
1152
@@ -199,6 +200,7 @@
 
1153
    if(bigint_cmp(z + x_size, x_size + 1, x, x_size) >= 0)
 
1154
       bigint_sub2(z + x_size, x_size + 1, x, x_size);
 
1155
    }
 
1156
+#endif
 
1157
 
 
1158
 }
 
1159
 
 
1160
diff -ur a/src/mutex.cpp b/src/mutex.cpp
 
1161
--- a/src/mutex.cpp     2007-03-24 11:51:37.000000000 -0700
 
1162
+++ b/src/mutex.cpp     2007-08-20 07:53:57.000000000 -0700
 
1163
@@ -3,8 +3,11 @@
 
1164
 * (C) 1999-2007 The Botan Project                *
 
1165
 *************************************************/
 
1166
 
 
1167
+#include <stdlib.h>
 
1168
 #include <botan/mutex.h>
 
1169
+#ifndef BOTAN_NO_LIBSTATE
 
1170
 #include <botan/libstate.h>
 
1171
+#endif
 
1172
 
 
1173
 namespace Botan {
 
1174
 
 
1175
@@ -26,6 +29,7 @@
 
1176
    mux->unlock();
 
1177
    }
 
1178
 
 
1179
+#ifndef BOTAN_NO_LIBSTATE
 
1180
 /*************************************************
 
1181
 * Named_Mutex_Holder Constructor                 *
 
1182
 *************************************************/
 
1183
@@ -42,12 +46,17 @@
 
1184
    {
 
1185
    global_state().get_named_mutex(mutex_name)->unlock();
 
1186
    }
 
1187
+#endif
 
1188
 
 
1189
 /*************************************************
 
1190
 * Default Mutex Factory                          *
 
1191
 *************************************************/
 
1192
+#ifdef BOTAN_FIX_GDB
 
1193
+namespace {
 
1194
+#else
 
1195
 Mutex* Default_Mutex_Factory::make()
 
1196
    {
 
1197
+#endif
 
1198
    class Default_Mutex : public Mutex
 
1199
       {
 
1200
       public:
 
1201
@@ -78,6 +87,12 @@
 
1202
          bool locked;
 
1203
       };
 
1204
 
 
1205
+#ifdef BOTAN_FIX_GDB
 
1206
+   } // end unnamed namespace
 
1207
+Mutex* Default_Mutex_Factory::make()
 
1208
+   {
 
1209
+#endif
 
1210
+
 
1211
    return new Default_Mutex;
 
1212
    }
 
1213
 
 
1214
diff -ur a/src/parsing.cpp b/src/parsing.cpp
 
1215
--- a/src/parsing.cpp   2007-03-24 11:51:37.000000000 -0700
 
1216
+++ b/src/parsing.cpp   2007-06-26 11:31:30.000000000 -0700
 
1217
@@ -12,6 +12,7 @@
 
1218
 /*************************************************
 
1219
 * Convert a string into an integer               *
 
1220
 *************************************************/
 
1221
+#ifndef BOTAN_TOOLS_ONLY
 
1222
 u32bit to_u32bit(const std::string& number)
 
1223
    {
 
1224
    u32bit n = 0;
 
1225
@@ -29,7 +30,7 @@
 
1226
       }
 
1227
    return n;
 
1228
    }
 
1229
-
 
1230
+#endif
 
1231
 
 
1232
 /*************************************************
 
1233
 * Convert an integer into a string               *
 
1234
@@ -54,6 +55,7 @@
 
1235
    return lenstr;
 
1236
    }
 
1237
 
 
1238
+#ifndef BOTAN_TOOLS_ONLY
 
1239
 /*************************************************
 
1240
 * Parse a SCAN-style algorithm name              *
 
1241
 *************************************************/
 
1242
@@ -237,5 +239,6 @@
 
1243
    else
 
1244
       return to_u32bit(expr);
 
1245
    }
 
1246
+#endif
 
1247
 
 
1248
 }
 
1249
diff -ur a/src/util.cpp b/src/util.cpp
 
1250
--- a/src/util.cpp      2007-03-24 11:51:37.000000000 -0700
 
1251
+++ b/src/util.cpp      2007-06-26 11:31:30.000000000 -0700
 
1252
@@ -4,7 +4,9 @@
 
1253
 *************************************************/
 
1254
 
 
1255
 #include <botan/util.h>
 
1256
+#ifndef BOTAN_TOOLS_ONLY
 
1257
 #include <botan/bit_ops.h>
 
1258
+#endif
 
1259
 #include <algorithm>
 
1260
 #include <cmath>
 
1261
 
 
1262
@@ -28,6 +30,7 @@
 
1263
    return (n - (n % align_to));
 
1264
    }
 
1265
 
 
1266
+#ifndef BOTAN_TOOLS_ONLY
 
1267
 /*************************************************
 
1268
 * Return the work required for solving DL        *
 
1269
 *************************************************/
 
1270
@@ -77,5 +80,6 @@
 
1271
 
 
1272
    return (estimate / 2);
 
1273
    }
 
1274
+#endif
 
1275
 
 
1276
 }