KDK_PRINTER_CANCEL_ALL_JOBS(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 KDK_PRINTER_CANCEL_ALL_JOBS 💖

okay bestie, so this one lives in the Library Functions Manual (section 3, the library-call girlies), and it's about one very specific, very satisfying thing: nuking every print job on a printer. all of them. the whole queue. gone. 🫶


✨ NAME ✨

kdk_printer_cancel_all_jobs — 清除某个打印机的所有打印队列

like, it clears all the print queues for a printer. that's the whole gig. no notes. 💅


🌸 SYNOPSIS 🌸

#include <libkyprinter.h>

extern int kdk_printer_cancel_all_jobs(const char *printername);

and you gotta link it up, okay:

Link with -lkyprinter.

🦋 Detailed Description 🦋

so the main function of the interface is to clears all print queues for a printer. yes, that's the actual job description. it walks in, it clears everything, it leaves. main character energy fr fr. 👑

the argument printername is printer name — specifically, it's the value that kdk_printer_get_list returned. so don't just make up a string, bestie, get it from the list function first. iykyk.


🎀 RETURN VALUE 🎀

  • on success, it returns 0. slay. ✨
  • on error, it returns -1. 😭

that's it. that's the whole vibe check.


🌈 EXAMPLES 🌈

here's the full little demo, copied exactly so nothing gets lost in the group chat:

#include "libkyprinter.h"
#include <stdio.h>

int main()
{
    int index = 0;
    //获取打印机列表
    char **printers = kdk_printer_get_available_list();
    while (printers[index])
    {
        printf("%zd: %s0, index + 1, printers[index]);

        //取消当前打印机所有打印任务
        kdk_printer_cancel_all_jobs(printers[index]);

        //获取url对应的文件名
        char *url = "http://www.cztouch.com/upfiles/soft/testpdf.pdf";
        int res = -1;
        char *filename = kdk_printer_get_filename(url); //从完整路径名中解析出文件名称,例如:/home/test/abc.txt,解析完成后为abc.txt
        printf("filename = %s0, filename);

        //设置打印参数
        kdk_printer_set_options(2, "A4", "lrtb", "two-sided-long-edge");

        //下载
        res = kdk_printer_print_download_remote_file(url, filename);
        printf("[%s] res = %d0, __FUNCTION__, res);
        printf("[%s] filepath = %s0, __FUNCTION__, filename);

        //打印
        int job_id = kdk_printer_print_local_file(printers[index], filename);
        if (job_id == 0)
        {
            //打印失败
            printf("[%s] create print job fail0, __FUNCTION__);
        }
        else
        {
            //打印成功,等待一会获取任务状态
            sleep(10);
            int status = kdk_printer_get_job_status(printers[index], job_id);
        }

        index++;
        free(filename);
    }
    kdk_printer_freeall(printers);
    return 0;
}

see how kdk_printer_cancel_all_jobs(printers[index]); just pops in there mid-loop and clears the current printer's whole queue before moving on? obsessed. 😌


💜 CONFORMING TO 💜

these functions are as per the withdrawn POSIX.1e draft specification. yes, withdrawn — it's giving vintage, it's giving retired icon, we still love her. 💀

the following functions are Linux extensions:

  • kdk_printer_get_list()
  • kdk_printer_get_available_list()
  • kdk_printer_set_options()
  • kdk_printer_print_download_remote_file()
  • kdk_printer_print_local_file()
  • kdk_printer_get_status()
  • kdk_printer_get_job_status()
  • kdk_printer_get_filename()
  • kdk_printer_freeall()

⭐ SEE ALSO ⭐

go read these next, bestie, they're all connected:


reminder that this page came from the Linux Programmer's Manual, dated Fri Aug 25 2023. that's the source and the version, periodt. 🩷

okay that's the whole page, go cancel some jobs, love u, bye 🧚✨

📦 where this page comes from