aboutsummaryrefslogtreecommitdiff
path: root/src/my/my_result_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/my/my_result_helper.c')
-rw-r--r--src/my/my_result_helper.c187
1 files changed, 92 insertions, 95 deletions
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c
index c0a1dff4d..a91a24d90 100644
--- a/src/my/my_result_helper.c
+++ b/src/my/my_result_helper.c
@@ -116,7 +116,7 @@ cleanup_varsize_blob (void *cls,
116 if (NULL != *ptr) 116 if (NULL != *ptr)
117 { 117 {
118 GNUNET_free (*ptr); 118 GNUNET_free (*ptr);
119 *ptr = NULL; 119 *ptr = NULL;
120 } 120 }
121} 121}
122 122
@@ -297,7 +297,7 @@ post_extract_rsa_public_key (void *cls,
297 GNUNET_free (buf); 297 GNUNET_free (buf);
298 return GNUNET_SYSERR; 298 return GNUNET_SYSERR;
299 } 299 }
300 300
301 *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, 301 *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf,
302 size); 302 size);
303 GNUNET_free (buf); 303 GNUNET_free (buf);
@@ -398,10 +398,10 @@ pre_extract_rsa_signature (void *cls,
398 */ 398 */
399static int 399static int
400post_extract_rsa_signature (void *cls, 400post_extract_rsa_signature (void *cls,
401 struct GNUNET_MY_ResultSpec *rs, 401 struct GNUNET_MY_ResultSpec *rs,
402 MYSQL_STMT *stmt, 402 MYSQL_STMT *stmt,
403 unsigned int column, 403 unsigned int column,
404 MYSQL_BIND *results) 404 MYSQL_BIND *results)
405{ 405{
406 struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; 406 struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst;
407 void *buf; 407 void *buf;
@@ -483,23 +483,23 @@ GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig)
483 483
484 484
485/** 485/**
486 * Extract data from a Mysql database @a result at row @a row 486 * Extract data from a Mysql database @a result at row @a row
487 * 487 *
488 * @param cls closure 488 * @param cls closure
489 * @param[in,out] rs 489 * @param[in,out] rs
490 * @param stmt the mysql statement that is being run 490 * @param stmt the mysql statement that is being run
491 * @param column the column that is being processed 491 * @param column the column that is being processed
492 * @param[out] results 492 * @param[out] results
493 * @return 493 * @return
494 * #GNUNET_OK if all results could be extracted 494 * #GNUNET_OK if all results could be extracted
495 * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) 495 * #GNUNET_SYSERR if a result was invalid (non existing field or NULL)
496 */ 496 */
497static int 497static int
498pre_extract_string (void * cls, 498pre_extract_string (void * cls,
499 struct GNUNET_MY_ResultSpec *rs, 499 struct GNUNET_MY_ResultSpec *rs,
500 MYSQL_STMT *stmt, 500 MYSQL_STMT *stmt,
501 unsigned int column, 501 unsigned int column,
502 MYSQL_BIND *results) 502 MYSQL_BIND *results)
503{ 503{
504 results[0].buffer = NULL; 504 results[0].buffer = NULL;
505 results[0].buffer_length = 0; 505 results[0].buffer_length = 0;
@@ -511,32 +511,31 @@ pre_extract_string (void * cls,
511 511
512 512
513/** 513/**
514 * Check size of extracted fixed size data from a Mysql database @a 514 * Check size of extracted fixed size data from a Mysql database @a
515 * 515 *
516 * @param cls closure 516 * @param cls closure
517 * @param[in,out] rs 517 * @param[in,out] rs
518 * @param stmt the mysql statement that is being run 518 * @param stmt the mysql statement that is being run
519 * @param column the column that is being processed 519 * @param column the column that is being processed
520 * @param[out] results 520 * @param[out] results
521 * @return 521 * @return
522 * #GNUNET_OK if all results could be extracted 522 * #GNUNET_OK if all results could be extracted
523 * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) 523 * #GNUNET_SYSERR if a result was invalid (non existing field or NULL)
524 */ 524 */
525static int 525static int
526post_extract_string (void * cls, 526post_extract_string (void * cls,
527 struct GNUNET_MY_ResultSpec *rs, 527 struct GNUNET_MY_ResultSpec *rs,
528 MYSQL_STMT *stmt, 528 MYSQL_STMT *stmt,
529 unsigned int column, 529 unsigned int column,
530 MYSQL_BIND *results) 530 MYSQL_BIND *results)
531{ 531{
532 size_t size; 532 size_t size = (size_t) rs->mysql_bind_output_length;
533 533 char *buf;
534 size = (size_t) rs->mysql_bind_output_length;
535 char buf[size];
536 534
537 if (rs->mysql_bind_output_length != size) 535 if (rs->mysql_bind_output_length != size)
538 return GNUNET_SYSERR; 536 return GNUNET_SYSERR;
539 537
538 buf = GNUNET_malloc (size);
540 results[0].buffer = buf; 539 results[0].buffer = buf;
541 results[0].buffer_length = size; 540 results[0].buffer_length = size;
542 results[0].buffer_type = MYSQL_TYPE_BLOB; 541 results[0].buffer_type = MYSQL_TYPE_BLOB;
@@ -550,9 +549,7 @@ post_extract_string (void * cls,
550 GNUNET_free (buf); 549 GNUNET_free (buf);
551 return GNUNET_SYSERR; 550 return GNUNET_SYSERR;
552 } 551 }
553
554 rs->dst = buf; 552 rs->dst = buf;
555
556 return GNUNET_OK; 553 return GNUNET_OK;
557} 554}
558 555
@@ -621,12 +618,12 @@ GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at)
621 */ 618 */
622static int 619static int
623pre_extract_uint16 (void *cls, 620pre_extract_uint16 (void *cls,
624 struct GNUNET_MY_ResultSpec *rs, 621 struct GNUNET_MY_ResultSpec *rs,
625 MYSQL_STMT *stmt, 622 MYSQL_STMT *stmt,
626 unsigned int column, 623 unsigned int column,
627 MYSQL_BIND *results) 624 MYSQL_BIND *results)
628{ 625{
629 results[0].buffer = (char *)rs->dst; 626 results[0].buffer = rs->dst;
630 results[0].buffer_length = rs->dst_size; 627 results[0].buffer_length = rs->dst_size;
631 results[0].length = &rs->mysql_bind_output_length; 628 results[0].length = &rs->mysql_bind_output_length;
632 results[0].buffer_type = MYSQL_TYPE_SHORT; 629 results[0].buffer_type = MYSQL_TYPE_SHORT;
@@ -649,10 +646,10 @@ pre_extract_uint16 (void *cls,
649 */ 646 */
650static int 647static int
651post_extract_uint16 (void *cls, 648post_extract_uint16 (void *cls,
652 struct GNUNET_MY_ResultSpec *rs, 649 struct GNUNET_MY_ResultSpec *rs,
653 MYSQL_STMT *stmt, 650 MYSQL_STMT *stmt,
654 unsigned int column, 651 unsigned int column,
655 MYSQL_BIND *results) 652 MYSQL_BIND *results)
656{ 653{
657 if (rs->dst_size != rs->mysql_bind_output_length) 654 if (rs->dst_size != rs->mysql_bind_output_length)
658 return GNUNET_SYSERR; 655 return GNUNET_SYSERR;
@@ -696,12 +693,12 @@ GNUNET_MY_result_spec_uint16 (uint16_t *u16)
696 */ 693 */
697static int 694static int
698pre_extract_uint32 (void *cls, 695pre_extract_uint32 (void *cls,
699 struct GNUNET_MY_ResultSpec *rs, 696 struct GNUNET_MY_ResultSpec *rs,
700 MYSQL_STMT *stmt, 697 MYSQL_STMT *stmt,
701 unsigned int column, 698 unsigned int column,
702 MYSQL_BIND *results) 699 MYSQL_BIND *results)
703{ 700{
704 results[0].buffer = (int *)rs->dst; 701 results[0].buffer = rs->dst;
705 results[0].buffer_length = rs->dst_size; 702 results[0].buffer_length = rs->dst_size;
706 results[0].length = &rs->mysql_bind_output_length; 703 results[0].length = &rs->mysql_bind_output_length;
707 results[0].buffer_type = MYSQL_TYPE_LONG; 704 results[0].buffer_type = MYSQL_TYPE_LONG;
@@ -725,10 +722,10 @@ pre_extract_uint32 (void *cls,
725 */ 722 */
726static int 723static int
727post_extract_uint32 (void *cls, 724post_extract_uint32 (void *cls,
728 struct GNUNET_MY_ResultSpec *rs, 725 struct GNUNET_MY_ResultSpec *rs,
729 MYSQL_STMT * stmt, 726 MYSQL_STMT * stmt,
730 unsigned int column, 727 unsigned int column,
731 MYSQL_BIND *results) 728 MYSQL_BIND *results)
732{ 729{
733 if (rs->dst_size != rs->mysql_bind_output_length) 730 if (rs->dst_size != rs->mysql_bind_output_length)
734 return GNUNET_SYSERR; 731 return GNUNET_SYSERR;
@@ -758,23 +755,23 @@ GNUNET_MY_result_spec_uint32 (uint32_t *u32)
758 755
759 756
760/** 757/**
761 * Extract data from a MYSQL database @a result at row @a row 758 * Extract data from a MYSQL database @a result at row @a row
762 * 759 *
763 * @param cls closure 760 * @param cls closure
764 * @param[in,out] rs 761 * @param[in,out] rs
765 * @param stmt the mysql statement that is being run 762 * @param stmt the mysql statement that is being run
766 * @param column the column that is being processed 763 * @param column the column that is being processed
767 * @param[out] results 764 * @param[out] results
768 * @return 765 * @return
769 * #GNUNET_OK if all results could be extracted 766 * #GNUNET_OK if all results could be extracted
770 * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) 767 * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
771 */ 768 */
772static int 769static int
773pre_extract_uint64 (void *cls, 770pre_extract_uint64 (void *cls,
774 struct GNUNET_MY_ResultSpec *rs, 771 struct GNUNET_MY_ResultSpec *rs,
775 MYSQL_STMT *stmt, 772 MYSQL_STMT *stmt,
776 unsigned int column, 773 unsigned int column,
777 MYSQL_BIND *results) 774 MYSQL_BIND *results)
778{ 775{
779 results[0].buffer = rs->dst; 776 results[0].buffer = rs->dst;
780 results[0].buffer_length = rs->dst_size; 777 results[0].buffer_length = rs->dst_size;
@@ -786,23 +783,23 @@ pre_extract_uint64 (void *cls,
786 783
787 784
788/** 785/**
789 * Check size of extracted fixe size data from a Mysql database 786 * Check size of extracted fixe size data from a Mysql database
790 * 787 *
791 * @param cls closure 788 * @param cls closure
792 * @param[in,out] rs 789 * @param[in,out] rs
793 * @param stmt the mysql statement that is being run 790 * @param stmt the mysql statement that is being run
794 * @param column the column that is being processed 791 * @param column the column that is being processed
795 * @param[out] results 792 * @param[out] results
796 * @return 793 * @return
797 * #GNUNET_OK if all results could be extracted 794 * #GNUNET_OK if all results could be extracted
798 * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) 795 * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL)
799 */ 796 */
800static int 797static int
801post_extract_uint64 (void *cls, 798post_extract_uint64 (void *cls,
802 struct GNUNET_MY_ResultSpec *rs, 799 struct GNUNET_MY_ResultSpec *rs,
803 MYSQL_STMT *stmt, 800 MYSQL_STMT *stmt,
804 unsigned int column, 801 unsigned int column,
805 MYSQL_BIND *results) 802 MYSQL_BIND *results)
806{ 803{
807 if (rs->dst_size != rs->mysql_bind_output_length) 804 if (rs->dst_size != rs->mysql_bind_output_length)
808 return GNUNET_SYSERR; 805 return GNUNET_SYSERR;
@@ -811,11 +808,11 @@ post_extract_uint64 (void *cls,
811 808
812 809
813/** 810/**
814 * uint64_t expected. 811 * uint64_t expected.
815 * 812 *
816 * @param[out] u64 where to store the result 813 * @param[out] u64 where to store the result
817 * @return array entry for the result specification to use 814 * @return array entry for the result specification to use
818 */ 815 */
819struct GNUNET_MY_ResultSpec 816struct GNUNET_MY_ResultSpec
820GNUNET_MY_result_spec_uint64 (uint64_t *u64) 817GNUNET_MY_result_spec_uint64 (uint64_t *u64)
821{ 818{