home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / unix_comp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-27  |  1.5 KB  |  80 lines

  1.  
  2. /*
  3.  *  UNIX_COMP.C
  4.  *
  5.  *  compress a file source to a destination file pointer, used by
  6.  *  BATCHNEWS.
  7.  *
  8.  *  This differs from COMP.C in that the AmigaUUCP ulog() call is not
  9.  *  used.
  10.  */
  11.  
  12. #define LOGERROR
  13. #define NO_ULOG
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "config.h"
  19.  
  20. Prototype int unix_compress_from_file(char *, FILE *, short);
  21. Prototype int unix_compress_from_fp(FILE *, FILE *, short);
  22. Prototype int unix_uncompress_to_file(FILE *, char *, short *);
  23. Prototype int unix_uncompress_to_fp(FILE *, FILE *, short *);
  24.  
  25. int
  26. unix_compress_from_file (char *inName, FILE *fo, short bits)
  27. {
  28.     FILE *fi;
  29.     int r = -1;
  30.  
  31.     if (initcomp(NULL, fo, bits, 0, 0) >= 0) {
  32.         if (fi = fopen(inName, "r")) {
  33.             r = compress(fo, fo);
  34.             fclose(fi);
  35.         }
  36.     }
  37.     deletecomp();
  38.     return r;
  39. }
  40.  
  41. int
  42. unix_compress_from_fp (FILE *fi, FILE *fo, short bits)
  43. {
  44.     int r = -1;
  45.  
  46.     if (initcomp(NULL, fo, bits, 0, 0) >= 0) {
  47.         r = compress(fi, fo);
  48.     }
  49.     deletecomp();
  50.     return r;
  51. }
  52.  
  53. int
  54. unix_uncompress_to_file (FILE *fi, char *outName, short *pbits)
  55. {
  56.     FILE *fo;
  57.     int r = -1;
  58.  
  59.     if (initcomp(fi, NULL, 0, 0, 0) >= 0) {
  60.         if (fo = fopen(outName, "w")) {
  61.             r = decompress(fi, fo, pbits);
  62.             fclose(fo);
  63.         }
  64.     }
  65.     deletecomp();
  66.     return r;
  67. }
  68.  
  69. int
  70. unix_uncompress_to_fp (FILE *fi, FILE *fo, short *pbits)
  71. {
  72.     int r = -1;
  73.  
  74.     if (initcomp(fi, NULL, 0, 0, 0) >= 0) {
  75.         r = decompress(fi, fo, pbits);
  76.     }
  77.     deletecomp();
  78.     return r;
  79. }
  80.