aboutsummaryrefslogtreecommitdiff
path: root/src/pq/pq_query_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pq/pq_query_helper.c')
-rw-r--r--src/pq/pq_query_helper.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
index b2bbe8ad4..1f13270c3 100644
--- a/src/pq/pq_query_helper.c
+++ b/src/pq/pq_query_helper.c
@@ -807,7 +807,7 @@ qconv_array (
807 case array_of_bool: 807 case array_of_bool:
808 { 808 {
809 GNUNET_assert (sizeof(bool) == sz); 809 GNUNET_assert (sizeof(bool) == sz);
810 GNUNET_memcpy (out, in, sz); 810 *(bool *) out = (*(bool *) in);
811 in += sz; 811 in += sz;
812 break; 812 break;
813 } 813 }
@@ -833,6 +833,7 @@ qconv_array (
833 break; 833 break;
834 } 834 }
835 case array_of_byte: 835 case array_of_byte:
836 case array_of_string:
836 { 837 {
837 const void *ptr; 838 const void *ptr;
838 839
@@ -840,6 +841,8 @@ qconv_array (
840 { 841 {
841 ptr = in; 842 ptr = in;
842 in += sz; 843 in += sz;
844 if (array_of_string == meta->typ)
845 in += 1; /* NULL-byte */
843 } 846 }
844 else 847 else
845 ptr = ((const void **) data)[i]; 848 ptr = ((const void **) data)[i];
@@ -847,74 +850,71 @@ qconv_array (
847 GNUNET_memcpy (out, ptr, sz); 850 GNUNET_memcpy (out, ptr, sz);
848 break; 851 break;
849 } 852 }
850 case array_of_string:
851 {
852 const void *ptr;
853 if (meta->continuous)
854 {
855 ptr = in;
856 in += sz + 1;
857 }
858 else
859 ptr = ((const char **) data)[i];
860
861 GNUNET_memcpy (out, ptr, sz);
862 break;
863 }
864 case array_of_abs_time: 853 case array_of_abs_time:
865 {
866 const struct GNUNET_TIME_Absolute *abs;
867
868 if (meta->continuous)
869 {
870 abs = (const struct GNUNET_TIME_Absolute *) in;
871 in += sz;
872 }
873 else
874 abs = ((const struct GNUNET_TIME_Absolute **) data)[i];
875
876 if (abs->abs_value_us > INT64_MAX)
877 *(uint64_t *) out = GNUNET_htonll (INT64_MAX);
878 else
879 *(uint64_t *) out = GNUNET_htonll (abs->abs_value_us);
880
881 break;
882 }
883 case array_of_rel_time: 854 case array_of_rel_time:
884 {
885 const struct GNUNET_TIME_Relative *rel;
886
887 if (meta->continuous)
888 {
889 rel = (const struct GNUNET_TIME_Relative *) in;
890 in += sz;
891 }
892 else
893 rel = ((const struct GNUNET_TIME_Relative **) data)[i];
894
895 if (rel->rel_value_us > INT64_MAX)
896 *(uint64_t *) out = GNUNET_htonll (INT64_MAX);
897 else
898 *(uint64_t *) out = GNUNET_htonll (rel->rel_value_us);
899
900 break;
901 }
902 case array_of_timestamp: 855 case array_of_timestamp:
903 { 856 {
904 const struct GNUNET_TIME_Timestamp *ts; 857 uint64_t val;
905 858
906 if (meta->continuous) 859 switch (meta->typ)
907 { 860 {
908 ts = (const struct GNUNET_TIME_Timestamp *) in; 861 case array_of_abs_time:
909 in += sz; 862 {
863 const struct GNUNET_TIME_Absolute *abs;
864
865 if (meta->continuous)
866 {
867 abs = (const struct GNUNET_TIME_Absolute *) in;
868 in += sz;
869 }
870 else
871 abs = ((const struct GNUNET_TIME_Absolute **) data)[i];
872
873 val = abs->abs_value_us;
874 break;
875 }
876 case array_of_rel_time:
877 {
878 const struct GNUNET_TIME_Relative *rel;
879
880 if (meta->continuous)
881 {
882 rel = (const struct GNUNET_TIME_Relative *) in;
883 in += sz;
884 }
885 else
886 rel = ((const struct GNUNET_TIME_Relative **) data)[i];
887
888 val = rel->rel_value_us;
889
890 break;
891 }
892 case array_of_timestamp:
893 {
894 const struct GNUNET_TIME_Timestamp *ts;
895
896 if (meta->continuous)
897 {
898 ts = (const struct GNUNET_TIME_Timestamp *) in;
899 in += sz;
900 }
901 else
902 ts = ((const struct GNUNET_TIME_Timestamp **) data)[i];
903
904 val = ts->abs_time.abs_value_us;
905
906 break;
907 }
908 default:
909 {
910 GNUNET_assert (0);
911 }
910 } 912 }
911 else
912 ts = ((const struct GNUNET_TIME_Timestamp **) data)[i];
913 913
914 if (ts->abs_time.abs_value_us > INT64_MAX) 914 if (val > INT64_MAX)
915 *(uint64_t *) out = GNUNET_htonll (INT64_MAX); 915 val = INT64_MAX;
916 else 916
917 *(uint64_t *) out = GNUNET_htonll (ts->abs_time.abs_value_us); 917 *(uint64_t *) out = GNUNET_htonll (val);
918 918
919 break; 919 break;
920 } 920 }