[PATCH 3/3] Update header parser for IRPF2014

Alexandre Oliva lxoliva en fsfla.org
Jue Mar 6 13:07:28 UTC 2014


Extend header length and parse new header fields introduced in
IRPF2014.
---
 decfile.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/decfile.c b/decfile.c
index 2220638..ed5d94a 100644
--- a/decfile.c
+++ b/decfile.c
@@ -79,7 +79,7 @@ static int decfile_parse_file(struct rnet_decfile *decfile);
 static int decfile_parse_header(struct rnet_decfile *decfile)
 {
 	char *buffer = get_header(decfile);
-	if (!buffer || strlen(buffer) != 765)
+	if (!buffer || strlen(buffer) != 793)
 		return 1;
 	return parse_header(decfile->header, buffer);
 }
@@ -224,6 +224,8 @@ static int parse_header(struct pmhash *hash, char *buffer)
 	parse("cpf_rra2", 11);
 	parse("trib_3rra", 1);
 	parse("cpf_rra3", 11);
+	parse("trib_4rra", 1);
+	parse("cpf_rra4", 11);
 	parse("vr_doacao", 13);
 	parse("cnpj1", 14);
 	parse("cnpj2", 14);
@@ -258,6 +260,9 @@ static int parse_header(struct pmhash *hash, char *buffer)
 	parse("vr_totisentos", 13);
 	parse("vr_totexclusivo", 13);
 	parse("vr_totpagamentos", 13);
+	parse("nr_conta", 13);
+	parse("nr_dv_conta", 2);
+	parse("in_dv_conta", 1);
 	parse("versaotestpgd", 3);
 	parse("controle", 10);
 
@@ -298,7 +303,7 @@ static int append_stripped_reg_ctrl(struct rnet_message **message, char *line)
 	len = strlen(line);
 	if (len < 12)
 		return -EINVAL;
-	if (msg->alen - msg->len < len) {
+	if (msg->alen < msg->len + len - 10) {
 		if (rnet_message_expand(message, MAX(msg->len, len)))
 			return -ENOMEM;
 		msg = *message;



Más información sobre la lista de distribución Softwares-impostos