KDK_PRINTE...LABLE_LIST(3)
✨ KDK_PRINTE...LABLE_LIST(3) ✨
okay bestie, welcome to the <libkyprinter.h> corner of the universe 💖 this whole page is technically filed under kdk_printer_get_available_list(3), but the star of the show inside is kdk_printer_set_options — she's the one actually doing the work, and she's serving.
💅 NAME 💅
kdk_printer_get_available_list — 设置打印参数
(yes the name and the job description are lowkey mismatched, we don't ask questions, we just print 🖨️✨)
🎀 SYNOPSIS 🎀
#include <libkyprinter.h>
extern void kdk_printer_set_options(int number_up, const char *media, const char *number_up_layout, const char *sides);
Link with -lkyprinter.
that's the whole vibe. link her in and she's ready 🫶
🌸 Detailed Description 🌸
so the main function of this interface is to set the printing parameters 📝 and the way she does it is: every single setting clears the previous set of printing parameters. no stacking, no layering, no "but I wanted both" — she wipes the slate and starts fresh, every time. iconic behaviour honestly 💅
and here's the part that matters: this setting is a global setting. so once you set it, all printers will use this parameter to print. every last one. no cap 👑
now let's meet the arguments, bestie:
number_up— this is a cups property. it's how many pages get printed onto one piece of paper, like2,4, etc. 📄media— also a cups property. it's the paper type, like"A4"📃number_up_layout— cups property again, like"lrtb"🧚sides— cups property, and she's the duplex queen:"one-sided","two-sided-long-edge","two-sided-short-edge"🌈
😭 RETURN VALUE 😭
No return value.
that's it. she gives you nothing back. she just does it. main character energy, honestly 💀
🔥 EXAMPLES 🔥
here's the full flex, copied exactly, no notes:
#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;
}
look at her go 🏃♀️ grab the printer list, cancel every job on each printer, pull a filename out of a URL, set the options to 2 pages-up on "A4" with "lrtb" layout and "two-sided-long-edge", download the file, print it locally, then check the job status after a lil sleep(10) nap 😴 and finally kdk_printer_freeall(printers) to clean up. the way that whole flow just works — obsessed 💜
👑 CONFORMING TO 👑
These functions are as per the withdrawn POSIX.1e draft specification.
⚠️ bestie, note the word withdrawn. it's a draft that got pulled. we're living on legacy lore here, iykyk 💀
The following functions are Linux extensions:
kdk_printer_get_list()kdk_printer_get_available_list()kdk_printer_print_download_remote_file()kdk_printer_print_local_file()kdk_printer_cancel_all_jobs()kdk_printer_get_status()kdk_printer_get_job_status()kdk_printer_get_filename()kdk_printer_freeall()
🌈 SEE ALSO 🌈
go read these next, fr fr:
kdk_printer_get_list(3)kdk_printer_get_available_list(3)kdk_printer_print_download_remote_file(3)kdk_printer_print_local_file(3)kdk_printer_cancel_all_jobs(3)kdk_printer_get_status(3)kdk_printer_get_job_status(3)kdk_printer_get_filename(3)kdk_printer_freeall(3)
and that's the whole page, bestie 🎀 this one's from the Linux Programmer's Manual, dated Fri Aug 25 2023, and it's filed under KDK_PRINTE...LABLE_LIST(3). go print something cute, you got this 💖✨🦋
📦 where this page comes from
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms