summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/fixown.c1
-rw-r--r--tools/libskrewt.c49
-rw-r--r--tools/libskrewt.h4
-rw-r--r--tools/makefile6
-rw-r--r--tools/ward.c45
5 files changed, 60 insertions, 45 deletions
diff --git a/tools/fixown.c b/tools/fixown.c
index 087e7c9..aefce86 100644
--- a/tools/fixown.c
+++ b/tools/fixown.c
@@ -27,6 +27,7 @@ map<string,owngroup> allowed({
x("fixown", "+root", ""),
x("fixown2", "+root", ""),
x("skrewt", "+qmaild", ""),
+ x("ward", "+qmaild", ""),
x("ltgrey", "+qmaild", ""),
x("greylist", "+qmaild", ""),
x("wripper", "", "+daemon"),
diff --git a/tools/libskrewt.c b/tools/libskrewt.c
new file mode 100644
index 0000000..a756863
--- /dev/null
+++ b/tools/libskrewt.c
@@ -0,0 +1,49 @@
+#include <iostream>
+#include "libskrewt.h"
+
+using namespace std;
+
+void parse_content(const string type_spec_line,
+ string &maintype, string &boundary) {
+ //xxx cerr << "parser called with: " << type_spec_line << endl;
+ string get_type(type_spec_line);
+
+ size_t where = get_type.find_first_of(" \t;\n");
+ string rest;
+ if (where == string::npos) {
+ // keep whole string
+ }
+ else {
+ rest = get_type.substr(where+1);
+ get_type = get_type.substr(0,where);
+ }
+ where = get_type.find("/");
+ if (where == string::npos){
+ maintype = "";
+ cerr << "could not find / in " << get_type << endl;
+ } else {
+ maintype = get_type.substr(0, where);
+ }
+
+// now need to find boundary
+
+ string srch = "boundary=";
+ where = rest.find(srch);
+ if (where != string::npos) {
+ where += srch.length();
+ boundary = rest.substr(where);
+ if (boundary[0] == '"') {
+ boundary = boundary.substr(1);
+ where = boundary.find_first_of("\"");
+ } else {
+ where = boundary.find_first_of(" \t;\n");
+ }
+ if (where == string::npos) {
+ /* do nothing, boundary=boundary as a whole */
+ } else {
+ boundary = boundary.substr(0, where);
+ }
+ } else {
+ //xxxxxxx cerr << "boundary= not found in " << type_spec_line << endl;
+ }
+}
diff --git a/tools/libskrewt.h b/tools/libskrewt.h
new file mode 100644
index 0000000..c9d6721
--- /dev/null
+++ b/tools/libskrewt.h
@@ -0,0 +1,4 @@
+#include <string>
+
+void parse_content(const std::string type_spec_line,
+ std::string &maintype, std::string &boundary);
diff --git a/tools/makefile b/tools/makefile
index 5bd5711..1cb1425 100644
--- a/tools/makefile
+++ b/tools/makefile
@@ -32,7 +32,7 @@ beware_other = checkpassword.c spamc.c
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
-all: $(qprogs) $(moreprogs) fixown2
+all: $(qprogs) $(moreprogs) fixown2 ward
show:
: --- $(qprogs) +++ $(moreprogs)
@@ -51,6 +51,10 @@ skrewt: skrewt.o utils.o sepofra.o
$(CC) $^ -lboost_filesystem-mt -lboost_system -lspf2 -o $@
./fixown $@
+ward: ward.o libskrewt.o utils.o sepofra.o
+ $(CC) $^ -lboost_filesystem-mt -lboost_system -lspf2 -o $@
+ ./fixown $@
+
greylist: greylist.o utils.o
$(CC) $^ -lboost_filesystem-mt -lboost_system -o $@
./fixown $@
diff --git a/tools/ward.c b/tools/ward.c
index 540b1cf..8be9f70 100644
--- a/tools/ward.c
+++ b/tools/ward.c
@@ -72,50 +72,7 @@ int mypid;
/* Content-Type: multipart/mixed; boundary="1170861315-1262462055-1341954763=:92165" */
//
-void parse_content(const string type_spec_line,
- string &maintype, string &boundary) {
- //xxx cerr << "parser called with: " << type_spec_line << endl;
- string get_type(type_spec_line);
-
- size_t where = get_type.find_first_of(" \t;\n");
- string rest;
- if (where == string::npos) {
- // keep whole string
- }
- else {
- rest = get_type.substr(where+1);
- get_type = get_type.substr(0,where);
- }
- where = get_type.find("/");
- if (where == string::npos){
- maintype = "";
- cerr << "could not find / in " << get_type << endl;
- } else {
- maintype = get_type.substr(0, where);
- }
-
-// now need to find boundary
-
- string srch = "boundary=";
- where = rest.find(srch);
- if (where != string::npos) {
- where += srch.length();
- boundary = rest.substr(where);
- if (boundary[0] == '"') {
- boundary = boundary.substr(1);
- where = boundary.find_first_of("\"");
- } else {
- where = boundary.find_first_of(" \t;\n");
- }
- if (where == string::npos) {
- /* do nothing, boundary=boundary as a whole */
- } else {
- boundary = boundary.substr(0, where);
- }
- } else {
- //xxxxxxx cerr << "boundary= not found in " << type_spec_line << endl;
- }
-}
+#include "libskrewt.h"
string join(const string sep, const list<string> stuff){
string rslt;