---
name: "kdk_package_get_packagelist"
section: "3"
platform: "linux"
package: "libkysdk-system"
version: "3.0.1.4-1"
release: "Arch Linux 2026-11-07"
platforms: ["linux"]
url: "https://carta.tech/man/kdk_package_get_packagelist"
---

# kdk\_package\_get\_packagelist(3)

获取系统中所有包列表

## NAME

kdk\_package\_get\_packagelist - 获取系统中所有包列表

## SYNOPSIS

```
#include <libkypackages.h>

extern kdk_package_list* kdk_package_get_packagelist();

Link with -lkypackage.
```

## Detailed Description

The main function of the interface is to obtain a list of all packages in the system.

## RETURN VALUE

On success, returns a pointer to a  *kdk\_package\_list* structure containing gateway information.

The  *kdk\_package\_list* structure is defined in *\<libkypackages.h\>* as follows:

            typedef struct {\
                 unsigned int nums;\
                 kdk\_package\_t \*\*list;\
             }kdk\_package\_list;

            typedef struct \_kdk\_package\_t{\
                 char \*name;     // 包名\
                 char \*version;  // 版本号\
                 char \*section;  // 包类型\
                 char \*status;   // 状态\
                 unsigned long size\_kb;   // 包大小\
                 struct \_kdk\_package\_t \*\*depends; // 依赖包\
             }kdk\_package\_t;

On error, return **NULL.**

## EXAMPLES

```
#include "libkypackages.h"
#include <stdio.h>
static void print_package(kdk_package_t *package)
{
    printf("包名：%s ", package->name);
    printf("版本号：%s ", package->version);
    printf("包类型：%s ", package->section);
    printf("包状态：%s ", package->status);
    printf("包大小：%lu0, package->size_kb);
}
int main()
{
    kdk_package_list *list = kdk_package_get_packagelist();
    printf("系统中一共%u个软件包0, list->nums);
    for (size_t i = 0; i < list->nums; i ++)
    {
        print_package(list->list[i]);
    }
    kdk_package_free_packagelist(list);
    printf("Evolution是否安装：%s0, kdk_package_is_installed("evolution", NULL) == 1 ? "是" : "否");
    char *version = kdk_package_get_version("evolution");
    printf("Evolution版本号：%s0, version);
    free(version);
    return 0;
}
```

## CONFORMING TO

These functions are as per the withdrawn POSIX.1e draft specification. The following functions are Linux extensions: **kdk\_package\_free\_packagelist**(), **kdk\_package\_get\_version**() and **kdk\_package\_is\_installed**().

## SEE ALSO

[**kdk\_package\_free\_packagelist**(3)](/man/kdk_package_free_packagelist/3.md), [**kdk\_package\_get\_version**(3)](/man/kdk_package_get_version/3.md) and [**kdk\_package\_is\_installed**(3)](/man/kdk_package_is_installed/3.md).
