summaryrefslogtreecommitdiff
blob: d43c2cb95ea9ddb1868d4d75c3ff8ef69f9c2e60 (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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
--- a/accept-confirmation.cpp
+++ b/accept-confirmation.cpp
@@ -52,7 +52,7 @@
     for (rc = read(fd, tmp, sizeof(tmp)); rc > 0; rc = read(fd, tmp, sizeof(tmp)))
       mail.append(tmp, rc);
     if (rc < 0)
-      throw system_error(string("Failed to read mail file '") + filename + "'");
+      throw mapson_system_error(string("Failed to read mail file '") + filename + "'");
     deliver(mail);
     unlink(filename.c_str());
   }
--- a/address-db.cpp
+++ b/address-db.cpp
@@ -26,7 +26,7 @@
 
   fd = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
   if (fd < 0)
-    throw system_error(string("Can't open address db '") +
+    throw mapson_system_error(string("Can't open address db '") +
                       filename + "' for reading");
   fd_sentry sentry(fd);
 
@@ -36,7 +36,7 @@
   lock.l_start  = 0;
   lock.l_len    = 0;
   if (fcntl(fd, F_SETLKW, &lock) != 0)
-    throw system_error(string("Can't lock file '") + filename + "'");
+    throw mapson_system_error(string("Can't lock file '") + filename + "'");
 
   // Read the file into memory.
 
@@ -47,7 +47,7 @@
        rc = read(fd, buffer, sizeof(buffer)))
     data.append(buffer, rc);
   if (rc < 0)
-    throw system_error(string("Failed to read address db '") +
+    throw mapson_system_error(string("Failed to read address db '") +
                       filename + "' into memory");
 
   // Success. Don't close the file descriptor.
@@ -107,7 +107,7 @@
   {
     ssize_t rc = write(fd, data.data()+len, data.size()-len);
     if (rc < 0)
-      throw system_error(string("Failed writing to the address db '") + filename + "'");
+      throw mapson_system_error(string("Failed writing to the address db '") + filename + "'");
     else
       len += rc;
   }
--- a/config.cpp
+++ b/config.cpp
@@ -70,9 +70,9 @@
     string tmp = string(name) + "=" + value;
     char* env = strdup(tmp.c_str());
     if (env == 0)
-      throw system_error("strdup() failed");
+      throw mapson_system_error("strdup() failed");
     if (putenv(env) != 0)
-      throw system_error("putenv() failed");
+      throw mapson_system_error("putenv() failed");
   }
 }
 
@@ -84,7 +84,7 @@
 
   pwd_sentry sentry(getpwuid(getuid()));
   if (sentry.pwd == 0)
-    throw system_error("Can't get my user name");
+    throw mapson_system_error("Can't get my user name");
   log_file.assign(sentry.pwd->pw_dir).append("/.mapson/log");
   spool_dir.assign(sentry.pwd->pw_dir).append("/.mapson/spool");
   address_db.assign(sentry.pwd->pw_dir).append("/.mapson/address-db");
--- a/deliver.cpp
+++ b/deliver.cpp
@@ -31,11 +31,11 @@
 
     FILE* fh = popen(config->mailbox.c_str()+1, "w");
     if (fh == NULL)
-      throw system_error(string("Can't start delivery pipe '") + config->mailbox + "'");
+      throw mapson_system_error(string("Can't start delivery pipe '") + config->mailbox + "'");
     int len = fwrite(mail.data(), mail.size(), 1, fh);
     pclose(fh);
     if (len != 1)
-      throw system_error(string("Failed to pipe to MTA process '") + config->mailbox + "'");
+      throw mapson_system_error(string("Failed to pipe to MTA process '") + config->mailbox + "'");
   }
   else
   {
@@ -43,7 +43,7 @@
 
     int fd = open(config->mailbox.c_str(), O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
     if (fd < 0)
-      throw system_error(string("Can't open mailbox file '") + config->mailbox + "' for writing");
+      throw mapson_system_error(string("Can't open mailbox file '") + config->mailbox + "' for writing");
     fd_sentry sentry(fd);
 
     struct flock lock;
@@ -52,13 +52,13 @@
     lock.l_start  = 0;
     lock.l_len    = 0;
     if (fcntl(fd, F_SETLKW, &lock) != 0)
-      throw system_error(string("Can't lock file '") + config->mailbox + "'");
+      throw mapson_system_error(string("Can't lock file '") + config->mailbox + "'");
 
     for (size_t len = 0; len < mail.size(); )
     {
       ssize_t rc = write(fd, mail.data()+len, mail.size()-len);
       if (rc < 0)
-        throw system_error(string("Failed writing to the mailbox file '") + config->mailbox + "'");
+        throw mapson_system_error(string("Failed writing to the mailbox file '") + config->mailbox + "'");
       else
         len += rc;
     }
--- a/lines2regex.cpp
+++ b/lines2regex.cpp
@@ -29,7 +29,7 @@
     if (errno == ENOENT)
       return "";
     else
-      throw system_error(string("Can't open regex db '") +
+      throw mapson_system_error(string("Can't open regex db '") +
                         filename + "' for reading");
   }
   fd_sentry sentry(fd);
@@ -40,7 +40,7 @@
   lock.l_start  = 0;
   lock.l_len    = 0;
   if (fcntl(fd, F_SETLKW, &lock) != 0)
-    throw system_error(string("Can't lock file '") + filename + "'");
+    throw mapson_system_error(string("Can't lock file '") + filename + "'");
 
   // Read the file into memory.
 
@@ -52,7 +52,7 @@
        rc = read(fd, buffer, sizeof(buffer)))
     data.append(buffer, rc);
   if (rc < 0)
-    throw system_error(string("Failed to read regex db '") +
+    throw mapson_system_error(string("Failed to read regex db '") +
                       filename + "' into memory");
 
   // Walk through the lines and compile the regexes.
--- a/log.cpp
+++ b/log.cpp
@@ -30,10 +30,10 @@
   char buf[64];
   time_t tstamp = time(0);
   if (tstamp == static_cast<time_t>(-1))
-    throw system_error("time(2) failed");
+    throw mapson_system_error("time(2) failed");
   struct tm* tmtime = localtime(&tstamp);
   if (tmtime == 0)
-    throw system_error("localtime(3) failed");
+    throw mapson_system_error("localtime(3) failed");
   strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tmtime);
   return buf;
 }
