1 Star 0 Fork 49

问书/systemd_bak

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0130-format-table-add-table_update-to-update-existing-ent.patch 2.53 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:59 . import systemd-239-29.el8.src.rpm
From a53afb337985f8f1c7fe8f620fe30cec87f554d5 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 8 Nov 2018 21:17:47 +0100
Subject: [PATCH] format-table: add table_update() to update existing entries
(cherry picked from commit 27e730e6d0a7709c17ccef170f10846e92dca2a0)
Related: #1689832
---
src/basic/format-table.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/basic/format-table.h | 2 ++
2 files changed, 42 insertions(+)
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
index a3ff527e91..302642d748 100644
--- a/src/basic/format-table.c
+++ b/src/basic/format-table.c
@@ -590,6 +590,46 @@ int table_set_url(Table *t, TableCell *cell, const char *url) {
return free_and_replace(table_get_data(t, cell)->url, copy);
}
+int table_update(Table *t, TableCell *cell, TableDataType type, const void *data) {
+ _cleanup_free_ char *curl = NULL;
+ TableData *nd, *od;
+ size_t i;
+
+ assert(t);
+ assert(cell);
+
+ i = TABLE_CELL_TO_INDEX(cell);
+ if (i >= t->n_cells)
+ return -ENXIO;
+
+ assert_se(od = t->data[i]);
+
+ if (od->url) {
+ curl = strdup(od->url);
+ if (!curl)
+ return -ENOMEM;
+ }
+
+ nd = table_data_new(
+ type,
+ data,
+ od->minimum_width,
+ od->maximum_width,
+ od->weight,
+ od->align_percent,
+ od->ellipsize_percent);
+ if (!nd)
+ return -ENOMEM;
+
+ nd->color = od->color;
+ nd->url = TAKE_PTR(curl);
+
+ table_data_unref(od);
+ t->data[i] = nd;
+
+ return 0;
+}
+
int table_add_many_internal(Table *t, TableDataType first_type, ...) {
TableDataType type;
va_list ap;
diff --git a/src/basic/format-table.h b/src/basic/format-table.h
index 07cb2351cb..4273c8c49b 100644
--- a/src/basic/format-table.h
+++ b/src/basic/format-table.h
@@ -46,6 +46,8 @@ int table_set_ellipsize_percent(Table *t, TableCell *cell, unsigned percent);
int table_set_color(Table *t, TableCell *cell, const char *color);
int table_set_url(Table *t, TableCell *cell, const char *color);
+int table_update(Table *t, TableCell *cell, TableDataType type, const void *data);
+
int table_add_many_internal(Table *t, TableDataType first_type, ...);
#define table_add_many(t, ...) table_add_many_internal(t, __VA_ARGS__, _TABLE_DATA_TYPE_MAX)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Weisson/systemd_bak.git
git@gitee.com:Weisson/systemd_bak.git
Weisson
systemd_bak
systemd_bak
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385