summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/hi-test.c14
-rw-r--r--tools/mail-scan.c26
-rw-r--r--tools/makefile13
-rw-r--r--tools/skrewt.c32
-rw-r--r--tools/utils.c16
-rw-r--r--tools/utils.h3
6 files changed, 30 insertions, 74 deletions
diff --git a/tools/hi-test.c b/tools/hi-test.c
index 0661ada..cd0152c 100644
--- a/tools/hi-test.c
+++ b/tools/hi-test.c
@@ -6,6 +6,7 @@
#include <sstream>
#include <stdio.h> /* perror() */
+#include "utils.h"
using namespace std;
@@ -16,13 +17,6 @@ const int sa_usage(64);
int verbosity(0);
-////////////////
-// 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 == sa_good) exit(sts);
@@ -69,12 +63,6 @@ void countsome(const int unit){
<< " read " << total << " bytes from unit " << unit << endl;
}
-string basename(const string path){
- size_t where = path.rfind("/");
- if (where != string::npos) return path.substr(1+where);
- return path;
-}
-
int main(int _argc, const char** _argv){
int snooze(0);
int status(0);
diff --git a/tools/mail-scan.c b/tools/mail-scan.c
index dc8aa5c..b0c4137 100644
--- a/tools/mail-scan.c
+++ b/tools/mail-scan.c
@@ -31,7 +31,7 @@
#include <stdio.h> /* perror */
#include <boost/regex.hpp>
-////#include <boost/lexical_cast.hpp>
+#include "utils.h"
using namespace std;
@@ -105,30 +105,6 @@ int cmp_casefold(const std::string& a, const std::string& b) {
return 0;
}
-
-string toLower(const std::string& a){
- string rslt = a;
- string::iterator rr;
- for (rr = rslt.begin(); rr != rslt.end(); rr++){
- *rr = tolower(*rr);
- }
- return rslt;
-}
-
-////////////////
-string ltrim(string foo){
- size_t where = foo.find_first_not_of(" \t\r\n");
- if (where == foo.npos) return foo;
- return foo.substr(where);
-}
-
-////////////////
-// 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 == sa_good) exit(sts);
diff --git a/tools/makefile b/tools/makefile
index f0a3f70..6594ca8 100644
--- a/tools/makefile
+++ b/tools/makefile
@@ -37,8 +37,8 @@ all: $(qprogs) $(moreprogs)
show:
: --- $(qprogs) +++ $(moreprogs)
-skrewt: skrewt.o
- $(CC) $< -lboost_filesystem-mt -lboost_system -o $@
+skrewt: skrewt.o utils.o
+ $(CC) $^ -lboost_filesystem-mt -lboost_system -o $@
greylist: greylist.o utils.o
$(CC) $^ -lboost_filesystem-mt -lboost_system -o $@
@@ -47,11 +47,14 @@ ltgrey: ltgrey.o utils.o libltgrey.o
$(CC) $^ -lboost_filesystem-mt -lboost_system -o $@
wripper: wripper.o
- $(CC) $< -o $@
+ $(CC) $^ -o $@
chgrp daemon $@ && chmod g+s $@ || true
-mail-scan: mail-scan.o
- $(CC) $< -lboost_regex -o $@
+mail-scan: mail-scan.o utils.o
+ $(CC) $^ -lboost_regex -o $@
+
+hi-test: hi-test.o utils.o
+ $(CC) $^ -lboost_regex -o $@
install:
install $(qprogs) /var/qmail/bin/
diff --git a/tools/skrewt.c b/tools/skrewt.c
index 3fee644..6749a01 100644
--- a/tools/skrewt.c
+++ b/tools/skrewt.c
@@ -38,7 +38,7 @@ void usage(const int sts){
}
#include "qq_exit_codes.h"
-
+#include "utils.h"
/////////////////////////////////////////////////////////
// Case insensitive comparison of strings
@@ -83,23 +83,6 @@ int cmp_casefold(const std::string& a, const std::string& b) {
return 0;
}
-
-string toLower(const std::string& a){
- string rslt = a;
- string::iterator rr;
- for (rr = rslt.begin(); rr != rslt.end(); rr++){
- *rr = tolower(*rr);
- }
- return rslt;
-}
-
-////////////////
-string ltrim(const string foo){
- size_t where = foo.find_first_not_of(" \t\r\n");
- if (where == foo.npos) return foo;
- return foo.substr(where);
-}
-
string noCR(const string bar){
string foo(bar);
int len = foo.length();
@@ -111,13 +94,6 @@ string noCR(const string bar){
return foo;
}
-////////////////
-// little utility to help with argument parsing:
-//
-int prefix(const string shorter, const string longer){
- return shorter == longer.substr(0, shorter.length());
-}
-
void maybe_exeunt(const int sts, const int really){
if (!really) return;
if (sts == ex_good) exit(sts);
@@ -142,12 +118,6 @@ void exeunt(const int sts){
maybe_exeunt(sts, 1);
}
-string basename(const string path){
- size_t where = path.rfind("/");
- if (where != string::npos) return path.substr(1+where);
- return path;
-}
-
string progname, progid;
int mypid;
diff --git a/tools/utils.c b/tools/utils.c
index 3ec6e4c..aecbfda 100644
--- a/tools/utils.c
+++ b/tools/utils.c
@@ -42,3 +42,19 @@ using namespace std;
foo << setw(didsome?2:1) << setfill('0') << sec;
return foo.str();
}
+
+std::string toLower(const std::string a){
+ std::string rslt = a;
+ std::string::iterator rr;
+ for (rr = rslt.begin(); rr != rslt.end(); rr++){
+ *rr = tolower(*rr);
+ }
+ return rslt;
+}
+
+////////////////
+std::string ltrim(const std::string foo){
+ size_t where = foo.find_first_not_of(" \t\r\n");
+ if (where == foo.npos) return foo;
+ return foo.substr(where);
+}
diff --git a/tools/utils.h b/tools/utils.h
index 450db85..ec467c6 100644
--- a/tools/utils.h
+++ b/tools/utils.h
@@ -1,3 +1,6 @@
std::string basename(const std::string path);
int prefix(const std::string shorter, const std::string longer);
std::string time_out(const int _ttt);
+
+std::string toLower(const std::string a);
+std::string ltrim(const std::string a);