summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-11-23 12:58:49 -0800
committerJohn Denker <jsd@av8n.com>2012-11-23 12:58:49 -0800
commitf95fae8eba793751547db6b203f417b6fe7a35f7 (patch)
tree649e7cf025c5d3116824524627f77a52d249a88b /tools
parent4134b154839c91f44bb39547af9297f4b6a353d3 (diff)
we have passable code for reading envelope data
Diffstat (limited to 'tools')
-rw-r--r--tools/envelope.datbin0 -> 29 bytes
-rw-r--r--tools/pipette.c78
-rwxr-xr-xtools/test-qq12
3 files changed, 89 insertions, 1 deletions
diff --git a/tools/envelope.dat b/tools/envelope.dat
new file mode 100644
index 0000000..f103b22
--- /dev/null
+++ b/tools/envelope.dat
Binary files differ
diff --git a/tools/pipette.c b/tools/pipette.c
index 1eda2d0..c76b9e5 100644
--- a/tools/pipette.c
+++ b/tools/pipette.c
@@ -26,6 +26,7 @@ using namespace std;
#include <vector>
#include <sstream>
#include <map>
+#include <string.h> /* for strlen() */
#include <sys/types.h> /* for fstat */
#include <sys/stat.h> /* .. */
@@ -438,11 +439,84 @@ void play() {
dumpstat(tube[rEnd]);
dumpstat(tube[wEnd]);
sleep(1.5);
+ int plus = dup(tube[wEnd]);
close(tube[rEnd]);
dumpstat(tube[rEnd]);
dumpstat(tube[wEnd]);
+ dumpstat(plus);
}
+void test_read(){
+// test with:
+// cat envelope.dat | 1<&0 ./pipette
+ char buf[1024];
+ list<string> rslt;
+ int didsome(0);
+ for (;;){ // loop over all read buffers
+ int nr = read(1, buf, sizeof(buf));
+ if (nr == 0) break;
+ if (nr < 0) {
+ cerr << "read failed " << strError() << endl;
+ exit(1);
+ }
+ for (;;){ // loop over all strings
+ for (int ii = 0; ii < nr; ii++) {
+ char ch = buf[ii];
+ if (ch == 0) {
+ if (!didsome) goto done;
+ didsome = 0;
+ continue;
+ }
+ if (!didsome) {
+ rslt.push_back("");
+ }
+ rslt.back() += ch;
+ didsome++;
+ }
+ }
+ }
+done:;;;;
+ for (list<string>::const_iterator ptr = rslt.begin();
+ ptr != rslt.end(); ptr++) {
+ cerr << *ptr << endl;
+ }
+}
+
+#if 0
+void old_test_read(){
+// test with:
+// echo asfd | 1<&0 ./pipette
+// cat pipette.c | 1<&0 ./pipette
+ char buf[1024];
+ for (;;){
+ int nr = read(1, buf, sizeof(buf));
+ if (nr == 0) break;
+ if (nr < 0) {
+ cerr << "read failed " << strError() << endl;
+ exit(1);
+ }
+// unit 1 fails: bad file descriptor:
+// int nw = write(1, buf, nr);
+ for (int ii = 0; ii < nr; ii++) {
+ char* foo;
+ char out[2] = {0, 0};
+ char ch = buf[ii];
+ if (ch) {
+ foo = out;
+ *foo = ch;
+ } else {
+ foo = "␀\n";
+ }
+ int nw = write(2, foo, strlen(foo));
+ if (nw < 0) {
+ cerr << "write failed " << strError() << endl;
+ exit(1);
+ }
+ }
+ }
+}
+#endif
+
int main(int argc, char** argv) {
{
progname = *argv;
@@ -452,7 +526,9 @@ int main(int argc, char** argv) {
progid = binder.str();
}
- play();
+// play();
+ test_read();
+ cerr << "<BuhBye>" << endl;
exit(0);
#define foo(name, num) codemap[num] = #name ;
diff --git a/tools/test-qq b/tools/test-qq
new file mode 100755
index 0000000..b747bc8
--- /dev/null
+++ b/tools/test-qq
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+host=0
+port=1288
+
+flags_not_used=" -u21165 -g21164 "
+
+PATH=/var/qmail/bin:$PATH # so we can find qmail-smtpd and friends
+
+QMAILQUEUE=/usr/src/netqmail-1.06/tools/pipette \
+ /usr/local/bin/tcpserver -R -x/etc/tcpserver/smtp.cdb \
+ $host $port qmail-smtpd