thorsson_cups 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/cups.c +23 -0
- metadata +2 -2
data/ext/cups.c
CHANGED
@@ -411,6 +411,28 @@ static VALUE cups_get_jobs(VALUE self, VALUE printer)
|
|
411
411
|
return job_list;
|
412
412
|
}
|
413
413
|
|
414
|
+
/*
|
415
|
+
* call-seq:
|
416
|
+
* Cups.cancel_print(cups_id) -> true or false
|
417
|
+
*
|
418
|
+
* Cancel the print job. Returns true if successful, false otherwise.
|
419
|
+
*/
|
420
|
+
static VALUE cups_cancel_print(int argc, VALUE* argv, VALUE self, VALUE self)
|
421
|
+
{
|
422
|
+
VALUE printer, job_id;
|
423
|
+
rb_scan_args(argc, argv, "12", &job_id, &printer);
|
424
|
+
|
425
|
+
if (NIL_P(job_id)) {
|
426
|
+
return Qfalse; // If @job_id is nil
|
427
|
+
} else { // Otherwise attempt to cancel
|
428
|
+
int job = NUM2INT(job_id);
|
429
|
+
char *target = RSTRING_PTR(printer); // Target printer string
|
430
|
+
int cancellation;
|
431
|
+
cancellation = cupsCancelJob(target, job);
|
432
|
+
return Qtrue;
|
433
|
+
}
|
434
|
+
}
|
435
|
+
|
414
436
|
/*
|
415
437
|
* call-seq:
|
416
438
|
* Cups.options_for(name) -> Hash or nil
|
@@ -476,5 +498,6 @@ void Init_cups() {
|
|
476
498
|
rb_define_singleton_method(rubyCups, "show_destinations", cups_show_dests, 0);
|
477
499
|
rb_define_singleton_method(rubyCups, "default_printer", cups_get_default, 0);
|
478
500
|
rb_define_singleton_method(rubyCups, "all_jobs", cups_get_jobs, 1);
|
501
|
+
rb_define_singleton_method(rubyCups, "cancel_print", cups_cancel_print, -1)
|
479
502
|
rb_define_singleton_method(rubyCups, "options_for", cups_get_options, 1);
|
480
503
|
}
|