called %(localmbox).
char *getusername(void);
char *getfullname(void);
+char *getlocalmbox(void);
/*
* Separators
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
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
#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
{ "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 },
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;
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 */
/*
+ * Get the full local mailbox name. This is in the form:
+ *
+ * User Name <user@name.com>
+ */
+
+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 <%s@%s>", 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.
fullname[sizeof(fullname) - 1] = '\0';
+ localmbox[0] = '\0';
+
return;
}
# 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}"