2 This file is part of GNUnet.
3 Copyright (C) 2009 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file auction/gnunet-service-auction.c
23 * @brief service for executing auctions
24 * @author Markus Teich
27 #include "gnunet_util_lib.h"
32 * Check AUCTION CREATE messages from the client.
34 * @param cls the client we received this message from
35 * @param msg the actual message received
36 * @return #GNUNET_OK (always)
39 check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
41 /* always well-formed due to arbitrary length description */
47 * Handler for CREATE messages.
49 * @param cls the client we received this message from
50 * @param msg the actual message received
53 handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
55 struct GNUNET_SERVICE_Client *client = cls;
56 // struct GNUNET_MQ_Handle *mq;
57 // struct GNUNET_MQ_Envelope *env;
58 // struct GNUNET_AUCTION_blabla em;
61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "Received CREATE message from client\n");
64 size = ntohs (msg->header.size);
66 /**TODO: create auction and return auction object */
67 // mq = GNUNET_SERVICE_client_get_mq (client);
68 // setup_info_message (&em);
69 // env = GNUNET_MQ_msg_copy (&em.header);
70 // GNUNET_MQ_send (mq, env);
72 GNUNET_SERVICE_client_continue (client);
77 * Task run during shutdown.
82 cleanup_task (void *cls)
84 /* FIXME: do clean up here */
89 * Callback called when a client connects to the service.
91 * @param cls closure for the service
92 * @param c the new client that connected to the service
93 * @param mq the message queue used to send messages to the client
97 client_connect_cb (void *cls,
98 struct GNUNET_SERVICE_Client *c,
99 struct GNUNET_MQ_Handle *mq)
106 * Callback called when a client disconnected from the service
108 * @param cls closure for the service
109 * @param c the client that disconnected
110 * @param internal_cls should be equal to @a c
113 client_disconnect_cb (void *cls,
114 struct GNUNET_SERVICE_Client *c,
117 GNUNET_assert (c == internal_cls);
122 * Process auction requests.
125 * @param cfg configuration to use
126 * @param service the initialized service
130 const struct GNUNET_CONFIGURATION_Handle *cfg,
131 struct GNUNET_SERVICE_Handle *service)
133 /* FIXME: do setup here */
134 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
139 * Define "main" method using service macro.
143 GNUNET_SERVICE_OPTION_NONE,
146 &client_disconnect_cb,
148 GNUNET_MQ_hd_var_size (create,
149 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
150 struct GNUNET_AUCTION_ClientCreateMessage,
152 GNUNET_MQ_handler_end ())
155 /* end of gnunet-service-auction.c */