/[mailutils]/mailutils/guimb/collect.c
ViewVC logotype

Diff of /mailutils/guimb/collect.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by gray, Thu Jan 17 22:30:55 2002 UTC revision 1.6 by gray, Mon Jan 21 06:23:15 2002 UTC
# Line 16  Line 16 
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
17    
18  #include "guimb.h"  #include "guimb.h"
 #ifdef HAVE_PATHS_H  
 # include <paths.h>  
 #endif  
   
 #ifndef _PATH_MAILDIR  
 # define _PATH_MAILDIR "/var/spool/mail"  
 #endif  
19    
20  char *temp_filename;  char *temp_filename;
21  FILE *temp_file;  FILE *temp_file;
# Line 32  void Line 25  void
25  collect_open_default ()  collect_open_default ()
26  {  {
27    size_t nmesg;    size_t nmesg;
28      
29      if (!default_mailbox)
30        {
31          asprintf (&default_mailbox, "%s%s", maildir, user_name);
32          if (!default_mailbox)
33            {
34              util_error ("not enough memory");
35              exit (1);
36            }
37        }
38    if (mailbox_create (&mbox, default_mailbox) != 0    if (mailbox_create (&mbox, default_mailbox) != 0
39        || mailbox_open (mbox, MU_STREAM_RDWR) != 0)        || mailbox_open (mbox, MU_STREAM_RDWR) != 0)
40      {      {
# Line 137  collect_output () Line 139  collect_output ()
139        return 0;        return 0;
140      }      }
141    
   if (!default_mailbox)  
     {  
       if (!user_name)  
         return 0;  
       asprintf (&default_mailbox, "%s/%s", _PATH_MAILDIR, user_name);  
       if (!default_mailbox)  
         {  
           fprintf (stderr, "guimb: not enough memory\n");  
           return 1;  
         }  
     }  
   
142    if (user_name)    if (user_name)
143      saved_umask = umask (077);      saved_umask = umask (077);
144        
# Line 197  collect_drop_mailbox () Line 187  collect_drop_mailbox ()
187        free (temp_filename);        free (temp_filename);
188      }      }
189  }  }
190    
191    int
192    guimb_catch_handler (void *unused, SCM tag, SCM throw_args)
193    {
194      collect_drop_mailbox ();
195      return scm_handle_by_message ("guimb", tag, throw_args);
196    }
197    
198    int
199    guimb_exit (void *unused1, mailbox_t unused2)
200    {
201      int rc = collect_output ();
202      collect_drop_mailbox ();
203      return rc;
204    }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26