summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Tse <liquidx@gentoo.org>2003-04-09 00:18:43 +0000
committerAlastair Tse <liquidx@gentoo.org>2003-04-09 00:18:43 +0000
commit0d1193d3b770286d369348eddeacbd4a887ea4df (patch)
tree76da16ec747e3d4cb13288d7c5f61482f822af79
parentsyncing with other ezmlm-idx* (diff)
downloadhistorical-0d1193d3b770286d369348eddeacbd4a887ea4df.tar.gz
historical-0d1193d3b770286d369348eddeacbd4a887ea4df.tar.bz2
historical-0d1193d3b770286d369348eddeacbd4a887ea4df.zip
syncing with other ezmlm-idx*
-rw-r--r--net-mail/ezmlm-idx-pgsql/files/digest-ezmlm-idx-pgsql-0.40-r26
-rw-r--r--net-mail/ezmlm-idx-pgsql/files/ezmlm-0.53-errno.patch9
-rw-r--r--net-mail/ezmlm-idx-pgsql/files/from-header.patch209
-rw-r--r--net-mail/ezmlm-idx-pgsql/files/get_header.c113
-rw-r--r--net-mail/ezmlm-idx-pgsql/files/get_header.h7
5 files changed, 341 insertions, 3 deletions
diff --git a/net-mail/ezmlm-idx-pgsql/files/digest-ezmlm-idx-pgsql-0.40-r2 b/net-mail/ezmlm-idx-pgsql/files/digest-ezmlm-idx-pgsql-0.40-r2
index 1bfb348b572a..9f35931e9e01 100644
--- a/net-mail/ezmlm-idx-pgsql/files/digest-ezmlm-idx-pgsql-0.40-r2
+++ b/net-mail/ezmlm-idx-pgsql/files/digest-ezmlm-idx-pgsql-0.40-r2
@@ -1,7 +1,7 @@
-MD5 31baef31f2ce0c9343530c3467220a60 /files/from-header.patch 6165
-MD5 b82b4c09c356dc91fcbe907a24326b52 /files/ezmlm-0.53-errno.patch 270
MD5 add751ca5856300f8e2a349fb944257c /files/get_header.c 3486
MD5 faac5e3fb54753c4a9f6475bb1a5b20a /files/get_header.h 101
-MD5 e7ebd30b3d6f45544e85f82d49f386f6 /ezmlm-idx-pgsql-0.40-r2.ebuild 2368
+MD5 b82b4c09c356dc91fcbe907a24326b52 /files/ezmlm-0.53-errno.patch 270
+MD5 31baef31f2ce0c9343530c3467220a60 /files/from-header.patch 6165
+MD5 216dc5b285d0497fb31747392ec986fe /ezmlm-idx-pgsql-0.40-r2.ebuild 2368
MD5 c6137114060cff19301a956e73d46fc0 ezmlm-idx-0.40.tar.gz 553974
MD5 108c632caaa8cdbfd3041e6c449191b2 ezmlm-0.53.tar.gz 62693
diff --git a/net-mail/ezmlm-idx-pgsql/files/ezmlm-0.53-errno.patch b/net-mail/ezmlm-idx-pgsql/files/ezmlm-0.53-errno.patch
new file mode 100644
index 000000000000..3028e5630f60
--- /dev/null
+++ b/net-mail/ezmlm-idx-pgsql/files/ezmlm-0.53-errno.patch
@@ -0,0 +1,9 @@
+diff -urN ezmlm-0.53/error.h ezmlm-0.53-new/error.h
+--- ezmlm-0.53/error.h 2003-04-06 07:59:49.000000000 +0200
++++ ezmlm-0.53-new/error.h 2003-04-06 08:09:25.000000000 +0200
+@@ -1,5 +1,6 @@
+ #ifndef ERROR_H
+ #define ERROR_H
++#include <errno.h>
+
+ extern int errno;
diff --git a/net-mail/ezmlm-idx-pgsql/files/from-header.patch b/net-mail/ezmlm-idx-pgsql/files/from-header.patch
new file mode 100644
index 000000000000..c5a306a5ab28
--- /dev/null
+++ b/net-mail/ezmlm-idx-pgsql/files/from-header.patch
@@ -0,0 +1,209 @@
+--- Makefile.orig Mon Nov 27 19:20:43 2000
++++ Makefile Mon Nov 27 18:41:29 2000
+@@ -350,9 +350,9 @@
+ ezmlm-gate: \
+ load ezmlm-gate.o subdb.a auto_bin.o getopt.a getln.a env.a sig.a strerr.a \
+ stralloc.a alloc.a error.a str.a case.a wait.a substdio.a open.a lock.a \
+-fs.a getconf.o slurpclose.o slurp.o seek.a conf-sqlld
++fs.a getconf.o slurpclose.o slurp.o seek.a conf-sqlld get_header.a
+ ./load ezmlm-gate subdb.a getconf.o slurpclose.o slurp.o \
+- getopt.a getln.a auto_bin.o env.a sig.a fs.a \
++ getopt.a getln.a auto_bin.o env.a sig.a fs.a get_header.a \
+ strerr.a substdio.a stralloc.a alloc.a error.a str.a case.a wait.a \
+ open.a lock.a seek.a ${SQLLD}
+
+@@ -362,7 +362,7 @@
+
+ ezmlm-gate.o: \
+ compile ezmlm-gate.c idx.h errtxt.h subscribe.h auto_bin.h \
+-sgetopt.h subgetopt.h substdio.h getconf.h \
++sgetopt.h subgetopt.h substdio.h getconf.h get_header.h substdio.h \
+ env.h sig.h strerr.h stralloc.h alloc.h error.h str.h case.h \
+ fork.h wait.h exit.h getln.h open.h
+ ./compile ezmlm-gate.c
+@@ -469,19 +469,20 @@
+
+ ezmlm-issubn: \
+ load ezmlm-issubn.o subdb.a getconf.o slurpclose.o slurp.o \
+-env.a fs.a strerr.a getln.a getopt.a conf-sqlld \
+-substdio.a stralloc.a alloc.a error.a str.a case.a open.a lock.a
++env.a fs.a strerr.a getln.a getopt.a conf-sqlld get_header.a \
++substdio.a stralloc.a alloc.a error.a str.a case.a open.a lock.a get_header.a
+ ./load ezmlm-issubn subdb.a getconf.o slurpclose.o slurp.o \
+- getopt.a env.a fs.a strerr.a \
++ getopt.a env.a fs.a strerr.a get_header.a substdio.a \
+ getln.a substdio.a stralloc.a alloc.a error.a str.a case.a \
+- open.a lock.a ${SQLLD}
++ open.a lock.a get_header.a ${SQLLD}
+
+ ezmlm-issubn.0: \
+ ezmlm-issubn.1
+ nroff -man ezmlm-issubn.1 > ezmlm-issubn.0
+
+ ezmlm-issubn.o: \
+-compile ezmlm-issubn.c strerr.h subscribe.h env.h errtxt.h sgetopt.h idx.h
++compile ezmlm-issubn.c strerr.h subscribe.h env.h errtxt.h sgetopt.h idx.h \
++substdio.h readwrite.h
+ ./compile ezmlm-issubn.c
+
+ ezmlm-limit: \
+@@ -1280,6 +1281,14 @@
+ stralloc.0: \
+ stralloc.3
+ nroff -man stralloc.3 > stralloc.0
++
++get_header.o: \
++compile get_header.c get_header.h substdio.h seek.h stralloc.h strerr.h \
++ ./compile get_header.c
++
++get_header.a: \
++makelib get_header.o
++ ./makelib get_header.a get_header.o stralloc.a seek_set.o strerr.a
+
+ stralloc.a: \
+ makelib stralloc_eady.o stralloc_pend.o stralloc_copy.o \
+--- ezmlm-gate.c.orig Mon Nov 27 19:20:49 2000
++++ ezmlm-gate.c Mon Nov 27 19:04:57 2000
+@@ -17,12 +17,18 @@
+ #include "errtxt.h"
+ #include "idx.h"
+ #include "subscribe.h"
++#include "get_header.h"
++#include "substdio.h"
++#include "readwrite.h"
+
+ #define FATAL "ezmlm-gate: fatal: "
+
++char buf0[256];
++substdio ssin = SUBSTDIO_FDBUF(read,0,buf0,(int) sizeof(buf0));
++
+ void die_usage()
+ {
+- strerr_die1x(100,"ezmlm-gate: usage: ezmlm-gate [-cCmMpPqrRsSvV] "
++ strerr_die1x(100,"ezmlm-gate: usage: ezmlm-gate [-fFcCmMpPqrRsSvV] "
+ "dir [moddir [...]]");
+ }
+ void die_nomem() { strerr_die2x(111,FATAL,ERR_NOMEM); }
+@@ -89,6 +95,9 @@
+ int opt;
+ int ret = 0;
+ unsigned int i,j,k;
++ int usefrom = 0;
++
++ char *from_addr = (char *)0;
+
+ umask(022);
+ sig_pipeignore();
+@@ -98,7 +107,7 @@
+ if (!stralloc_copys(&storeopt," -")) die_nomem();
+
+ while ((opt = getopt(argc,argv,
+- "cCmMpPq:Q:sSrRt:T:vV")) != opteof)
++ "fFcCmMpPq:Q:sSrRt:T:vV")) != opteof)
+ switch(opt) { /* pass on unrecognized options */
+ case 'c': /* ezmlm-send flags */
+ case 'C':
+@@ -116,6 +125,8 @@
+ szchar[0] = opt;
+ if (!stralloc_append(&storeopt,szchar)) die_nomem();
+ break;
++ case 'f': usefrom = 1; break;
++ case 'F': usefrom = 0; break;
+ case 'q': /* allow both qQ to be nice */
+ case 'Q': if (optarg) queryext = optarg; break;
+ case 'v':
+@@ -124,6 +135,10 @@
+ die_usage();
+ }
+
++ if (usefrom) {
++ from_addr = get_from(&ssin);
++ }
++
+ dir = argv[optind++];
+ if (!dir) die_usage();
+ if (chdir(dir) == -1)
+@@ -155,8 +170,12 @@
+ moddir = argv[optind++];
+ if (moddir && !ret) { /* if exit 0 and moddir, add issub */
+ pmod = (char *) 0;
+- while (moddir && !pmod && sender) {
+- pmod = issub(moddir,sender,(char *) 0,FATAL);
++ while (moddir && !pmod && (sender || from_addr)) {
++ if (sender)
++ pmod = issub(moddir,sender,(char *) 0,FATAL);
++ if (!pmod && from_addr)
++ pmod = issub(moddir,from_addr,(char *) 0,FATAL);
++
+ closesql();
+ moddir = argv[optind++];
+ }
+--- ezmlm-issubn.c.orig Mon Nov 27 19:20:54 2000
++++ ezmlm-issubn.c Mon Nov 27 19:05:59 2000
+@@ -6,14 +6,21 @@
+ #include "sgetopt.h"
+ #include "errtxt.h"
+ #include "idx.h"
++#include "get_header.h"
++#include "substdio.h"
++#include "readwrite.h"
+
+ #define FATAL "ezmlm-issubn: fatal: "
+
++char buf0[256];
++substdio ssin = SUBSTDIO_FDBUF(read,0,buf0,(int) sizeof(buf0));
++
+ void *psql = (void *) 0;
+
+ void die_usage()
+ {
+- strerr_die1x(100,"ezmlm-issubn: usage: ezmlm-issubn [-nN] dir [dir1 ...]");
++ strerr_die1x(100,
++ "ezmlm-issubn: usage: ezmlm-issubn [-fF] [-nN] dir [dir1 ...]");
+ }
+
+ void die_sender()
+@@ -28,15 +35,19 @@
+ char *dir;
+ char *addr;
+ int flagsub = 0;
++ int usefrom = 0;
+ int opt;
++ char *from_addr = (char *)0;
+
+ addr = env_get("SENDER");
+ if (!addr) die_sender(); /* REQUIRE sender */
+
+- while ((opt = getopt(argc,argv,"nNvV")) != opteof)
++ while ((opt = getopt(argc,argv,"fFnNvV")) != opteof)
+ switch(opt) {
+ case 'n': flagsub = 99; break;
+ case 'N': flagsub = 0; break;
++ case 'f': usefrom = 1; break;
++ case 'F': usefrom = 0; break;
+ case 'v':
+ case 'V': strerr_die2x(0,
+ "ezmlm-issubn version: ezmlm-0.53+",EZIDX_VERSION);
+@@ -44,6 +55,11 @@
+ die_usage();
+ }
+
++
++ if (usefrom) {
++ from_addr = get_from(&ssin);
++ }
++
+ dir = argv[optind];
+ if (chdir(dir) == -1)
+ strerr_die4sys(111,FATAL,ERR_SWITCH,dir,": ");
+@@ -54,6 +70,9 @@
+ if (issub(dir,addr,(char *) 0,FATAL)) {
+ closesql();
+ _exit(flagsub); /* subscriber */
++ } else if (from_addr && issub(dir, from_addr, (char *) 0, FATAL)) {
++ closesql();
++ _exit(flagsub);
+ }
+ }
+ closesql();
+
diff --git a/net-mail/ezmlm-idx-pgsql/files/get_header.c b/net-mail/ezmlm-idx-pgsql/files/get_header.c
new file mode 100644
index 000000000000..38b0bf3fd427
--- /dev/null
+++ b/net-mail/ezmlm-idx-pgsql/files/get_header.c
@@ -0,0 +1,113 @@
+#include "substdio.h"
+#include "seek.h"
+#include "get_header.h"
+#include "stralloc.h"
+#include "errtxt.h"
+#include "strerr.h"
+
+#define FATAL "get_header: fatal: "
+
+static stralloc line = {0};
+
+static void die_nomem()
+{
+ strerr_die2x(111,FATAL,ERR_NOMEM);
+}
+
+/**
+ * This function assumes that input is at the begining of the file;
+ * and it returns input to that state when the function has completed.
+ * The return is 0 if the header was not found, and 1 otherwise. If
+ * found, the header will be stored in the value stralloc struct.
+ */
+int get_header(input, name, value)
+substdio *input;
+char *name;
+stralloc *value;
+{
+ int match = 0;
+ int found_start = 0;
+ unsigned int len;
+ char *cp;
+
+ for (;;) {
+ if (getln(input, &line, &match, '\n') == -1)
+ strerr_die2sys(111, FATAL,ERR_READ_INPUT);
+ if (!match) break;
+ if (line.len == 1) break;
+ cp = line.s ; len = line.len;
+ if (found_start) {
+ if ((*cp == ' ' || *cp == '\t')) {
+ if (!stralloc_catb(value, cp, len - 1)) die_nomem();
+ } else {
+ break;
+ }
+ } else {
+ if (case_startb(cp,len,"from:")) {
+ if (!stralloc_copyb(value, cp, len - 1)) die_nomem();
+ found_start = 1;
+ }
+ }
+ }
+
+ if (seek_begin(input->fd) == -1)
+ strerr_die2sys(111,FATAL,ERR_SEEK_INPUT);
+
+ return found_start;
+}
+
+/**
+ * This function makes the same assumptions about input as get_header :
+ * it should be at the begining of the file, and once done, seek will
+ * be used to return it there. The return value is an e-mail address if
+ * one can be found, or null otherwise. No attempt is made to validate
+ * the email address, and the work done for parsing it is relatively
+ * simplistic; it will handle the following forms as shown:
+ *
+ * username@domain => username@domain
+ * "Name <username@domain>" => username@domain
+ * username1@domain, username2@domain => username1@domain
+ * username1@domain, "Name <username2@domain>" => username2@domain
+ *
+ * If junk is present in the From: header, this will return that. This
+ * function may not be appropriate if a valid e-mail address is required.
+ */
+char *get_from(input)
+substdio *input;
+{
+ stralloc from_header = {0};
+ int from_complete = 0, i;
+ char *from_addr = (char *) 0;
+
+ if (!get_header(input, "from:", &from_header))
+ return (char *) 0;
+
+ /* issub uses a char *, and stralloc structures aren't null
+ * terminated -- they're ... 'Z' terminated ...
+ * but the stuff in from_header is a copy anyway ... we'll modify it so
+ * we don't have to do strcpy or somesuch.
+ */
+ for (i = strlen("from:") ; i < from_header.len ; ++i) {
+ if (*(from_header.s + i) == '<') {
+ from_addr = from_header.s + (i + 1);
+ } else if (from_addr && *(from_header.s + i) == '>') {
+ from_complete = 1;
+ *(from_header.s+i) = '\0'; /* null terminate so from_addr is valid */
+ break;
+ }
+ }
+ if (!from_complete) { /* <...> not found ... assume a simpler format */
+ for(i = strlen("from:") ; i < from_header.len ; ++i) {
+ if (!from_addr && *(from_header.s + i) != ' ') {
+ from_addr = from_header.s + i;
+ } else if (from_addr && isspace(*(from_header.s + i)) ||
+ *(from_header.s + i) == ',') {
+ break;
+ }
+ }
+ *(from_header.s + i) = '\0'; /* this is safe even if i == from_header.len */
+ /* because strallocs have an extra char */
+ }
+ return from_addr;
+}
+
diff --git a/net-mail/ezmlm-idx-pgsql/files/get_header.h b/net-mail/ezmlm-idx-pgsql/files/get_header.h
new file mode 100644
index 000000000000..9af1d4fffdf8
--- /dev/null
+++ b/net-mail/ezmlm-idx-pgsql/files/get_header.h
@@ -0,0 +1,7 @@
+#ifndef GET_HEADER_H
+#define GET_HEADER_H
+
+extern int get_header();
+extern char *get_from();
+
+#endif