Implementa celular.
[cascardo/declara.git] / lib / contribuinte.c
1 /*
2  *  Copyright (C) 2015  Thadeu Lima de Souza Cascardo <cascardo@cascardo.eti.br>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include "cmd.h"
20 #include "declaracao.h"
21 #include "contribuinte.h"
22 #include "util.h"
23
24 #define SET_INT_CONTRIBUINTE(attr) \
25         SET_INT_(attr, attr, contribuinte.attr)
26
27 #define SET_STRING_CONTRIBUINTE(attr) \
28         SET_STRING_(attr, attr, contribuinte.attr)
29
30 SET_STRING_CONTRIBUINTE(uf);
31 SET_INT_CONTRIBUINTE(cd_municipio);
32 SET_STRING_CONTRIBUINTE(municipio);
33 SET_STRING_CONTRIBUINTE(cep);
34 SET_STRING_CONTRIBUINTE(bairro);
35 SET_STRING_CONTRIBUINTE(tipo_logradouro);
36 SET_STRING_CONTRIBUINTE(logradouro);
37 SET_STRING_CONTRIBUINTE(numero);
38 SET_STRING_CONTRIBUINTE(complemento);
39 SET_STRING_CONTRIBUINTE(titulo_eleitor);
40 SET_STRING_CONTRIBUINTE(nit);
41 SET_STRING_CONTRIBUINTE(dn);
42 SET_STRING_CONTRIBUINTE(ddd);
43 SET_STRING_CONTRIBUINTE(telefone);
44 SET_STRING_CONTRIBUINTE(celular);
45 SET_INT_CONTRIBUINTE(natureza_ocupacao);
46 SET_INT_CONTRIBUINTE(ocupacao_principal);
47
48 void contribuinte_salva(struct declaracao *dec, FILE *f)
49 {
50 #define SALVA_STRING(attr) \
51         if (dec->contribuinte.attr) \
52                 fprintf(f, #attr " \"%s\"\n", dec->contribuinte.attr);
53 #define SALVA_INT(attr) \
54         fprintf(f, #attr " %d\n", dec->contribuinte.attr);
55         SALVA_STRING(uf);
56         SALVA_INT(cd_municipio);
57         SALVA_STRING(municipio);
58         SALVA_STRING(cep);
59         SALVA_STRING(bairro);
60         SALVA_STRING(tipo_logradouro);
61         SALVA_STRING(logradouro);
62         SALVA_STRING(numero);
63         SALVA_STRING(complemento);
64         SALVA_STRING(titulo_eleitor);
65         SALVA_STRING(nit);
66         SALVA_STRING(dn);
67         SALVA_STRING(ddd);
68         SALVA_STRING(telefone);
69         SALVA_STRING(celular);
70         SALVA_INT(natureza_ocupacao);
71         SALVA_INT(ocupacao_principal);
72 }
73
74 int contribuinte_cmd_init(void)
75 {
76         cmd_add(&cmd_uf);
77         cmd_add(&cmd_cd_municipio);
78         cmd_add(&cmd_municipio);
79         cmd_add(&cmd_cep);
80         cmd_add(&cmd_bairro);
81         cmd_add(&cmd_tipo_logradouro);
82         cmd_add(&cmd_logradouro);
83         cmd_add(&cmd_numero);
84         cmd_add(&cmd_complemento);
85         cmd_add(&cmd_titulo_eleitor);
86         cmd_add(&cmd_nit);
87         cmd_add(&cmd_dn);
88         cmd_add(&cmd_ddd);
89         cmd_add(&cmd_telefone);
90         cmd_add(&cmd_celular);
91         cmd_add(&cmd_natureza_ocupacao);
92         cmd_add(&cmd_ocupacao_principal);
93         return 0;
94 }