@@ -42,7 +42,7 @@
 {
   fileh.file = fopen(file, "a");
   if (fileh.file == 0)
-    throw system_error(string("Could not open log file ") + file);
+    throw mapson_system_error(string("Could not open log file ") + file);
 
   struct flock lock;
   lock.l_type = F_WRLCK;
@@ -50,7 +50,7 @@
   lock.l_start  = 0;
   lock.l_len    = 0;
   if (fcntl(fileno(fileh.file), F_SETLKW, &lock) != 0)
-    throw system_error(string("Can't lock file '") + file + "'");
+    throw mapson_system_error(string("Can't lock file '") + file + "'");
 }
 
 void _debug(const char* fmt, ...)
--- a/mapson.cpp
+++ b/mapson.cpp
@@ -62,7 +62,7 @@
 
       fd = open(argv[i], O_RDONLY, 0);
       if (fd < 0)
-        throw system_error("Can't open file for reading");
+        throw mapson_system_error("Can't open file for reading");
       fd_sentry sentry(fd);
       string mail;
       for (rc = read(fd, buffer, sizeof(buffer));
@@ -72,7 +72,7 @@
         mail.append(buffer, rc);
       }
       if (rc < 0)
-        throw system_error("Failed to read from file");
+        throw mapson_system_error("Failed to read from file");
 
       // Extract the mail addresses.
 
@@ -196,7 +196,7 @@
     mail.append(buffer, rc);
   }
   if (rc < 0)
-    throw system_error("Failed to read mail from standard input");
+    throw mapson_system_error("Failed to read mail from standard input");
 
   // Check whether the mail contains a valid cookie. If it does,
   // mail will be replaced with the original e-mail, that was
--- a/parse-config-file.cpp
+++ b/parse-config-file.cpp
@@ -55,7 +55,7 @@
 
   std::ifstream file(filename);
   if (!file)
-    throw system_error(std::string("parse_config_file() failed to open '") + filename + "'");
+    throw mapson_system_error(std::string("parse_config_file() failed to open '") + filename + "'");
 
   // Now we read line by line and process each one seperately.
 
--- a/request-confirmation.cpp
+++ b/request-confirmation.cpp
@@ -157,7 +157,7 @@
   string filename = config->request_for_confirmation_file;
   int fd = multi_open(filename, O_RDONLY, S_IRUSR | S_IWUSR);
   if (fd < 0)
-    throw system_error(string("Can't open request-mail template file '") + filename + "' for reading");
+    throw mapson_system_error(string("Can't open request-mail template file '") + filename + "' for reading");
   fd_sentry sentry(fd);
 
   // Read the file into memory.
@@ -167,7 +167,7 @@
   for (rc = read(fd, buffer, sizeof(buffer)); rc > 0; rc = read(fd, buffer, sizeof(buffer)))
     mail_template.append(buffer, rc);
   if (rc < 0)
-    throw system_error(string("Failed to read request-mail template file '") + filename + "' into memory");
+    throw mapson_system_error(string("Failed to read request-mail template file '") + filename + "' into memory");
 
   // Expand variables in the template.
 
@@ -180,11 +180,11 @@
   debug(("Executing mail transport agent '%s'.", config->mta.c_str()));
   FILE* fh = popen(config->mta.c_str(), "w");
   if (fh == NULL)
-    throw system_error(string("Can't start MTA '") + config->mta + "'");
+    throw mapson_system_error(string("Can't start MTA '") + config->mta + "'");
   if (fwrite(mail_template.data(), mail_template.size(), 1, fh) != 1)
   {
     pclose(fh);
-    throw system_error(string("Failed to pipe to MTA process '") + config->mta + "'");
+    throw mapson_system_error(string("Failed to pipe to MTA process '") + config->mta + "'");
   }
   pclose(fh);
 }
--- a/spool.cpp
+++ b/spool.cpp
@@ -44,13 +44,13 @@
   info("Spooling e-mail '%s' as '%s'.", config->message_id.c_str(), filename.c_str());
   int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
   if (fd < 0)
-    throw system_error(string("Can't open spool file '") + filename + "' for writing");
+    throw mapson_system_error(string("Can't open spool file '") + filename + "' for writing");
   fd_sentry sentry(fd);
   for (size_t len = 0; len < mail.size(); )
   {
     ssize_t rc = write(fd, mail.data()+len, mail.size()-len);
     if (rc < 0)
-      throw system_error(string("Failed writing to the spool file '") + filename + "'");
+      throw mapson_system_error(string("Failed writing to the spool file '") + filename + "'");
     else
       len += rc;
   }
--- a/system-error.hpp
+++ b/system-error.hpp
@@ -23,14 +23,14 @@
 #include <string>
 #include <cstring>
 
-class system_error : public std::runtime_error
+class mapson_system_error : public std::runtime_error
 {
 public:
-  system_error() : runtime_error(str())
+  mapson_system_error() : runtime_error(str())
   {
   }
 
-  explicit system_error(std::string const & msg)
+  explicit mapson_system_error(std::string const & msg)
     : runtime_error(msg + ": " + str())
   {
   }