int main(int argc,char *argv[]) { bankAccount hisAcc; initialize(hisAcc); readF(&hisAcc,"DT.txt"); getInfo(&hisAcc); setType(&hisAcc); getMovements(&hisAcc); /*printf("%f \n",getTotalSpendings(hisAcc)); int i; for (i=0; i<8; i++) { printSpending(i); printf(": %f€ qui représente ",getTotalSpendingType(hisAcc)[i]); printf(" %f pourcents des dépenses.\n",getStatsSpendings(hisAcc)[i]); } */ }
static void ReadDataFromArchiveNone(ArchiveHandle * AH, read_f* readF) { size_t cnt; char *buf; size_t buflen; buf = malloc(ZLIB_OUT_SIZE); if (buf == NULL) die_horribly(NULL, modulename, "out of memory\n"); buflen = ZLIB_OUT_SIZE; while ((cnt = readF(AH, &buf, &buflen))) { ahwrite(buf, 1, cnt, AH); } free(buf); }
static void ReadDataFromArchiveZlib(ArchiveHandle * AH, read_f* readF) { z_streamp zp; char *out; int res = Z_OK; size_t cnt; char *buf; size_t buflen; zp = (z_streamp) malloc(sizeof(z_stream)); if (zp == NULL) die_horribly(NULL, modulename, "out of memory\n"); zp->zalloc = Z_NULL; zp->zfree = Z_NULL; zp->opaque = Z_NULL; buf = malloc(ZLIB_IN_SIZE); if (buf == NULL) die_horribly(NULL, modulename, "out of memory\n"); buflen = ZLIB_IN_SIZE; out = malloc(ZLIB_OUT_SIZE + 1); if (out == NULL) die_horribly(NULL, modulename, "out of memory\n"); if (inflateInit(zp) != Z_OK) die_horribly(NULL, modulename, "could not initialize compression library: %s\n", zp->msg); /* no minimal chunk size for zlib */ while ((cnt = readF(AH, &buf, &buflen))) { zp->next_in = (void *)buf; zp->avail_in = cnt; while (zp->avail_in > 0) { zp->next_out = (void *)out; zp->avail_out = ZLIB_OUT_SIZE; res = inflate(zp, 0); if (res != Z_OK && res != Z_STREAM_END) die_horribly(AH, modulename, "could not uncompress data: %s\n", zp->msg); out[ZLIB_OUT_SIZE - zp->avail_out] = '\0'; ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH); } } zp->next_in = NULL; zp->avail_in = 0; while (res != Z_STREAM_END) { zp->next_out = (void *)out; zp->avail_out = ZLIB_OUT_SIZE; res = inflate(zp, 0); if (res != Z_OK && res != Z_STREAM_END) die_horribly(AH, modulename, "could not uncompress data: %s\n", zp->msg); out[ZLIB_OUT_SIZE - zp->avail_out] = '\0'; ahwrite(out, 1, ZLIB_OUT_SIZE - zp->avail_out, AH); } if (inflateEnd(zp) != Z_OK) die_horribly(AH, modulename, "could not close compression library: %s\n", zp->msg); free(buf); free(out); free(zp); }