- fwrite(buf, bsize, 1, f);
- free(buf);
- return 0;
+ update_hash(dec, buf, bsize);
+ return list_add(&l, buf);
+}
+
+static void insert_hash(struct declaracao *dec, char *irpf)
+{
+ uLong c = crc32(0L, NULL, 0);
+ char cpf[13];
+ char crc[11];
+ snprintf(cpf, 13, "%-8.8s.DEC", dec->cpf);
+ c = crc32(c, cpf, 12);
+ snprintf(crc, 11, "%010ld", dec->hash);
+ memcpy(irpf + 101, crc, 10);
+ c = crc32(c, irpf, strlen(irpf) - 12);
+ snprintf(crc, 11, "%010ld", c);
+ memcpy(irpf + strlen(irpf) - 12, crc, 10);