int dflag = 0;
int zflag = 0;
int tflag = 0;
- int pflag = 0;
+ int qflag = 0;
long int volumesize = 0;
size_t pagesize = 32768; /* 32KB */
int ch;
t_BlockSort *bs;
- while ((ch = getopt(argc, argv, "cdzt:p:")) != -1) {
+ while ((ch = getopt(argc, argv, "cdzt:q:")) != -1) {
switch (ch) {
case 'c': cflag = 1;
break;
case 't': tflag = 1;
- volumesize = atol(optarg);
- break;
-
- case 'p': pflag = 1;
- pagesize = atoi(optarg);
- break;
+ volumesize = atol(optarg);
+ break;
+
+ case 'q': qflag = 1;
+ switch (atoi(optarg))
+ {
+ case 0: pagesize = 1024; /* 1K */
+ break;
+ case 1: pagesize = 2048; /* 2K */
+ break;
+ case 2: pagesize = 4096; /* 4K */
+ break;
+ case 3: pagesize = 8192; /* 8K */
+ break;
+ case 4: pagesize = 16384; /* 16K */
+ break;
+ case 5: pagesize = 32768; /* 32K */
+ break;
+ case 6: pagesize = 65536; /* 64K */
+ break;
+ case 7: pagesize = 131072; /* 128K */
+ break;
+ case 8: pagesize = 262144; /* 256K */
+ break;
+ case 9: pagesize = 524288; /* 512K */
+ break;
+ default: pagesize = 0; /* error */
+ }
+ break;
default: fprintf(stderr, "Usage: %s [-cdpt] sourcefile targetfile\n", argv[0]);
return(2);
fprintf(stderr,"Error: The volume size must be a non-zero value\n");
return (4);
}
- if ((pflag) && (pagesize <= 1u)) {
- fprintf(stderr,"Error: El tamaño de página debe ser mayor a 1 byte.\n");
+ if ((qflag) && (pagesize <= 1u)) {
+ fprintf(stderr,"Error: El nivel de compresión debe ser entre 0 (menor) y 9 (mayor).\n");
return (5);
}
bs_destroy(bs);
/* Comprimo con huffman */
- i = shuff_encode_file("tmp.comp",argv[optind+1], volumesize);
+ i = shuff_encode_file("tmp.comp", argv[optind+1], volumesize);
/* borro el temporal */
- unlink("tmp.comp");
+ remove("tmp.comp");
/* Muestro bpb */
printf("Comprimido a %.04f bpb.\n", get_file_size(argv[optind+1])*8.0/get_file_size(argv[optind]));
-# Makefile de ejemplo para C++
-#
-# Creado: jue abr 15 15:34:19 ART 2004
+#----------------------------------------------------------------------------
+# jacu
+#----------------------------------------------------------------------------
+# This file is part of jacu.
#
-# Copyleft 2004 - Leandro Lucarella, Bajo licencia GPL [http://www.gnu.org/]
+# 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
+#----------------------------------------------------------------------------
+# Creado: jue jun 17 00:41:52 ART 2004
+# Autores: Leandro Lucarella <llucare@fi.uba.ar>
+#----------------------------------------------------------------------------
+#
+# $Id: bufford.c 624 2004-05-30 20:18:04Z llucare $
#
-# CONFIGURACION
-################
-
-# Nombre del ejecutable.
-target = mtf
-
-# Extensión de los archivos a compilar (c para C, cpp o cc o cxx para C++).
-extension = c
-
-# Archivos con el código fuente que componen el ejecutable. Si no se especifica,
-# toma todos los archivos con la extensión mencionada. Para especificar hay que
-# descomentar la línea (quitarle el '#' del principio).
-# NOTA: No poner cabeceras (.h).
-#fuentes = entrada.cpp
-
-# Si es un programa GTK+, descomentá (quitale el '#' a) la siguiente línea.
-#gtk = si
-
-
-# CONFIGURACION "AVANZADA"
-###########################
-
-# Opciones para el compilador C.
-#CFLAGS = -Wall -ggdb -ansi -pedantic -DDEBUG
-CFLAGS = -Wall -O3 -ansi -pedantic -DNDEBUG -g
-
-# Opciones para el compilador C++.
-#CXXFLAGS = $(CFLAGS) -fno-inline
-CXXFLAGS = $(CFLAGS)
-
-
-# VARIABLES CALCULADAS A PARTIR DE LA CONFIGURACION
-####################################################
-
-# Agrego flags y libs de GTK+ de ser necesario.
-ifdef gtk
-CFLAGS += $(shell pkg-config --cflags gtk+-2.0)
-CXXFLAGS += $(shell pkg-config --cflags gtk+-2.0)
-LDFLAGS += $(shell pkg-config --libs gtk+-2.0)
-endif
-
-# Uso enlazador de c++ si es código no C.
-ifeq ($(extension), c)
-enlazador = $(CC)
-else
-enlazador = $(CXX)
-endif
-
-# Si no especifica archivos, tomo todos.
-fuentes ?= $(wildcard *.$(extension))
-
+TARGETS=main mtof
+COMMON=mtf.o
+SRCS=mtf.c main.c mtof.c
-# REGLAS
-#########
+#CFLAGS=-O3 -Wall -DNDEBUG
+CFLAGS=-ggdb -Wall -DDEBUG
-.PHONY: all clean
+all: $(TARGETS)
-all: $(target)
+main: $(COMMON) main.o
-o_files = $(patsubst %.$(extension),%.o,$(fuentes))
+mtof: $(COMMON) mtof.o
-$(target): $(o_files)
- $(enlazador) $(LDFLAGS) $(o_files) $(LOADLIBES) $(LDLIBS) -o $(target)
+depend:
+ makedepend -- $(CFLAGS) -- $(SRCS)
clean:
- @$(RM) -fv *.o $(target)
-
+ @$(RM) -f *.o $(TARGETS)
+
+.PHONY: all clean depend
+
+# DO NOT DELETE
+
+mtf.o: mtf.h /usr/include/stdio.h /usr/include/features.h
+mtf.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+mtf.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h
+mtf.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h
+mtf.o: /usr/include/bits/typesizes.h /usr/include/libio.h
+mtf.o: /usr/include/_G_config.h /usr/include/wchar.h
+mtf.o: /usr/include/bits/wchar.h /usr/include/gconv.h
+mtf.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h
+mtf.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h
+mtf.o: /usr/include/stdlib.h
+main.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h
+main.o: /usr/include/gnu/stubs.h
+main.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h
+main.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h
+main.o: /usr/include/bits/typesizes.h /usr/include/libio.h
+main.o: /usr/include/_G_config.h /usr/include/wchar.h
+main.o: /usr/include/bits/wchar.h /usr/include/gconv.h
+main.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h
+main.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h mtf.h
+main.o: /usr/include/stdlib.h /usr/include/string.h
+mtof.o: /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h
+mtof.o: /usr/include/gnu/stubs.h
+mtof.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h
+mtof.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h
+mtof.o: /usr/include/bits/typesizes.h /usr/include/libio.h
+mtof.o: /usr/include/_G_config.h /usr/include/wchar.h
+mtof.o: /usr/include/bits/wchar.h /usr/include/gconv.h
+mtof.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h
+mtof.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h mtf.h
+mtof.o: /usr/include/stdlib.h /usr/include/string.h