45e77948e9
requested_attributes is specified.
61 lines
2.3 KiB
Diff
61 lines
2.3 KiB
Diff
diff -U0 pycups-1.9.40/ChangeLog.requested_attributes pycups-1.9.40/ChangeLog
|
|
--- pycups-1.9.40/ChangeLog.requested_attributes 2008-06-20 17:58:49.000000000 +0100
|
|
+++ pycups-1.9.40/ChangeLog 2008-07-10 16:52:05.000000000 +0100
|
|
@@ -0,0 +1,5 @@
|
|
+2008-07-09 Tim Waugh <twaugh@redhat.com>
|
|
+
|
|
+ * cupsconnection.c (Connection_getPrinterAttributes): Fixed
|
|
+ requested_attributes parameter.
|
|
+
|
|
diff -up pycups-1.9.40/cupsconnection.c.requested_attributes pycups-1.9.40/cupsconnection.c
|
|
--- pycups-1.9.40/cupsconnection.c.requested_attributes 2008-06-20 10:36:50.000000000 +0100
|
|
+++ pycups-1.9.40/cupsconnection.c 2008-07-10 16:52:05.000000000 +0100
|
|
@@ -2240,6 +2240,7 @@ Connection_getPrinterAttributes (Connect
|
|
char *uri;
|
|
PyObject *requested_attrs = NULL;
|
|
char **attrs = NULL; /* initialised to calm compiler */
|
|
+ size_t n_attrs;
|
|
ipp_t *request, *answer;
|
|
ipp_attribute_t *attr;
|
|
char consuri[HTTP_MAX_URI];
|
|
@@ -2269,16 +2270,16 @@ Connection_getPrinterAttributes (Connect
|
|
}
|
|
|
|
if (requested_attrs) {
|
|
- int i, n;
|
|
+ int i;
|
|
|
|
if (!PyList_Check (requested_attrs)) {
|
|
PyErr_SetString (PyExc_TypeError, "List required");
|
|
return NULL;
|
|
}
|
|
|
|
- n = PyList_Size (requested_attrs);
|
|
- attrs = malloc ((n + 1) * sizeof (char *));
|
|
- for (i = 0; i < n; i++) {
|
|
+ n_attrs = PyList_Size (requested_attrs);
|
|
+ attrs = malloc ((n_attrs + 1) * sizeof (char *));
|
|
+ for (i = 0; i < n_attrs; i++) {
|
|
PyObject *val = PyList_GetItem (requested_attrs, i); // borrowed ref
|
|
if (!PyString_Check (val)) {
|
|
PyErr_SetString (PyExc_TypeError, "String required");
|
|
@@ -2294,7 +2295,7 @@ Connection_getPrinterAttributes (Connect
|
|
|
|
attrs[i] = strdup (PyString_AsString (val));
|
|
}
|
|
- attrs[n] = NULL;
|
|
+ attrs[n_attrs] = NULL;
|
|
}
|
|
|
|
debugprintf ("-> Connection_getPrinterAttributes(%s)\n",
|
|
@@ -2318,8 +2319,7 @@ Connection_getPrinterAttributes (Connect
|
|
"printer-uri", NULL, uri);
|
|
if (requested_attrs)
|
|
ippAddStrings (request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
|
|
- "requested-attributes",
|
|
- sizeof (attrs) / sizeof (attrs[0]), NULL,
|
|
+ "requested-attributes", n_attrs, NULL,
|
|
(const char **) attrs);
|
|
debugprintf ("trying request with uri %s\n", uri);
|
|
answer = cupsDoRequest (self->http, request, "/");
|