summaryrefslogtreecommitdiff
path: root/tools/greylist.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-29 16:50:11 -0700
committerJohn Denker <jsd@av8n.com>2012-07-29 16:50:11 -0700
commitd2564d25e802d1ee3230cf045c4940e836b5c6a2 (patch)
treeddc7c3feac95d01ccb859596c21f218b122060c5 /tools/greylist.c
parent92280557b6bdde0b3e1d8fa93ba2fae494d5c355 (diff)
split ltgrey (and libltgrey) off from greylist;
put some utility functions into their own file.
Diffstat (limited to 'tools/greylist.c')
-rw-r--r--tools/greylist.c50
1 files changed, 3 insertions, 47 deletions
diff --git a/tools/greylist.c b/tools/greylist.c
index 89396e7..9af70eb 100644
--- a/tools/greylist.c
+++ b/tools/greylist.c
@@ -22,7 +22,6 @@
#include <string.h> /* for memset() */
#include <arpa/inet.h> /* for inet_ntop() */
-
using namespace std;
const int minute(60);
@@ -33,18 +32,7 @@ const int minimum_age(15*minute);
const int maximum_age(32*day);
const int probation(4*hour);
-// error exit codes, mostly as stated in qmail.c
-#define foo(name, num) const int ex_ ## name = num
-#define bar foo(good, 0) ;\
-foo(spam, 21) ;\
-foo(penaltybox, 22) ;\
-foo(badDNS, 23) ;\
-foo(greylisting, 70) ;\
-foo(syserr, 71) ;\
-foo(comerr, 74) ;
-
-bar
-#undef foo
+#include "qq_exit_codes.h"
pid_t mypid;
string progname;
@@ -58,14 +46,6 @@ void dump(const string var){
else cerr << " is not set." << endl;
}
-
-////////////////
-// little utility to help with argument parsing:
-//
-int prefix(const string shorter, const string longer){
- return shorter == longer.substr(0, shorter.length());
-}
-
void exeunt(const int sts){
if (sts == ex_good) exit(sts);
@@ -93,6 +73,8 @@ void exeunt(const int sts){
exit(sts);
}
+#include "utils.h"
+
class whatsit{
public:
string dirname;
@@ -126,12 +108,6 @@ public:
int check_dns_sub(string &addr, string &host, vector<string> &checked);
};
-string basename(const string path){
- size_t where = path.rfind("/");
- if (where != string::npos) return path.substr(1+where);
- return path;
-}
-
int whatsit::setup(){
stringstream foo;
foo << basename(progname) << suffix
@@ -145,26 +121,6 @@ int whatsit::setup(){
return 0;
}
-string time_out(const int _ttt){
- int ttt(abs(_ttt));
- int sec(ttt % 60);
- int min((ttt / 60) % 60);
- int hr(ttt / 3600);
- stringstream foo;
- int didsome(0);
- if (_ttt < 0) foo << "-";
- if (hr) {
- foo << hr << ":";
- didsome++;
- }
- if (didsome || min){
- foo << setw(didsome?2:1) << setfill('0') << min << ":";
- didsome++;
- }
- foo << setw(didsome?2:1) << setfill('0') << sec;
- return foo.str();
-}
-
void scan(const string progid, const string p, const int copies=1){
timeval now;
gettimeofday(&now, NULL);