"Send the Brazilian Income Tax Report to the Brazilian "
"Tax Authority";
static const char rnetclient_args_doc[] =
- "[-d|--declaration] FILE [-o|--output-dir DIRECTORY]";
+ "[-d|--declaration] FILE [-o|--output-dir DIRECTORY]"
+ " [-s|--server-name SERVER]"
+ " [-c|--client-version CLIENT]";
+
+#define RNET_ADDRESS "receitanet.receita.fazenda.gov.br"
/* Description and definition of each option accepted by the program. */
"The directory where you wish to save the receipt.",
0 },
+ { "server-name", 's', "SERVER", 0,
+ "The server to connect to. Default is " RNET_ADDRESS ".",
+ 0 },
+
+ { "client-version", 'c', "CLIENT", 0,
+ "The client version to be used.",
+ 0 },
+
{ NULL },
};
/* Output filename. */
char output_file[PATH_MAX];
+
+ /* Server to connect to. */
+ char *server_name;
+
+ /* Client version to use. */
+ char *client_version;
};
/* Parser for command line arguments. */
a->output_dir = arg;
break;
+ case 's':
+ a->server_name = arg;
+ break;
+
+ case 'c':
+ a->client_version = arg;
+ break;
+
case ARGP_KEY_ARG:
/* The user has possibly provided a filename without
using any switches (e.g., by running './rnetclient
return 0;
}
-#define RNET_ADDRESS "receitanet.receita.fazenda.gov.br"
-
-static int connect_rnet(int *c)
+static int connect_rnet(int *c, char *server_name)
{
struct addrinfo *addresses;
struct addrinfo *addr;
hint.ai_socktype = SOCK_STREAM;
hint.ai_protocol = IPPROTO_TCP;
hint.ai_flags = AI_ADDRCONFIG;
- r = getaddrinfo(RNET_ADDRESS, "3456", &hint, &addresses);
+ r = getaddrinfo(server_name, "3456", &hint, &addresses);
if (r) {
return r;
}
The uploaded file may be larger: to upload such large
files, it suffices to send multiple records till the entire
file is transferred, without waiting for a response. Since
- we've alread informed the server of the file size in the
+ we've already informed the server of the file size in the
header, it knows exactly how much data to expect before
sending a response. It will only send an error message
before that if it times us out.
us. This is a bug, and should not happen in the current
state. */
memset(&rnet_args, 0, sizeof (rnet_args));
+ rnet_args.server_name = RNET_ADDRESS;
+ rnet_args.client_version = RNET_DEFAULT_VERSION;
err = argp_parse (&rnetclient_argp, argc, argv, 0, NULL, &rnet_args);
if (err != 0)
fprintf(stderr, "internal error while parsing command line arguments.");
gnutls_global_init();
session_new(&session);
- r = connect_rnet(&c);
+ r = connect_rnet(&c, rnet_args.server_name);
if (r) {
fprintf(stderr, "error connecting to server: %s\n",
r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r));
goto out_handshake;
}
- r = rnet_encode(decfile, &message);
+ r = rnet_encode(decfile, &message, rnet_args.client_version);
if (r < 0) {
fprintf(stderr, "error encoding message, file not supported?\n");
r = 1;