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 */
{
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");
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];
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);
#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*);
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*);
{
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;
/* FIXME : NO ME GUSTA :-/ */
t_Articulo *art;
void *tmp;
- int i,error;
+ int i, error = 0;
EMUFS_REG_SIZE size;
int n = atoi(numero);
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);
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;