From 6f79b499450512c4b92d0f9dbe12932a8e8d83b6 Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Tue, 3 Jan 2017 07:52:18 +0100 Subject: initial gnunet-auction commit --- src/Makefile.am | 1 + src/auction/.gitignore | 3 + src/auction/Makefile.am | 52 +++++++++++++++++ src/auction/gnunet-auction.c | 84 +++++++++++++++++++++++++++ src/auction/gnunet-service-auction.c | 106 +++++++++++++++++++++++++++++++++++ src/auction/test_auction_api.c | 42 ++++++++++++++ 6 files changed, 288 insertions(+) create mode 100644 src/auction/.gitignore create mode 100644 src/auction/Makefile.am create mode 100644 src/auction/gnunet-auction.c create mode 100644 src/auction/gnunet-service-auction.c create mode 100644 src/auction/test_auction_api.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c1f9b33f9..c6f320ae4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,6 +122,7 @@ SUBDIRS = \ psycstore \ psyc \ social \ + auction \ $(EXP_DIR) \ $(PROVIDER_DIR) diff --git a/src/auction/.gitignore b/src/auction/.gitignore new file mode 100644 index 000000000..768cce85b --- /dev/null +++ b/src/auction/.gitignore @@ -0,0 +1,3 @@ +gnunet-auction +gnunet-service-auction +test_auction_api diff --git a/src/auction/Makefile.am b/src/auction/Makefile.am new file mode 100644 index 000000000..0ced1ad22 --- /dev/null +++ b/src/auction/Makefile.am @@ -0,0 +1,52 @@ +# This Makefile.am is in the public domain +AM_CPPFLAGS = -I$(top_srcdir)/src/include + +pkgcfgdir= $(pkgdatadir)/config.d/ + +libexecdir= $(pkglibdir)/libexec/ + +dist_pkgcfg_DATA = \ + auction.conf + +if MINGW + WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols +endif + +if USE_COVERAGE + AM_CFLAGS = -fprofile-arcs -ftest-coverage +endif + +# Note: In a real installation, +# bin_PROGRAMS should be used for gnunet-auction +# libexec_PROGRAMS should be used for gnunet-service-auction + +noinst_PROGRAMS = \ + gnunet-auction \ + gnunet-service-auction + + +gnunet_auction_SOURCES = \ + gnunet-auction.c +gnunet_auction_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) + +gnunet_service_auction_SOURCES = \ + gnunet-service-auction.c +gnunet_service_auction_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) + + +check_PROGRAMS = \ + test_auction_api + +if ENABLE_TEST_RUN +AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; +TESTS = $(check_PROGRAMS) +endif + +test_auction_api_SOURCES = \ + test_auction_api.c +test_auction_api_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/auction/gnunet-auction.c b/src/auction/gnunet-auction.c new file mode 100644 index 000000000..a4af1152a --- /dev/null +++ b/src/auction/gnunet-auction.c @@ -0,0 +1,84 @@ +/* + This file is part of GNUnet. + Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V. + + GNUnet 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, or (at your + option) any later version. + + GNUnet 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +/** + * @file auction/gnunet-auction.c + * @brief auction for writing a tool + * @author Christian Grothoff + */ +#include "platform.h" +#include "gnunet_util_lib.h" +/* #include "gnunet_auction_service.h" */ + +/** + * Final status code. + */ +static int ret; + + +/** + * Main function that will be run by the scheduler. + * + * @param cls closure + * @param args remaining command-line arguments + * @param cfgfile name of the configuration file used (for saving, can be NULL!) + * @param cfg configuration + */ +static void +run (void *cls, + char *const *args, + const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + /* main code here */ +} + + +/** + * The main function. + * + * @param argc number of arguments from the command line + * @param argv command line arguments + * @return 0 ok, 1 on error + */ +int +main (int argc, char *const *argv) +{ + static const struct GNUNET_GETOPT_CommandLineOption options[] = { + /* FIMXE: add options here */ + GNUNET_GETOPT_OPTION_END + }; + if (GNUNET_OK != + GNUNET_STRINGS_get_utf8_args (argc, argv, + &argc, &argv)) + return 2; + + ret = (GNUNET_OK == + GNUNET_PROGRAM_run (argc, argv, + "gnunet-auction", + gettext_noop ("help text"), + options, + &run, + NULL)) ? ret : 1; + GNUNET_free ((void*) argv); + return ret; +} + +/* end of gnunet-auction.c */ diff --git a/src/auction/gnunet-service-auction.c b/src/auction/gnunet-service-auction.c new file mode 100644 index 000000000..b2587bfd7 --- /dev/null +++ b/src/auction/gnunet-service-auction.c @@ -0,0 +1,106 @@ +/* + This file is part of GNUnet. + Copyright (C) 2009 GNUnet e.V. + + GNUnet 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, or (at your + option) any later version. + + GNUnet 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +/** + * @file auction/gnunet-service-auction.c + * @brief program that does auction + * @author Christian Grothoff + */ +#include "platform.h" +#include "gnunet_util_lib.h" + + +/** + * Task run during shutdown. + * + * @param cls unused + */ +static void +cleanup_task (void *cls) +{ + /* FIXME: do clean up here */ +} + + +/** + * Callback called when a client connects to the service. + * + * @param cls closure for the service + * @param c the new client that connected to the service + * @param mq the message queue used to send messages to the client + * @return @a c + */ +static void * +client_connect_cb (void *cls, + struct GNUNET_SERVICE_Client *c, + struct GNUNET_MQ_Handle *mq) +{ + return c; +} + + +/** + * Callback called when a client disconnected from the service + * + * @param cls closure for the service + * @param c the client that disconnected + * @param internal_cls should be equal to @a c + */ +static void +client_disconnect_cb (void *cls, + struct GNUNET_SERVICE_Client *c, + void *internal_cls) +{ + GNUNET_assert (c == internal_cls); +} + + +/** + * Process auction requests. + * + * @param cls closure + * @param cfg configuration to use + * @param service the initialized service + */ +static void +run (void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + struct GNUNET_SERVICE_Handle *service) +{ + /* FIXME: do setup here */ + GNUNET_SCHEDULER_add_shutdown (&cleanup_task, + NULL); +} + + +/** + * Define "main" method using service macro. + */ +GNUNET_SERVICE_MAIN +("auction", + GNUNET_SERVICE_OPTION_NONE, + &run, + &client_connect_cb, + &client_disconnect_cb, + NULL, + GNUNET_MQ_handler_end ()) + + +/* end of gnunet-service-auction.c */ diff --git a/src/auction/test_auction_api.c b/src/auction/test_auction_api.c new file mode 100644 index 000000000..38e93c6fc --- /dev/null +++ b/src/auction/test_auction_api.c @@ -0,0 +1,42 @@ +/* + This file is part of GNUnet. + Copyright (C) 2009 GNUnet e.V. + + GNUnet 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, or (at your + option) any later version. + + GNUnet 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +/** + * @file auction/test_auction_api.c + * @brief testcase for auction.c + */ +#include "platform.h" + +static int +check () +{ + return 0; +} + +int +main (int argc, char *argv[]) +{ + int ret; + + ret = check (); + + return ret; +} + +/* end of test_auction_api.c */ -- cgit v1.2.3