[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nmh-commits] CVS: nmh/sbr ext_hook.c,NONE,1.1.2.1 Makefile.in,1.13,1.1
From: |
Jon Steinhart <address@hidden> |
Subject: |
[Nmh-commits] CVS: nmh/sbr ext_hook.c,NONE,1.1.2.1 Makefile.in,1.13,1.13.2.1 context_del.c,1.2,1.2.2.1 context_find.c,1.2,1.2.2.1 context_read.c,1.2,1.2.2.1 context_replace.c,1.2,1.2.2.1 folder_addmsg.c,1.2,1.2.2.1 folder_delmsgs.c,1.2,1.2.2.1 folder_pack.c,1.2,1.2.2.1 m_convert.c,1.2,1.2.2.1 pidwait.c,1.4,1.4.2.1 seq_read.c,1.2,1.2.2.1 seq_save.c,1.2,1.2.2.1 |
Date: |
Fri, 28 Feb 2003 14:08:38 -0500 |
Update of /cvsroot/nmh/nmh/sbr
In directory subversions:/tmp/cvs-serv6328/nmh/sbr
Modified Files:
Tag: RELEASE_1_1
Makefile.in context_del.c context_find.c context_read.c
context_replace.c folder_addmsg.c folder_delmsgs.c
folder_pack.c m_convert.c pidwait.c seq_read.c seq_save.c
Added Files:
Tag: RELEASE_1_1
ext_hook.c
Log Message:
Merged in changes from main branch. There are two classes of changes:
improved attachment handing for originating messages, and hooks that
provide an interface that allows external programs to to synchronize
a database with the contents of mail folders.
***** Error reading new file: [Errno 2] No such file or directory: 'ext_hook.c'
Index: Makefile.in
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/Makefile.in,v
retrieving revision 1.13
retrieving revision 1.13.2.1
diff -C2 -r1.13 -r1.13.2.1
*** Makefile.in 14 Dec 2000 01:30:45 -0000 1.13
--- Makefile.in 28 Feb 2003 19:08:36 -0000 1.13.2.1
***************
*** 58,62 ****
context_replace.c context_save.c copy.c \
copyip.c cpydata.c cpydgst.c discard.c done.c dtime.c dtimep.c \
! error.c fdcompare.c folder_addmsg.c folder_delmsgs.c \
folder_free.c folder_pack.c folder_read.c \
folder_realloc.c gans.c getans.c getanswer.c \
--- 58,62 ----
context_replace.c context_save.c copy.c \
copyip.c cpydata.c cpydgst.c discard.c done.c dtime.c dtimep.c \
! error.c ext_hook.c fdcompare.c folder_addmsg.c folder_delmsgs.c \
folder_free.c folder_pack.c folder_read.c \
folder_realloc.c gans.c getans.c getanswer.c \
Index: context_del.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/context_del.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** context_del.c 2 Jul 2002 22:09:14 -0000 1.2
--- context_del.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 22,29 ****
register struct node *np, *pp;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
if (!strcasecmp (np->n_name, key)) {
--- 22,25 ----
Index: context_find.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/context_find.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** context_find.c 2 Jul 2002 22:09:14 -0000 1.2
--- context_find.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 18,25 ****
struct node *np;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
for (np = m_defs; np; np = np->n_next)
if (!strcasecmp (np->n_name, str))
--- 18,21 ----
Index: context_read.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/context_read.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** context_read.c 2 Jul 2002 22:09:14 -0000 1.2
--- context_read.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 1,3 ****
-
/*
* context_read.c -- find and read profile and context files
--- 1,2 ----
***************
*** 8,115 ****
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
*/
! #include <h/mh.h>
! #include <errno.h>
! #include <pwd.h>
! extern int errno;
void
context_read (void)
{
! pid_t pid;
! register char *cp, *pp;
! char buf[BUFSIZ];
! struct stat st;
! register struct passwd *pw;
! register FILE *ib;
!
! if (defpath)
! return;
/*
! * Find user's home directory
*/
! if (!mypath) {
! if ((mypath = getenv ("HOME")))
! mypath = getcpy (mypath);
else
! if ((pw = getpwuid (getuid ())) == NULL
! || pw->pw_dir == NULL
! || *pw->pw_dir == 0)
! adios (NULL, "no HOME envariable");
! else
! mypath = getcpy (pw->pw_dir);
! if ((cp = mypath + strlen (mypath) - 1) > mypath && *cp == '/')
! *cp = 0;
}
/*
! * open and read user's profile
*/
! if ((cp = getenv ("MH")) && *cp != '\0') {
! defpath = path (cp, TFILE);
! if ((ib = fopen (defpath, "r")) == NULL)
! adios (defpath, "unable to read");
! if (*cp != '/')
! m_putenv ("MH", defpath);
! } else {
! defpath = concat (mypath, "/", mh_profile, NULL);
!
! if ((ib = fopen (defpath, "r")) == NULL) {
! switch (pid = vfork ()) {
! case -1:
! adios ("fork", "unable to");
!
! case 0:
! setgid (getgid ());
! setuid (getuid ());
!
! execlp (installproc, "install-mh", "-auto", NULL);
! fprintf (stderr, "unable to exec ");
! perror (installproc);
! _exit (-1);
!
! default:
! if (pidwait (pid, 0)
! || (ib = fopen (defpath, "r")) == NULL)
! adios (NULL, "[install-mh aborted]");
! }
! }
}
! readconfig (&m_defs, ib, mh_profile, 0);
fclose (ib);
/*
! * Find user's nmh directory
*/
! if ((pp = context_find ("path")) && *pp != '\0') {
! if (*pp != '/')
! snprintf (buf, sizeof(buf), "%s/%s", mypath, pp);
! else
! strncpy (buf, pp, sizeof(buf));
! if (stat(buf, &st) == -1) {
! if (errno != ENOENT)
! adios (buf, "error opening");
! cp = concat ("Your MH-directory \"", buf,
! "\" doesn't exist; Create it? ", NULL);
! if (!getanswer(cp))
! adios (NULL, "unable to access MH-directory \"%s\"", buf);
! free (cp);
! if (!makedir (buf))
! adios (NULL, "unable to create", buf);
! }
}
/*
! * open and read user's context file
*/
! if (!(cp = getenv ("MHCONTEXT")) || *cp == '\0')
cp = context;
ctxpath = getcpy (m_maildir (cp));
if ((ib = fopen (ctxpath, "r"))) {
readconfig ((struct node **) 0, ib, cp, 1);
fclose (ib);
}
}
--- 7,133 ----
* COPYRIGHT file in the root directory of the nmh distribution for
* complete copyright information.
+ *
+ * This function must be called early on in any nmh utility, and
+ * may only be called once. It does the following:
+ *
+ * o Sets the global variable "mypath" to the home directory path.
+ *
+ * o Sets the global variable "defpath" to the absolute path of
+ * the profile file.
+ *
+ * o Reads in the profile file. Bails out if it can't.
+ *
+ * o Makes sure that the mail directory exists, prompting for
+ * creation if it doesn't.
+ *
+ * o Reads the context file either as set by the MHCONTEXT
+ * environment variable or by the profile.
*/
! #include <h/mh.h> /* mh internals */
! #include <errno.h> /* system call errors */
! #include <pwd.h> /* structure for getpwuid()
results */
! extern int errno; /* system call error
number */
void
context_read (void)
{
! char buf[BUFSIZ]; /* path name buffer */
! char *cp; /* miscellaneous pointer */
! char *nd; /* nmh directory pointer */
! struct stat st; /* stat() results */
! register struct passwd *pw; /* getpwuid() results */
! register FILE *ib; /* profile and context file
pointer */
/*
! * Find user's home directory. Try the HOME environment variable
first,
! * the home directory field in the password file if that's not
found.
*/
!
! if ((mypath = getenv("HOME")) == (char *)0) {
! if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir ==
'\0')
! adios(NULL, "cannot determine your home directory");
else
! mypath = pw->pw_dir;
}
/*
! * Find and read user's profile. Check for the existence of an MH
environment
! * variable first with non-empty contents. Convert any relative
path name
! * found there to an absolute one. Look for the profile in the
user's home
! * directory if the MH environment variable isn't set.
*/
!
! if ((cp = getenv("MH")) && *cp != '\0') {
! defpath = path(cp, TFILE);
!
! if (stat(defpath, &st) != -1 && (st.st_mode & S_IFREG) == 0)
! adios((char *)0, "`%s' specified by your MH environment
variable is not a normal file", cp);
!
! if ((ib = fopen(defpath, "r")) == (FILE *)0)
! adios((char *)0, "unable to read the `%s' profile specified by your
MH environment variable", defpath);
! }
! else {
! defpath = concat(mypath, "/", mh_profile, NULL);
!
! if ((ib = fopen(defpath, "r")) == (FILE *)0)
! adios((char *)0, "Doesn't look like nmh is installed. Run
install-mh to do so.");
!
! cp = mh_profile;
}
!
! readconfig (&m_defs, ib, cp, 0);
fclose (ib);
/*
! * Find the user's nmh directory, which is specified by the "path"
profile component.
! * Convert a relative path name to an absolute one rooted in the
home directory.
*/
!
! if ((cp = context_find ("path")) == (char *)0)
! adios(NULL, "Your %s file does not contain a path entry.", defpath);
!
! if (*cp == '\0')
! adios(NULL, "Your `%s' profile file does not contain a valid path
entry.", defpath);
!
! if (*cp != '/')
! (void)snprintf (nd = buf, sizeof(buf), "%s/%s", mypath, cp);
! else
! nd = cp;
!
! if (stat(nd, &st) == -1) {
! if (errno != ENOENT)
! adios (nd, "error opening");
!
! cp = concat ("Your MH-directory \"", nd, "\" doesn't exist; Create it?
", NULL);
!
! if (!getanswer(cp))
! adios (NULL, "unable to access MH-directory \"%s\"", nd);
!
! free (cp);
!
! if (!makedir (nd))
! adios (NULL, "unable to create", nd);
}
+ else if ((st.st_mode & S_IFDIR) == 0)
+ adios ((char *)0, "`%s' is not a directory", nd);
+
/*
! * Open and read user's context file. The name of the context
file comes from the
! * profile unless overridden by the MHCONTEXT environment variable.
*/
!
! if ((cp = getenv ("MHCONTEXT")) == (char *)0 || *cp == '\0')
cp = context;
+
ctxpath = getcpy (m_maildir (cp));
+
if ((ib = fopen (ctxpath, "r"))) {
readconfig ((struct node **) 0, ib, cp, 1);
fclose (ib);
}
+
+ return;
}
Index: context_replace.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/context_replace.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** context_replace.c 2 Jul 2002 22:09:14 -0000 1.2
--- context_replace.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 18,25 ****
register struct node *np;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
/*
* If list is emtpy, allocate head of profile/context list.
--- 18,21 ----
Index: folder_addmsg.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/folder_addmsg.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** folder_addmsg.c 2 Jul 2002 22:09:14 -0000 1.2
--- folder_addmsg.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 21,28 ****
int
folder_addmsg (struct msgs **mpp, char *msgfile, int selected,
! int unseen, int preserve)
{
int infd, outfd, linkerr, first_time, msgnum;
char *nmsg, newmsg[BUFSIZ];
struct msgs *mp;
struct stat st1, st2;
--- 21,30 ----
int
folder_addmsg (struct msgs **mpp, char *msgfile, int selected,
! int unseen, int preserve, int deleting)
{
int infd, outfd, linkerr, first_time, msgnum;
char *nmsg, newmsg[BUFSIZ];
+ char oldmsg[BUFSIZ];
+ struct msgs *op;
struct msgs *mp;
struct stat st1, st2;
***************
*** 133,139 ****
/*
! * Now try to link message into folder
*/
if (link (msgfile, newmsg) != -1) {
return msgnum;
} else {
--- 135,155 ----
/*
! * Now try to link message into folder.
! * Then run the external hook on the message if one was specified in
the context.
! * Run the refile hook if we're moving the message from one place to
another.
! * We have to construct the from path name for this because it's not
there.
! * Run the add hook if the message is getting copied or lined somewhere
else.
*/
if (link (msgfile, newmsg) != -1) {
+
+ if (deleting) {
+ op = folder_read(getfolder(1));
+ (void)snprintf(oldmsg, sizeof (oldmsg), "%s/%s", op->foldpath,
msgfile);
+ folder_free(op);
+ (void)ext_hook("ref-hook", oldmsg, newmsg);
+ }
+ else
+ (void)ext_hook("add-hook", newmsg, (char *)0);
+
return msgnum;
} else {
***************
*** 184,187 ****
--- 200,209 ----
close (infd);
close (outfd);
+
+ if (deleting)
+ (void)ext_hook("ref-hook", newmsg, msgfile);
+ else
+ (void)ext_hook("add-hook", newmsg, (char *)0);
+
return msgnum;
}
Index: folder_delmsgs.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/folder_delmsgs.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** folder_delmsgs.c 2 Jul 2002 22:09:14 -0000 1.2
--- folder_delmsgs.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 23,31 ****
int
! folder_delmsgs (struct msgs *mp, int unlink_msgs)
{
pid_t pid;
int msgnum, vecp, retval = 0;
char buf[100], *dp, **vec;
/*
--- 23,32 ----
int
! folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook)
{
pid_t pid;
int msgnum, vecp, retval = 0;
char buf[100], *dp, **vec;
+ char msgpath[BUFSIZ];
/*
***************
*** 83,86 ****
--- 84,100 ----
unset_selected (mp, msgnum);
mp->numsel--;
+
+ /*
+ * Run the external hook on the message if one was specified in
the context.
+ * All we have is the message number; we have changed to the
directory
+ * containing the message. So, we need to extract that directory
to form
+ * the complete path. Note that the caller knows the directory,
but has
+ * no way of passing that to us.
+ */
+
+ if (!nohook) {
+ (void)snprintf(msgpath, sizeof (msgpath), "%s/%d",
getcwd(msgpath, sizeof (msgpath)), msgnum);
+ (void)ext_hook("del-hook", msgpath, (char *)0);
+ }
dp = m_name (msgnum);
Index: folder_pack.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/folder_pack.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** folder_pack.c 2 Jul 2002 22:09:14 -0000 1.2
--- folder_pack.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 60,63 ****
--- 60,71 ----
}
+ /*
+ * Invoke the external refile hook for each message being
renamed.
+ */
+
+ (void)snprintf(oldmsg, sizeof (oldmsg), "%s/%d", mp->foldpath,
msgnum);
+ (void)snprintf(newmsg, sizeof (newmsg), "%s/%d", mp->foldpath,
hole);
+ ext_hook("ref-hook", oldmsg, newmsg);
+
/* check if this is the current message */
if (msgnum == mp->curmsg)
Index: m_convert.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/m_convert.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** m_convert.c 2 Jul 2002 22:09:14 -0000 1.2
--- m_convert.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 226,230 ****
/*
* Convert the various message names to
! * there numeric value.
*
* n (integer)
--- 226,230 ----
/*
* Convert the various message names to
! * their numeric values.
*
* n (integer)
Index: pidwait.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/pidwait.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -r1.4 -r1.4.2.1
*** pidwait.c 2 Jul 2002 22:09:14 -0000 1.4
--- pidwait.c 28 Feb 2003 19:08:36 -0000 1.4.2.1
***************
*** 12,15 ****
--- 12,16 ----
#include <h/mh.h>
#include <h/signals.h>
+ #include <errno.h>
#include <signal.h>
***************
*** 37,41 ****
#ifdef HAVE_WAITPID
! pid = waitpid(id, &status, 0);
#else
while ((pid = wait(&status)) != -1 && pid != id)
--- 38,43 ----
#ifdef HAVE_WAITPID
! while ((pid = waitpid(id, &status, 0)) == -1 && errno == EINTR)
! ;
#else
while ((pid = wait(&status)) != -1 && pid != id)
Index: seq_read.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/seq_read.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** seq_read.c 2 Jul 2002 22:09:14 -0000 1.2
--- seq_read.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 30,37 ****
seq_read (struct msgs *mp)
{
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
/*
* Initialize the list of sequence names. Go ahead and
--- 30,33 ----
Index: seq_save.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/seq_save.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** seq_save.c 2 Jul 2002 22:09:14 -0000 1.2
--- seq_save.c 28 Feb 2003 19:08:36 -0000 1.2.2.1
***************
*** 32,39 ****
sigset_t set, oset;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
/* check if sequence information has changed */
if (!(mp->msgflags & SEQMOD))
--- 32,35 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nmh-commits] CVS: nmh/sbr ext_hook.c,NONE,1.1.2.1 Makefile.in,1.13,1.13.2.1 context_del.c,1.2,1.2.2.1 context_find.c,1.2,1.2.2.1 context_read.c,1.2,1.2.2.1 context_replace.c,1.2,1.2.2.1 folder_addmsg.c,1.2,1.2.2.1 folder_delmsgs.c,1.2,1.2.2.1 folder_pack.c,1.2,1.2.2.1 m_convert.c,1.2,1.2.2.1 pidwait.c,1.4,1.4.2.1 seq_read.c,1.2,1.2.2.1 seq_save.c,1.2,1.2.2.1,
Jon Steinhart <address@hidden> <=
- Prev by Date:
[Nmh-commits] CVS: nmh/h prototypes.h,1.5,1.5.2.1
- Next by Date:
[Nmh-commits] CVS: nmh/uip Makefile.in,1.15,1.15.2.1 anno.c,1.4,1.4.2.1 annosbr.c,1.3,1.3.2.1 burst.c,1.4,1.4.2.1 flist.c,1.4,1.4.2.1 folder.c,1.4,1.4.2.1 inc.c,1.13,1.13.2.1 install-mh.c,1.4,1.4.2.1 mhstoresbr.c,1.7,1.7.2.1 rcvstore.c,1.7,1.7.2.1 refile.c,1.4,1.4.2.1 rmf.c,1.4,1.4.2.1 rmm.c,1.4,1.4.2.1 scan.c,1.8.2.1,1.8.2.2 send.c,1.5,1.5.2.1 sendsbr.c,1.4,1.4.2.1 sortm.c,1.5,1.5.2.1 viamail.c,1.7,1.7.2.1 whatnowsbr.c,1.5,1.5.2.1
- Previous by thread:
[Nmh-commits] CVS: nmh/h prototypes.h,1.5,1.5.2.1
- Next by thread:
[Nmh-commits] CVS: nmh/uip Makefile.in,1.15,1.15.2.1 anno.c,1.4,1.4.2.1 annosbr.c,1.3,1.3.2.1 burst.c,1.4,1.4.2.1 flist.c,1.4,1.4.2.1 folder.c,1.4,1.4.2.1 inc.c,1.13,1.13.2.1 install-mh.c,1.4,1.4.2.1 mhstoresbr.c,1.7,1.7.2.1 rcvstore.c,1.7,1.7.2.1 refile.c,1.4,1.4.2.1 rmf.c,1.4,1.4.2.1 rmm.c,1.4,1.4.2.1 scan.c,1.8.2.1,1.8.2.2 send.c,1.5,1.5.2.1 sendsbr.c,1.4,1.4.2.1 sortm.c,1.5,1.5.2.1 viamail.c,1.7,1.7.2.1 whatnowsbr.c,1.5,1.5.2.1
- Index(es):