You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.9 KiB

  1. From 1b8adc11edec48a9b8fcb75b9efdaf618a6744bd Mon Sep 17 00:00:00 2001
  2. From: ejurgensen <espenjurgensen@gmail.com>
  3. Date: Fri, 25 Aug 2017 19:27:41 +0200
  4. Subject: [PATCH] [dmap] Use a wrapper for dmap_find_field() Avoids the need to
  5. have definition of dmap_find_field in dmap_common.h that must be kept in sync
  6. with the definition that gperf generates.
  7. Also should fix compilation problems when gperf is not present, ref pr #390
  8. ---
  9. configure.ac | 21 ---------------------
  10. src/dmap_common.c | 6 ++++++
  11. src/dmap_common.h | 4 +---
  12. src/httpd_daap.c | 2 +-
  13. 4 files changed, 8 insertions(+), 25 deletions(-)
  14. diff --git a/configure.ac b/configure.ac
  15. index 9b149be..9819c82 100644
  16. --- a/configure.ac
  17. +++ b/configure.ac
  18. @@ -32,27 +32,6 @@ to install it.]])],
  19. [AC_MSG_ERROR([[GNU gperf required, please install it.]])])
  20. ])
  21. -GPERF_TEST="$(echo foo,bar | ${GPERF} -L ANSI-C)"
  22. -
  23. -AC_COMPILE_IFELSE(
  24. - [AC_LANG_PROGRAM([
  25. - #include <string.h>
  26. - const char * in_word_set(const char *, size_t);
  27. - $GPERF_TEST]
  28. - )],
  29. - [GPERF_LEN_TYPE=size_t],
  30. - [AC_COMPILE_IFELSE(
  31. - [AC_LANG_PROGRAM([
  32. - #include <string.h>
  33. - const char * in_word_set(const char *, unsigned);
  34. - $GPERF_TEST]
  35. - )],
  36. - [GPERF_LEN_TYPE=unsigned],
  37. - [AC_MSG_ERROR([** unable to determine gperf len type])]
  38. - )]
  39. -)
  40. -
  41. -AC_DEFINE_UNQUOTED([GPERF_LEN_TYPE], [$GPERF_LEN_TYPE], [gperf len type])
  42. AC_PATH_PROG([ANTLR], [[antlr3]])
  43. AS_IF([[test -z "$ANTLR"]],
  44. [AS_IF([[test -f "$srcdir/src/SMARTPLLexer.h"]],
  45. diff --git a/src/dmap_common.c b/src/dmap_common.c
  46. index 250a2d1..b2bc362 100644
  47. --- a/src/dmap_common.c
  48. +++ b/src/dmap_common.c
  49. @@ -42,6 +42,12 @@ dmap_get_fields_table(int *nfields)
  50. return dmap_fields;
  51. }
  52. +// This wrapper is so callers don't need to include dmap_fields_hash.h
  53. +const struct dmap_field *
  54. +dmap_find_field_wrapper(const char *str, int len)
  55. +{
  56. + return dmap_find_field(str, len);
  57. +}
  58. void
  59. dmap_add_container(struct evbuffer *evbuf, const char *tag, int len)
  60. diff --git a/src/dmap_common.h b/src/dmap_common.h
  61. index 93a2bdc..73f72d0 100644
  62. --- a/src/dmap_common.h
  63. +++ b/src/dmap_common.h
  64. @@ -2,7 +2,6 @@
  65. #ifndef __DMAP_HELPERS_H__
  66. #define __DMAP_HELPERS_H__
  67. -#include "config.h"
  68. #include <event2/buffer.h>
  69. #include <event2/http.h>
  70. @@ -45,9 +44,8 @@ extern const struct dmap_field_map dfm_dmap_aeSP;
  71. const struct dmap_field *
  72. dmap_get_fields_table(int *nfields);
  73. -/* From dmap_fields.gperf - keep in sync, don't alter */
  74. const struct dmap_field *
  75. -dmap_find_field (register const char *str, register GPERF_LEN_TYPE len);
  76. +dmap_find_field_wrapper(const char *str, int len);
  77. void
  78. diff --git a/src/httpd_daap.c b/src/httpd_daap.c
  79. index aef2fe0..0564275 100644
  80. --- a/src/httpd_daap.c
  81. +++ b/src/httpd_daap.c
  82. @@ -738,7 +738,7 @@ parse_meta(struct evhttp_request *req, char *tag, const char *param, const struc
  83. if (n == i)
  84. {
  85. - meta[i] = dmap_find_field(field, strlen(field));
  86. + meta[i] = dmap_find_field_wrapper(field, strlen(field));
  87. if (!meta[i])
  88. {
  89. --
  90. 2.7.4