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.
17 * @file auction/gnunet-service-auction.c
18 * @brief service for executing auctions
19 * @author Markus Teich
22 #include "gnunet_util_lib.h"
27 * Check AUCTION CREATE messages from the client.
29 * @param cls the client we received this message from
30 * @param msg the actual message received
31 * @return #GNUNET_OK (always)
34 check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
36 /* always well-formed due to arbitrary length description */
42 * Handler for CREATE messages.
44 * @param cls the client we received this message from
45 * @param msg the actual message received
48 handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
50 struct GNUNET_SERVICE_Client *client = cls;
51 // struct GNUNET_MQ_Handle *mq;
52 // struct GNUNET_MQ_Envelope *env;
53 // struct GNUNET_AUCTION_blabla em;
56 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
57 "Received CREATE message from client\n");
59 size = ntohs (msg->header.size);
61 /**TODO: create auction and return auction object */
62 // mq = GNUNET_SERVICE_client_get_mq (client);
63 // setup_info_message (&em);
64 // env = GNUNET_MQ_msg_copy (&em.header);
65 // GNUNET_MQ_send (mq, env);
67 GNUNET_SERVICE_client_continue (client);
72 * Task run during shutdown.
77 cleanup_task (void *cls)
79 /* FIXME: do clean up here */
84 * Callback called when a client connects to the service.
86 * @param cls closure for the service
87 * @param c the new client that connected to the service
88 * @param mq the message queue used to send messages to the client
92 client_connect_cb (void *cls,
93 struct GNUNET_SERVICE_Client *c,
94 struct GNUNET_MQ_Handle *mq)
101 * Callback called when a client disconnected from the service
103 * @param cls closure for the service
104 * @param c the client that disconnected
105 * @param internal_cls should be equal to @a c
108 client_disconnect_cb (void *cls,
109 struct GNUNET_SERVICE_Client *c,
112 GNUNET_assert (c == internal_cls);
117 * Process auction requests.
120 * @param cfg configuration to use
121 * @param service the initialized service
125 const struct GNUNET_CONFIGURATION_Handle *cfg,
126 struct GNUNET_SERVICE_Handle *service)
128 /* FIXME: do setup here */
129 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
134 * Define "main" method using service macro.
138 GNUNET_SERVICE_OPTION_NONE,
141 &client_disconnect_cb,
143 GNUNET_MQ_hd_var_size (create,
144 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
145 struct GNUNET_AUCTION_ClientCreateMessage,
147 GNUNET_MQ_handler_end ())
150 /* end of gnunet-service-auction.c */