libkysdk-system/man/packages/kdk_package_get_version.3

66 lines
1.8 KiB
Groff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.TH "KDK_PACKAGE_GET_VERSION" 3 "Mon Sep 18 2023" "Linux Programmer's Manual" \"
.SH NAME
kdk_package_get_version - 获取系统中指定包的版本号
.SH SYNOPSIS
.nf
.B #include <libkynetinfo.h>
.sp
.BI "extern char* kdk_package_get_version(const char *"name ");"
.sp
Link with \fI\-lkynetinfo\fP.
.SH "Detailed Description"
The main function of the interface is to obtain the version number of the specified package in the system.
.PP
The argument
.I name
is the package name.
.SH "RETURN VALUE"
On success, returns the version of type char *; The returned string needs to be released by
.I free
.PP
On error, return
.BR NULL.
.SH EXAMPLES
.EX
#include "libkypackages.h"
#include <stdio.h>
static void print_package(kdk_package_t *package)
{
printf("包名:%s\t", package->name);
printf("版本号:%s\t", package->version);
printf("包类型:%s\t", package->section);
printf("包状态:%s\t", package->status);
printf("包大小:%lu\n", package->size_kb);
}
int main()
{
kdk_package_list *list = kdk_package_get_packagelist();
printf("系统中一共%u个软件包\n", list->nums);
for (size_t i = 0; i < list->nums; i ++)
{
print_package(list->list[i]);
}
kdk_package_free_packagelist(list);
printf("Evolution是否安装%s\n", kdk_package_is_installed("evolution", NULL) == 1 ? "是" : "否");
char *version = kdk_package_get_version("evolution");
printf("Evolution版本号%s\n", version);
free(version);
return 0;
}
.SH "CONFORMING TO"
These functions are as per the withdrawn POSIX.1e draft specification.
The following functions are Linux extensions:
.BR kdk_package_get_packagelist (),
.BR kdk_package_free_packagelist ()
and
.BR kdk_package_is_installed ().
.SH "SEE ALSO"
.BR kdk_package_get_packagelist (3),
.BR kdk_package_free_packagelist (3)
and
.BR kdk_package_is_installed (3).