+/*----------------------------------------------------------------------------
+ * jacu - Just Another Compression Utility
+ *----------------------------------------------------------------------------
+ * This file is part of jacu.
+ *
+ * jacu is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * jacu is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with jacu; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ *----------------------------------------------------------------------------
+ */
+
#include "bs.h"
#include <stdlib.h>
PALABRA(" tener"),
PALABRA(" ningún"),
PALABRA(" fácil"),
+ /* Algunas cosas de ingles para mejorar otros textos */
+ PALABRA(" as "),
+ PALABRA(" will "),
+ PALABRA(" with "),
+ PALABRA(" this "),
+ PALABRA(" program "),
+ PALABRA(" are "),
+ PALABRA(" The "),
+ PALABRA(" it "),
+ PALABRA(" which "),
+ PALABRA(" for "),
+ PALABRA(" be "),
+ PALABRA(" that "),
+ PALABRA(" is "),
+ PALABRA(" and "),
+ PALABRA(" to "),
+ PALABRA(" of "),
+ PALABRA(" the ")
};
typedef struct _bs_decode_t_ {
while ((!feof(fp)) && ((i+buffer_pos) < pagesize)) {
c = fgetc(fp);
- hint = check_hint(c);
-
+
if (usar_dic != 1) {
data[i++] = c;
continue;
}
+ if (c == ESCAPE_CHARACTER) {
+ data[i++] = c;
+ data[i++] = 0xF;
+ bs_clean_dic();
+ continue;
+ }
+
+ hint = check_hint(c);
+
switch (hint) {
case -1:
/* No hay hints, vacio el buffer y luego saco el c */
/* Trato de hacer que el caracter sea comun en textos, para que no me rompa
* la localidad
*/
- data[i++] = hint+32;
+ data[i++] = hint;
bs_clean_dic();
- /* Imprimo el buffer que deberia ser la palabra que reemplazo */
-/* {
- int iii;
- for(iii=0; iii<buffer_pos; iii++)
- printf("%c", buffer[iii]);
- printf("%c\n", c);
- } */
/* El buffer no lo necesito mas */
buffer_pos = 0;
}
return i;
}
+char *bs_finalblock(char *data, Uint32 len, Uint32 *new_size)
+{
+ Uint32 size=0, i, j;
+ char *out = NULL;
+ unsigned char tmp;
+
+ for(i=0; i < len; i++) {
+ if (data[i] == ESCAPE_CHARACTER) {
+ i++;
+ if (data[i] == 0xF) {
+ /* Solo tengo que dejar el ESCAPE_CHARACTER */
+ size++;
+ out = (char *)realloc(out, size*sizeof(char));
+ out[size-1] = data[i];
+ /* Salteo ese caracter */
+ } else {
+ /* Va una palabra!! */
+ tmp = data[i];
+ size += dic[(size_t)tmp].len;
+ out = (char *)realloc(out, size*sizeof(char));
+ for(j=0; j<dic[(size_t)tmp].len; j++) {
+ out[size-dic[(size_t)tmp].len+j] = dic[(size_t)tmp].word[j];
+ }
+ /* Salteo el caracter siguiente al de escape */
+ }
+ } else {
+ size++;
+ out = (char *)realloc(out, size*sizeof(char));
+ out[size-1] = data[i];
+ }
+ }
+
+ (*new_size) = size;
+ return out;
+}
+