diff options
Diffstat (limited to 'src/pq/pq_query_helper.c')
-rw-r--r-- | src/pq/pq_query_helper.c | 54 |
1 files changed, 1 insertions, 53 deletions
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c index f5b4f38a2..ce8ce8f87 100644 --- a/src/pq/pq_query_helper.c +++ b/src/pq/pq_query_helper.c | |||
@@ -554,62 +554,10 @@ GNUNET_PQ_query_param_absolute_time_nbo ( | |||
554 | } | 554 | } |
555 | 555 | ||
556 | 556 | ||
557 | /** | ||
558 | * Function called to convert input argument into SQL parameters. | ||
559 | * | ||
560 | * @param cls closure | ||
561 | * @param data pointer to input argument | ||
562 | * @param data_len number of bytes in @a data (if applicable) | ||
563 | * @param[out] param_values SQL data to set | ||
564 | * @param[out] param_lengths SQL length data to set | ||
565 | * @param[out] param_formats SQL format data to set | ||
566 | * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays | ||
567 | * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() | ||
568 | * @param scratch_length number of entries left in @a scratch | ||
569 | * @return -1 on error, number of offsets used in @a scratch otherwise | ||
570 | */ | ||
571 | static int | ||
572 | qconv_timestamp (void *cls, | ||
573 | const void *data, | ||
574 | size_t data_len, | ||
575 | void *param_values[], | ||
576 | int param_lengths[], | ||
577 | int param_formats[], | ||
578 | unsigned int param_length, | ||
579 | void *scratch[], | ||
580 | unsigned int scratch_length) | ||
581 | { | ||
582 | const struct GNUNET_TIME_Timestamp *u = data; | ||
583 | struct GNUNET_TIME_Absolute abs; | ||
584 | uint64_t *u_nbo; | ||
585 | |||
586 | GNUNET_break (NULL == cls); | ||
587 | if (1 != param_length) | ||
588 | return -1; | ||
589 | abs = u->abs_time; | ||
590 | if (abs.abs_value_us > INT64_MAX) | ||
591 | abs.abs_value_us = INT64_MAX; | ||
592 | u_nbo = GNUNET_new (uint64_t); | ||
593 | scratch[0] = u_nbo; | ||
594 | *u_nbo = GNUNET_htonll (abs.abs_value_us); | ||
595 | param_values[0] = (void *) u_nbo; | ||
596 | param_lengths[0] = sizeof(uint64_t); | ||
597 | param_formats[0] = 1; | ||
598 | return 1; | ||
599 | } | ||
600 | |||
601 | |||
602 | struct GNUNET_PQ_QueryParam | 557 | struct GNUNET_PQ_QueryParam |
603 | GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x) | 558 | GNUNET_PQ_query_param_timestamp (const struct GNUNET_TIME_Timestamp *x) |
604 | { | 559 | { |
605 | struct GNUNET_PQ_QueryParam res = { | 560 | return GNUNET_PQ_query_param_absolute_time (&x->abs_time); |
606 | .conv = &qconv_timestamp, | ||
607 | .data = x, | ||
608 | .size = sizeof(*x), | ||
609 | .num_params = 1 | ||
610 | }; | ||
611 | |||
612 | return res; | ||
613 | } | 561 | } |
614 | 562 | ||
615 | 563 | ||