1 /* vim: set noexpandtab tabstop=4 shiftwidth=4 wrap:
2 *----------------------------------------------------------------------------
4 *----------------------------------------------------------------------------
5 * This file is part of jacu.
7 * jacu is free software; you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option) any later
12 * jacu is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along
18 * with jacu; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
20 *----------------------------------------------------------------------------
21 * Creado: lun jun 21 05:40:38 ART 2004
22 * Autores: Leandro Lucarella <llucare@fi.uba.ar>
23 *----------------------------------------------------------------------------
25 * $Id: vfile.c 748 2004-06-21 00:46:08Z llucare $
29 #include "zerogrouping.h"
35 * ImplementaciĆ³n del agrupador de ceros. TODO completar doc.
40 * El dst se asume que tiene reservada al menos ceil(size/2.0)+size bytes de
41 * memoria por si se llegara a expandir. size es el tamaƱo a leer de src. Se
42 * devuelve la cantidad de bytes escritos en dst. */
43 size_t zg_group(char* dst, char *src, size_t size)
49 for (i = 0; i < size; ++i)
55 ++count; /* FIXME verificar que no pase 255 */
59 in_zero = 1; /* entramos en serie de ceros */
60 count = 0; /* reiniciamos contador de ceros */
71 dst[total++] = src[i];
74 if (in_zero) /* si estaba en una serie de ceros, terminamos de escribir. */
82 size_t zg_ungroup(char* dst, char *src, size_t size)