home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxgzlib.zip / tst2gzlb.cmd < prev    next >
OS/2 REXX Batch file  |  1999-12-20  |  3KB  |  111 lines

  1. /* Simple demo of rxgzlib Functions. Requires an hpfs drive (for multi-extension file names) */
  2.  
  3. /* Load the rxgzlib functions */
  4. if rxfuncquery('rxgzLoadFuncs') then do
  5.    foo=RxFuncAdd( 'rxgzLoadFuncs', 'rxgzLIB', 'rxgzLoadFuncs')
  6.    if foo=0 then do
  7.       call rxgzLoadFuncs
  8.    end
  9.    else do
  10.       say "Sorry, rxgzlib.dll is not available"
  11.       exit
  12.    end /* do */
  13. end /* if */
  14.  
  15. parse source . . thisfile
  16.  
  17. say "This program will test the compatability of rxgzInflateString (and "
  18. say " rxgzDeflateString) with GZIP.EXE -- the goal is interoperability, and "
  19. say " not bytewise exactness"
  20.  
  21. say " 1) choose your test file (this file is used by default)."
  22. say " 2) use GZIP.EXE to deflate this, saving the result to EXE_VER.GZ"
  23. say "   [For example, use GZIP -c input_file > EXE_VER.GZ] "
  24. say " 3) run this program, and see what it reports."
  25. say "    Note that this program creates def_string.GZ and def_file.GZ "
  26. say "   (the result of rxgzDeflateString and rxgzDeflateFile, respectively)"
  27. say " or "
  28. say " 4) Run GZIP.EXE against EXE_VER.GZ and PROC_VER.GZ, and compare these"
  29. say '    against your input_file'
  30. say
  31. call charout,'Enter an input file: '
  32. pull input_file
  33. if input_file='' then do
  34.     input_file=thisfile
  35.     say ' ... using 'input_file
  36. end
  37. say 
  38.  
  39. foo=stream(input_file,'c','query size')
  40. orig_string=charin(input_file,1,foo)
  41. foo=stream(input_File,'c','close')
  42.  
  43. orig_gz=rxgzdeflatestring(orig_string)
  44.  
  45. out1='def_String.gz'
  46. foo=charout(out1,orig_gz,1)
  47. foo=stream(out1,'c','close')
  48.  
  49. say out1 " is the rxgzdeflatestring of " input_file
  50. say " enter to continue "
  51. pull goo
  52.  
  53. out2='def_file.gz'
  54. out2a='undef_file.out'
  55. stat=rxgzdeflatefile(input_file,out2)
  56. say "Status from rxgzdeflatefile: "stat
  57. stat=rxgzinflatefile(out2,out2a)
  58. say "Status from rxgzinflatefile: "stat
  59.  
  60. say out2 " is rxgzdeflatefile of " input_file
  61. say " enter to continue "
  62. pull goo
  63.  
  64. /* read and decompress the rxgzdeflatestring version */
  65.  
  66. sz=stream(out1,'c','query size')
  67. proc_ver=charin(out1,1,sz)
  68. foo=stream(out1,'c','close')
  69.  
  70. say " length of proc_ver (gz'ed) string= "length(proc_ver)
  71. proc_ver_deflated=rxgzinflatestring(proc_ver)
  72. say " proc_Ver_deflated string is "length(proc_ver_deflated)
  73. say " enter to continue "
  74. pull goo
  75.  
  76. /* read and decompress the "gzip.exe" version */
  77.  
  78. gzexe_file='exe_ver.gz'
  79. sz=stream(gzexe_file,'c','query size')
  80. if sz=0 | sz='' then do
  81.    say gzexe_file " does not exist "
  82. end /* do */
  83. else do
  84.   exe_ver=charin(gzexe_file,1,sz)
  85.   foo=stream(gzexe_file,'c','close')
  86.   say " Reading GZIP.EXE'd version of input_file = "gzexe_file
  87.   say " length of exe_ver (gz'ed) string= "length(exe_ver)
  88.   exe_ver_deflated=rxgzinflatestring(exe_ver)
  89.   say " exe_Ver_deflated string is "length(exe_ver_deflated)
  90.   say " enter to continue "
  91.   pull goo
  92.  
  93. /* compare the two */
  94.  
  95.   if exe_ver_deflated=proc_ver_deflated then
  96.      say "SUCCESS. exe_ver and proc_ver are the same "
  97.   else
  98.      say "ERROR!! exe_ver and proc_Ver are different "
  99. end
  100.  
  101. say " more tests ... "
  102.  
  103. test='this is a test'
  104. say "  Trying to inflate 'this is a test' "
  105. xx=rxgzinflatestring(test)
  106. say "       yields: " xx
  107.  
  108. oo=rxgzinflatefile(thisfile,thisfile'.tmp')
  109. say " Trying to inflate non-gzip file, status=" oo
  110.  
  111.