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.
Files changed (2) hide show
  1. data/ext/cups.c +7 -7
  2. 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 printerName)
444
+ static VALUE cups_get_device_uri(VALUE self, VALUE printer)
445
445
  {
446
- if (!printer_exists(printerName))
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
- printer = RSTRING_PTR(printerName);
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", printer);
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
- // //int c = 0;
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
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 30
9
- version: 0.0.30
8
+ - 31
9
+ version: 0.0.31
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Turkovic