thorsson_cups 0.0.30 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/cups.c +7 -7
- metadata +2 -2
data/ext/cups.c
CHANGED
@@ -441,33 +441,32 @@ static VALUE cups_cancel_print(int argc, VALUE* argv, VALUE self)
|
|
441
441
|
*
|
442
442
|
* Return uri for requested printer.
|
443
443
|
*/
|
444
|
-
static VALUE cups_get_device_uri(VALUE self, VALUE
|
444
|
+
static VALUE cups_get_device_uri(VALUE self, VALUE printer)
|
445
445
|
{
|
446
|
-
if (!printer_exists(
|
446
|
+
if (!printer_exists(printer))
|
447
447
|
{
|
448
448
|
rb_raise(rb_eRuntimeError, "The printer or destination doesn't exist!");
|
449
449
|
}
|
450
450
|
|
451
|
+
VALUE options_list;
|
451
452
|
http_t *http;
|
452
453
|
ipp_t *request;
|
453
454
|
ipp_t *response;
|
454
455
|
ipp_attribute_t *attr;
|
455
456
|
char uri[1024];
|
456
457
|
char *location;
|
457
|
-
char *printer;
|
458
458
|
|
459
|
-
|
459
|
+
char *name = RSTRING_PTR(printer);
|
460
460
|
|
461
461
|
request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
|
462
|
-
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", 0, "/printers/%s",
|
462
|
+
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", 0, "/printers/%s", name);
|
463
463
|
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
|
464
464
|
|
465
465
|
if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
466
466
|
{
|
467
467
|
if((attr = ippFindAttribute(response, "device-uri", IPP_TAG_URI)) != NULL)
|
468
468
|
{
|
469
|
-
|
470
|
-
// // sprintf(location, "%s", attr->values[0].string.text);
|
469
|
+
return rb_str_new2(attr->values[0].string.text);
|
471
470
|
}
|
472
471
|
ippDelete(response);
|
473
472
|
}
|
@@ -543,4 +542,5 @@ void Init_cups() {
|
|
543
542
|
rb_define_singleton_method(rubyCups, "cancel_print", cups_cancel_print, -1);
|
544
543
|
rb_define_singleton_method(rubyCups, "options_for", cups_get_options, 1);
|
545
544
|
rb_define_singleton_method(rubyCups, "device_uri_for", cups_get_device_uri, 1);
|
545
|
+
rb_define_singleton_method(rubyCups, "get_connection_for", cups_get_device_uri, 1);
|
546
546
|
}
|