X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Flibreceita.git;a=blobdiff_plain;f=irpf.c;fp=irpf.c;h=1a7db5a873cd521fed51d5e32c94e347373c2269;hp=0000000000000000000000000000000000000000;hb=35630c3647185be255acc1b0f32a3b0bd5e5bdbc;hpb=cb7e69c68f48505873b6590f457b4fbed4eeaf67 diff --git a/irpf.c b/irpf.c new file mode 100644 index 0000000..1a7db5a --- /dev/null +++ b/irpf.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012-2014 Thadeu Lima de Souza Cascardo + * Copyright (C) 2014 Alexandre Oliva + * Copyright (C) 2014 Sergio Durigan Junior + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include +#include "decfile.h" + +static char *chop(char *str, int off, int len) +{ + char *s; + s = malloc(len + 1); + if (!s) + return NULL; + memcpy(s, str + off, len); + s[len] = 0; + return s; +} + +int main(int argc, char **argv) +{ + struct rnet_decfile *decfile; + + char *contrib; + char *end; + + decfile = rnet_decfile_open(argv[1]); + if (!decfile) { + fprintf(stderr, "could not parse file \"%s\": %s\n", argv[1], strerror(errno)); + exit(1); + } + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "nome")); + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "hash")); + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "banco")); + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "agencia")); + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "nr_conta")); + fprintf(stdout, "%s\n", rnet_decfile_get_header_field(decfile, "nr_dv_conta")); + + contrib = rnet_decfile_get_line(decfile, 1); + end = chop(contrib, 2+11+60+15, 40); + fprintf(stdout, "%s\n", end); + + rnet_decfile_close(decfile); + return 0; +}