Mensagens ao validar parâmetros, verificar o ano suportado e erro ao
abrir arquivo são emitidas.
static int gera(struct declaracao *dec, char *filename)
{
FILE *f;
static int gera(struct declaracao *dec, char *filename)
{
FILE *f;
int i;
struct rendimento *rendimento;
struct isento *isento;
int i;
struct rendimento *rendimento;
struct isento *isento;
} while (0);
f = fopen(filename, "w");
} while (0);
f = fopen(filename, "w");
+ if (!f) {
+ r = -errno;
+ dec_set_error(dec, "Não foi possível abrir arquivo %s: %s.",
+ filename, strerror(errno));
memset(dec->linhas, 0, sizeof(dec->linhas));
W(gera_header);
W(gera_contribuinte);
memset(dec->linhas, 0, sizeof(dec->linhas));
W(gera_header);
W(gera_contribuinte);
static int run_gera(struct declaracao *dec, char **args, int argc)
{
static int run_gera(struct declaracao *dec, char **args, int argc)
{
+ if (argc != 2) {
+ dec_set_error(dec, "Comando %s recebe um nome de arquivo como parâmetro.",
+ args[0]);
- if (!ANO_VALIDO(dec->ano))
+ }
+ if (!ANO_VALIDO(dec->ano)) {
+ dec_set_error(dec, "Comando %s não suporta ano %d.",
+ args[0], dec->ano);
return gera(dec, args[1]);
}
return gera(dec, args[1]);
}