KDK_PRINTER_GET_STATUS(3)

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

🌸 kdk_printer_get_status — a lil manual page, section 3 of the Library Functions Manual 🌸

okay bestie, sit down, grab a boba, because we're about to talk about <libkyprinter.h> and the girlies who print 💅


✨ NAME ✨

kdk_printer_get_status — 获取当前打印机状态(状态不是实时更新)

(translation for the monolingual girlies: it grabs the current printer status. and no, it is not updated in real time. she's giving snapshot, not livestream. 📸)


✨ SYNOPSIS ✨

#include <libkyprinter.h>

extern int kdk_printer_get_status(const char *printername);

Link with -lkyprinter.


💫 Detailed Description 💫

so the main function of this interface is literally just: obtain the current printer status. that's the whole job. the status is not updated in real time, so like… don't @ her expecting live updates, she said what she said. 🫶

the argument printername is the printer name — specifically, it's the return value that kdk_printer_get_list gave you. so you get the name from one function, you feed it to this one. chain of custody, no cap. 👑


🎀 RETURN VALUE 🎀

  • on success, returns a status code of type int. iconic. slay. ✨
  • on error, return -2. 😭 that's your girl telling you something went wrong.

🔥 EXAMPLES 🔥

here's the whole vibe, verbatim, don't touch a single character:

#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;
}

🌈 CONFORMING TO 🌈

these functions are as per the withdrawn POSIX.1e draft specification. (withdrawn, bestie. she's retired but still relevant. main character energy that never left the group chat. 💀)

and these following functions are Linux extensions — so they're the bonus tracks:

  • 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_job_status()
  • kdk_printer_get_filename()
  • kdk_printer_freeall()

🦋 SEE ALSO 🦋

go read her sisters, they're all serving:


🌟 that's the whole page, bestie. status = not real-time, error = -2, and you got this. iykyk. 💜

kisses from the Linux Programmer's Manual, dated Fri Aug 25 2023 — KDK_PRINTER_GET_STATUS(3) and out. bye babe, go print something cute 🎀🖨️✨

📦 where this page comes from