From: Ricardo Markiewicz Date: Sat, 10 Apr 2004 19:34:40 +0000 (+0000) Subject: * Ajusto algunas cosas al coding style. X-Git-Tag: svn_import_r684~579 X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/commitdiff_plain/3a8f34126fd2b8cf8b2ae8822a800aa62003625d?ds=inline * Ajusto algunas cosas al coding style. --- diff --git a/emufs/idx.c b/emufs/idx.c index d0dd436..6ee1b87 100644 --- a/emufs/idx.c +++ b/emufs/idx.c @@ -68,30 +68,31 @@ int emufs_idx_crear(EMUFS *efs) /* Devuelve el mayor id de registro utilizado so far en el archivo de datos, revisando el indice. */ EMUFS_REG_ID emufs_idx_buscar_mayor_id(EMUFS *emu) { - EMUFS_REG_ID n_IdReg, max = 0; + EMUFS_REG_ID n_idreg, max = 0; FILE *f_idx; EMUFS_IDX reg; char name_f_idx[255]; /* TODO usar malloc para no limitar el tamaƱo de nombre de archivo */ - unsigned short int b_Found = 0; + unsigned short int b_found = 0; strcpy(name_f_idx,emu->nombre); strcat(name_f_idx, EMUFS_IDX_EXT); if ( (f_idx = fopen(name_f_idx,"r")) == NULL) return -1; /*ERROR*/ - n_IdReg = -1; + n_idreg = -1; while ( !feof(f_idx) ){ /* Me aseguro de leer la cantidad de bytes correcta */ if (fread(®,sizeof(EMUFS_IDX),1,f_idx) != 1) continue; - if ( reg.n_IdReg >= max ) { - max = reg.n_IdReg; - b_Found = 1; + if ( reg.n_idreg >= max ) { + max = reg.n_idreg; + b_found = 1; } } fclose(f_idx); - if (!b_Found) return (0); - else return(max+1); - return n_IdReg; + if (!b_found) + return (0); + else + return(max+1); } /* busca el registro ID en el archivo ".idx" y devuelve el nro de bloque en el que se encuentra */ @@ -109,18 +110,20 @@ EMUFS_BLOCK_ID emufs_idx_buscar_registro(EMUFS *emu, EMUFS_REG_ID n_IdReg) while (!feof(f_idx) && !b_Found){ if (fread(®,sizeof(EMUFS_IDX),1,f_idx) != 1) continue; - if (reg.n_IdReg == n_IdReg) b_Found = 1; + if (reg.n_idreg == n_IdReg) b_Found = 1; } fclose(f_idx); /* Sino lo encontre devuelvo uno, otherwise el offset o bloque */ - if (!b_Found) return(-1); - else return(reg.n_Location); + if (!b_Found) + return(-1); + else + return(reg.n_location); } /* agrega un registro al final del archivo */ -int emufs_idx_agregar(EMUFS *emu, EMUFS_REG_ID n_IdReg, EMUFS_BLOCK_ID n_Location) +int emufs_idx_agregar(EMUFS *emu, EMUFS_REG_ID n_idreg, EMUFS_BLOCK_ID n_location) { FILE *f_idx; EMUFS_IDX reg; @@ -132,8 +135,8 @@ int emufs_idx_agregar(EMUFS *emu, EMUFS_REG_ID n_IdReg, EMUFS_BLOCK_ID n_Locatio if ( (f_idx = fopen(name_f_idx,"a+"))==NULL ) return -1; /* Note: Location = Bloque para Tipo 1 y 3, Offset para Tipo 2 */ - reg.n_IdReg = n_IdReg; - reg.n_Location = n_Location; + reg.n_idreg = n_idreg; + reg.n_location = n_location; fwrite(®,sizeof(EMUFS_IDX),1,f_idx); fclose(f_idx); return 0; @@ -155,7 +158,7 @@ int emufs_idx_borrar(EMUFS *emu, EMUFS_REG_ID n_IdReg) while ( !feof(f_idx) ){ /*busco cual tengo que borrar*/ if ( fread(®, sizeof(EMUFS_IDX), 1, f_idx) != 1 ) continue; - if ( reg.n_IdReg == n_IdReg ) + if ( reg.n_idreg == n_IdReg ) break; } diff --git a/emufs/idx.h b/emufs/idx.h index 7e7cff9..510e78c 100644 --- a/emufs/idx.h +++ b/emufs/idx.h @@ -45,8 +45,8 @@ #define EMUFS_IDX_EXT ".idx" typedef struct emufs_idx_t { - unsigned long int n_IdReg; - unsigned long int n_Location; + unsigned long int n_idreg; + unsigned long int n_location; } EMUFS_IDX; FILE* emufs_idx_abrir(EMUFS*, const char*); diff --git a/emufs/tipo1_test.c b/emufs/tipo1_test.c index 7249e44..188ef8b 100644 --- a/emufs/tipo1_test.c +++ b/emufs/tipo1_test.c @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { return 1; } - if (efs->leer_registro(efs, 0, registro1, 4) == -1) { + if (efs->leer_registro(efs, 0, registro1) == -1) { printf("No se pudo leer el registro 1.\n"); return 1; }