From 9a841b8e8f01dfad72596cf98e76812bf02d9cdd Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 11 Apr 2004 15:42:31 +0000 Subject: [PATCH] =?utf8?q?-=20Uso=20tipos=20EMUFS=5FXXX=20en=20los=20nuevo?= =?utf8?q?s=20emufs=5Fidx=5Fxxx().=20-=20Vuelvo=20a=20agregar=20chequeo=20?= =?utf8?q?de=20error=20sobre=20emufs=5Fdid=5Fget=5Flast().=20-=20Agrego=20?= =?utf8?q?algunas=20'b'=20al=20fopen()=20para=20compatibilidad=20ANSI.=20-?= =?utf8?q?=20Saco=20(*err)=20=3D=200;=20en=20funciones=20(para=20la=20pol?= =?utf8?q?=C3=A9mica).=20Inicializo=20variable=20error=20en=20=20=20la=20G?= =?utf8?q?UI=20para=20que=20ande.=20Ricky,=20el=20ultimo=20punto=20es=20pa?= =?utf8?q?ra=20que=20veas=20como=20habia=20pensado=20yo=20lo=20de=20los=20?= =?utf8?q?errores.=20Si=20sigue=20sin=20convencerte,=20lo=20dejamos=20como?= =?utf8?q?=20vos=20queres,=20no=20tengo=20ganas=20de=20seguir=20peleando?= =?utf8?q?=20por=20esta=20boludez.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- emufs/idx.c | 18 ++++++++++-------- emufs/idx.h | 8 ++++---- emufs_gui/articulos.c | 6 +++--- emufs_gui/facturas.c | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/emufs/idx.c b/emufs/idx.c index 6db15a3..f5b1562 100644 --- a/emufs/idx.c +++ b/emufs/idx.c @@ -78,7 +78,6 @@ EMUFS_REG_ID emufs_idx_buscar_mayor_id_libre(EMUFS* emu, int* err) strcpy(name_f_idx, emu->nombre); strcat(name_f_idx, EMUFS_IDX_EXT); - (*err) = 0; if ((f_idx = fopen(name_f_idx, "rb")) == NULL) { PERR("No se puede abrir archivo"); *err = 4; /* EMUFS_ERROR_CANT_OPEN_FILE */ @@ -210,9 +209,12 @@ EMUFS_REG_ID emufs_idx_get_new_id(EMUFS* efs, int* err) { EMUFS_REG_ID id; - (*err) = 0; id = emufs_did_get_last(efs, err); if (id == EMUFS_NOT_FOUND) { + if (*err) { + PERR("error al obtener ultimo id"); + return id; + } id = emufs_idx_buscar_mayor_id_libre(efs, err); if (*err) { PERR("error al obtener id mayor"); @@ -222,26 +224,26 @@ EMUFS_REG_ID emufs_idx_get_new_id(EMUFS* efs, int* err) return id; } -unsigned int emufs_idx_get_count(EMUFS *emu) +EMUFS_REG_ID emufs_idx_get_count(EMUFS *emu) { FILE *fp; char name_f_idx[255]; - long tam; + EMUFS_REG_ID tam; strcpy(name_f_idx,emu->nombre); strcat(name_f_idx, EMUFS_IDX_EXT); - fp = fopen(name_f_idx, "r"); + fp = fopen(name_f_idx, "rb"); if (fp == NULL) return 0; - fseek(fp, 0, SEEK_END); + fseek(fp, 0l, SEEK_END); tam = ftell(fp); fclose(fp); return tam/sizeof(EMUFS_IDX); } -unsigned long emufs_idx_get_id_at(EMUFS *emu, unsigned int pos) +EMUFS_REG_ID emufs_idx_get_id_at(EMUFS *emu, long pos) { FILE *fp; char name_f_idx[255]; @@ -250,7 +252,7 @@ unsigned long emufs_idx_get_id_at(EMUFS *emu, unsigned int pos) strcpy(name_f_idx,emu->nombre); strcat(name_f_idx, EMUFS_IDX_EXT); - fp = fopen(name_f_idx, "r"); + fp = fopen(name_f_idx, "rb"); if (fp == NULL) return EMUFS_NOT_FOUND; fseek(fp, pos*sizeof(EMUFS_IDX), SEEK_SET); diff --git a/emufs/idx.h b/emufs/idx.h index fea4f3a..605bf1b 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 id_reg; - unsigned long int location; + EMUFS_REG_ID id_reg; + EMUFS_BLOCK_ID location; } EMUFS_IDX; FILE* emufs_idx_abrir(EMUFS*, const char*); @@ -61,9 +61,9 @@ int emufs_idx_agregar(EMUFS*, EMUFS_BLOCK_ID, EMUFS_REG_ID); int emufs_idx_borrar(EMUFS*, EMUFS_REG_ID); -unsigned int emufs_idx_get_count(EMUFS *); +EMUFS_REG_ID emufs_idx_get_count(EMUFS *); -unsigned long emufs_idx_get_id_at(EMUFS *, unsigned int pos); +EMUFS_REG_ID emufs_idx_get_id_at(EMUFS *, long pos); EMUFS_REG_ID emufs_idx_get_new_id(EMUFS*, int*); diff --git a/emufs_gui/articulos.c b/emufs_gui/articulos.c index 4899ab3..26ed7fd 100644 --- a/emufs_gui/articulos.c +++ b/emufs_gui/articulos.c @@ -13,7 +13,7 @@ t_LstArticulos *art_cargar(const char *filename) { xmlDocPtr document; xmlNode *node, *inicio; - int cant, size, error, i, id; + int cant, size, error = 0, i, id; void *save; t_LstArticulos *tmp; lst_articulos = NULL; @@ -126,7 +126,7 @@ t_Articulo *art_obtener(t_LstArticulos *lst, const char *numero) /* FIXME : NO ME GUSTA :-/ */ t_Articulo *art; void *tmp; - int i,error; + int i, error = 0; EMUFS_REG_SIZE size; int n = atoi(numero); @@ -243,7 +243,7 @@ void art_agregar(char *s) t_Form *form; t_Articulo art; void *save; - int error, size, existe, i; + int error = 0, size, existe, i; win = newwin(8, COLS-2, 13, 1); box(win, 0, 0); diff --git a/emufs_gui/facturas.c b/emufs_gui/facturas.c index 7114dce..a27ba72 100644 --- a/emufs_gui/facturas.c +++ b/emufs_gui/facturas.c @@ -12,7 +12,7 @@ static void *procesar_guardar_factura(t_Factura *f, t_LstFacturas *lst, int *siz t_LstFacturas *fact_cargar(const char *filename) { - int i, numero, size, error, cant; + int i, numero, size, error = 0, cant; char *estados[6] = {"PN", "CD", "CM", "CF", "PM", "NC"}; char *fps[6] = {"CO", "CR", "CH"}; void *save; -- 2.43.0