StonePhpSafeCrypt_compressors.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /////////
  3. //
  4. // Stone PHP SafeCrypt Compressors
  5. // -------------------------------
  6. //
  7. // To add a new compressor, create a new member in the $compressors array. Its key should be
  8. // the string by which the user calls the compressor. Its value should be an array with two
  9. // members, 'encode' and 'decode', each themselves arrays. Each of the compressor entries
  10. // should also have a 'desc' member, to give a descriptive name to each compression method,
  11. // in case someone wants to build something larger on this library and needs tooltip or
  12. // statusbar descriptive text.
  13. //
  14. // Each encode and decode must have the 'fname' member, which contains the name of the encoding
  15. // or decoding function as appropriate.
  16. //
  17. // Each may have the 'args' member, which is a list of arguments that will be passed to the
  18. // function, in order. If either array has the 'args' member, it must therefore also have the
  19. // 'data_arg' member, which is the index of the argument to override with the actual data to be
  20. // compressed or uncompressed.
  21. //
  22. // If the array does not have the 'args' and 'data_args' members, the function will be assumed
  23. // to take only one value, the data for compression or decompression.
  24. $compressors = array(
  25. 'gz' => array(
  26. 'encode' => array('fname' => 'gzcompress', 'args' => array(false, 9), 'data_arg' => 0),
  27. 'decode' => array('fname' => 'gzuncompress'),
  28. 'desc' => 'RFC 1950 ZLib compression at maximum'
  29. ),
  30. 'gz_deflate' => array(
  31. 'encode' => array('fname' => 'gzdeflate', 'args' => array(false, 9), 'data_arg' => 0),
  32. 'decode' => array('fname' => 'gzinflate'),
  33. 'desc' => 'RFC 1951 ZLib deflate at maximum'
  34. ),
  35. 'bz' => array(
  36. 'encode' => array('fname' => 'bzcompress', 'args' => array(false, 9, 30), 'data_arg' => 0),
  37. 'decode' => array('fname' => 'bzdecompress'),
  38. 'desc' => 'BZip2 compress at maximum, using work factor 30'
  39. ),
  40. // add other compressors here
  41. );
  42. ?>