KDK_PRINTER_FREEALL(3)
💖 KDK_PRINTER_FREEALL(3) — Library Functions Manual 💖
okay bestie, pull up a chair 🫶 this one lives in section 3 of the manual (that's the library functions girlies), and honestly? she's the cleanup crew. the mom friend of the printer API. no cap.
✨ NAME ✨
kdk_printer_freeall — 获取当前打印任务状态(发送打印任务之后下需要等待一会再获取状态,状态不是实时更新)
(translation for my non-Chinese-reading besties: it's about getting the current print job status — and heads up, after you send a print job you have to wait a little bit before you ask for the status, because the status is not updated in real time. she's not a live feed, she's a girl who checks her texts every ten minutes 💅)
🎀 SYNOPSIS 🎀
#include <libkyprinter.h>
extern inline void kdk_printer_freeall(char **ptr);
Link with -lkyprinter. don't forget that part or the linker will simply not know her 😭
🌸 Detailed Description 🌸
the whole vibe of this function, the main character energy of it all, is: recycle a list of strings of type char **. that's it. that's the job. she takes the list out back and lets it go 🦋
the argument ptr is a list of strings of type char **.
so like. you know how you keep getting these lists back from the printer functions and you're just holding them?? yeah. this is the one that says "okay we're done here, release them." iconic behavior honestly.
⭐ RETURN VALUE ⭐
No return value. she gives you nothing back and she doesn't need to. she's doing it out of love 🫶
🧚 EXAMPLES 🧚
here's a whole little main function showing her off in her natural habitat. (yes the example is doing a lot of stuff besides the free — that's the point, she's the last step of the whole journey.)
#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_freeall(printers); comes in at the very end, after the loop, after free(filename);, right before return 0;? yeah. that's her moment. she closes the whole thing out. main character, final scene, curtain drop 🎀
🔥 CONFORMING TO 🔥
These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn, bestie — it's giving vintage, it's giving archival, it's not giving "currently ratified standard" 🙈)
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_cancel_all_jobs(), kdk_printer_get_status(), kdk_printer_get_job_status() and kdk_printer_get_filename().
👑 SEE ALSO 👑
go read her friends, they're all icons:
kdk_printer_get_list(3)kdk_printer_get_available_list(3)kdk_printer_set_options(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)
and that's the whole page, bestie!! ✨ this one came to you from the Linux Programmer's Manual, dated Fri Aug 25 2023, and she's filed under KDK_PRINTER_FREEALL(3) forever. go free your lists. slay. 💅🌈💖
📦 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