PageRenderTime 46ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/libgnomecups/patches/libgnomecups-0.2.3-cups-1.6.patch

https://gitlab.com/abchk1234/slackbuilds
Patch | 285 lines | 255 code | 30 blank | 0 comment | 0 complexity | b9e1d6a5eda9ecb98a1fcb6f8d0e9b4d MD5 | raw file
  1. From ae783efde4fa69578651994505462f02b8639220 Mon Sep 17 00:00:00 2001
  2. From: Alexandre Rostovtsev <tetromino@gentoo.org>
  3. Date: Tue, 7 Aug 2012 06:53:09 -0400
  4. Subject: [PATCH] Use CUPS-1.6 IPP API getter/setter functions
  5. CUPS 1.6 makes various structures private and introduces these ippGet
  6. and ippSet functions for all of the fields in these structures.
  7. http://www.cups.org/str.php?L3928
  8. We define our own accessors when building against CUPS < 1.6.
  9. Based on work by Jiri Popelka <jpopelka@redhat.com> at
  10. https://bugzilla.gnome.org/show_bug.cgi?id=679759
  11. ---
  12. libgnomecups/gnome-cups-printer.c | 48 +++++++++++++++++++++++++++++-------
  13. libgnomecups/gnome-cups-queue.c | 43 +++++++++++++++++++++++++++------
  14. libgnomecups/gnome-cups-request.c | 44 ++++++++++++++++++++++++++++-----
  15. 3 files changed, 110 insertions(+), 25 deletions(-)
  16. diff --git a/libgnomecups/gnome-cups-printer.c b/libgnomecups/gnome-cups-printer.c
  17. index c924af0..f5e1ef7 100644
  18. --- a/libgnomecups/gnome-cups-printer.c
  19. +++ b/libgnomecups/gnome-cups-printer.c
  20. @@ -37,6 +37,34 @@
  21. #define UPDATE_TIMEOUT 5000
  22. +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
  23. +#define HAVE_CUPS_1_6 1
  24. +#endif
  25. +
  26. +#ifndef HAVE_CUPS_1_6
  27. +#define ippGetCount(attr) attr->num_values
  28. +#define ippGetName(attr) attr->name
  29. +#define ippGetInteger(attr, element) attr->values[element].integer
  30. +#define ippGetString(attr, element, language) attr->values[element].string.text
  31. +
  32. +static ipp_attribute_t *
  33. +ippFirstAttribute(ipp_t *ipp)
  34. +{
  35. + if (!ipp)
  36. + return (NULL);
  37. + return (ipp->current = ipp->attrs);
  38. +}
  39. +
  40. +static ipp_attribute_t *
  41. +ippNextAttribute(ipp_t *ipp)
  42. +{
  43. + if (!ipp || !ipp->current)
  44. + return (NULL);
  45. + return (ipp->current = ipp->current->next);
  46. +}
  47. +#endif
  48. +
  49. +
  50. struct _GnomeCupsPPDFile {
  51. char name[1];
  52. };
  53. @@ -173,9 +201,9 @@ map_reasons (GnomeCupsPrinter *printer,
  54. printer->details->state_reasons = NULL;
  55. /* cf. RFC2911 4.4.12 */
  56. - for (i = 0; i < attr->num_values; i++) {
  57. + for (i = 0; i < ippGetCount (attr); i++) {
  58. const char *p;
  59. - const char *keyword = attr->values [i].string.text;
  60. + const char *keyword = ippGetString (attr, i, NULL);
  61. reason = g_new (GnomeCupsPrinterReason, 1);
  62. @@ -224,8 +252,8 @@ gnome_cups_printer_get_info (GnomeCupsPrinter *printer)
  63. return printer->details->info;
  64. }
  65. -#define MAP_INT(v,a) {if (!g_ascii_strcasecmp (attr->name, (a))) { if ((v) != attr->values[0].integer) { changed = TRUE; } (v) = attr->values[0].integer; }}
  66. -#define MAP_STRING(v,a) {if (!g_ascii_strcasecmp (attr->name, (a))) { if (!v || strcmp (v, attr->values[0].string.text)) { g_free (v); changed = TRUE; (v) = g_strdup (attr->values[0].string.text); }}}
  67. +#define MAP_INT(v,a) {if (!g_ascii_strcasecmp (ippGetName (attr), (a))) { if ((v) != ippGetInteger (attr, 0)) { changed = TRUE; } (v) = ippGetInteger (attr, 0); }}
  68. +#define MAP_STRING(v,a) {if (!g_ascii_strcasecmp (ippGetName (attr), (a))) { if (!v || strcmp (v, ippGetString (attr, 0, NULL))) { g_free (v); changed = TRUE; (v) = g_strdup (ippGetString (attr, 0, NULL)); }}}
  69. static void
  70. attributes_update_cb (guint id,
  71. @@ -243,14 +271,14 @@ attributes_update_cb (guint id,
  72. changed = FALSE;
  73. if (!error && response) {
  74. - for (attr = response->attrs; attr != NULL; attr = attr->next) {
  75. - if (!attr->name) {
  76. + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) {
  77. + if (!ippGetName (attr)) {
  78. continue;
  79. }
  80. - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !strcmp (attr->name, "attributes-charset")) {
  81. + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !strcmp (ippGetName (attr), "attributes-charset")) {
  82. continue;
  83. }
  84. - if (!g_ascii_strcasecmp (attr->name, "printer-state-reasons")) {
  85. + if (!g_ascii_strcasecmp (ippGetName (attr), "printer-state-reasons")) {
  86. map_reasons (printer, attr);
  87. }
  88. MAP_INT (printer->details->state, "printer-state");
  89. @@ -570,7 +598,7 @@ get_default (void)
  90. attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME);
  91. if (attr) {
  92. - name = g_strdup (attr->values[0].string.text);
  93. + name = g_strdup (ippGetString (attr, 0, NULL));
  94. } else {
  95. name = NULL;
  96. }
  97. @@ -698,7 +726,7 @@ get_printer_names (void)
  98. attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME);
  99. while (attr) {
  100. ret = g_list_prepend (ret,
  101. - g_strdup (attr->values[0].string.text));
  102. + g_strdup (ippGetString (attr, 0, NULL)));
  103. attr = ippFindNextAttribute (response,
  104. "printer-name",
  105. diff --git a/libgnomecups/gnome-cups-queue.c b/libgnomecups/gnome-cups-queue.c
  106. index 9f98ed9..298db42 100644
  107. --- a/libgnomecups/gnome-cups-queue.c
  108. +++ b/libgnomecups/gnome-cups-queue.c
  109. @@ -15,6 +15,33 @@
  110. #define UPDATE_TIMEOUT 3000
  111. +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
  112. +#define HAVE_CUPS_1_6 1
  113. +#endif
  114. +
  115. +#ifndef HAVE_CUPS_1_6
  116. +#define ippGetName(attr) attr->name
  117. +#define ippGetInteger(attr, element) attr->values[element].integer
  118. +#define ippGetString(attr, element, language) attr->values[element].string.text
  119. +
  120. +static ipp_attribute_t *
  121. +ippFirstAttribute(ipp_t *ipp)
  122. +{
  123. + if (!ipp)
  124. + return (NULL);
  125. + return (ipp->current = ipp->attrs);
  126. +}
  127. +
  128. +static ipp_attribute_t *
  129. +ippNextAttribute(ipp_t *ipp)
  130. +{
  131. + if (!ipp || !ipp->current)
  132. + return (NULL);
  133. + return (ipp->current = ipp->current->next);
  134. +}
  135. +#endif
  136. +
  137. +
  138. struct _GnomeCupsQueueDetails {
  139. char *queue_name;
  140. GList *jobs;
  141. @@ -199,8 +226,8 @@ finish_job (GnomeCupsJob *job)
  142. job->size = job->size * 1024;
  143. }
  144. -#define MAP_STR(dest, src) { if (!g_ascii_strcasecmp (attr->name, (src))) { if ((dest) != NULL) g_free (dest); (dest) = g_strdup (attr->values[0].string.text);}}
  145. -#define MAP_INT(dest, src) { if (!g_ascii_strcasecmp (attr->name, (src))) { (dest) = attr->values[0].integer; } }
  146. +#define MAP_STR(dest, src) { if (!g_ascii_strcasecmp (ippGetName (attr), (src))) { if ((dest) != NULL) g_free (dest); (dest) = g_strdup (ippGetString (attr, 0, NULL));}}
  147. +#define MAP_INT(dest, src) { if (!g_ascii_strcasecmp (ippGetName (attr), (src))) { (dest) = ippGetInteger (attr, 0); } }
  148. static void
  149. get_jobs_cb (guint id,
  150. @@ -231,8 +258,8 @@ get_jobs_cb (guint id,
  151. if (response) {
  152. job = g_new0 (GnomeCupsJob, 1);
  153. - for (attr = response->attrs; attr != NULL; attr = attr->next) {
  154. - if (attr->name == NULL) {
  155. + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) {
  156. + if (ippGetName (attr) == NULL) {
  157. if (job->name) {
  158. finish_job (job);
  159. jobs = g_list_prepend (jobs, job);
  160. @@ -244,7 +271,7 @@ get_jobs_cb (guint id,
  161. continue;
  162. }
  163. - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !g_ascii_strcasecmp (attr->name, "attributes-charset")) {
  164. + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !g_ascii_strcasecmp (ippGetName (attr), "attributes-charset")) {
  165. continue;
  166. }
  167. @@ -355,8 +382,8 @@ gnome_cups_queue_get_job_nocache (GnomeCupsQueue *queue,
  168. if (response) {
  169. job = g_new0 (GnomeCupsJob, 1);
  170. - for (attr = response->attrs; attr != NULL; attr = attr->next) {
  171. - if (attr->name == NULL) {
  172. + for (attr = ippFirstAttribute (response); attr != NULL; attr = ippNextAttribute (response)) {
  173. + if (ippGetName (attr) == NULL) {
  174. if (job->name) {
  175. finish_job (job);
  176. } else {
  177. @@ -366,7 +393,7 @@ gnome_cups_queue_get_job_nocache (GnomeCupsQueue *queue,
  178. break;
  179. }
  180. - if (!g_ascii_strcasecmp (attr->name, "attributes-charset") || !g_ascii_strcasecmp (attr->name, "attributes-charset")) {
  181. + if (!g_ascii_strcasecmp (ippGetName (attr), "attributes-charset") || !g_ascii_strcasecmp (ippGetName (attr), "attributes-charset")) {
  182. continue;
  183. }
  184. diff --git a/libgnomecups/gnome-cups-request.c b/libgnomecups/gnome-cups-request.c
  185. index c94f623..13f0948 100644
  186. --- a/libgnomecups/gnome-cups-request.c
  187. +++ b/libgnomecups/gnome-cups-request.c
  188. @@ -19,6 +19,36 @@
  189. #define STOP_UNUSED_THREADS_TIMEOUT 60
  190. #define CLOSE_UNUSED_CONNECTIONS_TIMEOUT 30
  191. +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
  192. +#define HAVE_CUPS_1_6 1
  193. +#endif
  194. +
  195. +#ifndef HAVE_CUPS_1_6
  196. +#define ippGetCount(attr) attr->num_values
  197. +#define ippGetValueTag(attr) attr->value_tag
  198. +#define ippGetName(attr) attr->name
  199. +#define ippGetBoolean(attr, element) attr->values[element].boolean
  200. +#define ippGetInteger(attr, element) attr->values[element].integer
  201. +#define ippGetString(attr, element, language) attr->values[element].string.text
  202. +
  203. +static ipp_attribute_t *
  204. +ippFirstAttribute(ipp_t *ipp)
  205. +{
  206. + if (!ipp)
  207. + return (NULL);
  208. + return (ipp->current = ipp->attrs);
  209. +}
  210. +
  211. +static ipp_attribute_t *
  212. +ippNextAttribute(ipp_t *ipp)
  213. +{
  214. + if (!ipp || !ipp->current)
  215. + return (NULL);
  216. + return (ipp->current = ipp->current->next);
  217. +}
  218. +#endif
  219. +
  220. +
  221. typedef struct
  222. {
  223. GMutex *mutex;
  224. @@ -276,14 +306,14 @@ dump_request (ipp_t const *req)
  225. unsigned i;
  226. ipp_attribute_t *attr;
  227. - for (attr = req->attrs; attr != NULL; attr = attr->next) {
  228. - g_print ("%s", attr->name);
  229. - for (i = 0 ; i < attr->num_values ; i++) {
  230. + for (attr = ippFirstAttribute (req); attr != NULL; attr = ippNextAttribute (req)) {
  231. + g_print ("%s", ippGetName (attr));
  232. + for (i = 0 ; i < ippGetCount (attr) ; i++) {
  233. g_print ("\t[%d] = ", i);
  234. - switch (attr->value_tag & ~IPP_TAG_COPY) {
  235. + switch (ippGetValueTag (attr) & ~IPP_TAG_COPY) {
  236. case IPP_TAG_INTEGER:
  237. case IPP_TAG_ENUM:
  238. - g_print ("%d\n", attr->values[i].integer);
  239. + g_print ("%d\n", ippGetInteger (attr, i));
  240. break;
  241. case IPP_TAG_STRING:
  242. @@ -294,11 +324,11 @@ dump_request (ipp_t const *req)
  243. case IPP_TAG_CHARSET:
  244. case IPP_TAG_LANGUAGE:
  245. case IPP_TAG_MIMETYPE:
  246. - g_print ("'%s'\n", attr->values[i].string.text);
  247. + g_print ("'%s'\n", ippGetString (attr, i, NULL));
  248. break;
  249. case IPP_TAG_BOOLEAN:
  250. - g_print ("%s\n", (int)attr->values[i].boolean ? "true" : "false");
  251. + g_print ("%s\n", (int)ippGetBoolean (attr, i) ? "true" : "false");
  252. break;
  253. default:
  254. --
  255. 1.7.8.6