KDK_USB_GET_LIST(3)
💖 kdk_usb_get_list 💖
okay bestie, welcome to the kdk_usb_get_list(3) page from the Library Functions Manual — yes it's section 3, we're in library-functions territory, stay with me 🫶
✨ NAME ✨
kdk_usb_get_list — 获取外接usb设备信息
like, it gets you the info on your external USB devices. that's the whole job. and it does it slayfully. 💅
🦋 SYNOPSIS 🦋
#include <libkyusb.h>
extern pDriverInfoList kdk_usb_get_list();
Link with -lkyusb.
so you pull in <libkyusb.h>, you call kdk_usb_get_list() with no arguments at all (it takes none, periodt), and you gotta link with -lkyusb or the linker will simply not know her. 🔥
🌸 Detailed Description 🌸
The main function of the interface is to obtain the external usb device information.
that's it, that's the vibe. the whole point of this function is grabbing the external USB device info for you. main character energy, honestly. 👑
💜 RETURN VALUE 💜
On success, returns a pointer to a pDriverInfoList structure containing usb information. 🎀
The pDriverInfoList structure is defined in <libkyusb.h> as follows:
typedef struct driver_list
{
struct driver_info *data;
struct driver_list *next;
} DriverInfoList, *pDriverInfoList;
typedef struct driver_info
{
char name[32]; //名称
char type[2 + 1]; //类型
char pid[4 + 1];
char vid[4 + 1];
char serialNo[32]; //序列号
char devNode[32]; //路径
} DriverInfo, *pDriverInfo;
On error, return NULL.
okay so real talk — check for NULL before you go dereferencing anything, or it's giving segfault. 😭
🌈 EXAMPLES 🌈
here's the whole thing in action, copy-paste coded by the universe itself:
#include "stdio.h"
#include "libkyusb.h"
int main()
{
pDriverInfoList list = kdk_usb_get_list();
if(list)
{
pDriverInfoList tmp = list;
while (tmp)
{
printf("Name: %s",tmp->data->name);
printf("Class: %s",tmp->data->type);
printf("PID: %s",tmp->data->pid);
printf("VID: %s",tmp->data->vid);
printf("Serial: %s",tmp->data->serialNo);
printf("DevNode: %s0,tmp->data->devNode);
tmp = tmp->next;
}
}
kdk_usb_free(list);
return 0;
}
notice how it walks the linked list with tmp = tmp->next and then cleans up with kdk_usb_free(list) at the end — that's the self-care part, don't skip it bestie 🧚
⭐ CONFORMING TO ⭐
These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: kdk_usb_free().
lowkey important: that POSIX.1e draft spec is withdrawn, and kdk_usb_free() is a Linux extension — so it's not portable-portable, iykyk. 💀
👑 SEE ALSO 👑
and that's the page!! from the Linux Programmer's Manual, dated Fri Aug 25 2023 — go forth and enumerate your USB devices, you absolute icon 🌟💖✨
📦 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