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

  1. /*++
  2. /* NAME
  3. /*    create 3
  4. /* SUMMARY
  5. /*    create a mail message
  6. /* PROJECT
  7. /*    pc-mail
  8. /* PACKAGE
  9. /*    mail
  10. /* SYNOPSIS
  11. /*    #include "mail.h"
  12. /*
  13. /*    int create()
  14. /* DESCRIPTION
  15. /*      Create() creates a template message and invokes an editor.
  16. /*    It then passes control to the work_disp() function (the function that
  17. /*    lets the user decide on the disposition of the message).
  18. /* COMMANDS
  19. /*    The program specified in the EDITOR environment variable,
  20. /*    or a system-dependent default.
  21. /* FILES
  22. /*    mail.msg, file being edited in the current directory
  23. /*      $MAILDIR/ennnnn, message file (body)
  24. /*    $MAILDIR/cnnnnn, meta file (summary)
  25. /*    $MAILDIR/header, template mail header file
  26. /*    $MAILDIR/trailer, template signature file
  27. /* SEE ALSO
  28. /*      pager(3), pager(5), kbdinp(3), edit(3)
  29. /* AUTHOR(S)
  30. /*      W.Z. Venema
  31. /*      Eindhoven University of Technology
  32. /*      Department of Mathematics and Computer Science
  33. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  34. /* CREATION DATE
  35. /*    Tue May 12 15:35:20 GMT+1:00 1987
  36. /* LAST MODIFICATION
  37. /*    90/01/22 13:01:27
  38. /* VERSION/RELEASE
  39. /*    2.1
  40. /*--*/
  41.  
  42. #include <stdio.h>
  43.  
  44. #include "defs.h"
  45. #include "path.h"
  46. #include "mail.h"
  47. #include "status.h"
  48. #include "screen.h"
  49.  
  50. hidden int create_work();        /* forward declaration */
  51.  
  52. /* create - create, edit, and dispose of a mail message */
  53.  
  54. public int create()
  55. {
  56.     register int stat;
  57.  
  58.     if ((stat = create_work())            /* try to create the message */
  59.     || (stat = edit(message, MAILFILE)))    /* try to edit the message */
  60.     errdisp(stat);                /* we had a problem */
  61.     work_disp("");                /* ask for disposition */
  62.     return (S_REDRAW);                /* say screen has changed */
  63. }
  64.  
  65. /* create_work - create template mail message */
  66.  
  67. hidden int create_work()
  68. {
  69.     register FILE *fp;
  70.     register int err;
  71.  
  72.     if (fp = fopen(message, "w")) {
  73.     (void) fprintf(fp, "Subject: \n");    /* Subject: line */
  74.     (void) textcopy(header_file(), fp);    /* personalized mail header */
  75.     putc('\n', fp);
  76.     (void) textcopy(trailer_file(), fp);    /* personalized signature */
  77.     err = (fflush(fp) || ferror(fp));
  78.     (void) fclose(fp);
  79.     return (err ? E_WRITERR : 0);
  80.     } else {
  81.     return (E_WRITERR);
  82.     }
  83. }
  84.