New upstream version 2017.1

This commit is contained in:
Sergio Durigan Junior 2017-08-11 15:06:25 -04:00
parent 1bfd5ff57c
commit dd6d8286d6
14 changed files with 102 additions and 65 deletions

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1080,7 +1080,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
@ -1106,7 +1106,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
@ -1124,7 +1124,7 @@ dist dist-all:
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
@ -1134,7 +1134,7 @@ distcheck: dist
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac

6
NEWS
View File

@ -1,3 +1,9 @@
= 2017.1 =
Allow server to be specified.
Update client version.
Allow client version to be specified.
= 2016.1 =
Support years ahead of 2015.

44
aclocal.m4 vendored
View File

@ -1,6 +1,6 @@
# generated automatically by aclocal 1.15 -*- Autoconf -*-
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.15], [],
m4_if([$1], [1.15.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.15])dnl
[AM_AUTOMAKE_VERSION([1.15.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -605,7 +605,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -626,7 +626,7 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -647,7 +647,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -697,7 +697,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -736,7 +736,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -765,7 +765,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -812,7 +812,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -831,7 +831,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -912,7 +912,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -972,7 +972,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1000,7 +1000,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# Copyright (C) 2006-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1019,7 +1019,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
# Copyright (C) 2004-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

20
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for rnetclient 2016.0.
# Generated by GNU Autoconf 2.69 for rnetclient 2017.1.
#
# Report bugs to <softwares-impostos@fsfla.org>.
#
@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='rnetclient'
PACKAGE_TARNAME='rnetclient'
PACKAGE_VERSION='2016.0'
PACKAGE_STRING='rnetclient 2016.0'
PACKAGE_VERSION='2017.1'
PACKAGE_STRING='rnetclient 2017.1'
PACKAGE_BUGREPORT='softwares-impostos@fsfla.org'
PACKAGE_URL='http://wiki.libreplanetbr.org/rnetclient'
@ -1236,7 +1236,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures rnetclient 2016.0 to adapt to many kinds of systems.
\`configure' configures rnetclient 2017.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1303,7 +1303,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of rnetclient 2016.0:";;
short | recursive ) echo "Configuration of rnetclient 2017.1:";;
esac
cat <<\_ACEOF
@ -1394,7 +1394,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
rnetclient configure 2016.0
rnetclient configure 2017.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -1495,7 +1495,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by rnetclient $as_me 2016.0, which was
It was created by rnetclient $as_me 2017.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -2358,7 +2358,7 @@ fi
# Define the identity of the package.
PACKAGE='rnetclient'
VERSION='2016.0'
VERSION='2017.1'
cat >>confdefs.h <<_ACEOF
@ -4212,7 +4212,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by rnetclient $as_me 2016.0, which was
This file was extended by rnetclient $as_me 2017.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -4279,7 +4279,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
rnetclient config.status 2016.0
rnetclient config.status 2017.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -19,7 +19,7 @@ dnl Run ./bootstrap.sh on the source directory in order to process this
dnl file.
dnl Initialization routines.
AC_INIT([rnetclient], [2016.0], [softwares-impostos@fsfla.org], [],
AC_INIT([rnetclient], [2017.1], [softwares-impostos@fsfla.org], [],
[http://wiki.libreplanetbr.org/rnetclient])
dnl If you update this auxiliary directory, remember to also update the
dnl value of $AUX_DIR in the 'bootstrap.sh' script.

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# data/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -150,15 +150,15 @@ OBJEXT = o
PACKAGE = rnetclient
PACKAGE_BUGREPORT = softwares-impostos@fsfla.org
PACKAGE_NAME = rnetclient
PACKAGE_STRING = rnetclient 2016.0
PACKAGE_STRING = rnetclient 2017.1
PACKAGE_TARNAME = rnetclient
PACKAGE_URL = http://wiki.libreplanetbr.org/rnetclient
PACKAGE_VERSION = 2016.0
PACKAGE_VERSION = 2017.1
PATH_SEPARATOR = :
SET_MAKE =
SHELL = /bin/bash
STRIP =
VERSION = 2016.0
VERSION = 2017.1
abs_builddir = /home/cascardo/code/rnetclient/data
abs_srcdir = /home/cascardo/code/rnetclient/data
abs_top_builddir = /home/cascardo/code/rnetclient

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2014 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
* Copyright (C) 2013-2017 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
* Copyright (C) 2014 Alexandre Oliva <lxoliva@fsfla.org>
*
* This program is free software; you can redistribute it and/or modify
@ -27,7 +27,7 @@
#include "rnet_message.h"
#include "decfile.h"
int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg)
int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg, char *client)
{
int r = -EIO;
@ -46,6 +46,9 @@ int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg)
size_t header_size, header_head, header_tail;
if (client == NULL)
client = RNET_DEFAULT_VERSION;
*msg = rnet_message_new();
if (*msg == NULL) {
return -ENOMEM;
@ -96,7 +99,7 @@ int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg)
r = rnet_message_add_ascii(msg, "versao_java", "1.5.0-gij;Free Software rnetclient pretending to be GNU Interpreter for Java");
r = rnet_message_add_ascii(msg, "origem", "JA2R");
r = rnet_message_add_ascii(msg, "so", "GNU");
r = rnet_message_add_ascii(msg, "cliente", "201105");
r = rnet_message_add_ascii(msg, "cliente", client);
r = rnet_message_add_buffer(msg, "dados_val",
header + header_head,
header_size - header_tail - header_head);

View File

@ -22,6 +22,8 @@
#include "rnet_message.h"
#include "decfile.h"
int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg);
#define RNET_DEFAULT_VERSION "201704"
int rnet_encode(struct rnet_decfile *decfile, struct rnet_message **msg, char *client);
#endif

View File

@ -50,7 +50,11 @@ static const char rnetclient_doc[] =
"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. */
@ -63,6 +67,14 @@ static const struct argp_option rnetclient_options_desc[] = {
"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 },
};
@ -75,6 +87,12 @@ struct rnetclient_args {
/* 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. */
@ -93,6 +111,14 @@ static error_t rnetclient_parse_opt(int key, char *arg, struct argp_state *state
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
@ -210,9 +236,7 @@ static int inflateRecord(char *buffer, size_t len, char **out, size_t *olen)
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;
@ -224,7 +248,7 @@ static int connect_rnet(int *c)
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;
}
@ -280,7 +304,7 @@ static int rnet_send(gnutls_session_t session, char *buffer, size_t len, int hea
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.
@ -453,6 +477,8 @@ int main(int argc, char **argv)
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.");
@ -493,7 +519,7 @@ int main(int argc, char **argv)
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));
@ -513,7 +539,7 @@ int main(int argc, char **argv)
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;

View File

@ -41,7 +41,7 @@ int main(void)
return -1;
}
r = rnet_encode(decfile, &message);
r = rnet_encode(decfile, &message, NULL);
if (r < 0) {
fprintf(stderr, "Error encoding message\n");
return -1;