home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume10 / pcmail2 / part01 / main / textcopy.c < prev    next >
C/C++ Source or Header  |  1990-01-24  |  1KB  |  60 lines

  1. /*++
  2. /* NAME
  3. /*    textcopy 3
  4. /* SUMMARY
  5. /*    copy text to stream
  6. /* PROJECT
  7. /*    pc-mail
  8. /* PACKAGE
  9. /*    mail
  10. /* SYNOPSIS
  11. /*    int textcopy(path, fp)
  12. /*    char *path;
  13. /*    FILE *fp;
  14. /* DESCRIPTION
  15. /*      This function filters the contents of a file and writes the result
  16. /*    to a stdio stream. It can be used, for example, to provide optional
  17. /*    headers and trailers for new mail messages and for replies.
  18. /* SEE ALSO
  19. /*    ascf(3) text filter
  20. /* DIAGNOSTICS
  21. /*    A nonzero value is returned in case of problems.
  22. /* AUTHOR(S)
  23. /*      W.Z. Venema
  24. /*      Eindhoven University of Technology
  25. /*      Department of Mathematics and Computer Science
  26. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  27. /* CREATION DATE
  28. /*    Fri Dec 15 21:39:26 MET 1989
  29. /* LAST MODIFICATION
  30. /*    90/01/22 13:02:48
  31. /* VERSION/RELEASE
  32. /*    2.1
  33. /*--*/
  34.  
  35. #include <stdio.h>
  36.  
  37. #include "defs.h"
  38. #include "ascf.h"
  39.  
  40. /* textcopy - copy text to stream */
  41.  
  42. public int textcopy(path, fp)
  43. char   *path;
  44. FILE   *fp;
  45. {
  46.     char    buf[BUFSIZ];
  47.     int     ret;
  48.     FILE   *ip;
  49.  
  50.     if ((ip = ascopen(path, "r")) == 0) {
  51.     return (1);
  52.     } else {
  53.     while (ascgets(buf, sizeof(buf), ip))
  54.         fputs(buf, fp), putc('\n', fp);
  55.     ret = ferror(ip);
  56.     ascclose(ip);
  57.     return (ret);
  58.     }
  59. }
  60.