[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated
From: |
Ken Hornstein |
Subject: |
[Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated. 4877596410e850f2295f1015738bd8ca6e86ee0f |
Date: |
Fri, 17 Feb 2012 20:56:56 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The nmh Mail Handling System".
The branch, master has been updated
via 4877596410e850f2295f1015738bd8ca6e86ee0f (commit)
via 4f9a626afed661270364f0f7982fc3767f688e05 (commit)
via 3521e294c63116319993193971e2f0d708ac0530 (commit)
from 4eaf25e2a1d634b6f7bfa01a96e6e86768837e9b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=4877596410e850f2295f1015738bd8ca6e86ee0f
commit 4877596410e850f2295f1015738bd8ca6e86ee0f
Author: Ken Hornstein <address@hidden>
Date: Fri Feb 17 15:56:08 2012 -0500
Beginning support for mh-format support in comp(1). Includes changes to
default component file.
diff --git a/Makefile.am b/Makefile.am
index 6417e11..dc63866 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -209,6 +209,7 @@ uip_burst_SOURCES = uip/burst.c
uip_comp_SOURCES = uip/comp.c uip/whatnowproc.c uip/whatnowsbr.c uip/sendsbr.c
\
uip/annosbr.c uip/distsbr.c
+uip_comp_LDADD = $(LDADD) $(ICONVLIB)
uip_dist_SOURCES = uip/dist.c uip/whatnowproc.c uip/whatnowsbr.c uip/sendsbr.c
\
uip/annosbr.c uip/distsbr.c
diff --git a/etc/components b/etc/components
index 7f255ea..95be90c 100644
--- a/etc/components
+++ b/etc/components
@@ -1,3 +1,4 @@
+From: %(localmbox)
To:
cc:
Fcc: +outbox
diff --git a/man/comp.man b/man/comp.man
index bfb78b3..643c056 100644
--- a/man/comp.man
+++ b/man/comp.man
@@ -96,6 +96,17 @@ The
.I file
switch says to use the named file as the message draft.
.PP
+Forms that are selected via the
+.B \-form
+switch are processed via the mh template system; see
+.BR mh\-format (5)
+for details. Drafts constructed from another mssage or with the
+.B \-use
+or
+.B \-file
+switchs will NOT be processed with
+.BR mh\-format (5).
+.PP
If the draft already exists,
.B comp
will ask you as to the disposition
diff --git a/uip/comp.c b/uip/comp.c
index 5ebce6e..6882372 100644
--- a/uip/comp.c
+++ b/uip/comp.c
@@ -9,6 +9,7 @@
#include <h/mh.h>
#include <h/utils.h>
+#include <h/fmt_scan.h>
#include <fcntl.h>
static struct swit switches[] = {
@@ -71,12 +72,14 @@ int
main (int argc, char **argv)
{
int use = NOUSE, nedit = 0, nwhat = 0;
- int i, in, isdf = 0, out;
+ int i, in, isdf = 0, out, dat[5], ncomps, format_len;
+ int outputlinelen = OUTPUTLINELEN;
char *cp, *cwd, *maildir, *dfolder = NULL;
char *ed = NULL, *file = NULL, *form = NULL;
char *folder = NULL, *msg = NULL, buf[BUFSIZ];
char drft[BUFSIZ], **argp, **arguments;
struct msgs *mp = NULL;
+ struct format *fmt;
struct stat st;
#ifdef LOCALE
@@ -195,6 +198,8 @@ main (int argc, char **argv)
if (form && (folder || msg))
adios (NULL, "can't mix forms and folders/msgs");
+ cp = NULL;
+
if (folder || msg) {
/*
* Use a message as the "form" for the new message.
@@ -226,8 +231,17 @@ main (int argc, char **argv)
if ((in = open (form = getcpy (m_name (mp->lowsel)), O_RDONLY)) ==
NOTOK)
adios (form, "unable to open message");
- } else
- in = open_form(&form, components);
+ } else {
+ if (! form)
+ form = components;
+
+ cp = new_fs(form, NULL, NULL);
+ format_len = strlen(cp);
+ ncomps = fmt_compile(cp, &fmt);
+ if (ncomps > 0) {
+ adios(NULL, "format components not supported when using comp");
+ }
+ }
try_it_again:
strncpy (drft, m_draft (dfolder, file, use, &isdf), sizeof(drft));
@@ -284,8 +298,23 @@ try_it_again:
if ((out = creat (drft, m_gmprot ())) == NOTOK)
adios (drft, "unable to create");
- cpydata (in, out, form, drft);
- close (in);
+ if (cp) {
+ char *scanl;
+
+ i = format_len + 1024;
+ scanl = mh_xmalloc((size_t) i + 2);
+ dat[0] = 0;
+ dat[1] = 0;
+ dat[2] = 0;
+ dat[3] = outputlinelen;
+ dat[4] = 0;
+ fmt_scan(fmt, scanl, i, dat);
+ write(out, scanl, strlen(scanl));
+ free(scanl);
+ } else {
+ cpydata (in, out, form, drft);
+ close (in);
+ }
close (out);
edit_it:
http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=4f9a626afed661270364f0f7982fc3767f688e05
commit 4f9a626afed661270364f0f7982fc3767f688e05
Author: Ken Hornstein <address@hidden>
Date: Fri Feb 17 15:10:06 2012 -0500
Sigh. Looks like we need a function after all; create a new function
called %(localmbox).
diff --git a/h/mts.h b/h/mts.h
index a8d795f..2888c57 100644
--- a/h/mts.h
+++ b/h/mts.h
@@ -24,6 +24,7 @@ extern char *uucplfil;
char *getusername(void);
char *getfullname(void);
+char *getlocalmbox(void);
/*
* Separators
diff --git a/man/mh-format.man b/man/mh-format.man
index 57cf771..6b384d1 100644
--- a/man/mh-format.man
+++ b/man/mh-format.man
@@ -263,6 +263,7 @@ timenow integer seconds since the UNIX epoch
me string the user's mailbox (username)
myhost string the user's local hostname
myname string the user's name
+localmbox string the complete local mailbox
eq literal boolean \fInum\fR == \fIarg\fR
ne literal boolean \fInum\fR != \fIarg\fR
gt literal boolean \fInum\fR > \fIarg\fR
@@ -323,7 +324,17 @@ is not configured. The (\fImyname\fR\^) function will
return the value of
the
.B SIGNATURE
environment variable if set, otherwise will return the passwd GECOS field for
-the current user.
+the current user. The (\fIlocalmbox\fR\^) function will return the complete
+form of the local mailbox, suitable for use in a \*(lqFrom\*(rq header.
+It will return the
+.RI \*(lq Local-Mailbox \*(rq
+profile entry if it is set; if it is not, it will be equivalent to:
+.PP
+.RS 5
+.nf
+%(myname) <%(me)@%(myhost)>
+.fi
+.RE
.PP
The following functions require a date component as an argument:
.PP
diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c
index 239243f..0b739cf 100644
--- a/sbr/fmt_compile.c
+++ b/sbr/fmt_compile.c
@@ -78,6 +78,7 @@ extern struct mailname fmt_mnull;
#define TF_NOP 8 /* like expr but no result */
#define TF_MYNAME 9 /* special - get current name of user */
#define TF_MYHOST 10 /* special - get "local" hostname */
+#define TF_LMBOX 11 /* special - get full local mailbox */
/* ftable->flags */
/* NB that TFL_PUTS is also used to decide whether the test
@@ -158,6 +159,7 @@ static struct ftable functable[] = {
{ "me", TF_MYBOX, FT_LS_LIT, 0, TFL_PUTS },
{ "myname", TF_MYNAME, FT_LS_LIT, 0,
TFL_PUTS },
{ "myhost", TF_MYHOST, FT_LS_LIT, 0,
TFL_PUTS },
+ { "localmbox", TF_LMBOX, FT_LS_LIT, 0, TFL_PUTS },
{ "plus", TF_NUM, FT_LV_PLUS_L, 0, TFL_PUTN },
{ "minus", TF_NUM, FT_LV_MINUS_L, 0, TFL_PUTN },
{ "divide", TF_NUM, FT_LV_DIVIDE_L, 0, TFL_PUTN },
@@ -601,6 +603,10 @@ do_func(char *sp)
LS(t->f_type, LocalName(0));
break;
+ case TF_LMBOX:
+ LS(t->f_type, getlocalmbox());
+ break;
+
case TF_NOW:
LV(t->f_type, time((time_t *) 0));
break;
diff --git a/sbr/mts.c b/sbr/mts.c
index 868e603..d298c88 100644
--- a/sbr/mts.c
+++ b/sbr/mts.c
@@ -54,9 +54,10 @@ char *uucplfil = "";
char *mmdlm1 = "\001\001\001\001\n";
char *mmdlm2 = "\001\001\001\001\n";
-/* Cache the username and fullname of the user */
+/* Cache the username, fullname, and mailbox of the user */
static char username[BUFSIZ];
static char fullname[BUFSIZ];
+static char localmbox[BUFSIZ];
/* Variables for username masquerading: */
boolean draft_from_masquerading = FALSE; /* also used from post.c */
@@ -352,6 +353,34 @@ getfullname (void)
/*
+ * Get the full local mailbox name. This is in the form:
+ *
+ * User Name <address@hidden>
+ */
+
+char *
+getlocalmbox (void)
+{
+ if (username[0] == '\0')
+ getuserinfo();
+
+ if (localmbox[0] == '\0') {
+ char *cp;
+
+ if ((cp = context_find("Local-Mailbox")) != NULL) {
+ strncpy(localmbox, cp, sizeof(localmbox));
+ } else {
+ snprintf(localmbox, sizeof(localmbox), "%s <address@hidden>",
fullname,
+ username, LocalName(0));
+ }
+
+ localmbox[sizeof(localmbox) - 1] = '\0';
+ }
+
+ return localmbox;
+}
+
+/*
* Find the user's username and full name, and cache them.
* Also, handle "mmailid" username masquerading controlled from the GECOS field
* of the passwd file.
@@ -429,6 +458,8 @@ getuserinfo (void)
fullname[sizeof(fullname) - 1] = '\0';
+ localmbox[0] = '\0';
+
return;
}
diff --git a/test/format/test-localmbox b/test/format/test-localmbox
index 8ee6884..a0d4392 100755
--- a/test/format/test-localmbox
+++ b/test/format/test-localmbox
@@ -19,7 +19,7 @@ echo "Local-Mailbox: ${testname}" >> ${MH}
# We can use "ap" to get the output of format commands
-testoutput=$(${MH_LIB_DIR}/ap -format "%(profile Local-Mailbox)" ignore)
+testoutput=$(${MH_LIB_DIR}/ap -format "%(localmbox)" ignore)
if [ x"${testname}" != x"${testoutput}" ]; then
echo "Expected ${testname}, got ${testoutput}"
http://git.savannah.gnu.org/cgit/nmh.git/commit/?id=3521e294c63116319993193971e2f0d708ac0530
commit 3521e294c63116319993193971e2f0d708ac0530
Author: Ken Hornstein <address@hidden>
Date: Fri Feb 17 14:02:44 2012 -0500
Switch to including h/mts.h for getusername() prototype.
diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c
index 7bf4673..9edb139 100644
--- a/sbr/addrsbr.c
+++ b/sbr/addrsbr.c
@@ -10,6 +10,7 @@
#include <h/mh.h>
#include <h/addrsbr.h>
#include <h/mf.h>
+#include <h/mts.h>
/* High level parsing of addresses:
@@ -79,12 +80,6 @@ static char adr[BUFSIZ];
extern boolean username_extension_masquerading; /* defined in mts.c */
-/*
- * external prototypes
- */
-char *getusername (void);
-
-
char *
getname (char *addrs)
{
-----------------------------------------------------------------------
Summary of changes:
Makefile.am | 1 +
etc/components | 1 +
h/mts.h | 1 +
man/comp.man | 11 +++++++++++
man/mh-format.man | 13 ++++++++++++-
sbr/addrsbr.c | 7 +------
sbr/fmt_compile.c | 6 ++++++
sbr/mts.c | 33 ++++++++++++++++++++++++++++++++-
test/format/test-localmbox | 2 +-
uip/comp.c | 39 ++++++++++++++++++++++++++++++++++-----
10 files changed, 100 insertions(+), 14 deletions(-)
hooks/post-receive
--
The nmh Mail Handling System
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nmh-commits] [SCM] The nmh Mail Handling System branch, master, updated. 4877596410e850f2295f1015738bd8ca6e86ee0f,
Ken Hornstein <=