KDK_HW_FREE_HW(3)

NAME
kdk_hw_free_hw - 释放kdk_hw_get_hwinfo返回的硬件信息结构体

SYNOPSIS
#include <libkyhw.h>

extern void kdk_hw_free_hw(struct HWInfo *list);

Link with -lkyhwinfo.

Detailed Description
The main function of the interface is to release the hardware information structure returned by the kdk_hw_get_hwinfo.

The argument list is the return value of the kdk_hw_get_hwinfo.

RETURN VALUE
No return value

EXAMPLES
    #include "libkyhw.h"
    #include <stdio.h>
    #include <string.h>
    static _print_hw(struct HWInfo *hw)
    {
        struct HWInfo *tmp = hw;
        while (tmp)
        {
            printf("	model : %s, tmp->model);
            printf("		vendor : %s, tmp->vendor);
            printf("		device : %s, tmp->device);
            printf("		driver : %s, tmp->driver);
            printf("		revision : %s, tmp->revision);
            printf("		devicenum : %s, tmp->devicenum);
            printf("		clock : %s, tmp->clock);
            printf("		width : %s, tmp->width);
            tmp = tmp->next;
        }
    }
    static void Traverse_hardware()
    {
        struct HWInfo *keyboard = kdk_hw_get_hwinfo(3);
        printf("KeyBoard Info:);
        _print_hw(keyboard);
        kdk_hw_free_hw(keyboard);
        struct HWInfo *mouse = kdk_hw_get_hwinfo(5);
        printf("Mouse Info:);
        _print_hw(mouse);
        kdk_hw_free_hw(mouse);
        struct HWInfo *bound = kdk_hw_get_hwinfo(15);
        printf("Bound Info:);
        _print_hw(bound);
        kdk_hw_free_hw(bound);
        struct HWInfo *cdrom = kdk_hw_get_hwinfo(23);
        printf("CDRom Info:);
        _print_hw(cdrom);
        kdk_hw_free_hw(cdrom);
        struct HWInfo *camera = kdk_hw_get_hwinfo(27);
        printf("Camera Info:);
        _print_hw(camera);
        kdk_hw_free_hw(camera);
    }
    static void Traverse_power()
    {
        struct Power * power = kdk_hw_get_powerinfo();
        printf("on_battery : %s, power->on_battery ? "true" : "false");
        printf("lid_is_closed : %s, power->lid_is_closed ? "true" : "false");
        printf("lid_is_present : %s, power->lid_is_present ? "true" : "false");
        printf("daemon version : %s, power->daemon_version);
        printf("critical action : %s, power->critical_action);
        struct power_device *tmp = power->devices;
        while (tmp)
        {
            printf("name : %s, tmp->name);
            printf("	native path : %s, tmp->native_path);
            printf("	power supply : %s, tmp->power_supply ? "true" : "false");
            printf("	updated : %s, tmp->updated);
            printf("	has history : %s, tmp->has_history ? "true" : "false");
            printf("	has statistics : %s, tmp->has_statistics ? "true" : "false");
            printf("	is persent: %s, tmp->is_persent ? "true" : "false");
            printf("	is rechargeable : %s, tmp->is_rechargeable ? "true" : "false");
            printf("	state : %s, tmp->state);
            printf("	waring level : %s, tmp->warning_level);
            printf("	energy : %0.2f, tmp->energy);
            printf("	energy empty : %0.2f, tmp->energy_empty);
            printf("	energy full: %0.2f, tmp->energy_full);
            printf("	energy full design : %0.2f, tmp->energy_full_design);
            printf("	energy rate : %0.2f, tmp->energy_rate);
            printf("	voltage : %0.2f, tmp->voltage);
            printf("	time to empty : %ld, tmp->time_to_empty);
            printf("	time to full : %ld, tmp->time_to_full);
            printf("	percentage : %0.2f, tmp->percentage);
            printf("	temperature : %0.2f, tmp->temperature);
            printf("	capacity : %0.2f, tmp->capacity);
            printf("	technology : %s, tmp->technology);
            printf("	online : %s, tmp->online ? "true" : "false");
            printf("	icon name : %s, tmp->icon_name);
            tmp = tmp->next;
        }
        kdk_hw_free_power_info(power);
    }
    int main(int argc, char *argv[])
    {
        if (argc < 2)
        {
            printf("please use like >> kyhwinfo-test --[target]);
            printf("hardware");
            printf("	power");
            printf(");
            return 0;
        }
        if (0 == strcmp(argv[1], "--hardware"))
            Traverse_hardware();
        if (0 == strcmp(argv[1], "--power"))
            Traverse_power();
    }

CONFORMING TO
These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: kdk_hw_get_hwinfo(), kdk_hw_get_powerinfo() and kdk_hw_free_power_info().

SEE ALSO
kdk_hw_get_hwinfo(3), kdk_hw_get_powerinfo(3) and kdk_hw_free_power_info(3).