home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 March / PCO3_97.ISO / filesbbs / os2 / lzo026.arj / LZO026.ZIP / lzo-0.26 / src / lzo1b_xx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-24  |  2.1 KB  |  85 lines

  1. /* lzo1b_xx.c -- LZO1B compression public entry point
  2.  
  3.    This file is part of the LZO real-time data compression library.
  4.  
  5.    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  6.  
  7.    The LZO library is free software; you can redistribute it and/or
  8.    modify it under the terms of the GNU General Public License as
  9.    published by the Free Software Foundation; either version 2 of
  10.    the License, or (at your option) any later version.
  11.  
  12.    The LZO library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with the LZO library; see the file COPYING.
  19.    If not, write to the Free Software Foundation, Inc.,
  20.    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21.  
  22.    Markus F.X.J. Oberhumer
  23.    markus.oberhumer@jk.uni-linz.ac.at
  24.  */
  25.  
  26.  
  27. #include "config1b.h"
  28.  
  29.  
  30. /***********************************************************************
  31. //
  32. ************************************************************************/
  33.  
  34. static const lzo_compress_t * const c_funcs [9] = 
  35. {
  36.     &_lzo1b_1_compress_func,
  37.     &_lzo1b_2_compress_func,
  38.     &_lzo1b_3_compress_func,
  39.     &_lzo1b_4_compress_func,
  40.     &_lzo1b_5_compress_func,
  41.     &_lzo1b_6_compress_func,
  42.     &_lzo1b_7_compress_func,
  43.     &_lzo1b_8_compress_func,
  44.     &_lzo1b_9_compress_func
  45. };
  46.  
  47.  
  48. lzo_compress_t _lzo1b_get_compress_func(int clevel)
  49. {
  50.     const lzo_compress_t *f;
  51.  
  52.     if (clevel < LZO1B_BEST_SPEED || clevel > LZO1B_BEST_COMPRESSION)
  53.     {
  54.         if (clevel == LZO1B_DEFAULT_COMPRESSION)
  55.             clevel = LZO1B_BEST_SPEED;
  56.         else
  57.             return NULL;
  58.     }
  59.     f = c_funcs[clevel-1];
  60.     assert(f != NULL && *f != NULL);
  61.     return *f;
  62. }
  63.  
  64.  
  65. LZO_PUBLIC(int)
  66. lzo1b_compress ( const lzo_byte *src, lzo_uint  src_len,
  67.                        lzo_byte *dst, lzo_uint *dst_len,
  68.                        lzo_voidp wrkmem,
  69.                        int clevel )
  70. {
  71.     lzo_compress_t f;
  72.  
  73.     f = _lzo1b_get_compress_func(clevel);
  74.     if (f == NULL)
  75.         return LZO_E_ERROR;
  76.     return _lzo1b_do_compress(src,src_len,dst,dst_len,wrkmem,f);
  77. }
  78.  
  79.  
  80.  
  81. /*
  82. vi:ts=4
  83. */
  84.  
  85.