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 *----------------------------------------------------------------------------
29 #include "zerogrouping.h"
35 * Implementación del agrupador de ceros. TODO completar doc.
45 * El dst se asume que tiene al menos 2 bytes reservados para escribir,
46 * por si se llegara a expandir. src es el caracter a encodear. Se
47 * devuelve la cantidad de bytes escritos en dst. */
48 size_t zg_group(ZG* zg, char *dst, char src)
54 zg->count++; /* FIXME verificar que no pase 255 */
55 return 0; /* indico que no hay nada */
59 zg->in_zero = 1; /* entramos en serie de ceros */
60 zg->count = 0; /* reiniciamos contador de ceros */
61 *dst = '\0'; /* devuelvo el cero */
62 return 1; /* indico que hay un caracter */
65 else /* no es un cero */
70 zg->in_zero = 0; /* saldo de serie de ceros */
71 *dst = zg->count; /* devuelvo cantidad de ceros */
72 dst++; /* me muevo al siguiente caracter */
73 ret++; /* indico que hay un caracter más */
75 *dst = src; /* devuelvo el caracter */
76 return ret; /* indico la cantidad de caracteres devueltos */
80 size_t zg_ungroup(char* dst, char *src, size_t size)