summaryrefslogtreecommitdiff
blob: 448af31a8966d519963af3a2b25a4ca6856c871f (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
diff -NrU5 postal-0.69.orig/bhm.cpp postal-0.69/bhm.cpp
--- postal-0.69.orig/bhm.cpp	2008-04-23 22:39:01.000000000 +0200
+++ postal-0.69/bhm.cpp	2008-04-24 01:31:54.000000000 +0200
@@ -7,10 +7,11 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <stdio.h>
+#include <cstdlib>
 #include <sys/poll.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/ip.h>
diff -NrU5 postal-0.69.orig/bhmusers.cpp postal-0.69/bhmusers.cpp
--- postal-0.69.orig/bhmusers.cpp	2008-04-10 03:36:27.000000000 +0200
+++ postal-0.69/bhmusers.cpp	2008-04-24 00:04:07.000000000 +0200
@@ -1,9 +1,10 @@
 #include "bhmusers.h"
 #include <stdio.h>
 #include <cstring>
 #include "expand.h"
+#include <cstdlib>
 
 BHMUsers::BHMUsers(const char *userListFile)
 {
   char buf[1024];
   FILE *fp = fopen(userListFile, "r");
diff -NrU5 postal-0.69.orig/bhmusers.h postal-0.69/bhmusers.h
--- postal-0.69.orig/bhmusers.h	2006-09-28 17:20:28.000000000 +0200
+++ postal-0.69/bhmusers.h	2008-04-24 00:14:05.000000000 +0200
@@ -4,16 +4,21 @@
 using namespace std;
 
 #include <string>
 #include "conf.h"
 
+#if (defined HAVE_STDCXX_0X) || (__cplusplus >= 201103L)
+#include <unordered_map>
+#include <tr1/functional_hash.h>
+#else
 #ifdef HAVE_EXT_HASH_MAP
 using namespace __gnu_cxx;
 #include <ext/hash_map>
 #else
 #include <hash_map.h>
 #endif
+#endif
 
 #include "postal.h"
 
 typedef enum { eNone = 0, eDefer, eReject, eBounce, eGrey } USER_SMTP_ACTION;
 
@@ -21,10 +26,13 @@
 {
   USER_SMTP_ACTION action;
   int sync_time;
 } BHM_DATA;
 
+#if (defined HAVE_STDCXX_0X) || (__cplusplus >= 201103L)
+typedef unordered_map<string, BHM_DATA , hash<string> > NAME_MAP;
+#else
 namespace __gnu_cxx
 {
   template<> struct hash< std::string >
   {
     size_t operator() ( const std::string &x ) const
@@ -33,10 +41,11 @@
     }
   };
 }
 
 typedef hash_map<string, BHM_DATA , hash<string> > NAME_MAP;
+#endif
 
 class BHMUsers
 {
 public:
   BHMUsers(const char *userListFile);
diff -NrU5 postal-0.69.orig/configure.in postal-0.69/configure.in
--- postal-0.69.orig/configure.in	2008-04-23 22:39:01.000000000 +0200
+++ postal-0.69/configure.in	2008-04-24 01:20:35.000000000 +0200
@@ -155,6 +155,98 @@
 
 AC_CHECK_HEADERS(vector ext/hash_map)
 
 dnl Checks for library functions.
 
+AC_DEFUN([AC_COMPILE_STDCXX_0X], [
+  AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
+  ac_cv_cxx_compile_cxx0x_native,
+  [AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  AC_TRY_COMPILE([
+  template <typename T>
+    struct check 
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = c;],,
+  ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
+  AC_LANG_RESTORE
+  ])
+
+  AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
+  ac_cv_cxx_compile_cxx0x_cxx,
+  [AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=c++0x"       
+  AC_TRY_COMPILE([
+  template <typename T>
+    struct check 
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = c;],,
+  ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+  ])
+
+  AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
+  ac_cv_cxx_compile_cxx0x_gxx,
+  [AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  ac_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS -std=gnu++0x"     
+  AC_TRY_COMPILE([
+  template <typename T>
+    struct check 
+    {
+      static_assert(sizeof(int) <= sizeof(T), "not big enough");
+    };
+
+    typedef check<check<bool>> right_angle_brackets;
+
+    int a;
+    decltype(a) b;
+
+    typedef check<int> check_type;
+    check_type c;
+    check_type&& cr = c;],,
+  ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
+  CXXFLAGS="$ac_save_CXXFLAGS"
+  AC_LANG_RESTORE
+  ])
+
+  if test "$ac_cv_cxx_compile_cxx0x_native" = yes || 
+     test "$ac_cv_cxx_compile_cxx0x_cxx" = yes || 
+     test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
+    AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
+  fi
+])
+
+AC_COMPILE_STDCXX_0X
+
+AC_SUBST(cstd)
+cstd=
+if test "$ac_cv_cxx_compile_cxx0x_cxx" = yes; then
+	cstd=-std=c++0x
+fi
+
 AC_OUTPUT(Makefile postal.h port.h postal.spec sun/pkginfo)
+
diff -NrU5 postal-0.69.orig/Makefile.in postal-0.69/Makefile.in
--- postal-0.69.orig/Makefile.in	2008-04-23 22:39:01.000000000 +0200
+++ postal-0.69/Makefile.in	2008-04-24 00:29:40.000000000 +0200
@@ -8,12 +8,12 @@
 prefix=@prefix@
 eprefix=@exec_prefix@
 WFLAGS=-Wall -W -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wcast-qual -pedantic
 WPLUS=-Woverloaded-virtual -ffor-scope
 
-CXX=@CXX@ $(CFLAGS) -O2 -g $(WFLAGS) $(WPLUS)
-CC=@CC@ $(CFLAGS) -O2 -g $(WFLAGS)
+CXX=@CXX@ @cstd@ $(CFLAGS) $(WFLAGS) $(WPLUS)
+CC=@CC@ $(CFLAGS) $(WFLAGS)
 
 INSTALL=@INSTALL@
 
 TESTEXE=ex-test
 BASEOBJS=userlist.o thread.o results.o address.o tcp.o cmd5.o mutex.o logit.o expand.o @extra_objs@
diff -NrU5 postal-0.69.orig/postal.cpp postal-0.69/postal.cpp
--- postal-0.69.orig/postal.cpp	2007-01-14 05:40:23.000000000 +0100
+++ postal-0.69/postal.cpp	2008-04-24 01:30:49.000000000 +0200
@@ -6,10 +6,11 @@
 #include "smtp.h"
 #include <unistd.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <stdio.h>
+#include <cstdlib>
 #include "postal.h"
 #include "logit.h"
 #ifdef USE_GNUTLS
 #include <errno.h>
 #include <gcrypt.h>
diff -NrU5 postal-0.69.orig/smtp.cpp postal-0.69/smtp.cpp
--- postal-0.69.orig/smtp.cpp	2008-04-19 00:01:39.000000000 +0200
+++ postal-0.69/smtp.cpp	2008-04-24 00:14:49.000000000 +0200
@@ -7,10 +7,11 @@
 #include <time.h>
 #include "userlist.h"
 #include "logit.h"
 #include "results.h"
 #include <cstring>
+#include <cstdlib>
 
 smtpData::smtpData()
  : m_quit("QUIT\r\n")
  , m_randomLetters("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 `~!@#$%^&*()-_=+[]{};:'\"|/?<>,")
  , m_randomLen(strlen(m_randomLetters))
diff -NrU5 postal-0.69.orig/smtp.h postal-0.69/smtp.h
--- postal-0.69.orig/smtp.h	2008-04-19 00:01:23.000000000 +0200
+++ postal-0.69/smtp.h	2008-04-24 00:18:03.000000000 +0200
@@ -4,16 +4,20 @@
 using namespace std;
 #include <string>
 #include <cstring>
 #include <time.h>
 #include "conf.h"
+#if (defined HAVE_STDCXX_0X) || (__cplusplus >= 201103L)
+#include <unordered_map>
+#else
 #ifdef HAVE_EXT_HASH_MAP
 using namespace __gnu_cxx;
 #include <ext/hash_map>
 #else
 #include <hash_map.h>
 #endif
+#endif
 #include "tcp.h"
 #include "mutex.h"
 
 class results;
 
@@ -28,11 +32,15 @@
   {
     return (l1 == l2);
   }
 };
 
+#if (defined HAVE_STDCXX_0X) || (__cplusplus >= 201103L)
+typedef unordered_map<unsigned long, string *, hash<unsigned long>, eqlng> NAME_MAP;
+#else
 typedef hash_map<unsigned long, string *, hash<unsigned long>, eqlng> NAME_MAP;
+#endif
 
 class smtpData
 {
 public:
   smtpData();