aboutsummaryrefslogtreecommitdiff
path: root/src/mint/taler-mint-httpd_parsing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mint/taler-mint-httpd_parsing.c')
-rw-r--r--src/mint/taler-mint-httpd_parsing.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/mint/taler-mint-httpd_parsing.c b/src/mint/taler-mint-httpd_parsing.c
index 56744c6b0..c4e28bba7 100644
--- a/src/mint/taler-mint-httpd_parsing.c
+++ b/src/mint/taler-mint-httpd_parsing.c
@@ -553,22 +553,29 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
553{ 553{
554 unsigned int i; 554 unsigned int i;
555 int ret; 555 int ret;
556 void *ptr;
556 557
557 ret = GNUNET_YES; 558 ret = GNUNET_YES;
558 for (i=0; NULL != spec[i].field_name; i++) 559 for (i=0; NULL != spec[i].field_name; i++)
559 { 560 {
560 if (0 == spec[i].destination_size_in) 561 if (0 == spec[i].destination_size_in)
562 {
563 ptr = NULL;
561 parse_variable_json_data (connection, root, 564 parse_variable_json_data (connection, root,
562 spec[i].field_name, 565 spec[i].field_name,
563 (void **) spec[i].destination, 566 &ptr,
564 &spec[i].destination_size_out, 567 &spec[i].destination_size_out,
565 &ret); 568 &ret);
569 spec[i].destination = ptr;
570 }
566 else 571 else
572 {
567 parse_fixed_json_data (connection, root, 573 parse_fixed_json_data (connection, root,
568 spec[i].field_name, 574 spec[i].field_name,
569 spec[i].destination, 575 spec[i].destination,
570 spec[i].destination_size_in, 576 spec[i].destination_size_in,
571 &ret); 577 &ret);
578 }
572 } 579 }
573 if (GNUNET_YES != ret) 580 if (GNUNET_YES != ret)
574 TALER_MINT_release_parsed_data (spec); 581 TALER_MINT_release_parsed_data (spec);
@@ -641,4 +648,63 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
641 return GNUNET_OK; 648 return GNUNET_OK;
642} 649}
643 650
651
652/**
653 * Extraxt variable-size base32crockford encoded data from request.
654 *
655 * Queues an error response to the connection if the parameter is missing
656 * or the encoding is invalid.
657 *
658 * @param connection the MHD connection
659 * @param param_name the name of the parameter with the key
660 * @param[out] out_data pointer to allocate buffer and store the result
661 * @param[out] out_size set to the size of the buffer allocated in @a out_data
662 * @return
663 * #GNUNET_YES if the the argument is present
664 * #GNUNET_NO if the argument is absent or malformed
665 * #GNUNET_SYSERR on internal error (error response could not be sent)
666 */
667int
668TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
669 const char *param_name,
670 void **out_data,
671 size_t *out_size)
672{
673 const char *str;
674 size_t slen;
675 size_t olen;
676 void *out;
677
678 str = MHD_lookup_connection_value (connection,
679 MHD_GET_ARGUMENT_KIND,
680 param_name);
681 if (NULL == str)
682 {
683 return (MHD_NO ==
684 TALER_MINT_reply_arg_missing (connection, param_name))
685 ? GNUNET_SYSERR : GNUNET_NO;
686 }
687 slen = strlen (str);
688 olen = (slen * 5) / 8;
689 out = GNUNET_malloc (olen);
690 if (GNUNET_OK !=
691 GNUNET_STRINGS_string_to_data (str,
692 strlen (str),
693 out,
694 olen))
695 {
696 GNUNET_free (out);
697 *out_size = 0;
698 return (MHD_NO ==
699 TALER_MINT_reply_arg_invalid (connection, param_name))
700 ? GNUNET_SYSERR : GNUNET_NO;
701 }
702 *out_data = out;
703 *out_size = olen;
704 return GNUNET_OK;
705
706}
707
708
709
644/* end of taler-mint-httpd_parsing.c */ 710/* end of taler-mint-httpd_parsing.c */