-void block_sorting(char *in, char *out, unsigned long int *k, unsigned long int len)
+void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsigned int leido)
+{
+ unsigned int l;
+ l = bs->len;
+ /* Hack para pedasos menores a la pagina */
+ if (leido < bs->len) bs->len = leido;
+
+ generar_array(in, bs);
+ ordenar_array(in, bs);
+ (*k) = generar_salida(in, bs, out);
+
+ bs->len = l;
+}
+
+void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len)
+{
+ unsigned long int i, current;
+ t_BlockSortDecode *in;
+
+ in = malloc(sizeof(t_BlockSortDecode)*len);
+
+ for(i=0; i<len; i++) {
+ in[i].c = c[i];
+ in[i].pos = i;
+ }
+
+ qsort(in, len, sizeof(t_BlockSortDecode), _compare);
+
+ current = k;
+ i=0;
+ do {
+ dst[i++] = in[current].c;
+ current = in[current].pos;
+ } while (current != k);
+ free(in);
+}
+
+t_BlockSort *bs_create(unsigned int len)