home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / uucp / amigauucpsrc / lib / uncomp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  1.0 KB  |  67 lines

  1.  
  2. /*
  3.  *  UNCOMP.C
  4.  *
  5.  *  uncompress a file pointer into a file destination.
  6.  */
  7.  
  8. #define DECOMPRESS_ONLY     /*  sneaky shit to avoid repeating core code */
  9. #define BITS  16        /*  maximum (dynamically allocate)           */
  10. #define XENIX_16
  11. #include <stdio.h>
  12. #undef stdin
  13. #undef stdout
  14. #define stdin    Fi
  15. #define stdout    Fo
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "config.h"
  19.  
  20. static FILE *Fi;
  21. static FILE *Fo;
  22.  
  23. #define LOGERROR    ulog(-1, "UNCOMPRESS ERROR")
  24.  
  25. #include "/unix/compress.ch"
  26.  
  27. Prototype int uncompress_to_file(FILE *, char *);
  28. Prototype int uncompress_to_fp(FILE *, FILE *);
  29.  
  30. int
  31. uncompress_to_file(fi, outName)
  32. FILE *fi;
  33. char *outName;
  34. {
  35.     FILE *fo;
  36.     int r = -1;
  37.  
  38.     if (initcomp(fi, NULL, 0) >= 0) {
  39.     if (fo = fopen(outName, "w")) {
  40.         Fi = fi;
  41.         Fo = fo;
  42.         r = decompress();
  43.         fclose(fo);
  44.     }
  45.     }
  46.     deletecomp();
  47.     return(r);
  48. }
  49.  
  50. int
  51. uncompress_to_fp(fi, fo)
  52. FILE *fi;
  53. FILE *fo;
  54. {
  55.     int r = -1;
  56.  
  57.     if (initcomp(fi, NULL, 0) >= 0) {
  58.     Fi = fi;
  59.     Fo = fo;
  60.     r = decompress();
  61.     }
  62.     deletecomp();
  63.     return(r);
  64. }
  65.  
  66.  
  67.