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 it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file auction/gnunet-service-auction.c
21 * @brief service for executing auctions
22 * @author Markus Teich
25 #include "gnunet_util_lib.h"
30 * Check AUCTION CREATE messages from the client.
32 * @param cls the client we received this message from
33 * @param msg the actual message received
34 * @return #GNUNET_OK (always)
37 check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
39 /* always well-formed due to arbitrary length description */
45 * Handler for CREATE messages.
47 * @param cls the client we received this message from
48 * @param msg the actual message received
51 handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
53 struct GNUNET_SERVICE_Client *client = cls;
54 // struct GNUNET_MQ_Handle *mq;
55 // struct GNUNET_MQ_Envelope *env;
56 // struct GNUNET_AUCTION_blabla em;
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
60 "Received CREATE message from client\n");
62 size = ntohs (msg->header.size);
64 /**TODO: create auction and return auction object */
65 // mq = GNUNET_SERVICE_client_get_mq (client);
66 // setup_info_message (&em);
67 // env = GNUNET_MQ_msg_copy (&em.header);
68 // GNUNET_MQ_send (mq, env);
70 GNUNET_SERVICE_client_continue (client);
75 * Task run during shutdown.
80 cleanup_task (void *cls)
82 /* FIXME: do clean up here */
87 * Callback called when a client connects to the service.
89 * @param cls closure for the service
90 * @param c the new client that connected to the service
91 * @param mq the message queue used to send messages to the client
95 client_connect_cb (void *cls,
96 struct GNUNET_SERVICE_Client *c,
97 struct GNUNET_MQ_Handle *mq)
104 * Callback called when a client disconnected from the service
106 * @param cls closure for the service
107 * @param c the client that disconnected
108 * @param internal_cls should be equal to @a c
111 client_disconnect_cb (void *cls,
112 struct GNUNET_SERVICE_Client *c,
115 GNUNET_assert (c == internal_cls);
120 * Process auction requests.
123 * @param cfg configuration to use
124 * @param service the initialized service
128 const struct GNUNET_CONFIGURATION_Handle *cfg,
129 struct GNUNET_SERVICE_Handle *service)
131 /* FIXME: do setup here */
132 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
137 * Define "main" method using service macro.
141 GNUNET_SERVICE_OPTION_NONE,
144 &client_disconnect_cb,
146 GNUNET_MQ_hd_var_size (create,
147 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
148 struct GNUNET_AUCTION_ClientCreateMessage,
150 GNUNET_MQ_handler_end ())
153 /* end of gnunet-service-auction.c */