summaryrefslogtreecommitdiff
path: root/usr/src/lib/libmail
diff options
context:
space:
mode:
authorstevel@tonic-gate <none@none>2005-06-14 00:00:00 -0700
committerstevel@tonic-gate <none@none>2005-06-14 00:00:00 -0700
commit7c478bd95313f5f23a4c958a745db2134aa03244 (patch)
treec871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libmail
downloadillumos-gate-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libmail')
-rw-r--r--usr/src/lib/libmail/Makefile93
-rw-r--r--usr/src/lib/libmail/Makefile.com80
-rw-r--r--usr/src/lib/libmail/amd64/Makefile40
-rw-r--r--usr/src/lib/libmail/common/abspath.c60
-rw-r--r--usr/src/lib/libmail/common/casncmp.c62
-rw-r--r--usr/src/lib/libmail/common/copystream.c65
-rw-r--r--usr/src/lib/libmail/common/delempty.c74
-rw-r--r--usr/src/lib/libmail/common/getdomain.c146
-rw-r--r--usr/src/lib/libmail/common/llib-lmail42
-rw-r--r--usr/src/lib/libmail/common/maillock.c187
-rw-r--r--usr/src/lib/libmail/common/notifyu.c118
-rw-r--r--usr/src/lib/libmail/common/popenvp.c126
-rw-r--r--usr/src/lib/libmail/common/s_string.c417
-rw-r--r--usr/src/lib/libmail/common/setup_exec.c95
-rw-r--r--usr/src/lib/libmail/common/skipspace.c49
-rw-r--r--usr/src/lib/libmail/common/strmove.c56
-rw-r--r--usr/src/lib/libmail/common/substr.c59
-rw-r--r--usr/src/lib/libmail/common/systemvp.c75
-rw-r--r--usr/src/lib/libmail/common/trimnl.c51
-rw-r--r--usr/src/lib/libmail/common/xgetenv.c209
-rw-r--r--usr/src/lib/libmail/i386/Makefile38
-rw-r--r--usr/src/lib/libmail/inc/libmail.h96
-rw-r--r--usr/src/lib/libmail/inc/maillock.h66
-rw-r--r--usr/src/lib/libmail/inc/s_string.h103
-rw-r--r--usr/src/lib/libmail/inc/synonyms.h582
-rw-r--r--usr/src/lib/libmail/sparc/Makefile38
-rw-r--r--usr/src/lib/libmail/sparcv9/Makefile41
-rw-r--r--usr/src/lib/libmail/spec/Makefile30
-rw-r--r--usr/src/lib/libmail/spec/Makefile.targ35
-rw-r--r--usr/src/lib/libmail/spec/amd64/Makefile44
-rw-r--r--usr/src/lib/libmail/spec/i386/Makefile44
-rw-r--r--usr/src/lib/libmail/spec/mail.spec242
-rw-r--r--usr/src/lib/libmail/spec/sparc/Makefile44
-rw-r--r--usr/src/lib/libmail/spec/sparcv9/Makefile45
-rw-r--r--usr/src/lib/libmail/spec/versions43
35 files changed, 3595 insertions, 0 deletions
diff --git a/usr/src/lib/libmail/Makefile b/usr/src/lib/libmail/Makefile
new file mode 100644
index 0000000000..477c986063
--- /dev/null
+++ b/usr/src/lib/libmail/Makefile
@@ -0,0 +1,93 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/Makefile
+
+include ../../Makefile.master
+include ../Makefile.lib
+
+SUBDIRS= spec .WAIT $(MACH) $(BUILD64) $(MACH64)
+LINTDIRS= $(MACH) $(BUILD64) $(MACH64)
+
+all := TARGET= all
+clean := TARGET= clean
+clobber := TARGET= clobber
+install := TARGET= install
+lint := TARGET= lint
+_msg := TARGET= _msg
+package := TARGET= package
+
+LIBRARY= libmail.a
+TEXT_DOMAIN= SUNW_OST_OSLIB
+XGETFLAGS= -a
+POFILE= $(LIBRARY:.a=.po)
+POFILES= generic.po
+
+SED= sed
+CP= cp
+
+.KEEP_STATE:
+
+all clean clobber install package: $(SUBDIRS)
+
+lint: $(LINTDIRS)
+
+# definitions for install_h target
+HDRS= maillock.h libmail.h s_string.h
+ROOTHDRDIR= $(ROOT)/usr/include
+ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
+
+# install rule for install_h target
+$(ROOTHDRDIR)/%: inc/%
+ $(INS.file)
+
+install_h: $(ROOTHDRS)
+
+# definitions for check
+PUBHDRS= maillock.h
+CHECKHDRS= $(PUBHDRS:%.h=inc/%.check)
+
+check: $(CHECKHDRS)
+
+$(MACH) $(MACH64) spec: FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+_msg: $(MSGDOMAIN) $(POFILE)
+ $(RM) $(MSGDOMAIN)/$(POFILE)
+ $(CP) $(POFILE) $(MSGDOMAIN)
+
+$(POFILE): $(POFILES)
+ $(RM) $@
+ $(CAT) $(POFILES) > $@
+
+$(POFILES):
+ $(RM) messages.po
+ $(XGETTEXT) $(XGETFLAGS) *.[ch]* */*.[ch]*
+ $(SED) -e '/^# msg/d' -e '/^domain/d' messages.po > $@
+ $(RM) messages.po
+
+FRC:
diff --git a/usr/src/lib/libmail/Makefile.com b/usr/src/lib/libmail/Makefile.com
new file mode 100644
index 0000000000..e3cdd63e3a
--- /dev/null
+++ b/usr/src/lib/libmail/Makefile.com
@@ -0,0 +1,80 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/Makefile.com
+#
+
+LIBRARY= libmail.a
+VERS= .1
+
+OBJECTS= abspath.o casncmp.o copystream.o delempty.o \
+ getdomain.o maillock.o notifyu.o popenvp.o \
+ s_string.o setup_exec.o strmove.o skipspace.o \
+ substr.o systemvp.o trimnl.o xgetenv.o
+
+# include library definitions
+include ../../Makefile.lib
+
+MAPFILE= $(MAPDIR)/mapfile
+SRCS= $(OBJECTS:%.o=../common/%.c)
+
+LIBS = $(DYNLIB) $(LINTLIB)
+
+$(LINTLIB):= SRCS = ../common/llib-lmail
+
+LINTSRC= $(LINTLIB:%.ln=%)
+
+CPPFLAGS = -I../inc $(CPPFLAGS.master)
+CFLAGS += $(CCVERBOSE)
+DYNFLAGS += -M $(MAPFILE)
+LDLIBS += -lc
+
+.KEEP_STATE:
+
+lint: lintcheck
+
+$(DYNLIB) $(DYNLIB64): $(MAPFILE)
+
+$(MAPFILE):
+ @cd $(MAPDIR); $(MAKE) mapfile
+
+# include library targets
+include ../../Makefile.targ
+
+pics/%.o: ../common/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+pics/%.o: ../inc/%.h
+
+# install rule for lint library target
+$(ROOTLINTDIR)/%: ../common/%
+ $(INS.file)
+
+# install rule for 64 bit lint library target
+$(ROOTLINTDIR64)/%: ../common/%
+ $(INS.file)
diff --git a/usr/src/lib/libmail/amd64/Makefile b/usr/src/lib/libmail/amd64/Makefile
new file mode 100644
index 0000000000..bf7f82677c
--- /dev/null
+++ b/usr/src/lib/libmail/amd64/Makefile
@@ -0,0 +1,40 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+MAPDIR= ../spec/amd64
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+LIBS= $(DYNLIB) $(LINTLIB)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libmail/common/abspath.c b/usr/src/lib/libmail/common/abspath.c
new file mode 100644
index 0000000000..584d57b044
--- /dev/null
+++ b/usr/src/lib/libmail/common/abspath.c
@@ -0,0 +1,60 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+/*
+ * NAME
+ * abspath - expand a path relative to some `.'
+ *
+ * SYNOPSIS
+ * string *abspath(char *path, char *dot, string *to)
+ *
+ * DESCRIPTION
+ * If "path" is relative, ie: does not start with `.', the
+ * the value of "dot" will be prepended and the result
+ * returned in "to". Otherwise, the value of "path" is
+ * returned in "to".
+ */
+#include "synonyms.h"
+#include "libmail.h"
+#include <sys/types.h>
+
+string *
+abspath(char *path, char *dot, string *to)
+{
+ if (*path == '/') {
+ to = s_append(to, path);
+ } else {
+ to = s_append(to, dot);
+ to = s_append(to, path);
+ }
+ return (to);
+}
diff --git a/usr/src/lib/libmail/common/casncmp.c b/usr/src/lib/libmail/common/casncmp.c
new file mode 100644
index 0000000000..46f750f9ab
--- /dev/null
+++ b/usr/src/lib/libmail/common/casncmp.c
@@ -0,0 +1,62 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+/*
+ * NAME
+ * casncmp - compare strings ignoring case
+ *
+ * SYNOPSIS
+ * int casncmp(char *s1, char *s2, ssize_t n)
+ *
+ * DESCRIPTION
+ * Compare two strings ignoring case differences.
+ * Stop after n bytes or the trailing NUL.
+ */
+
+#include "synonyms.h"
+#include "libmail.h"
+#include <ctype.h>
+#include <sys/types.h>
+
+int
+casncmp(char *s1, char *s2, ssize_t n)
+{
+ if (s1 == s2)
+ return (0);
+ while ((--n >= 0) && (tolower(*s1) == tolower(*s2))) {
+ s2++;
+ if (*s1++ == '\0')
+ return (0);
+ }
+ return ((n < 0)? 0: (*s1 - *s2));
+}
diff --git a/usr/src/lib/libmail/common/copystream.c b/usr/src/lib/libmail/common/copystream.c
new file mode 100644
index 0000000000..1c12d6d13c
--- /dev/null
+++ b/usr/src/lib/libmail/common/copystream.c
@@ -0,0 +1,65 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.2 */
+/*LINTLIBRARY*/
+
+/*
+ NAME
+ copystream - copy one FILE stream to another
+
+ SYNOPSIS
+ int copystream(FILE *infp, FILE *outfp)
+
+ DESCRIPTION
+ copystream() copies one stream to another. The stream
+ infp must be opened for reading and the stream outfp
+ must be opened for writing.
+
+ It returns true if the stream is successively copied;
+ false if any writes fail.
+*/
+
+#include "synonyms.h"
+#include "libmail.h"
+#include <sys/types.h>
+
+int
+copystream(FILE *infp, FILE *outfp)
+{
+ char buffer[BUFSIZ];
+ size_t nread;
+
+ while ((nread = fread(buffer, sizeof (char), sizeof (buffer),
+ infp)) > 0)
+ if (fwrite(buffer, sizeof (char), nread, outfp) != nread)
+ return (0);
+ return (1);
+}
diff --git a/usr/src/lib/libmail/common/delempty.c b/usr/src/lib/libmail/common/delempty.c
new file mode 100644
index 0000000000..ceb9a0e65e
--- /dev/null
+++ b/usr/src/lib/libmail/common/delempty.c
@@ -0,0 +1,74 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+/*
+ * NAME
+ * delempty - delete an empty mail box
+ *
+ * SYNOPSIS
+ * int delempty(mode_t mode, char *mailname)
+ *
+ * DESCRIPTION
+ * Delete an empty mail box if it's allowed. Check
+ * the value of xgetenv("DEL_EMPTY_MFILE") for
+ * "yes" [always], "no" [never] or the default [based
+ * on the mode].
+ */
+
+#include "synonyms.h"
+#include "libmail.h"
+#include <sys/types.h>
+#include <unistd.h>
+
+int
+delempty(mode_t mode, char *mailname)
+{
+ char *del_empty = Xgetenv("DEL_EMPTY_MFILE");
+ size_t del_len;
+ int do_del = 0;
+
+ del_len = strlen(del_empty);
+ /* "yes" means always remove the mailfile */
+ if (casncmp(del_empty, "yes", (ssize_t)del_len))
+ do_del = 1;
+ /* "no" means never remove the mailfile */
+ else if (!casncmp(del_empty, "no", (ssize_t)del_len)) {
+ /* check for mode 0660 */
+ if ((mode & 07777) == MFMODE)
+ do_del = 1;
+ }
+
+ if (do_del)
+ (void) unlink(mailname);
+ return (do_del);
+}
diff --git a/usr/src/lib/libmail/common/getdomain.c b/usr/src/lib/libmail/common/getdomain.c
new file mode 100644
index 0000000000..94688baa90
--- /dev/null
+++ b/usr/src/lib/libmail/common/getdomain.c
@@ -0,0 +1,146 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include "libmail.h"
+#include <sys/types.h>
+#include <ctype.h>
+#ifdef SVR4
+#include <sys/utsname.h>
+#include <sys/systeminfo.h>
+#endif
+
+#define NMLN 512
+#ifdef SVR4
+#if SYS_NMLN > NMLN
+#undef NMLN
+#define NMLN SYS_NMLN
+#endif
+#endif
+
+static char *look4domain(char *, char *, int);
+static char *readdomain(char *, int);
+
+/*
+ * NAME
+ * maildomain() - retrieve the domain name
+ *
+ * SYNOPSIS
+ * char *maildomain()
+ *
+ * DESCRIPTION
+ * Retrieve the domain name from xgetenv("DOMAIN").
+ * If that is not set, look in /etc/resolv.conf, /etc/inet/named.boot
+ * and /etc/named.boot for "^domain[ ]+<domain>".
+ * If that is not set, use sysinfo(SI_SRPC_DOMAIN) from
+ * -lnsl. Otherwise, return an empty string.
+ */
+
+/* read a file for the domain */
+static char *look4domain(char *file, char *buf, int size)
+{
+ char *ret = 0;
+ FILE *fp = fopen(file, "r");
+
+ if (!fp)
+ return (0);
+
+ while (fgets(buf, size, fp))
+ if (strncmp(buf, "domain", 6) == 0)
+ if (isspace(buf[6])) {
+ char *x = skipspace(buf + 6);
+ if (isgraph(*x)) {
+ trimnl(x);
+ strmove(buf, x);
+ ret = buf;
+ break;
+ }
+ }
+
+ (void) fclose(fp);
+ return (ret);
+}
+
+/* read the domain from the xenvironment or one of the files */
+static char *readdomain(char *buf, int size)
+{
+ char *ret;
+
+ if ((ret = xgetenv("DOMAIN")) != 0) {
+ (void) strncpy(buf, ret, size);
+ return (buf);
+ }
+
+ if (((ret = look4domain("/etc/resolv.conf", buf, size)) != 0) ||
+ ((ret = look4domain("/etc/inet/named.boot", buf, size)) != 0) ||
+ ((ret = look4domain("/etc/named.boot", buf, size)) != 0))
+ return (ret);
+
+#ifdef SVR4
+ if (sysinfo(SI_SRPC_DOMAIN, buf, size) >= 0)
+ return (buf);
+#endif
+
+ return (0);
+}
+
+char *
+maildomain(void)
+{
+ static char *domain = 0;
+ static char dombuf[NMLN+1] = ".";
+
+ /* if we've already been here, return the info */
+ if (domain != 0)
+ return (domain);
+
+ domain = readdomain(dombuf+1, NMLN);
+
+ /* Make certain that the domain begins with a single dot */
+ /* and does not have one at the end. */
+ if (domain) {
+ size_t len;
+ domain = dombuf;
+ while (*domain && *domain == '.')
+ domain++;
+ domain--;
+ len = strlen(domain);
+ while ((len > 0) && (domain[len-1] == '.'))
+ domain[--len] = '\0';
+ }
+ /* no domain information */
+ else
+ domain = "";
+
+ return (domain);
+}
diff --git a/usr/src/lib/libmail/common/llib-lmail b/usr/src/lib/libmail/common/llib-lmail
new file mode 100644
index 0000000000..5db5e51906
--- /dev/null
+++ b/usr/src/lib/libmail/common/llib-lmail
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* LINTLIBRARY */
+/* PROTOLIB1 */
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <maillock.h>
+
+/*
+ * usr/src/lib/libmail
+ */
+
+/* maillock.c */
+int maillock(char *, int);
+void mailunlock(void);
+void touchlock(void);
diff --git a/usr/src/lib/libmail/common/maillock.c b/usr/src/lib/libmail/common/maillock.c
new file mode 100644
index 0000000000..aaaccbcce5
--- /dev/null
+++ b/usr/src/lib/libmail/common/maillock.c
@@ -0,0 +1,187 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include "maillock.h"
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <utime.h>
+
+#include <sys/stat.h>
+
+static char *lockext = ".lock"; /* Lock suffix for mailname */
+static char curlock[PATHSIZE]; /* Last used name of lock */
+static int locked; /* To note that we locked it */
+static time_t locktime; /* time lock file was touched */
+static time_t lock1(char *, char *);
+
+/*
+ * Lock the specified mail file by setting the file mailfile.lock.
+ * We must, of course, be careful to remove the lock file by a call
+ * to unlock before we stop. The algorithm used here is to see if
+ * the lock exists, and if it does, to check its modify time. If it
+ * is older than 5 minutes, we assume error and set our own file.
+ * Otherwise, we wait for 5 seconds and try again.
+ */
+
+/*ARGSUSED*/
+int
+maillock(char *user, int retrycnt)
+{
+ time_t t;
+ struct stat sbuf;
+ int statfailed;
+ char locktmp[PATHSIZE]; /* Usable lock temporary */
+ char file[PATHSIZE];
+
+ if (locked)
+ return (0);
+ (void) strcpy(file, MAILDIR);
+ (void) strcat(file, user);
+ (void) strcpy(curlock, file);
+ (void) strcat(curlock, lockext);
+ (void) strcpy(locktmp, file);
+ (void) strcat(locktmp, "XXXXXX");
+ (void) mktemp(locktmp);
+ (void) remove(locktmp);
+ statfailed = 0;
+ for (;;) {
+ t = lock1(locktmp, curlock);
+ if (t == (time_t)0) {
+ locked = 1;
+ locktime = time(0);
+ return (0);
+ }
+ if (stat(curlock, &sbuf) < 0) {
+ if (statfailed++ > 5)
+ return (-1);
+ (void) sleep(5);
+ continue;
+ }
+ statfailed = 0;
+
+ /*
+ * Compare the time of the temp file with the time
+ * of the lock file, rather than with the current
+ * time of day, since the files may reside on
+ * another machine whose time of day differs from
+ * ours. If the lock file is less than 5 minutes
+ * old, keep trying.
+ */
+ if (t < sbuf.st_ctime + 300) {
+ (void) sleep(5);
+ continue;
+ }
+ (void) remove(curlock);
+ }
+}
+
+/*
+ * Remove the mail lock, and note that we no longer
+ * have it locked.
+ */
+void
+mailunlock(void)
+{
+ (void) remove(curlock);
+ locked = 0;
+}
+
+/*
+ * Attempt to set the lock by creating the temporary file,
+ * then doing a link/unlink. If it succeeds, return 0,
+ * else return a guess of the current time on the machine
+ * holding the file.
+ */
+static time_t
+lock1(char tempfile[], char name[])
+{
+ int fd;
+ struct stat sbuf;
+
+ fd = open(tempfile, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (fd < 0)
+ return (time(0));
+ (void) fstat(fd, &sbuf);
+ /*
+ * Write the string "0" into the lock file to give us some
+ * interoperability with SVR4 mailers. SVR4 mailers expect
+ * a process ID to be written into the lock file and then
+ * use kill() to see if the process is alive or not. We write
+ * 0 into it so that SVR4 mailers will always think our lock file
+ * is valid.
+ */
+ (void) write(fd, "0", 2);
+ (void) close(fd);
+ if (link(tempfile, name) < 0) {
+ (void) remove(tempfile);
+ return (sbuf.st_ctime);
+ }
+ (void) remove(tempfile);
+ return ((time_t)0);
+}
+
+/*
+ * Update the change time on the lock file so
+ * others will know we're still using it.
+ */
+void
+touchlock(void)
+{
+ struct stat sbuf;
+ time_t t;
+ struct utimbuf tp;
+
+ if (!locked)
+ return;
+
+ /* if it hasn't been at least 3 minutes, don't bother */
+ if (time(&t) < locktime + 180)
+ return;
+ locktime = t;
+
+ if (stat(curlock, &sbuf) < 0)
+ return;
+ /*
+ * Don't actually change the times, we just want the
+ * side effect that utime causes st_ctime to be set
+ * to the current time.
+ */
+ tp.actime = sbuf.st_atime;
+ tp.modtime = sbuf.st_mtime;
+ (void) utime(curlock, &tp);
+}
diff --git a/usr/src/lib/libmail/common/notifyu.c b/usr/src/lib/libmail/common/notifyu.c
new file mode 100644
index 0000000000..5158839ce3
--- /dev/null
+++ b/usr/src/lib/libmail/common/notifyu.c
@@ -0,0 +1,118 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include "libmail.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <utmpx.h>
+#include <syslog.h>
+#if !defined(__cplusplus) && !defined(c_plusplus)
+typedef void (*SIG_PF) (int);
+#endif
+#include <unistd.h>
+#include <signal.h>
+
+static SIG_PF catcher(void);
+
+static SIG_PF catcher(void)
+{
+ /* do nothing, but allow the write() to break */
+ return (0);
+}
+
+void
+notify(char *user, char *msg, int check_mesg_y, char *etcdir)
+{
+ /* search the utmp file for this user */
+ SIG_PF old;
+ unsigned int oldalarm;
+ struct utmpx utmpx, *putmpx = &utmpx;
+
+ setutxent();
+
+ /* grab the tty name */
+ while ((putmpx = getutxent()) != NULL) {
+ if (strncmp(user, utmpx.ut_name,
+ sizeof (utmpx.ut_name)) == 0) {
+ char tty[sizeof (utmpx.ut_line)+1];
+ char dev[MAXFILENAME];
+ FILE *port;
+ size_t i;
+ int fd;
+
+ for (i = 0; i < sizeof (utmpx.ut_line); i++)
+ tty[i] = utmpx.ut_line[i];
+ tty[i] = '\0';
+
+ /* stick /dev/ in front */
+ (void) sprintf(dev, "%s/dev/%s", etcdir, tty);
+
+ /* break out if write() to the tty hangs */
+ old = (SIG_PF)signal(SIGALRM, (SIG_PF)catcher);
+ oldalarm = alarm(300);
+
+ /* check if device is really a tty */
+ if ((fd = open(dev, O_WRONLY|O_NOCTTY)) == -1) {
+ (void) fprintf(stderr,
+ "Cannot open %s.\n", dev);
+ continue;
+ } else {
+ if (!isatty(fd)) {
+ (void) fprintf(stderr, "%s in utmpx is "
+ "not a tty\n", tty);
+ openlog("mail", 0, LOG_AUTH);
+ syslog(LOG_CRIT, "%s in utmp is "
+ "not a tty\n", tty);
+ closelog();
+ (void) close(fd);
+ continue;
+ }
+ }
+ (void) close(fd);
+
+ /* write to the tty */
+ port = fopen(dev, "w");
+ if (port != 0) {
+ (void) fprintf(port, "\r\n%s\r\n", msg);
+ (void) fclose(port);
+ }
+
+ /* clean up our alarm */
+ (void) alarm(0);
+ (void) signal(SIGALRM, old);
+ (void) alarm(oldalarm);
+ }
+ }
+ endutxent();
+}
diff --git a/usr/src/lib/libmail/common/popenvp.c b/usr/src/lib/libmail/common/popenvp.c
new file mode 100644
index 0000000000..cade21151f
--- /dev/null
+++ b/usr/src/lib/libmail/common/popenvp.c
@@ -0,0 +1,126 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+/*
+ * These routines are based on the standard UNIX stdio popen/pclose
+ * routines. This version takes an argv[][] argument instead of a string
+ * to be passed to the shell. The routine execvp() is used to call the
+ * program, hence the name popenvp() and the argument types.
+ *
+ * This routine avoids an extra shell completely, along with not having
+ * to worry about quoting conventions in strings that have spaces,
+ * quotes, etc.
+ */
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include <assert.h>
+#include <string.h>
+#include "libmail.h"
+#include <sys/wait.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <errno.h>
+
+#define tst(a, b) (*mode == 'r'? (b) : (a))
+#define RDR 0
+#define WTR 1
+
+#include <unistd.h>
+static pid_t popen_pid[20];
+
+/* Functions calling popenvp() should ensure 'file' is non-NULL */
+
+FILE *
+popenvp(char *file, char **argv, char *mode, int resetid)
+{
+ int p[2];
+ int myside, yourside;
+ pid_t pid;
+
+ assert(file != NULL);
+ if (pipe(p) < 0)
+ return (NULL);
+ myside = tst(p[WTR], p[RDR]);
+ yourside = tst(p[RDR], p[WTR]);
+ if ((pid = fork()) == 0) {
+ /* myside and yourside reverse roles in child */
+ int stdio;
+
+ if (resetid) {
+ (void) setgid(getgid());
+ (void) setuid(getuid());
+ }
+ stdio = tst(0, 1);
+ (void) close(myside);
+ (void) close(stdio);
+ (void) fcntl(yourside, F_DUPFD, stdio);
+ (void) close(yourside);
+ (void) execvp(file, argv);
+ (void) fprintf(stderr, "exec of \"%s\" failed: %s\n",
+ file, strerror(errno));
+ (void) fflush(stderr);
+ _exit(1);
+ }
+ if (pid == (pid_t)-1)
+ return (NULL);
+ popen_pid[myside] = pid;
+ (void) close(yourside);
+ return (fdopen(myside, mode));
+}
+
+int
+pclosevp(FILE *ptr)
+{
+ int f;
+ pid_t r;
+ int status;
+ void (*hstat)(int), (*istat)(int), (*qstat)(int);
+
+ f = fileno(ptr);
+ (void) fclose(ptr);
+ istat = signal(SIGINT, SIG_IGN);
+ qstat = signal(SIGQUIT, SIG_IGN);
+ hstat = signal(SIGHUP, SIG_IGN);
+ do
+ r = wait(&status);
+ while (r != popen_pid[f] && r != (pid_t)-1);
+
+ if (r == (pid_t)-1)
+ status = -1;
+ (void) signal(SIGINT, istat);
+ (void) signal(SIGQUIT, qstat);
+ (void) signal(SIGHUP, hstat);
+ return (status);
+}
diff --git a/usr/src/lib/libmail/common/s_string.c b/usr/src/lib/libmail/common/s_string.c
new file mode 100644
index 0000000000..b74b35c908
--- /dev/null
+++ b/usr/src/lib/libmail/common/s_string.c
@@ -0,0 +1,417 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "s_string.h"
+#include <stdlib.h>
+
+/* global to this file */
+#define STRLEN 128UL
+#define STRALLOC 128UL
+#define MAXINCR 250000UL
+
+/* buffer pool for allocating string structures */
+typedef struct {
+ string s[STRALLOC];
+ size_t o;
+} stralloc;
+static stralloc *freep = NULL;
+
+/* pool of freed strings */
+static string *freed = NULL;
+static string *s_alloc(void);
+static void s_simplegrow(string *, size_t);
+
+void
+s_free(string *sp)
+{
+ if (sp != NULL) {
+ sp->ptr = (char *)freed;
+ freed = sp;
+ }
+}
+
+/* allocate a string head */
+static string *
+s_alloc(void)
+{
+ if (freep == NULL || freep->o >= STRALLOC) {
+ freep = (stralloc *)malloc(sizeof (stralloc));
+ if (freep == NULL) {
+ perror("allocating string");
+ exit(1);
+ }
+ freep->o = (size_t)0;
+ }
+ return (&(freep->s[freep->o++]));
+}
+
+/* create a new `short' string */
+string *
+s_new(void)
+{
+ string *sp;
+
+ if (freed != NULL) {
+ sp = freed;
+ /*LINTED*/
+ freed = (string *)(freed->ptr);
+ sp->ptr = sp->base;
+ return (sp);
+ }
+ sp = s_alloc();
+ sp->base = sp->ptr = malloc(STRLEN);
+ if (sp->base == NULL) {
+ perror("allocating string");
+ exit(1);
+ }
+ sp->end = sp->base + STRLEN;
+ s_terminate(sp);
+ return (sp);
+}
+
+/* grow a string's allocation by at least `incr' bytes */
+static void
+s_simplegrow(string *sp, size_t incr)
+{
+ char *cp;
+ size_t size;
+
+ /*
+ * take a larger increment to avoid mallocing too often
+ */
+ if (((sp->end - sp->base) < incr) && (MAXINCR < incr))
+ size = (sp->end - sp->base) + incr;
+ else if ((sp->end - sp->base) > MAXINCR)
+ size = (sp->end - sp->base) + MAXINCR;
+ else
+ size = (size_t)2 * (sp->end - sp->base);
+
+ cp = realloc(sp->base, size);
+ if (cp == NULL) {
+ perror("string:");
+ exit(1);
+ }
+ sp->ptr = (sp->ptr - sp->base) + cp;
+ sp->end = cp + size;
+ sp->base = cp;
+}
+
+/* grow a string's allocation */
+int
+s_grow(string *sp, int c)
+{
+ s_simplegrow(sp, (size_t)2);
+ s_putc(sp, c);
+ return (c);
+}
+
+/* return a string containing a character array (this had better not grow) */
+string *
+s_array(char *cp, size_t len)
+{
+ string *sp = s_alloc();
+
+ sp->base = sp->ptr = cp;
+ sp->end = sp->base + len;
+ return (sp);
+}
+
+/* return a string containing a copy of the passed char array */
+string*
+s_copy(char *cp)
+{
+ string *sp;
+ size_t len;
+
+ sp = s_alloc();
+ len = strlen(cp)+1;
+ sp->base = malloc(len);
+ if (sp->base == NULL) {
+ perror("string:");
+ exit(1);
+ }
+ sp->end = sp->base + len; /* point past end of allocation */
+ (void) strcpy(sp->base, cp);
+ sp->ptr = sp->end - (size_t)1; /* point to NULL terminator */
+ return (sp);
+}
+
+/* convert string to lower case */
+void
+s_tolower(string *sp)
+{
+ char *cp;
+
+ for (cp = sp->ptr; *cp; cp++)
+ *cp = tolower(*cp);
+}
+
+void
+s_skipwhite(string *sp)
+{
+ while (isspace(*sp->ptr))
+ s_skipc(sp);
+}
+
+/* append a char array to a string */
+string *
+s_append(string *to, char *from)
+{
+ if (to == NULL)
+ to = s_new();
+ if (from == NULL)
+ return (to);
+ for (; *from; from++)
+ s_putc(to, (int)(unsigned int)*from);
+ s_terminate(to);
+ return (to);
+}
+
+/*
+ * Append a logical input sequence into a string. Ignore blank and
+ * comment lines. Backslash preceding newline indicates continuation.
+ * The `lineortoken' variable indicates whether the sequence to beinput
+ * is a whitespace delimited token or a whole line.
+ *
+ * FILE *fp; stream to read from
+ * string *to; where to put token
+ * int lineortoken; how the sequence terminates
+ *
+ * Returns a pointer to the string or NULL. Trailing newline is stripped off.
+ */
+string *
+s_seq_read(FILE *fp, string *to, int lineortoken)
+{
+ int c;
+ int done = 0;
+
+ if (feof(fp))
+ return (NULL);
+
+ /* get rid of leading goo */
+ do {
+ c = getc(fp);
+ switch (c) {
+ case EOF:
+ if (to != NULL)
+ s_terminate(to);
+ return (NULL);
+ case '#':
+ /*LINTED*/
+ while ((c = getc(fp)) != '\n' && c != EOF);
+ break;
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ case '\f':
+ break;
+ default:
+ done = 1;
+ break;
+ }
+ } while (!done);
+
+ if (to == NULL)
+ to = s_new();
+
+ /* gather up a sequence */
+ for (;;) {
+ switch (c) {
+ case '\\':
+ c = getc(fp);
+ if (c != '\n') {
+ s_putc(to, (int)(unsigned int)'\\');
+ s_putc(to, c);
+ }
+ break;
+ case EOF:
+ case '\r':
+ case '\f':
+ case '\n':
+ s_terminate(to);
+ return (to);
+ case ' ':
+ case '\t':
+ if (lineortoken == TOKEN) {
+ s_terminate(to);
+ return (to);
+ }
+ /* fall through */
+ default:
+ s_putc(to, c);
+ break;
+ }
+ c = getc(fp);
+ }
+}
+
+string *
+s_tok(string *from, char *split)
+{
+ char *splitend = strpbrk(from->ptr, split);
+
+ if (splitend) {
+ string *to = s_new();
+ for (; from->ptr < splitend; ) {
+ s_putc(to, (int)(unsigned int)*from->ptr);
+ from->ptr++;
+ }
+ s_terminate(to);
+ s_restart(to);
+ /* LINT: warning due to lint bug */
+ from->ptr += strspn(from->ptr, split);
+ return (to);
+ }
+
+ else if (from->ptr[0]) {
+ string *to = s_clone(from);
+ while (*from->ptr)
+ from->ptr++;
+ return (to);
+ }
+
+ else
+ return (NULL);
+}
+
+/*
+ * Append an input line to a string.
+ *
+ * Returns a pointer to the string (or NULL).
+ * Trailing newline is left on.
+ */
+char *
+s_read_line(FILE *fp, string *to)
+{
+ int c;
+ size_t len = 0;
+
+ s_terminate(to);
+
+ /* end of input */
+ if (feof(fp) || (c = getc(fp)) == EOF)
+ return (NULL);
+
+ /* gather up a line */
+ for (; ; ) {
+ len++;
+ switch (c) {
+ case EOF:
+ s_terminate(to);
+ return (to->ptr - len);
+ case '\n':
+ s_putc(to, (int)(unsigned int)'\n');
+ s_terminate(to);
+ return (to->ptr - len);
+ default:
+ s_putc(to, c);
+ break;
+ }
+ c = getc(fp);
+ }
+}
+
+/*
+ * Read till eof
+ */
+size_t
+s_read_to_eof(FILE *fp, string *to)
+{
+ size_t got;
+ size_t have;
+
+ s_terminate(to);
+
+ for (; ; ) {
+ if (feof(fp))
+ break;
+ /* allocate room for a full buffer */
+ have = to->end - to->ptr;
+ if (have < 4096UL)
+ s_simplegrow(to, (size_t)4096);
+
+ /* get a buffers worth */
+ have = to->end - to->ptr;
+ got = fread(to->ptr, (size_t)1, have, fp);
+ if (got == (size_t)0)
+ break;
+ /* LINT: warning due to lint bug */
+ to->ptr += got;
+ }
+
+ /* null terminate the line */
+ s_terminate(to);
+ return (to->ptr - to->base);
+}
+
+/*
+ * Get the next field from a string. The field is delimited by white space,
+ * single or double quotes.
+ *
+ * string *from; string to parse
+ * string *to; where to put parsed token
+ */
+string *
+s_parse(string *from, string *to)
+{
+ while (isspace(*from->ptr))
+ from->ptr++;
+ if (*from->ptr == '\0')
+ return (NULL);
+ if (to == NULL)
+ to = s_new();
+ if (*from->ptr == '\'') {
+ from->ptr++;
+ for (; *from->ptr != '\'' && *from->ptr != '\0'; from->ptr++)
+ s_putc(to, (int)(unsigned int)*from->ptr);
+ if (*from->ptr == '\'')
+ from->ptr++;
+ } else if (*from->ptr == '"') {
+ from->ptr++;
+ for (; *from->ptr != '"' && *from->ptr != '\0'; from->ptr++)
+ s_putc(to, (int)(unsigned int)*from->ptr);
+ if (*from->ptr == '"')
+ from->ptr++;
+ } else {
+ for (; !isspace(*from->ptr) && *from->ptr != '\0'; from->ptr++)
+ s_putc(to, (int)(unsigned int)*from->ptr);
+ }
+ s_terminate(to);
+
+ return (to);
+}
diff --git a/usr/src/lib/libmail/common/setup_exec.c b/usr/src/lib/libmail/common/setup_exec.c
new file mode 100644
index 0000000000..e1987806ad
--- /dev/null
+++ b/usr/src/lib/libmail/common/setup_exec.c
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include <ctype.h>
+#include "libmail.h"
+
+#define TRUE 1
+#define FALSE 0
+
+char **
+setup_exec(char *s)
+{
+ char *p = s, *q;
+ static char *argvec[256]; /* is this enough? */
+ int i = 0;
+ int stop;
+ int ignorespace = FALSE;
+
+ /* Parse up string into arg. vec. for subsequent exec. Assume */
+ /* whitespace delimits args. Any non-escaped double quotes will */
+ /* be used to group multiple whitespace-delimited tokens into */
+ /* a single exec arg. */
+ p = skipspace(p);
+ while (*p) {
+ q = p;
+ stop = FALSE;
+ while (*q && (stop == FALSE)) {
+ again:
+ switch (*q) {
+ case '\\':
+ /* Slide command string 1 char to left */
+ strmove(q, q+1);
+ break;
+ case '"':
+ ignorespace = ((ignorespace == TRUE) ?
+ FALSE : TRUE);
+ /* Slide command string 1 char to left */
+ strmove(q, q+1);
+ goto again;
+ default:
+ if (isspace((int)*q) &&
+ (ignorespace == FALSE)) {
+ stop = TRUE;
+ continue;
+ }
+ break;
+ }
+ q++;
+ }
+ if (*q == '\0') {
+ argvec[i++] = p;
+ break;
+ }
+ *q++ = '\0';
+ argvec[i++] = p;
+ p = skipspace(q);
+ }
+ argvec[i] = NULL;
+ if (i == 0) {
+ return (NULL);
+ }
+ return (argvec);
+}
diff --git a/usr/src/lib/libmail/common/skipspace.c b/usr/src/lib/libmail/common/skipspace.c
new file mode 100644
index 0000000000..37468a902e
--- /dev/null
+++ b/usr/src/lib/libmail/common/skipspace.c
@@ -0,0 +1,49 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+#include <ctype.h>
+
+/*
+ * Return pointer to first non-blank character in p
+ */
+char *
+skipspace(char *p)
+{
+ while (*p && isspace(*p)) {
+ p++;
+ }
+ return (p);
+}
diff --git a/usr/src/lib/libmail/common/strmove.c b/usr/src/lib/libmail/common/strmove.c
new file mode 100644
index 0000000000..ee6f967e6a
--- /dev/null
+++ b/usr/src/lib/libmail/common/strmove.c
@@ -0,0 +1,56 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+
+/*
+ * NAME
+ * strmove - copy a string, permitting overlaps
+ *
+ * SYNOPSIS
+ * void strmove(char *to, char *from)
+ *
+ * DESCRIPTION
+ * strmove() acts exactly like strcpy() with the additional
+ * guarantee that it will work with overlapping strings.
+ * It does it left-to-right, a byte at a time.
+ */
+
+void
+strmove(char *to, char *from)
+{
+ while ((*to++ = *from++) != 0)
+ ;
+}
diff --git a/usr/src/lib/libmail/common/substr.c b/usr/src/lib/libmail/common/substr.c
new file mode 100644
index 0000000000..74c7be8de7
--- /dev/null
+++ b/usr/src/lib/libmail/common/substr.c
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+
+/*
+ * This routine looks for string2 in string1.
+ * If found, it returns the position string2 is found at,
+ * otherwise it returns a -1.
+ */
+int
+substr(char *string1, char *string2)
+{
+ int i, j, len1, len2;
+
+ /* the size of the substring will always fit into an int */
+ /*LINTED*/
+ len1 = (int)strlen(string1);
+ /*LINTED*/
+ len2 = (int)strlen(string2);
+ for (i = 0; i < len1 - len2 + 1; i++) {
+ for (j = 0; j < len2 && string1[i+j] == string2[j]; j++);
+ if (j == len2)
+ return (i);
+ }
+ return (-1);
+}
diff --git a/usr/src/lib/libmail/common/systemvp.c b/usr/src/lib/libmail/common/systemvp.c
new file mode 100644
index 0000000000..cbcc350cb9
--- /dev/null
+++ b/usr/src/lib/libmail/common/systemvp.c
@@ -0,0 +1,75 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+/*
+ * These routines are based on the standard UNIX stdio popen/pclose
+ * routines. This version takes an argv[][] argument instead of a string
+ * to be passed to the shell. The routine execvp() is used to call the
+ * program, hence the name popenvp() and the argument types.
+ *
+ * This routine avoids an extra shell completely, along with not having
+ * to worry about quoting conventions in strings that have spaces,
+ * quotes, etc.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+#include <signal.h>
+#include <unistd.h>
+#include <wait.h>
+
+pid_t
+systemvp(char *file, char **argv, int resetid)
+{
+ int status;
+ pid_t pid, w;
+ void (*istat)(int), (*qstat)(int);
+
+ if ((pid = fork()) == 0) {
+ if (resetid) {
+ (void) setgid(getgid());
+ (void) setuid(getuid());
+ }
+ (void) execvp(file, argv);
+ _exit(127);
+ }
+ istat = signal(SIGINT, SIG_IGN);
+ qstat = signal(SIGQUIT, SIG_IGN);
+ do
+ w = wait(&status);
+ while (w != pid && w != (pid_t)-1);
+ (void) signal(SIGINT, istat);
+ (void) signal(SIGQUIT, qstat);
+ return ((w == (pid_t)-1)? w: (pid_t)status);
+}
diff --git a/usr/src/lib/libmail/common/trimnl.c b/usr/src/lib/libmail/common/trimnl.c
new file mode 100644
index 0000000000..badc5167c6
--- /dev/null
+++ b/usr/src/lib/libmail/common/trimnl.c
@@ -0,0 +1,51 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
+/*LINTLIBRARY*/
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+#include <string.h>
+
+/*
+ * Trim trailing newlines from string.
+ */
+void
+trimnl(char *s)
+{
+ char *p;
+
+ p = s + strlen(s) - 1;
+ while ((*p == '\n') && (p >= s)) {
+ *p-- = '\0';
+ }
+}
diff --git a/usr/src/lib/libmail/common/xgetenv.c b/usr/src/lib/libmail/common/xgetenv.c
new file mode 100644
index 0000000000..15f4b0a08f
--- /dev/null
+++ b/usr/src/lib/libmail/common/xgetenv.c
@@ -0,0 +1,209 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+/*LINTLIBRARY*/
+
+/*
+ * NAME
+ * xsetenv, xgetenv, Xgetenv - manage an alternate environment space
+ *
+ * SYNOPSIS
+ * int ret = xsetenv(file)
+ * char *x = xgetenv("FOO");
+ * char *x = Xgetenv("FOO");
+ *
+ * DESCRIPTION
+ * xsetenv() reads the given file into an internal buffer
+ * and sets up an alternate environment.
+ *
+ * Return values: 1 - OKAY
+ * 0 - troubles reading the file
+ * -1 - troubles opening the file
+ *
+ * xgetenv() returns the environment value from the
+ * alternate environment.
+ *
+ * Return values: (char *)0 - no value for that variable
+ * pointer - the value
+ *
+ * Xgetenv() returns the environment value from the
+ * alternate environment.
+ *
+ * Return values: "" - no value for that variable
+ * pointer - the value
+ *
+ * LIMITATIONS
+ * Assumes the environment is < 5120 bytes, as in the UNIX
+ * System environment. Assumes < 512 lines in the file.
+ * These values may be adjusted below.
+ */
+
+#include "synonyms.h"
+#include <sys/types.h>
+#include "libmail.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <ctype.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#define MAXVARS 512
+#define MAXENV 5120
+
+static char **xenv = 0;
+static char *(xenvptrs[MAXVARS]);
+static char xbuf[MAXENV];
+
+static void reduce(char *);
+
+/*
+ * set up an environment buffer
+ * and the pointers into it
+ */
+int
+xsetenv(char *xfile)
+{
+ int envctr, infd;
+ ssize_t i, nread;
+
+ /* Open the file */
+ infd = open(xfile, O_RDONLY);
+ if (infd == -1) {
+ return (-1);
+ }
+
+ /* Read in the entire file. */
+ nread = read(infd, xbuf, sizeof (xbuf));
+ if (nread < 0) {
+ (void) close(infd);
+ return (0);
+ }
+
+ /*
+ * Set up pointers into the buffer.
+ * Replace \n with \0.
+ * Collapse white space around the = sign and at the
+ * beginning and end of the line.
+ */
+ xenv = xenvptrs;
+ xenv[0] = &xbuf[0];
+ for (i = 0, envctr = 0; i < nread; i++) {
+ if (xbuf[i] == '\n') {
+ xbuf[i] = '\0';
+ reduce(xenv[envctr]);
+ xenv[++envctr] = &xbuf[i+1];
+ if (envctr == MAXVARS) {
+ break;
+ }
+ }
+ }
+
+ xenv[envctr] = 0;
+ (void) close(infd);
+ return (1);
+}
+
+/*
+ * Let getenv() do the dirty work
+ * of looking up the variable. We
+ * do this by temporarily resetting
+ * environ to point to the local area.
+ */
+char *
+xgetenv(char *env)
+{
+ extern char **environ;
+ char *ret, **svenviron = environ;
+
+ environ = xenv;
+ ret = getenv(env);
+ environ = svenviron;
+ return (ret);
+}
+
+/*
+ * Let xgetenv() do the dirty work
+ * of looking up the variable.
+ */
+char *
+Xgetenv(char *env)
+{
+ char *ret = xgetenv(env);
+ return (ret ? ret : "");
+}
+
+/*
+ * Remove the spaces within the environment variable.
+ * The variable can look like this:
+ *
+ * <sp1> variable <sp2> = <sp3> value <sp4> \0
+ *
+ * All spaces can be removed, except within
+ * the variable name and the value.
+ */
+
+static void
+reduce(char *from)
+{
+ char *to = from;
+ char *svfrom = from;
+
+ /* <sp1> */
+ while (*from &&isspace((int)*from))
+ from++;
+
+ /* variable */
+ while (*from && (*from != '=') && !isspace((int)*from))
+ *to++ = *from++;
+
+ /* <sp2> */
+ while (*from && isspace((int)*from))
+ from++;
+
+ /* = */
+ if (*from == '=')
+ *to++ = *from++;
+
+ /* <sp3> */
+ while (*from && isspace((int)*from))
+ from++;
+
+ /* value */
+ while (*from)
+ *to++ = *from++;
+
+ /* <sp4> */
+ while ((to > svfrom) && isspace((int)to[-1]))
+ to--;
+ *to = '\0';
+}
diff --git a/usr/src/lib/libmail/i386/Makefile b/usr/src/lib/libmail/i386/Makefile
new file mode 100644
index 0000000000..9e9ecfbaf6
--- /dev/null
+++ b/usr/src/lib/libmail/i386/Makefile
@@ -0,0 +1,38 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/i386/Makefile
+
+MAPDIR= ../spec/i386
+
+include ../Makefile.com
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libmail/inc/libmail.h b/usr/src/lib/libmail/inc/libmail.h
new file mode 100644
index 0000000000..348e42891f
--- /dev/null
+++ b/usr/src/lib/libmail/inc/libmail.h
@@ -0,0 +1,96 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+/* This is a private header file. */
+
+#ifndef _LIBMAIL_H
+#define _LIBMAIL_H
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */
+
+#include <stdio.h>
+#include <maillock.h>
+#include "s_string.h"
+
+#ifndef MFMODE
+#define MFMODE 0660 /* create mode for `/var/mail' files */
+#endif
+#ifdef FILENAME_MAX
+#define MAXFILENAME FILENAME_MAX /* max length of a filename */
+#else
+#define MAXFILENAME 512 /* max length of a filename */
+#endif
+
+/* The following typedefs must be used in SVR4 */
+#ifdef SVR3
+typedef int mode_t;
+#else
+# include <sys/types.h>
+#endif
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern string *abspath(char *path, char *dot, string *to);
+extern int casncmp(char *s1, char *s2, ssize_t n);
+extern int copystream(FILE *infp, FILE *outfp);
+extern int delempty(mode_t m, char *mailname);
+extern char *maildomain(void);
+extern void notify(char *user, char *msg, int check_mesg_y, char *etcdir);
+extern int pclosevp(FILE *fp);
+extern FILE *popenvp(char *file, char **argv, char *mode, int resetid);
+extern char **setup_exec(char *s);
+extern char *skipspace(char *p);
+extern int substr(char *string1, char *string2);
+extern void strmove(char *from, char *to);
+extern pid_t systemvp(char *file, char **argv, int resetid);
+extern void trimnl(char *s);
+extern char *Xgetenv(char *env);
+extern char *xgetenv(char *env);
+extern int xsetenv(char *file);
+#else
+extern string *abspath();
+extern int casncmp();
+extern int copystream();
+extern int delempty();
+extern char *maildomain();
+extern void notify();
+extern int pclosevp();
+extern FILE *popenvp();
+extern char **setup_exec();
+extern char *skipspace();
+extern void strmove();
+extern int substr();
+extern pid_t systemvp();
+extern void trimnl();
+extern char *Xgetenv();
+extern char *xgetenv();
+extern int xsetenv();
+#endif
+
+#endif /* _LIBMAIL_H */
diff --git a/usr/src/lib/libmail/inc/maillock.h b/usr/src/lib/libmail/inc/maillock.h
new file mode 100644
index 0000000000..069952a6f1
--- /dev/null
+++ b/usr/src/lib/libmail/inc/maillock.h
@@ -0,0 +1,66 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+#ifndef _MAILLOCK_H
+#define _MAILLOCK_H
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAILDIR "/var/mail/"
+#define SAVEDIR "/var/mail/:saved/"
+
+#define PATHSIZE 1024 /* maximum path length of a lock file */
+#define L_SUCCESS 0
+#define L_NAMELEN 1 /* recipient name > 13 chars */
+#define L_TMPLOCK 2 /* problem creating temp lockfile */
+#define L_TMPWRITE 3 /* problem writing pid into temp lockfile */
+#define L_MAXTRYS 4 /* cannot link to lockfile after N tries */
+#define L_ERROR 5 /* Something other than EEXIST happened */
+#define L_MANLOCK 6 /* cannot set mandatory lock on temp lockfile */
+
+#if defined(__STDC__)
+extern int maillock(char *user, int retrycnt);
+extern void mailunlock(void);
+extern void touchlock(void);
+#else
+extern int maillock();
+extern void mailunlock();
+extern void touchlock();
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _MAILLOCK_H */
diff --git a/usr/src/lib/libmail/inc/s_string.h b/usr/src/lib/libmail/inc/s_string.h
new file mode 100644
index 0000000000..2153a54e02
--- /dev/null
+++ b/usr/src/lib/libmail/inc/s_string.h
@@ -0,0 +1,103 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright (c) 1999, by Sun Microsystems, Inc.
+ * All rights reserved.
+ */
+
+/* This is a private header file. */
+
+#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.4 */
+/* extensible strings */
+
+#ifndef _S_STRING_H
+#define _S_STRING_H
+
+#include <string.h>
+
+typedef struct string {
+ char *base; /* base of string */
+ char *end; /* end of allocated space+1 */
+ char *ptr; /* ptr into string */
+} string;
+
+/*
+ * LINT: expect lint warnings from the following macros
+ * Some macros have an integer at the end, which has null effect according
+ * to lint, but causes the last expression to be evaluated as an int (didn't
+ * change this).
+ */
+#define s_clone(s) s_copy((s)->ptr)
+#define s_curlen(s) ((s)->ptr - (s)->base)
+#define s_dup(s) s_copy((s)->base)
+#define s_getc(s) (*((s)->ptr++))
+#define s_peek(s) (*((s)->ptr))
+#define s_putc(s,c) (((s)->ptr < (s)->end) ? (*((s)->ptr)++ = (char)(c)) : s_grow((s),(c)))
+#define s_reset(s) ((s) ? (*((s)->ptr = (s)->base) = '\0' , (s)) : s_new())
+#define s_restart(s) ((s)->ptr = (s)->base , (s))
+#define s_skipc(s) ((s)->ptr++)
+#define s_space(s) ((s)->end - (s)->base)
+#define s_terminate(s) (((s)->ptr < (s)->end) ? (*(s)->ptr = 0) : (s_grow((s),0), (s)->ptr--, 0))
+#define s_to_c(s) ((s)->base)
+#define s_ptr_to_c(s) ((s)->ptr)
+
+#ifdef __STDC__
+extern string *s_append(string *to, char *from);
+extern string *s_array(char *, size_t len);
+extern string *s_copy(char *);
+extern void s_free(string*);
+extern int s_grow(string *sp, int c);
+extern string *s_new(void);
+extern string *s_parse(string *from, string *to);
+extern char *s_read_line(FILE *fp, string *to);
+extern size_t s_read_to_eof(FILE *fp, string *to);
+extern string *s_seq_read(FILE *fp, string *to, int lineortoken);
+extern void s_skipwhite(string *from);
+extern string *s_tok(string*, char*);
+extern void s_tolower(string*);
+#else
+extern string *s_append();
+extern string *s_array();
+extern string *s_copy();
+extern void s_free();
+extern int s_grow();
+extern string *s_new();
+extern string *s_parse();
+extern char *s_read_line();
+extern size_t s_read_to_eof();
+extern string *s_seq_read();
+extern void s_skipwhite();
+extern string *s_tok();
+extern void s_tolower();
+#endif
+
+/* controlling the action of s_seq_read */
+#define TOKEN 0 /* read the next whitespace delimited token */
+#define LINE 1 /* read the next logical input line */
+#define s_getline(a,b) s_seq_read(a,b,LINE)
+#define s_gettoken(a,b) s_seq_read(a,b,TOKEN)
+
+#endif /* _S_STRING_H */
diff --git a/usr/src/lib/libmail/inc/synonyms.h b/usr/src/lib/libmail/inc/synonyms.h
new file mode 100644
index 0000000000..a0f7cd54c8
--- /dev/null
+++ b/usr/src/lib/libmail/inc/synonyms.h
@@ -0,0 +1,582 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/* Copyright (c) 1988 AT&T */
+/* All Rights Reserved */
+
+
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _LIBMAIL_SYNONYMS_H
+#define _LIBMAIL_SYNONYMS_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* external data */
+#define altzone _altzone
+#define daylight _daylight
+#define lone _lone
+#define lten _lten
+#define lzero _lzero
+#define timezone _timezone
+#define tzname _tzname
+
+/* functions */
+#define Msgdb _Msgdb
+#define a64l _a64l
+#define access _access
+#define acct _acct
+#define acl _acl
+#define addseverity _addseverity
+#define adjtime _adjtime
+#define alarm _alarm
+#define ascftime _ascftime
+#define asctime_r _asctime_r
+#define basename _basename
+#define brk _brk
+#define brkbase _brkbase
+#define bsd_signal _bsd_signal
+#define catclose _catclose
+#define catgets _catgets
+#define catopen _catopen
+#define cfgetispeed _cfgetispeed
+#define cfgetospeed _cfgetospeed
+#define cfree _cfree
+#define cfsetispeed _cfsetispeed
+#define cfsetospeed _cfsetospeed
+#define cftime _cftime
+#define ctime_r _ctime_r
+#define chdir _chdir
+#define chmod _chmod
+#define chown _chown
+#define chroot _chroot
+#define close _close
+#define closedir _closedir
+#define closelog _closelog
+#define countbase _countbase
+#define creat _creat
+#define crypt _crypt
+#define ctermid _ctermid
+#define cuserid _cuserid
+#define dial _dial
+#define dirname _dirname
+#define dlclose _dlclose
+#define dlopen _dlopen
+#define dlsym _dlsym
+#define dlerror _dlerror
+#define door_bind _door_bind
+#define door_call _door_call
+#define door_create _door_create
+#define door_cred _door_cred
+#define door_getparam _door_getparam
+#define door_info _door_info
+#define door_return _door_return
+#define door_revoke _door_revoke
+#define door_setparam _door_setparam
+#define door_server_create _door_server_create
+#define door_ucred _door_ucred
+#define door_unbind _door_unbind
+#define drand48 _drand48
+#define dup _dup
+#define dup2 _dup2
+#define ecvt _ecvt
+#define edata _edata
+#define encrypt _encrypt
+#define end _end
+#define endgrent _endgrent
+#define endpwent _endpwent
+#define endspent _endspent
+#define endutent _endutent
+#define endutxent _endutxent
+#define environ _environ
+#define erand48 _erand48
+#define etext _etext
+#define execl _execl
+#define execle _execle
+#define execlp _execlp
+#define execv _execv
+#define execve _execve
+#define execvp _execvp
+#define exportfs _exportfs
+#define facl _facl
+#define fattach _fattach
+#define fchdir _fchdir
+#define fchmod _fchmod
+#define fchown _fchown
+#define fchroot _fchroot
+#define fcntl _fcntl
+#define fcvt _fcvt
+#define fdetach _fdetach
+#define fdopen _fdopen
+#define ffs _ffs
+#define fgetgrent _fgetgrent
+#define fgetgrent_r _fgetgrent_r
+#define fgetpwent _fgetpwent
+#define fgetpwent_r _fgetpwent_r
+#define fgetspent _fgetspent
+#define fgetspent_r _fgetspent_r
+#define finite _finite
+#define fmtmsg _fmtmsg
+#define fork _fork
+#define fork1 _fork1
+#define fpathconf _fpathconf
+#define fpclass _fpclass
+#define fpgetmask _fpgetmask
+#define fpgetround _fpgetround
+#define fpgetsticky _fpgetsticky
+#define fprintf _fprintf
+#define fpsetmask _fpsetmask
+#define fpsetround _fpsetround
+#define fpsetsticky _fpsetsticky
+#define fstat _fstat
+#define fstatfs _fstatfs
+#define fstatvfs _fstatvfs
+#define fsync _fsync
+#define ftell _ftell
+#define ftello _ftello
+#define fseek _fseek
+#define fseeko _fseeko
+#define ftok _ftok
+#define ftruncate _ftruncate
+#define gcvt _gcvt
+#define getcontext _getcontext
+#define getcwd _getcwd
+#define getdate _getdate
+#if !defined(_REENTRANT)
+#define getdate_err _getdate_err
+#else /* defined(_REENTRANT) */
+#define _getdate_err getdate_err
+#endif /* !defined(_REENTRANT) */
+#define getdents _getdents
+#define getegid _getegid
+#define geteuid _geteuid
+#define getexecname _getexecname
+#define getgid _getgid
+#define getisax _getisax
+#define getloadavg _getloadavg
+#define getgrent _getgrent
+#define getgrent_r _getgrent_r
+#define getgrgid _getgrgid
+#define getgrgid_r _getgrgid_r
+#define getgrnam _getgrnam
+#define getgrnam_r _getgrnam_r
+#define getgroups _getgroups
+#define gethz _gethz
+#define getitimer _getitimer
+#define getlogin _getlogin
+#define getmntany _getmntany
+#define getmntent _getmntent
+#define getmsg _getmsg
+#define getopt _getopt
+#define getpass _getpass
+#define getpassphrase _getpassphrase
+#define getpgid _getpgid
+#define getpgrp _getpgrp
+#define getpid _getpid
+#define getpmsg _getpmsg
+#define getppid _getppid
+#define getpw _getpw
+#define getpwent _getpwent
+#define getpwent_r _getpwent_r
+#define getpwnam _getpwnam
+#define getpwnam_r _getpwnam_r
+#define getpwuid _getpwuid
+#define getpwuid_r _getpwuid_r
+#define getrlimit _getrlimit
+#define getsid _getsid
+#define getspent _getspent
+#define getspent_r _getspent_r
+#define getspnam _getspnam
+#define getspnam_r _getspnam_r
+#define getsubopt _getsubopt
+#define gettimeofday _gettimeofday
+#define gettxt _gettxt
+#define getuid _getuid
+#define getutent _getutent
+#define getutid _getutid
+#define getutline _getutline
+#define getutmp _getutmp
+#define getutmpx _getutmpx
+#define getutxent _getutxent
+#define getutxid _getutxid
+#define getutxline _getutxline
+#define getvfsany _getvfsany
+#define getvfsent _getvfsent
+#define getvfsfile _getvfsfile
+#define getvfsspec _getvfsspec
+#define getw _getw
+#define grantpt _grantpt
+#define gsignal _gsignal
+#define gtty _gtty
+#define hasmntopt _hasmntopt
+#define hcreate _hcreate
+#define hdestroy _hdestroy
+#define hsearch _hsearch
+#define initgroups _initgroups
+#define insque _insque
+#define install_utrap _install_utrap
+#define ioctl _ioctl
+#define isaexec _isaexec
+#define isastream _isastream
+#define isatty _isatty
+#define jrand48 _jrand48
+#define kaio _kaio
+#define kill _kill
+#define l64a _l64a
+#define ladd _ladd
+#define lchown _lchown
+#define lckpwdf _lckpwdf
+#define lcong48 _lcong48
+#define ldivide _ldivide
+#define lexp10 _lexp10
+#define lfind _lfind
+#define link _link
+#define llog10 _llog10
+#define llseek _llseek
+#define lmul _lmul
+#define lockf _lockf
+#define localtime_r _localtime_r
+#define longjmp _longjmp
+#define lrand48 _lrand48
+#define lsearch _lsearch
+#define lseek _lseek
+#define lshiftl _lshiftl
+#define lsign _lsign
+#define lstat _lstat
+#define lsub _lsub
+#define ltol3 _ltol3
+#define madvise _madvise
+#define makecontext _makecontext
+#define makeut _makeut
+#define makeutx _makeutx
+#define memalign _memalign
+#define memccpy _memccpy
+#define memcntl _memcntl
+#define memcmp _memcmp
+#define memcpy _memcpy
+#define memmove _memmove
+#define memset _memset
+#define mincore _mincore
+#define mkdir _mkdir
+#define mkfifo _mkfifo
+#define mknod _mknod
+#define mktemp _mktemp
+#define mkstemp _mkstemp
+#define mlock _mlock
+#define mlockall _mlockall
+#define mmap _mmap
+#define modut _modut
+#define modutx _modutx
+#define monitor _monitor
+#define mount _mount
+#define mprotect _mprotect
+#define mrand48 _mrand48
+#define msgctl _msgctl
+#define msgget _msgget
+#define msgrcv _msgrcv
+#define msgsnd _msgsnd
+#define msync _msync
+#define munlock _munlock
+#define munlockall _munlockall
+#define munmap _munmap
+#define nfs_getfh _nfs_getfh
+#define nfssvc _nfssvc
+#define nftw _nftw
+#define nice _nice
+#define nrand48 _nrand48
+#define nss_delete _nss_delete
+#define nss_endent _nss_endent
+#define nss_getent _nss_getent
+#define nss_search _nss_search
+#define nss_setent _nss_setent
+#define ntp_gettime _ntp_gettime
+#define ntp_adjtime _ntp_adjtime
+#define open _open
+#define opendir _opendir
+#define openlog _openlog
+#define pathconf _pathconf
+#define pause _pause
+#define pclose _pclose
+#define pcsample _pcsample
+#define pipe _pipe
+#define plock _plock
+#define poll _poll
+#define popen _popen
+#define pread _pread
+#define pset_create _pset_create
+#define pset_destroy _pset_destroy
+#define pset_assign _pset_assign
+#define pset_info _pset_info
+#define pset_bind _pset_bind
+#define profil _profil
+#define psiginfo _psiginfo
+#define psignal _psignal
+#define ptrace _ptrace
+#define ptsname _ptsname
+#define pwrite _pwrite
+#define putenv _putenv
+#define putmsg _putmsg
+#define putpmsg _putpmsg
+#define putpwent _putpwent
+#define putspent _putspent
+#define pututline _pututline
+#define pututxline _pututxline
+#define putw _putw
+#define read _read
+#define readdir _readdir
+#define readdir_r _readdir_r
+#define readlink _readlink
+#define readv _readv
+#define realpath _realpath
+#define regcmp _regcmp
+#define regcomp _regcomp
+#define regerror _regerror
+#define regex _regex
+#define regexec _regexec
+#define regfree _regfree
+#define remque _remque
+#define resolvepath _resolvepath
+#define rmdir _rmdir
+#define sbrk _sbrk
+#define scrwidth _scrwidth
+#define seed48 _seed48
+#define seekdir _seekdir
+#define select _select
+#define semctl _semctl
+#define semget _semget
+#define semop _semop
+#define setcontext _setcontext
+#define setegid _setegid
+#define seteuid _seteuid
+#define setgid _setgid
+#define setgrent _setgrent
+#define setgroups _setgroups
+#define setitimer _setitimer
+#define setjmp _setjmp
+#define setkey _setkey
+#define setlocale _setlocale
+#define setlogmask _setlogmask
+#define setpgid _setpgid
+#define setpgrp _setpgrp
+#define setpwent _setpwent
+#define setregid _setregid
+#define setreuid _setreuid
+#define setrlimit _setrlimit
+#define setsid _setsid
+#define setspent _setspent
+#define settimeofday _settimeofday
+#define setuid _setuid
+#define setutent _setutent
+#define setutxent _setutxent
+#define shmat _shmat
+#define shmctl _shmctl
+#define shmdt _shmdt
+#define shmget _shmget
+#define sig2str _sig2str
+#define sigaction _sigaction
+#define sigaddset _sigaddset
+#define sigaltstack _sigaltstack
+#define sigdelset _sigdelset
+#define sigemptyset _sigemptyset
+#define sigfillset _sigfillset
+#define sigflag _sigflag
+#define sigfpe _sigfpe
+#define sighold _sighold
+#define sigignore _sigignore
+#define siginterrupt _siginterrupt
+#define sigismember _sigismember
+#define siglongjmp _siglongjmp
+#define sigpause _sigpause
+#define sigpending _sigpending
+#define sigprocmask _sigprocmask
+#define sigrelse _sigrelse
+#define sigsend _sigsend
+#define sigsendset _sigsendset
+#define sigset _sigset
+#define signal _signal
+#define sigsetjmp _sigsetjmp
+#define sigsuspend _sigsuspend
+#define sigwait _sigwait
+#define sleep _sleep
+#define srand48 _srand48
+#define ssignal _ssignal
+#define stat _stat
+#define statfs _statfs
+#define statvfs _statvfs
+#define stime _stime
+#define str2sig _str2sig
+#define strdup _strdup
+#define stty _stty
+#define swab _swab
+#define swapcontext _swapcontext
+#define swapctl _swapctl
+#define symlink _symlink
+#define sync _sync
+#define synchutmp _synchutmp
+#define syssun _syssun
+#define sys_errlist _sys_errlist
+#define sys_nerr _sys_nerr
+#define syscall _syscall
+#define sysconf _sysconf
+#define sysfs _sysfs
+#define sysinfo _sysinfo
+#define syslog _syslog
+#define tcdrain _tcdrain
+#define tcflow _tcflow
+#define tcflush _tcflush
+#define tcgetattr _tcgetattr
+#define tcgetpgrp _tcgetpgrp
+#define tcgetsid _tcgetsid
+#define tcsendbreak _tcsendbreak
+#define tcsetattr _tcsetattr
+#define tcsetpgrp _tcsetpgrp
+#define tdelete _tdelete
+#define tell _tell
+#define telldir _telldir
+#define tempnam _tempnam
+#define tfind _tfind
+#define time _time
+#define times _times
+#define truncate _truncate
+#define tsearch _tsearch
+#define ttyname _ttyname
+#define ttyslot _ttyslot
+#define twalk _twalk
+#define tzname _tzname
+#define tzset _tzset
+#define uadmin _uadmin
+#define ulckpwdf _ulckpwdf
+#define ulimit _ulimit
+#define umask _umask
+#define umount _umount
+#define uname _uname
+#define undial _undial
+#define unlink _unlink
+#define unlockpt _unlockpt
+#define unordered _unordered
+#define updutfile _updutfile
+#define updutxfile _updutxfile
+#define updutmp _updutmp
+#define updutmpx _updutmpx
+#define updwtmp _updwtmp
+#define updwtmpx _updwtmpx
+#define ustat _ustat
+#define utime _utime
+#define utimes _utimes
+#define utmpname _utmpname
+#define utmpxname _utmpxname
+#define utssys _utssys
+#define valloc _valloc
+#define vfork _vfork
+#define vhangup _vhangup
+#define vsyslog _vsyslog
+#define wait _wait
+#define waitid _waitid
+#define waitpid _waitpid
+#define wcwidth _wcwidth
+#define wcswidth _wcswidth
+#define write _write
+#define writev _writev
+#define yield _yield
+#define usleep _usleep
+#define wait3 _wait3
+#define _assert __assert
+#define _cladm __cladm
+#define _ctype __ctype
+#define _filbuf __filbuf
+#define _flsbuf __flsbuf
+#define _iob __iob
+
+/* fp and ll functions */
+#define decimal_to_double _decimal_to_double
+#define decimal_to_extended _decimal_to_extended
+#define decimal_to_quadruple _decimal_to_quadruple
+#define decimal_to_single _decimal_to_single
+#define double_to_decimal _double_to_decimal
+#define econvert _econvert
+#define extended_to_decimal _extended_to_decimal
+#define fconvert _fconvert
+#define file_to_decimal _file_to_decimal
+#define func_to_decimal _func_to_decimal
+#define gconvert _gconvert
+#define qeconvert _qeconvert
+#define qecvt _qecvt
+#define qfconvert _qfconvert
+#define qfcvt _qfcvt
+#define qgconvert _qgconvert
+#define qgcvt _qgcvt
+#define quadruple_to_decimal _quadruple_to_decimal
+#define seconvert _seconvert
+#define sfconvert _sfconvert
+#define sgconvert _sgconvert
+#define single_to_decimal _single_to_decimal
+#define string_to_decimal _string_to_decimal
+#define atoll _atoll
+#define llabs _llabs
+#define lldiv _lldiv
+#define lltostr _lltostr
+#define strtoll _strtoll
+#define strtoull _strtoull
+#define ulltostr _ulltostr
+
+#if !defined(_LP64)
+/* transitional large file interfaces */
+#define creat64 _creat64
+#define ftello64 _ftello64
+#define fseeko64 _fseeko64
+#define fstat64 _fstat64
+#define ftw64 _ftw64
+#define fstatvfs64 _fstatvfs64
+#define ftruncate64 _ftruncate64
+#define getdents64 _getdents64
+#define getrlimit64 _getrlimit64
+#define lockf64 _lockf64
+#define lseek64 _lseek64
+#define lstat64 _lstat64
+#define mkstemp64 _mkstemp64
+#define mmap64 _mmap64
+#define nftw64 _nftw64
+#define open64 _open64
+#define pread64 _pread64
+#define pwrite64 _pwrite64
+#define readdir64 _readdir64
+#define readdir64_r _readdir64_r
+#define seekdir64 _seekdir64
+#define tell64 _tell64
+#define telldir64 _telldir64
+#define setrlimit64 _setrlimit64
+#define stat64 _stat64
+#define statvfs64 _statvfs64
+#define truncate64 _truncate64
+#endif /* !_LP64 */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBMAIL_SYNONYMS_H */
diff --git a/usr/src/lib/libmail/sparc/Makefile b/usr/src/lib/libmail/sparc/Makefile
new file mode 100644
index 0000000000..6089c3ee87
--- /dev/null
+++ b/usr/src/lib/libmail/sparc/Makefile
@@ -0,0 +1,38 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/sparc/Makefile
+
+MAPDIR= ../spec/sparc
+
+include ../Makefile.com
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libmail/sparcv9/Makefile b/usr/src/lib/libmail/sparcv9/Makefile
new file mode 100644
index 0000000000..29a3f01d2b
--- /dev/null
+++ b/usr/src/lib/libmail/sparcv9/Makefile
@@ -0,0 +1,41 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/sparcv9/Makefile
+
+MAPDIR= ../spec/sparcv9
+
+include ../Makefile.com
+include ../../Makefile.lib.64
+
+LIBS= $(DYNLIB) $(LINTLIB)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libmail/spec/Makefile b/usr/src/lib/libmail/spec/Makefile
new file mode 100644
index 0000000000..62af484744
--- /dev/null
+++ b/usr/src/lib/libmail/spec/Makefile
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libkstat/spec/Makefile
+
+include $(SRC)/lib/Makefile.spec.arch
diff --git a/usr/src/lib/libmail/spec/Makefile.targ b/usr/src/lib/libmail/spec/Makefile.targ
new file mode 100644
index 0000000000..56e7ce4f20
--- /dev/null
+++ b/usr/src/lib/libmail/spec/Makefile.targ
@@ -0,0 +1,35 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/spec/Makefile.targ
+
+LIBRARY = libmail.a
+VERS = .1
+
+OBJECTS = mail.o
+
+SPECCPP = -I../../inc
diff --git a/usr/src/lib/libmail/spec/amd64/Makefile b/usr/src/lib/libmail/spec/amd64/Makefile
new file mode 100644
index 0000000000..d334868181
--- /dev/null
+++ b/usr/src/lib/libmail/spec/amd64/Makefile
@@ -0,0 +1,44 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+
+# Uncomment the following if the linker complains
+#amd64_C_PICFLAGS = $(amd64_C_BIGPICFLAGS)
+
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB64)
diff --git a/usr/src/lib/libmail/spec/i386/Makefile b/usr/src/lib/libmail/spec/i386/Makefile
new file mode 100644
index 0000000000..b52967dd4d
--- /dev/null
+++ b/usr/src/lib/libmail/spec/i386/Makefile
@@ -0,0 +1,44 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/spec/i386/Makefile
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+
+# Uncomment the following if the linker complains
+#i386_C_PICFLAGS = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
diff --git a/usr/src/lib/libmail/spec/mail.spec b/usr/src/lib/libmail/spec/mail.spec
new file mode 100644
index 0000000000..b6f96cf54d
--- /dev/null
+++ b/usr/src/lib/libmail/spec/mail.spec
@@ -0,0 +1,242 @@
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/spec/mail.spec
+
+function maillock
+include <maillock.h>
+declaration int maillock(char *user, int retrycnt)
+version SUNW_1.1
+end
+
+function mailunlock
+include <maillock.h>
+declaration void mailunlock(void)
+version SUNW_1.1
+end
+
+function touchlock
+include <maillock.h>
+declaration void touchlock(void)
+version SUNW_1.1
+end
+
+function abspath
+include <libmail.h>
+declaration string *abspath(char *path, char *dot, string *to)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function casncmp
+include <libmail.h>
+declaration int casncmp(char *s1, char *s2, ssize_t n)
+version SUNWprivate_1.1
+end
+
+function copystream
+include <libmail.h>
+declaration int copystream(FILE *infp, FILE *outfp)
+version SUNWprivate_1.1
+end
+
+function delempty
+include <libmail.h>
+declaration int delempty(mode_t m, char *mailname)
+version SUNWprivate_1.1
+end
+
+function maildomain
+include <libmail.h>
+declaration char *maildomain(void)
+version SUNWprivate_1.1
+end
+
+function notify
+include <libmail.h>
+declaration void notify(char *user, char *msg, int check_mesg_y, char *etcdir)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function pclosevp
+include <libmail.h>
+declaration int pclosevp(FILE *fp)
+version SUNWprivate_1.1
+end
+
+function popenvp
+include <libmail.h>
+declaration FILE *popenvp(char *file, char **argv, char *mode, int resetid)
+version SUNWprivate_1.1
+end
+
+function setup_exec
+include <libmail.h>
+declaration char **setup_exec(char *s)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function skipspace
+include <libmail.h>
+declaration char *skipspace(char *p)
+version SUNWprivate_1.1
+end
+
+function substr
+include <libmail.h>
+declaration int substr(char *string1, char *string2)
+version SUNWprivate_1.1
+end
+
+function strmove
+include <libmail.h>
+declaration void strmove(char *from, char *to)
+version SUNWprivate_1.1
+end
+
+function systemvp
+include <libmail.h>
+declaration pid_t systemvp(char *file, char **argv, int resetid)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function trimnl
+include <libmail.h>
+declaration void trimnl(char *s)
+version SUNWprivate_1.1
+end
+
+function Xgetenv
+include <libmail.h>
+declaration char *Xgetenv(char *env)
+version SUNWprivate_1.1
+end
+
+function xgetenv
+include <libmail.h>
+declaration char *xgetenv(char *env)
+version SUNWprivate_1.1
+end
+
+function xsetenv
+include <libmail.h>
+declaration int xsetenv(char *file)
+version SUNWprivate_1.1
+end
+
+function s_append
+include <s_string.h>
+declaration string *s_append(string *to, char *from)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_array
+include <s_string.h>
+declaration string *s_array(char *, size_t len)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_copy
+include <s_string.h>
+declaration string *s_copy(char *)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_free
+include <s_string.h>
+declaration void s_free(string*)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_grow
+include <s_string.h>
+declaration int s_grow(string *sp, int c)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_new
+include <s_string.h>
+declaration string *s_new(void)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_parse
+include <s_string.h>
+declaration string *s_parse(string *from, string *to)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_read_line
+include <s_string.h>
+declaration char *s_read_line(FILE *fp, string *to)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_read_to_eof
+include <s_string.h>
+declaration size_t s_read_to_eof(FILE *fp, string *to)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_seq_read
+include <s_string.h>
+declaration string *s_seq_read(FILE *fp, string *to, int lineortoken)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_skipwhite
+include <s_string.h>
+declaration void s_skipwhite(string *from)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_tok
+include <s_string.h>
+declaration string *s_tok(string*, char*)
+arch sparc i386
+version SUNWprivate_1.1
+end
+
+function s_tolower
+include <s_string.h>
+declaration void s_tolower(string*)
+arch sparc i386
+version SUNWprivate_1.1
+end
diff --git a/usr/src/lib/libmail/spec/sparc/Makefile b/usr/src/lib/libmail/spec/sparc/Makefile
new file mode 100644
index 0000000000..dfa6699b45
--- /dev/null
+++ b/usr/src/lib/libmail/spec/sparc/Makefile
@@ -0,0 +1,44 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/spec/sparc/Makefile
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+
+# Uncomment the following if the linker complains
+#sparc_C_PICFLAGS = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB)
diff --git a/usr/src/lib/libmail/spec/sparcv9/Makefile b/usr/src/lib/libmail/spec/sparcv9/Makefile
new file mode 100644
index 0000000000..587fa638cb
--- /dev/null
+++ b/usr/src/lib/libmail/spec/sparcv9/Makefile
@@ -0,0 +1,45 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+# Copyright (c) 1999, by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#pragma ident "%Z%%M% %I% %E% SMI"
+#
+# lib/libmail/spec/sparcv9/Makefile
+
+.KEEP_STATE:
+
+include ../Makefile.targ
+
+# Add arch specific objects here
+OBJECTS +=
+
+include $(SRC)/lib/Makefile.lib
+include $(SRC)/lib/Makefile.lib.64
+
+# Uncomment the following if the linker complains
+#sparcv9_C_PICFLAGS = -K PIC
+
+include $(SRC)/lib/Makefile.spec
+
+install: $(ROOTABILIB64)
diff --git a/usr/src/lib/libmail/spec/versions b/usr/src/lib/libmail/spec/versions
new file mode 100644
index 0000000000..38a2cfc77a
--- /dev/null
+++ b/usr/src/lib/libmail/spec/versions
@@ -0,0 +1,43 @@
+#
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# ident "%Z%%M% %I% %E% SMI"
+#
+
+sparc {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+sparcv9 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+i386 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}
+amd64 {
+ SUNW_1.1;
+ SUNWprivate_1.1;
+}