m2.alobe/src/defi.c
glenux 5ca782e8b1 alobe: inital import (test).
git-svn-id: https://websvn.glenux.net/svn/Upoc/alobe/trunk@1348 eaee96b3-f302-0410-b096-c6cfd47f7835
2009-05-02 07:36:25 +00:00

56 lines
1.1 KiB
C

/* vim: set sw=4 ts=4 si et: */
#include "defi.h"
#define DEBUG 1
Defi_t * defi_create(Config_io_t * io, nodeindex_t size){
Defi_t * defi = (Defi_t *) malloc (sizeof(Defi_t));
defi->_io = io;
defi->_size = size;
defi->_list = connexcomponentlist_create();
return defi;
}
void defi_destroy(Defi_t * defi){
free (defi);
defi = NULL;
}
void defi_run(Defi_t * defi){
printf("Run !!!\n");
char * buf = (char *) malloc (sizeof(char) * 100);
char * buf2;
nodeindex_t one, two;
int re;
gzrewind(defi->_io->input);
gzclearerr(defi->_io->input);
printf("Searching connex comFilling the Big Table...\n");
for (;;){
if (gzeof(defi->_io->input)){ break; }
buf2 = gzgets(defi->_io->input, buf, 100);
if (buf2 == Z_NULL){
printf("READ OFF\n");
break;
} else {
re = sscanf(buf, "%ld %ld", &one, &two);
pDEBUG("=== DEFI READING %ld %ld ===\n", one, two);
defi->_list =
connexcomponentlist_insert_edge(defi->_list, one, two);
if (DEBUG) { connexcomponentlist_display(defi->_list); }
}
}
connexcomponentlist_destroy(&(defi->_list));
free(buf);
printf("done\n");
}
#undef DEBUG