- new program_run and run_2
[oweals/gnunet.git] / src / gns / gnunet-gns-fcfsd.c
1 /*
2      This file is part of GNUnet.
3      (C) 2012 Christian Grothoff (and other contributing authors)
4
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.
9
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.
14
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., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file gnunet-gns-fcfsd.c
22  * @brief HTTP daemon that offers first-come-first-serve GNS domain registration
23  * @author Christian Grothoff
24  *
25  * TODO:
26  * - the code currently contains a 'race' between checking that the
27  *   domain name is available and allocating it to the new public key
28  *   (should this race be solved by namestore or by fcfsd?)
29  * - nicer error reporting to browser
30  * - figure out where this binary should go (is gns the right directory!?)
31  */
32 #include "platform.h"
33 #include <gnunet_util_lib.h>
34 #include <microhttpd.h>
35 #include <gnunet_namestore_service.h>
36
37 /**
38  * Invalid method page.
39  */
40 #define METHOD_ERROR "<html><head><title>Illegal request</title></head><body>Go away.</body></html>"
41
42 /**
43  * Front page. (/)
44  */
45 #define MAIN_PAGE "<html><head><title>Welcome</title></head><body><form action=\"/S\" method=\"post\">What is your desired domain name? <input type=\"text\" name=\"domain\" /> <p> What is your public key? <input type=\"text\" name=\"pkey\" /> <input type=\"submit\" value=\"Next\" /></body></html>"
46
47 /**
48  * Second page (/S)
49  */
50 #define SUBMIT_PAGE "<html><head><title>%s</title></head><body>%s</body></html>"
51
52 /**
53  * Mime type for HTML pages.
54  */
55 #define MIME_HTML "text/html"
56
57 /**
58  * Name of our cookie.
59  */
60 #define COOKIE_NAME "gns-fcfs"
61
62
63 /**
64  * Phases a request goes through.
65  */
66 enum Phase
67   {
68     /**
69      * Start phase (parsing POST, checking).
70      */
71     RP_START = 0,
72
73     /**
74      * Lookup to see if the domain name is taken.
75      */
76     RP_LOOKUP,
77
78     /**
79      * Storing of the record.
80      */
81     RP_PUT,
82
83     /**
84      * We're done with success.
85      */
86     RP_SUCCESS,
87
88     /**
89      * Send failure message.
90      */
91     RP_FAIL
92   };
93
94
95 /**
96  * Data kept per request.
97  */
98 struct Request
99 {
100
101   /**
102    * Associated session.
103    */
104   struct Session *session;
105
106   /**
107    * Post processor handling form data (IF this is
108    * a POST request).
109    */
110   struct MHD_PostProcessor *pp;
111
112   /**
113    * URL to serve in response to this POST (if this request 
114    * was a 'POST')
115    */
116   const char *post_url;
117
118   /**
119    * Active request with the namestore.
120    */
121   struct GNUNET_NAMESTORE_QueueEntry *qe;
122   
123   /**
124    * Current processing phase.
125    */
126   enum Phase phase;
127
128   /**
129    * Domain name submitted via form.
130    */
131   char domain_name[64];
132
133   /**
134    * Public key submitted via form.
135    */
136   char public_key[1024];
137
138 };
139
140
141 /**
142  * MHD deamon reference.
143  */
144 static struct MHD_Daemon *httpd;
145
146 /**
147  * Main HTTP task.
148  */
149 static GNUNET_SCHEDULER_TaskIdentifier httpd_task;
150
151 /**
152  * Handle to the namestore.
153  */
154 static struct GNUNET_NAMESTORE_Handle *ns;
155
156 /**
157  * Hash of the public key of the fcfsd zone.
158  */
159 static GNUNET_HashCode fcfsd_zone;
160
161 /**
162  * Private key for the fcfsd zone.
163  */
164 static struct GNUNET_CRYPTO_RsaPrivateKey *fcfs_zone_pkey;
165                         
166
167 /**
168  * Handler that returns a simple static HTTP page.
169  *
170  * @param connection connection to use
171  * @return MHD_YES on success
172  */
173 static int
174 serve_main_page (struct MHD_Connection *connection)
175 {
176   int ret;
177   struct MHD_Response *response;
178
179   /* return static form */
180   response = MHD_create_response_from_buffer (strlen (MAIN_PAGE),
181                                               (void *) MAIN_PAGE,
182                                               MHD_RESPMEM_PERSISTENT);
183   MHD_add_response_header (response,
184                            MHD_HTTP_HEADER_CONTENT_ENCODING,
185                            MIME_HTML);
186   ret = MHD_queue_response (connection, 
187                             MHD_HTTP_OK, 
188                             response);
189   MHD_destroy_response (response);
190   return ret;
191 }
192
193
194 /**
195  * Send the 'SUBMIT_PAGE'.
196  *
197  * @param info information string to send to the user
198  * @param request request information
199  * @param connection connection to use
200  */
201 static int
202 fill_s_reply (const char *info,
203               struct Request *request,
204               struct MHD_Connection *connection)
205 {
206   int ret;
207   char *reply;
208   struct MHD_Response *response;
209
210   GNUNET_asprintf (&reply,
211                    SUBMIT_PAGE,
212                    info,
213                    info);
214   /* return static form */
215   response = MHD_create_response_from_buffer (strlen (reply),
216                                               (void *) reply,
217                                               MHD_RESPMEM_MUST_FREE);
218   MHD_add_response_header (response,
219                            MHD_HTTP_HEADER_CONTENT_ENCODING,
220                            MIME_HTML);
221   ret = MHD_queue_response (connection, 
222                             MHD_HTTP_OK, 
223                             response);
224   MHD_destroy_response (response);
225   return ret;
226 }
227
228
229 /**
230  * Iterator over key-value pairs where the value
231  * maybe made available in increments and/or may
232  * not be zero-terminated.  Used for processing
233  * POST data.
234  *
235  * @param cls user-specified closure
236  * @param kind type of the value
237  * @param key 0-terminated key for the value
238  * @param filename name of the uploaded file, NULL if not known
239  * @param content_type mime-type of the data, NULL if not known
240  * @param transfer_encoding encoding of the data, NULL if not known
241  * @param data pointer to size bytes of data at the
242  *              specified offset
243  * @param off offset of data in the overall value
244  * @param size number of bytes in data available
245  * @return MHD_YES to continue iterating,
246  *         MHD_NO to abort the iteration
247  */
248 static int
249 post_iterator (void *cls,
250                enum MHD_ValueKind kind,
251                const char *key,
252                const char *filename,
253                const char *content_type,
254                const char *transfer_encoding,
255                const char *data, uint64_t off, size_t size)
256 {
257   struct Request *request = cls;
258
259   if (0 == strcmp ("domain", key))
260     {
261       if (size + off >= sizeof(request->domain_name))
262         size = sizeof (request->domain_name) - off - 1;
263       memcpy (&request->domain_name[off],
264               data,
265               size);
266       request->domain_name[size+off] = '\0';
267       return MHD_YES;
268     }
269   if (0 == strcmp ("pkey", key))
270     {
271       if (size + off >= sizeof(request->public_key))
272         size = sizeof (request->public_key) - off - 1;
273       memcpy (&request->public_key[off],
274               data,
275               size);
276       request->public_key[size+off] = '\0';
277       return MHD_YES;
278     }
279   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
280               _("Unsupported form value `%s'\n"),
281               key);
282   return MHD_YES;
283 }
284
285
286 /**
287  * Task run whenever HTTP server operations are pending.
288  *
289  * @param cls unused
290  * @param tc scheduler context
291  */
292 static void
293 do_httpd (void *cls,
294           const struct GNUNET_SCHEDULER_TaskContext *tc);
295
296
297 /**
298  * Schedule task to run MHD server now.
299  */
300 static void
301 run_httpd_now ()
302 {
303   if (GNUNET_SCHEDULER_NO_TASK != httpd_task)
304   {
305     GNUNET_SCHEDULER_cancel (httpd_task);
306     httpd_task = GNUNET_SCHEDULER_NO_TASK;
307   }
308   httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, NULL);
309 }
310
311
312 /**
313  * Continuation called to notify client about result of the
314  * operation.
315  *
316  * @param cls closure
317  * @param success GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate)
318  *                GNUNET_NO if content was already there
319  *                GNUNET_YES (or other positive value) on success
320  * @param emsg NULL on success, otherwise an error message
321  */
322 static void 
323 put_continuation (void *cls,
324                   int32_t success,
325                   const char *emsg)
326 {
327   struct Request *request = cls;
328
329   request->qe = NULL;
330   if (0 >= success)
331   {
332     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
333                 _("Failed to create record for domain `%s': %s\n"),
334                 request->domain_name,
335                 emsg);
336     request->phase = RP_FAIL;
337   }
338   else
339     request->phase = RP_SUCCESS;
340   run_httpd_now ();
341 }
342
343
344 /**
345  * Process a record that was stored in the namestore.
346  *
347  * @param cls closure
348  * @param zone_key public key of the zone
349  * @param expire when does the corresponding block in the DHT expire (until
350  *               when should we never do a DHT lookup for the same name again)?; 
351  *               GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore,
352  *               or the expiration time of the block in the namestore (even if there are zero
353  *               records matching the desired record type)
354  * @param name name that is being mapped (at most 255 characters long)
355  * @param rd_count number of entries in 'rd' array
356  * @param rd array of records with data to store
357  * @param signature signature of the record block, NULL if signature is unavailable (i.e. 
358  *        because the user queried for a particular record type only)
359  */
360 static void 
361 lookup_result_processor (void *cls,
362                          const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
363                          struct GNUNET_TIME_Absolute expire,                        
364                          const char *name,
365                          unsigned int rd_count,
366                          const struct GNUNET_NAMESTORE_RecordData *rd,
367                          const struct GNUNET_CRYPTO_RsaSignature *signature)
368 {
369   struct Request *request = cls;
370   struct GNUNET_NAMESTORE_RecordData r;
371   GNUNET_HashCode pub;
372   
373   GNUNET_assert (GNUNET_OK ==
374                  GNUNET_CRYPTO_hash_from_string2 (request->public_key,
375                                                   strlen (request->public_key),
376                                                   &pub));
377   request->qe = NULL;
378   if (0 != rd_count)
379   {
380     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
381                 _("Found %u existing records for domain `%s'\n"),
382                 rd_count,
383                 request->domain_name);
384     request->phase = RP_FAIL;
385     run_httpd_now ();
386     return;
387   }
388   r.data = &pub;
389   r.data_size = sizeof (pub);
390   r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
391   r.record_type = htonl (GNUNET_NAMESTORE_TYPE_PKEY);
392   r.flags = htonl (GNUNET_NAMESTORE_RF_AUTHORITY);
393   request->qe = GNUNET_NAMESTORE_record_create (ns,
394                                                 fcfs_zone_pkey,
395                                                 request->domain_name,
396                                                 &r,
397                                                 &put_continuation,
398                                                 request);
399 }
400
401
402 /**
403  * Main MHD callback for handling requests.
404  *
405  * @param cls unused
406  * @param connection MHD connection handle
407  * @param url the requested url
408  * @param method the HTTP method used ("GET", "PUT", etc.)
409  * @param version the HTTP version string (i.e. "HTTP/1.1")
410  * @param upload_data the data being uploaded (excluding HEADERS,
411  *        for a POST that fits into memory and that is encoded
412  *        with a supported encoding, the POST data will NOT be
413  *        given in upload_data and is instead available as
414  *        part of MHD_get_connection_values; very large POST
415  *        data *will* be made available incrementally in
416  *        upload_data)
417  * @param upload_data_size set initially to the size of the
418  *        upload_data provided; the method must update this
419  *        value to the number of bytes NOT processed;
420  * @param ptr pointer to location where we store the 'struct Request'
421  * @return MHS_YES if the connection was handled successfully,
422  *         MHS_NO if the socket must be closed due to a serios
423  *         error while handling the request
424  */
425 static int
426 create_response (void *cls,
427                  struct MHD_Connection *connection,
428                  const char *url,
429                  const char *method,
430                  const char *version,
431                  const char *upload_data, 
432                  size_t *upload_data_size,
433                  void **ptr)
434 {
435   struct MHD_Response *response;
436   struct Request *request;
437   int ret;
438   GNUNET_HashCode pub;
439
440   if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
441        (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
442     {
443       ret = serve_main_page (connection);
444       if (ret != MHD_YES)
445         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
446                     _("Failed to create page for `%s'\n"),
447                     url);
448       return ret;
449     }
450   if (0 == strcmp (method, MHD_HTTP_METHOD_POST))
451     {   
452       request = *ptr;
453       if (NULL == request)
454       {
455         request = GNUNET_malloc (sizeof (struct Request));
456         *ptr = request;
457         request->pp = MHD_create_post_processor (connection, 1024,
458                                                  &post_iterator, request);
459         if (NULL == request->pp)
460           {
461             GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
462                         _("Failed to setup post processor for `%s'\n"),
463                         url);
464             return MHD_NO; /* internal error */
465           }    
466         return MHD_YES;
467       }
468       if (NULL != request->pp)
469       {
470         /* evaluate POST data */
471         MHD_post_process (request->pp,
472                           upload_data,
473                           *upload_data_size);
474         if (0 != *upload_data_size)
475           {
476             *upload_data_size = 0;
477             return MHD_YES;
478           }
479         /* done with POST data, serve response */
480         MHD_destroy_post_processor (request->pp);
481         request->pp = NULL;
482       }
483       if (GNUNET_OK !=
484           GNUNET_CRYPTO_hash_from_string2 (request->public_key,
485                                            strlen (request->public_key),
486                                            &pub))
487       {
488         /* parse error */
489         return fill_s_reply ("Failed to parse given public key",
490                              request, connection);
491       }
492       switch (request->phase)
493         {
494         case RP_START:
495           request->phase = RP_LOOKUP;
496           request->qe = GNUNET_NAMESTORE_lookup_record (ns,
497                                                         &fcfsd_zone,
498                                                         request->domain_name,
499                                                         GNUNET_NAMESTORE_TYPE_PKEY,
500                                                         &lookup_result_processor,
501                                                         request);
502           break;
503         case RP_LOOKUP:
504           break;
505         case RP_PUT:
506           break;
507         case RP_FAIL:
508           return fill_s_reply ("Request failed, sorry.",
509                                request, connection);
510         case RP_SUCCESS:
511           return fill_s_reply ("Success.",
512                                request, connection);
513         default:
514           GNUNET_break (0);
515           return MHD_NO;
516         }
517         return MHD_YES; /* will have a reply later... */    
518     }
519   /* unsupported HTTP method */
520   response = MHD_create_response_from_buffer (strlen (METHOD_ERROR),
521                                               (void *) METHOD_ERROR,
522                                               MHD_RESPMEM_PERSISTENT);
523   ret = MHD_queue_response (connection, 
524                             MHD_HTTP_METHOD_NOT_ACCEPTABLE, 
525                             response);
526   MHD_destroy_response (response);
527   return ret;
528 }
529
530
531 /**
532  * Callback called upon completion of a request.
533  * Decrements session reference counter.
534  *
535  * @param cls not used
536  * @param connection connection that completed
537  * @param con_cls session handle
538  * @param toe status code
539  */
540 static void
541 request_completed_callback (void *cls,
542                             struct MHD_Connection *connection,
543                             void **con_cls,
544                             enum MHD_RequestTerminationCode toe)
545 {
546   struct Request *request = *con_cls;
547
548   if (NULL == request)
549     return;
550   if (NULL != request->pp)
551     MHD_destroy_post_processor (request->pp);
552   if (NULL != request->qe)
553     GNUNET_NAMESTORE_cancel (request->qe);
554   GNUNET_free (request);
555 }
556
557
558 /**
559  * Schedule tasks to run MHD server.
560  */
561 static void
562 run_httpd ()
563 {
564   fd_set rs;
565   fd_set ws;
566   fd_set es;
567   struct GNUNET_NETWORK_FDSet *wrs;
568   struct GNUNET_NETWORK_FDSet *wws;
569   struct GNUNET_NETWORK_FDSet *wes;
570   int max;
571   int haveto;
572   unsigned MHD_LONG_LONG timeout;
573   struct GNUNET_TIME_Relative tv;
574
575   FD_ZERO (&rs);
576   FD_ZERO (&ws);
577   FD_ZERO (&es);
578   wrs = GNUNET_NETWORK_fdset_create ();
579   wes = GNUNET_NETWORK_fdset_create ();
580   wws = GNUNET_NETWORK_fdset_create ();
581   max = -1;
582   GNUNET_assert (MHD_YES == MHD_get_fdset (httpd, &rs, &ws, &es, &max));
583   haveto = MHD_get_timeout (httpd, &timeout);
584   if (haveto == MHD_YES)
585     tv.rel_value = (uint64_t) timeout;
586   else
587     tv = GNUNET_TIME_UNIT_FOREVER_REL;
588   GNUNET_NETWORK_fdset_copy_native (wrs, &rs, max + 1);
589   GNUNET_NETWORK_fdset_copy_native (wws, &ws, max + 1);
590   GNUNET_NETWORK_fdset_copy_native (wes, &es, max + 1);
591   httpd_task =
592       GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_HIGH,
593                                    GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws,
594                                    &do_httpd, NULL);
595   GNUNET_NETWORK_fdset_destroy (wrs);
596   GNUNET_NETWORK_fdset_destroy (wws);
597   GNUNET_NETWORK_fdset_destroy (wes);
598 }
599
600
601 /**
602  * Task run whenever HTTP server operations are pending.
603  *
604  * @param cls unused
605  * @param tc scheduler context
606  */
607 static void
608 do_httpd (void *cls,
609           const struct GNUNET_SCHEDULER_TaskContext *tc)
610 {
611   httpd_task = GNUNET_SCHEDULER_NO_TASK;
612   MHD_run (httpd);
613   run_httpd ();
614 }
615
616
617 /**
618  * Task run on shutdown.  Cleans up everything.
619  *
620  * @param cls unused
621  * @param tc scheduler context
622  */
623 static void
624 do_shutdown (void *cls,
625              const struct GNUNET_SCHEDULER_TaskContext *tc)
626 {
627   if (GNUNET_SCHEDULER_NO_TASK != httpd_task)
628   {
629     GNUNET_SCHEDULER_cancel (httpd_task);
630     httpd_task = GNUNET_SCHEDULER_NO_TASK;
631   }
632   if (NULL != ns)
633   {
634     GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
635     ns = NULL;
636   }
637   if (NULL != httpd)
638   {
639     MHD_stop_daemon (httpd);
640     httpd = NULL;
641   }
642   if (NULL != fcfs_zone_pkey)
643   {
644     GNUNET_CRYPTO_rsa_key_free (fcfs_zone_pkey);
645     fcfs_zone_pkey = NULL;
646   }
647 }
648
649
650 /**
651  * Main function that will be run.
652  *
653  * @param cls closure
654  * @param args remaining command-line arguments
655  * @param cfgfile name of the configuration file used (for saving, can be NULL!)
656  * @param cfg configuration
657  */
658 static void
659 run (void *cls, char *const *args, const char *cfgfile,
660      const struct GNUNET_CONFIGURATION_Handle *cfg)
661 {
662   char *keyfile;
663   unsigned long long port;
664   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
665
666   if (GNUNET_OK !=
667       GNUNET_CONFIGURATION_get_value_number (cfg,
668                                              "fcfsd",
669                                              "HTTPPORT",
670                                              &port))
671   {
672       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
673                   _("Option `%s' not specified in configuration section `%s'\n"),
674                   "HTTPPORT",
675                   "fcfsd");
676       return;
677   }
678   if (GNUNET_OK !=
679       GNUNET_CONFIGURATION_get_value_filename (cfg,
680                                                "fcfsd",
681                                                "ZONEKEY",
682                                                &keyfile))
683   {
684     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
685                 _("Option `%s' not specified in configuration section `%s'\n"),
686                 "ZONEKEY",
687                 "fcfsd");
688     return;
689   }
690   fcfs_zone_pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
691   GNUNET_free (keyfile);
692   if (NULL == fcfs_zone_pkey)
693   {
694     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
695                 _("Failed to read or create private zone key\n"));
696     return;
697   }
698   GNUNET_CRYPTO_rsa_key_get_public (fcfs_zone_pkey,
699                                     &pub);
700   GNUNET_CRYPTO_hash (&pub, sizeof (pub), &fcfsd_zone);
701   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
702               _("Managing `%s' as FCFS zone on port %llu\n"),
703               GNUNET_h2s_full (&fcfsd_zone),
704               port);
705   ns = GNUNET_NAMESTORE_connect (cfg);
706   if (NULL == ns)
707     {
708       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
709                   _("Failed to connect to namestore\n"));
710       return;
711     }
712   httpd = MHD_start_daemon (MHD_USE_DEBUG,
713                             (uint16_t) port,
714                             NULL, NULL, 
715                             &create_response, NULL, 
716                             MHD_OPTION_CONNECTION_LIMIT, (unsigned int) 128,
717                             MHD_OPTION_PER_IP_CONNECTION_LIMIT, (unsigned int) 1,
718                             MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
719                             MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (4 * 1024), 
720                             MHD_OPTION_NOTIFY_COMPLETED, &request_completed_callback, NULL,
721                             MHD_OPTION_END);
722   if (NULL == httpd)
723   {
724     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
725                 _("Failed to start HTTP server\n"));
726     GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
727     ns = NULL;
728     return;
729   }
730   run_httpd ();
731   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
732                                 &do_shutdown, NULL);
733 }
734
735
736 /**
737  * The main function for the fcfs daemon.
738  *
739  * @param argc number of arguments from the command line
740  * @param argv command line arguments
741  * @return 0 ok, 1 on error
742  */
743 int
744 main (int argc, char *const *argv)
745 {
746   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
747     GNUNET_GETOPT_OPTION_END
748   };
749
750   int ret;
751
752   GNUNET_log_setup ("fcfsd", "WARNING", NULL);
753   ret =
754       (GNUNET_OK ==
755        GNUNET_PROGRAM_run (argc, argv, "fcfsd",
756                            _("GNUnet GNS first come first serve registration service"), 
757                            options,
758                            &run, NULL)) ? 0 : 1;
759
760   return ret;
761 }
762
763 /* end of gnunet-gns-fcfsd.c */