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

  1. /*++
  2.  
  3. /* NAME
  4.  
  5. /*    textcopy 3
  6.  
  7. /* SUMMARY
  8.  
  9. /*    copy text to stream
  10.  
  11. /* PROJECT
  12.  
  13. /*    pc-mail
  14.  
  15. /* PACKAGE
  16.  
  17. /*    mail
  18.  
  19. /* SYNOPSIS
  20.  
  21. /*    int textcopy(path, fp)
  22.  
  23. /*    char *path;
  24.  
  25. /*    FILE *fp;
  26.  
  27. /* DESCRIPTION
  28.  
  29. /*      This function filters the contents of a file and writes the result
  30.  
  31. /*    to a stdio stream. It can be used, for example, to provide optional
  32.  
  33. /*    headers and trailers for new mail messages and for replies.
  34.  
  35. /* SEE ALSO
  36.  
  37. /*    ascf(3) text filter
  38.  
  39. /* DIAGNOSTICS
  40.  
  41. /*    A nonzero value is returned in case of problems.
  42.  
  43. /* AUTHOR(S)
  44.  
  45. /*      W.Z. Venema
  46.  
  47. /*      Eindhoven University of Technology
  48.  
  49. /*      Department of Mathematics and Computer Science
  50.  
  51. /*      Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  52.  
  53. /* CREATION DATE
  54.  
  55. /*    Fri Dec 15 21:39:26 MET 1989
  56.  
  57. /* LAST MODIFICATION
  58.  
  59. /*    90/01/22 13:02:48
  60.  
  61. /* VERSION/RELEASE
  62.  
  63. /*    2.1
  64.  
  65. /*--*/
  66.  
  67.  
  68.  
  69. #include <stdio.h>
  70.  
  71.  
  72.  
  73. #include "defs.h"
  74.  
  75. #include "ascf.h"
  76.  
  77.  
  78.  
  79. /* textcopy - copy text to stream */
  80.  
  81.  
  82.  
  83. public int textcopy(path, fp)
  84.  
  85. char   *path;
  86.  
  87. FILE   *fp;
  88.  
  89. {
  90.  
  91.     char    buf[BUFSIZ];
  92.  
  93.     int     ret;
  94.  
  95.     FILE   *ip;
  96.  
  97.  
  98.  
  99.     if ((ip = ascopen(path, "r")) == 0) {
  100.  
  101.     return (1);
  102.  
  103.     } else {
  104.  
  105.     while (ascgets(buf, sizeof(buf), ip))
  106.  
  107.         fputs(buf, fp), putc('\n', fp);
  108.  
  109.     ret = ferror(ip);
  110.  
  111.     ascclose(ip);
  112.  
  113.     return (ret);
  114.  
  115.     }
  116.  
  117. }
  118.  
  119.