X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/90781e95d22ac07ccc263ce5bbca7d7d878c96b1..fd6fd64c670641da85e91b3e4c9416bc18ad49e6:/emufs/tipo3_main.c diff --git a/emufs/tipo3_main.c b/emufs/tipo3_main.c index bdf5787..602609a 100644 --- a/emufs/tipo3_main.c +++ b/emufs/tipo3_main.c @@ -1,13 +1,48 @@ +/* vim: set noexpandtab tabstop=4 shiftwidth=4: + *---------------------------------------------------------------------------- + * emufs + *---------------------------------------------------------------------------- + * This file is part of emufs. + * + * emufs 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. + * + * emufs 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 emufs; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA + *---------------------------------------------------------------------------- + * Creado: mié mar 31 17:26:46 ART 2004 + * Autores: Nicolás Dimov + *---------------------------------------------------------------------------- + * + * $Id$ + * + */ + +/** \file + * + * Prueba de archivo \ref tipo3.h "tipo3". + * + */ + #include #include #include "emufs.h" +#include "fsc.h" int main(int argc, char *argv[]) { EMUFS *fp; - int n1, n2, n3, n4, n5, n6, n7, n8; + EMUFS_REG_ID v[8]; + EMUFS_REG_SIZE reg_size; char a[100]; - char b[100]; char c[100]; char d[100]; char e[100]; @@ -15,17 +50,15 @@ int main(int argc, char *argv[]) char g[100]; char h[100]; char i[100]; - + char* b_ptr; + int err = 0, max, min, j; + + EMUFS_Estadisticas s; if (argc != 2) { printf("Modo de uso : %s tam_bloque\n", argv[0]); return 1; } - - if (atoi(argv[1]) < 104) { - printf("El tamaño de bloque debe ser mayor a 104\n"); - return 1; - } - + strcpy(a, "1234567890"); strcpy(c, "REGISTRO NUMERO 2. ESTE REGISTRO ES MUCHO MAS LARGO QUE EL UNO"); strcpy(d, "ABCDEFGHIJKL"); @@ -36,33 +69,45 @@ int main(int argc, char *argv[]) strcpy(i, "me argrego despues de borrar a un registro"); fp = emufs_crear("articulos", T3, atoi(argv[1]), 100); + printf("cant de bloques = %d\n", fp->tam_reg/(fp->tam_bloque-sizeof(EMUFS_REG_ID)) +1); + printf("GRABANDO REGISTROS....\n"); + v[0] = fp->grabar_registro(fp, a, 100, &err); + v[1] = fp->grabar_registro(fp, c, 100, &err); + v[2] = fp->grabar_registro(fp, d, 100, &err); + v[3] = fp->grabar_registro(fp, e, 100, &err); + v[4] = fp->grabar_registro(fp, f, 100, &err); + v[5] = fp->grabar_registro(fp, g, 100, &err); + v[6] = fp->grabar_registro(fp, h, 100, &err); + v[7] = fp->grabar_registro(fp, i, 100, &err); + for (j=0; j<8; j++) + printf("Grabado : %d\n", v[j]); - n1 = fp->grabar_registro(fp, a, 100); - n2 = fp->grabar_registro(fp, c, 100); - n3 = fp->grabar_registro(fp, d, 100); - n4 = fp->grabar_registro(fp, e, 100); - n5 = fp->grabar_registro(fp, f, 100); - n6 = fp->grabar_registro(fp, g, 100); - n7 = fp->grabar_registro(fp, h, 100); - - printf("ID0 = %d\n", n1); - printf("ID1 = %d\n", n2); - printf("ID2 = %d\n", n3); - printf("ID3 = %d\n", n4); - printf("ID4 = %d\n", n5); - printf("ID5 = %d\n", n6); - printf("ID6 = %d\n", n7); - - - fp->borrar_registro(fp, n4, 100); - n8 = fp->grabar_registro(fp, i, 100); - fp->leer_registro(fp, n8, b, 100); - - printf("Recuperado : %s\n", b); - - ver_archivo_FS(fp); + printf("RECUPERANDO REGISTROS....\n"); + for (j=0; j<8; j++){ + b_ptr = fp->leer_registro(fp, v[j], ®_size, &err); + printf("Recuperado : %s\n", b_ptr); + } - emufs_destruir(fp); + printf("BORRANDO REGISTROS....\n"); + for (j=0; j<8; j++){ + fp->borrar_registro(fp, v[j]); + printf("borrado : %d\n", v[j]); + } + + printf("GRABANDO REGISTROS....\n"); + v[0] = fp->grabar_registro(fp, a, 100, &err); + v[1] = fp->grabar_registro(fp, c, 100, &err); + v[2] = fp->grabar_registro(fp, d, 100, &err); + v[3] = fp->grabar_registro(fp, e, 100, &err); + v[4] = fp->grabar_registro(fp, f, 100, &err); + v[5] = fp->grabar_registro(fp, g, 100, &err); + v[6] = fp->grabar_registro(fp, h, 100, &err); + v[7] = fp->grabar_registro(fp, i, 100, &err); + + free(b_ptr); + ver_archivo_FS(fp); + +emufs_destruir(fp); return 0; }