home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / communic / pcmail / main / lmail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-05  |  2.9 KB  |  112 lines

  1. /*++
  2. /* NAME
  3. /*      lmail 1
  4. /* SUMMARY
  5. /*      local delivery of mail received via GNUUCP
  6. /* PROJECT
  7. /*      pc-mail
  8. /* PACKAGE
  9. /*      gnu
  10. /* SYNOPSIS
  11. /*      lmail [arguments]
  12. /* DESCRIPTION
  13. /*    This program replaces the receiving function of the pc-mail "cico"
  14. /*    program, on systems that use GNUUCP for message transport.
  15. /*
  16. /*      lmail reads one mail message from its standard input and installs
  17. /*    it as a message file in the pc-mail mail data base. Any command-line
  18. /*    arguments are ignored (since pc-mail is a single-user mail system).
  19. /*
  20. /*    This command should be installed such that it can be found by the 
  21. /*    GNUUCP "rmail" command. The actual program name may be different
  22. /*    from "lmail"; this depends on how the GNUUCP software was configured.
  23. /* ENVIRONMENT
  24. /*    MAILDIR, path to pc-mail message data base
  25. /* FILES
  26. /*      In the spool directory:
  27. /*    h<seqno>    new mail message.
  28. /* SEE ALSO
  29. /*      path(5)         spool directory, file names
  30. /*    nmail(1)    extracts sender and subject from new mail.
  31. /* DIAGNOSTICS
  32. /*      Problems are reported on the standard error output, and cause the
  33. /*    program to terminate with a nonzero exit status.
  34. /* AUTHOR(S)
  35. /*      W.Z. Venema
  36. /*      Eindhoven University of Technology
  37. /*      Department of Mathematics and Computer Science
  38. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  39. /* CREATION DATE
  40. /*    Wed Jan  3 22:16:08 MET 1990
  41. /* LAST MODIFICATION
  42. /*    90/01/22 13:02:00
  43. /* VERSION/RELEASE
  44. /*    2.1
  45. /*--*/
  46.  
  47. #include <stdio.h>
  48. #include <varargs.h>
  49.  
  50. #include "defs.h"
  51. #include "path.h"
  52.  
  53. extern int errno;
  54. extern char *sys_errlist[];
  55.  
  56. extern char *fgets();
  57.  
  58. hidden void error();
  59. public char *progname = "lmail";
  60.  
  61. /* pc-mail is a single-user mailer, so we ignore command-line arguments */
  62.  
  63. main()
  64. {
  65.     char    buf[BUFSIZ];
  66.     char   *fname;
  67.     FILE   *fp;
  68.  
  69.     /* Find out where the mail data base lives */
  70.  
  71.     if (pathinit())
  72.     error("no mail directory or MAILDIR environment variable not set");
  73.  
  74.     /* Create a mail message file only - let nmail extract sender and subject */
  75.  
  76.     (void) umask(0222);                /* make files read-only */
  77.     if ((fp = fopen(fname = new_mesg(newseqno()), "w")) == 0)
  78.     error("cannot open %s: %s", fname, sys_errlist[errno]);
  79.  
  80.     /* Copy standard input to message file */
  81.  
  82.     while (fgets(buf, sizeof(buf), stdin))
  83.     (void) fputs(buf, fp);
  84.  
  85.     /* Error checking */
  86.  
  87.     if (fflush(fp) || ferror(fp) || fclose(fp))
  88.     error("%s: write error: %s", fname, sys_errlist[errno]);
  89.  
  90.     exit(0);
  91.     /* NOTREACHED */
  92. }
  93.  
  94. /* error - complain */
  95.  
  96. /* VARARGS */
  97.  
  98. hidden void error(va_alist) 
  99. va_dcl
  100. {
  101.     va_list ap;
  102.     char   *fmt;
  103.  
  104.     (void) fprintf(stderr, "%s: ", progname);
  105.     va_start(ap);
  106.     fmt = va_arg(ap, char *);
  107.     (void) vfprintf(stderr, fmt, ap);
  108.     va_end(ap);
  109.     (void) putc('\n', stderr);
  110.     exit(2);
  111. }
  112.