KDK_PRINTE...JOB_STATUS(3)

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

💖 KDK_PRINTER_GET_JOB_STATUS 💖

okay bestie, welcome to KDK_PRINTE...JOB_STATUS(3) from the Library Functions Manual — yes the title is lowkey truncated with ... in the middle, that's just how it is, we don't question it, we respect it. 🫶


✨ NAME ✨

kdk_printer_get_job_status — 获取当前打印任务状态(发送打印任务之后下需要等待一会再获取状态,状态不是实时更新)

translation for the girlies who don't read Chinese: it grabs the current print job status. and NO, it is not real-time, so after you send a job you have to wait a lil minute before you ask. patience is a virtue, bestie. 💅


✨ SYNOPSIS ✨

#include <libkyprinter.h>

extern int kdk_printer_get_job_status(const char *printername, int jobid);

Link with -lkyprinter.


✨ Detailed Description ✨

so the whole ~main character~ job of this interface is to get the current print task status. that's it, that's the gig. 👑

🚨 IMPORTANT VIBE CHECK: after sending the print task, you need to wait for a while to get the status — the status is not updated in real time. do not come for this function when you just hit print, she will not have the tea yet. 😭

now the args, bestie, listen up:

  • printername — the printer name. this is literally the value that kdk_printer_get_list gave you back. don't make one up, that's not the vibe. 🌸
  • jobid — the id of the print job. the little number that says "this one, right here". 🎀

✨ RETURN VALUE ✨

  • on success 💖 — returns a status code of type int.
  • on error 💀 — returns 0. yes, zero. that's the fail signal. ngl, handle it.

✨ EXAMPLES ✨

here's the full serve, copied exactly, no cap:

#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 that sleep(10) before the kdk_printer_get_job_status call? that's the whole point, bestie — you wait, then you ask. the function said it's not real time and the example is out here proving it. iconic consistency honestly. 🧚


✨ CONFORMING TO ✨

these functions are as per the withdrawn POSIX.1e draft specification. (withdrawn, as in, the draft got cancelled — still slaying tho 💅)

and these 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_cancel_all_jobs()
  • kdk_printer_get_status()
  • kdk_printer_get_filename()
  • kdk_printer_freeall()

✨ SEE ALSO ✨

go read your sisters, bestie, they all ate:


and that's the page, bestie!! 🦋 Linux Programmer's Manual, dated Fri Aug 25 2023 — mwah, love that for us. now go wait your ten seconds before checking the job status, i'm literally begging. 💖✨🎀

📦 where this page comes from