同步主线和解决依赖问题
This commit is contained in:
parent
3d174f3008
commit
09aff52c22
|
@ -1,3 +1,60 @@
|
|||
libkysdk-system (2.2.3.5-0k0.15) yangtze; urgency=medium
|
||||
|
||||
*Bug号:
|
||||
*需求号:
|
||||
*其他修改:libysdk-system在openkylin上编包安装报错
|
||||
libkysdk-location包内定义的依赖不足导致安装或运行失败
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Thu, 21 Sep 2023 17:31:25 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.14) yangtze; urgency=medium
|
||||
|
||||
*Bug号:190186 【日历】修改系统语言为英文,重启进入系统后任务栏日历显示三
|
||||
*需求号:
|
||||
*其他修改:
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Tue, 05 Sep 2023 17:19:20 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.13) yangtze; urgency=medium
|
||||
|
||||
*Bug号:
|
||||
*需求号:
|
||||
*其他修改:kyrealtime增加c++接口
|
||||
|
||||
-- tianshaoshuai <tianshaoshuai@kylinos.cn> Thu, 31 Aug 2023 15:38:00 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.12) yangtze; urgency=medium
|
||||
|
||||
*Bug号:190215 【走查】sdk时间格式切换未实时变化
|
||||
*需求号:
|
||||
*其他修改:
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Wed, 30 Aug 2023 16:56:09 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.11) yangtze; urgency=medium
|
||||
|
||||
*Bug号:187435 【可信开发试点】libkysdk-system 缓冲区溢出类安全编码问题整改
|
||||
*需求号:
|
||||
*其他修改:
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Mon, 21 Aug 2023 09:10:09 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.10) yangtze; urgency=medium
|
||||
|
||||
*Bug号:
|
||||
*需求号:
|
||||
*其他修改:拆分libkysdk-hardware的动态库
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Fri, 11 Aug 2023 17:07:47 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.9) yangtze; urgency=medium
|
||||
|
||||
*Bug号:185309
|
||||
*需求号:
|
||||
*其他修改:
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Thu, 03 Aug 2023 10:07:56 +0800
|
||||
|
||||
libkysdk-system (2.2.3.5-0k0.8) yangtze; urgency=medium
|
||||
|
||||
*Bug号:184351 184469
|
||||
|
|
|
@ -320,7 +320,8 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: libkysdk-systemcommon,
|
||||
libglib2.0-0,
|
||||
libc6
|
||||
libc6,
|
||||
python3-requests
|
||||
Multi-Arch: same
|
||||
Description: 地理位置库
|
||||
|
||||
|
@ -455,7 +456,8 @@ Depends: libkysdk-systemcommon,
|
|||
logrotate,
|
||||
libc6,
|
||||
libgcc-s1 | libgcc1,
|
||||
libstdc++6
|
||||
libstdc++6,
|
||||
cron
|
||||
Multi-Arch: same
|
||||
Description: 日志转储服务
|
||||
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
usr/lib/kysdk/kysdk-system/libkyhw.so*
|
||||
usr/lib/kysdk/kysdk-system/libkybluetooth.so*
|
||||
usr/lib/kysdk/kysdk-system/libkyedid.so*
|
||||
usr/lib/kysdk/kysdk-system/libkyfan.so*
|
||||
usr/lib/kysdk/kysdk-system/libkyhwinfo.so*
|
||||
usr/lib/kysdk/kysdk-system/libkyprinter.so*
|
||||
usr/lib/kysdk/kysdk-system/libkyusb.so*
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
usr/lib/kysdk/kysdk-system/libkysysinfo.so*
|
||||
po/kysdk-sysinfo_mn.mo usr/share/locale/mn/LC_MESSAGES/
|
||||
po/kysdk-sysinfo_zh_CN.mo usr/share/locale/zh_CN/LC_MESSAGES/
|
||||
po/kysdk-sysinfo_bo_CN.mo usr/share/locale/bo_CN/LC_MESSAGES/
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
mv /usr/share/locale/mn/LC_MESSAGES/kysdk-sysinfo_mn.mo /usr/share/locale/mn/LC_MESSAGES/kysdk-sysinfo.mo
|
||||
mv /usr/share/locale/zh_CN/LC_MESSAGES/kysdk-sysinfo_zh_CN.mo /usr/share/locale/zh_CN/LC_MESSAGES/kysdk-sysinfo.mo
|
||||
mv /usr/share/locale/bo_CN/LC_MESSAGES/kysdk-sysinfo_bo_CN.mo /usr/share/locale/bo_CN/LC_MESSAGES/kysdk-sysinfo.mo
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-03 13:56+0800\n"
|
||||
"PO-Revision-Date: 2023-08-03 13:59+0800\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"Language: bo_CN\n"
|
||||
|
||||
#: src/systeminfo/libkysysinfo.c:161
|
||||
#, c-format
|
||||
msgid "Kylin Linux Desktop V10 (SP1)"
|
||||
msgstr "ཆི་ལིན་གྱི་ཅོག་ངོས་ V10(SP1)"
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-02 16:06+0800\n"
|
||||
"PO-Revision-Date: 2023-08-02 16:10+0800\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: mn\n"
|
||||
|
||||
#: src/systeminfo/libkysysinfo.c:143
|
||||
#, c-format
|
||||
msgid "Kylin Linux Desktop V10 (SP1)"
|
||||
msgstr "ᠶᠢᠨ ᠾᠧ ᠴᠢ ᠯᠢᠨ ᠵᠢᠯᠤᠭᠤᠳᠬᠤ ᠰᠢᠰᠲ᠋ᠧᠮ v10(sp1)"
|
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-08-02 16:28+0800\n"
|
||||
"PO-Revision-Date: 2023-08-02 16:30+0800\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.3\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"Language: zh_CN\n"
|
||||
|
||||
#: src/systeminfo/libkysysinfo.c:146
|
||||
#, c-format
|
||||
msgid "Kylin Linux Desktop V10 (SP1)"
|
||||
msgstr "银河麒麟桌面操作系统V10 (SP1)"
|
|
@ -319,7 +319,7 @@ char** kdk_get_disklist()
|
|||
goto err_out;
|
||||
}
|
||||
res = tmp;
|
||||
res[counts] = malloc(PATH_MAX * sizeof(char) + 1);
|
||||
res[counts] = malloc(PATH_MAX * sizeof(char) + 1 + PATH_MAX);
|
||||
res[counts][PATH_MAX + 1] = 0;
|
||||
|
||||
// 调整出绝对路径
|
||||
|
@ -498,7 +498,7 @@ kdk_diskinfo *kdk_get_diskinfo(const char *diskname)
|
|||
{
|
||||
strcpy(res->fwrev, "None");
|
||||
}else{
|
||||
char buf[10] = {0};
|
||||
char buf[FWREV_SIZE] = {0};
|
||||
read(tfd, buf, FWREV_SIZE);
|
||||
strcpy(res->fwrev, buf);
|
||||
close(tfd);
|
||||
|
@ -754,12 +754,12 @@ char* kdk_get_hard_serial(const char *hardname)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
char *hard_serial = (char *)malloc(128*sizeof(char));
|
||||
char *hard_serial = (char *)malloc(256*sizeof(char));
|
||||
if (!hard_serial)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
memset(hard_serial, 0, 128);
|
||||
memset(hard_serial, 0, 256);
|
||||
char line[256] = "\0";
|
||||
char path[128] = "\0";
|
||||
char tmp[1024] = "\0";
|
||||
|
|
|
@ -1,10 +1,68 @@
|
|||
aux_source_directory(. SOURCESCODE)
|
||||
include_directories(.)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(GLIB REQUIRED glib-2.0)
|
||||
include_directories(${GLIB_INCLUDE_DIRS})
|
||||
add_library(kyhw SHARED ${SOURCESCODE})
|
||||
|
||||
set(HARDWARE_TOP_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(hwcode
|
||||
"${HARDWARE_TOP_DIR}/libkybios.h"
|
||||
"${HARDWARE_TOP_DIR}/libkybios.c"
|
||||
"${HARDWARE_TOP_DIR}/libkyboard.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyboard.c"
|
||||
"${HARDWARE_TOP_DIR}/libkycpu.h"
|
||||
"${HARDWARE_TOP_DIR}/libkycpu.c"
|
||||
"${HARDWARE_TOP_DIR}/libkydisplay.h"
|
||||
"${HARDWARE_TOP_DIR}/libkydisplay.c"
|
||||
"${HARDWARE_TOP_DIR}/libkync.h"
|
||||
"${HARDWARE_TOP_DIR}/libkync.c")
|
||||
|
||||
|
||||
set(bluetoothcode
|
||||
"${HARDWARE_TOP_DIR}/libkybluetooth.h"
|
||||
"${HARDWARE_TOP_DIR}/libkybluetooth.c")
|
||||
|
||||
set(edidcode
|
||||
"${HARDWARE_TOP_DIR}/libkyedid.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyedid.c")
|
||||
|
||||
set(fancode
|
||||
"${HARDWARE_TOP_DIR}/libkyfan.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyfan.c")
|
||||
|
||||
set(hwinfocode
|
||||
"${HARDWARE_TOP_DIR}/libkyhw.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyhw.c")
|
||||
|
||||
set(printercode
|
||||
"${HARDWARE_TOP_DIR}/libkyprinter.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyprinter.c")
|
||||
|
||||
set(usbcode
|
||||
"${HARDWARE_TOP_DIR}/libkyusb.h"
|
||||
"${HARDWARE_TOP_DIR}/libkyusb.c")
|
||||
|
||||
|
||||
|
||||
add_library(kyhw SHARED ${hwcode})
|
||||
set_target_properties(kyhw PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kybluetooth SHARED ${bluetoothcode})
|
||||
set_target_properties(kybluetooth PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kyedid SHARED ${edidcode})
|
||||
set_target_properties(kyedid PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kyfan SHARED ${fancode})
|
||||
set_target_properties(kyfan PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kyhwinfo SHARED ${hwinfocode})
|
||||
set_target_properties(kyhwinfo PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kyprinter SHARED ${printercode})
|
||||
set_target_properties(kyprinter PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_library(kyusb SHARED ${usbcode})
|
||||
set_target_properties(kyusb PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_executable(kync-test test/kync-test.c)
|
||||
add_executable(kycpu-test test/kycpu-test.c)
|
||||
add_executable(kyprinterlist-test test/kyprinterlist-test.c)
|
||||
|
@ -18,23 +76,48 @@ add_executable(kybluetooth-test test/kybluetooth-test.c)
|
|||
add_executable(kyfan-test test/kyfan-test.c)
|
||||
add_executable(kyhw-test test/kyhw-test.c)
|
||||
# 额外链接的库在这一行
|
||||
target_link_libraries(kyhw kylog kyconf pthread systemd cups curl udev X11 Xrandr bluetooth sensors hd pci gobject-2.0 dbus-glib-1 ${GLIB_LIBRARIES})
|
||||
target_link_libraries(kyprinterprint-test kyhw)
|
||||
target_link_libraries(kyprinterlist-test kyhw)
|
||||
target_link_libraries(kyhw kylog kyconf pthread systemd ${GLIB_LIBRARIES})
|
||||
target_link_libraries(kybluetooth bluetooth hd gobject-2.0)
|
||||
target_link_libraries(kyedid kylog m X11 Xrandr hd)
|
||||
target_link_libraries(kyfan sensors)
|
||||
target_link_libraries(kyhwinfo kylog hd pci dbus-glib-1)
|
||||
target_link_libraries(kyprinter cups curl)
|
||||
target_link_libraries(kyusb kylog udev)
|
||||
# target_link_libraries(kyhw kylog kyconf pthread systemd cups curl udev X11 Xrandr bluetooth sensors hd pci gobject-2.0 dbus-glib-1 ${GLIB_LIBRARIES})
|
||||
target_link_libraries(kyprinterprint-test kyprinter)
|
||||
target_link_libraries(kyprinterlist-test kyprinter)
|
||||
target_link_libraries(kync-test kyhw)
|
||||
target_link_libraries(kycpu-test kyhw)
|
||||
target_link_libraries(kyusb-test kyhw)
|
||||
target_link_libraries(kyusb-test kyusb)
|
||||
target_link_libraries(kybios-test kyhw)
|
||||
target_link_libraries(kyboard-test kyhw)
|
||||
target_link_libraries(kydisplay-test kyhw)
|
||||
target_link_libraries(kyedid-test kyhw)
|
||||
target_link_libraries(kybluetooth-test kyhw)
|
||||
target_link_libraries(kyfan-test kyhw)
|
||||
target_link_libraries(kyhw-test kyhw)
|
||||
target_link_libraries(kyedid-test kyedid)
|
||||
target_link_libraries(kybluetooth-test kybluetooth)
|
||||
target_link_libraries(kyfan-test kyfan)
|
||||
target_link_libraries(kyhw-test kyhwinfo)
|
||||
|
||||
install(TARGETS kyhw
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kybluetooth
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kyedid
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kyfan
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kyhwinfo
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kyprinter
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(TARGETS kyusb
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkync.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
#include "libkyedid.h"
|
||||
#include "hd.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int edid_lines = 0;
|
||||
|
||||
// static int claims_one_point_oh = 0;
|
||||
|
@ -53,6 +58,69 @@ int verify_file(char *pFileName)
|
|||
}
|
||||
}
|
||||
|
||||
char *cmd_exec(char *file)
|
||||
{
|
||||
char *res = (char *)malloc(sizeof(char) * 128);
|
||||
memset(res, 0, 128);
|
||||
int fd[2];
|
||||
if (pipe(fd) == -1) {
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid == -1) {
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
close(fd[0]); // 关闭读取端
|
||||
dup2(fd[1], STDOUT_FILENO); // 将管道写入端连接到标准输出
|
||||
|
||||
// 使用execve执行所需的命令,例如:
|
||||
char* args[] = {"edid-decode", file, NULL};
|
||||
execve("/bin/edid-decode", args, NULL);
|
||||
|
||||
// 如果execve执行失败,需要打印错误信息并退出
|
||||
perror("Failed to execute command");
|
||||
exit(1);
|
||||
} else {
|
||||
close(fd[1]); // 关闭写入端
|
||||
|
||||
char buffer[1024];
|
||||
const char* targetLine1 = "Display Product Name"; // 要匹配的目标行
|
||||
const char* targetLine2 = "Alphanumeric Data String"; // 要匹配的目标行
|
||||
|
||||
FILE* fp = fdopen(fd[0], "r"); // 将读取端转换为文件指针
|
||||
char *val = get_val_from_file(fp, targetLine1);
|
||||
if(!val)
|
||||
{
|
||||
char *value = get_val_from_file(fp, targetLine2);
|
||||
if(!value)
|
||||
{
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
else{
|
||||
strcpy(res, value);
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
else{
|
||||
strcpy(res, val);
|
||||
free(val);
|
||||
}
|
||||
|
||||
fclose(fp); // 关闭文件指针
|
||||
|
||||
// 等待子进程退出并获取退出状态
|
||||
int status;
|
||||
waitpid(pid, &status, 0);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void kdk_edid(char *name)
|
||||
{
|
||||
char edid_text[2048] = "\0";
|
||||
|
@ -846,15 +914,18 @@ char *kdk_edid_get_model(char *name)
|
|||
char *str_model = get_val_from_file(fp, "Alphanumeric Data String");
|
||||
if(!str_model)
|
||||
{
|
||||
free(edid_text);
|
||||
goto err_out;
|
||||
}
|
||||
else{
|
||||
strcpy(model, str_model);
|
||||
}
|
||||
free(str_model);
|
||||
}
|
||||
else{
|
||||
strcpy(model, edid_text);
|
||||
}
|
||||
free(edid_text);
|
||||
|
||||
if(strlen(model) == 0)
|
||||
{
|
||||
|
@ -864,66 +935,52 @@ char *kdk_edid_get_model(char *name)
|
|||
pclose(fp);
|
||||
return model;
|
||||
}
|
||||
sprintf(str_path, "edid-decode %s", path);
|
||||
|
||||
FILE *fp = popen(str_path, "r");
|
||||
if(!fp)
|
||||
char *cmd_val = cmd_exec(path);
|
||||
if(!cmd_val)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
edid_text = get_val_from_file(fp, "Display Product Name");
|
||||
if(!edid_text)
|
||||
{
|
||||
char *str_model = get_val_from_file(fp, "Alphanumeric Data String");
|
||||
if(!str_model)
|
||||
hd_data_t *hd_data;
|
||||
hd_data = (hd_data_t *)calloc(1, sizeof *hd_data);
|
||||
if(!hd_data)
|
||||
{
|
||||
hd_data_t *hd_data;
|
||||
hd_data = (hd_data_t *)calloc(1, sizeof *hd_data);
|
||||
if(!hd_data)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
char src_model[128] = "\0";
|
||||
memset(src_model, 0, 128);
|
||||
goto err_out;
|
||||
}
|
||||
char src_model[128] = "\0";
|
||||
memset(src_model, 0, 128);
|
||||
|
||||
hd_data->progress = NULL;
|
||||
hd_data->debug = ~(HD_DEB_DRIVER_INFO | HD_DEB_HDDB);
|
||||
hd_data->progress = NULL;
|
||||
hd_data->debug = ~(HD_DEB_DRIVER_INFO | HD_DEB_HDDB);
|
||||
|
||||
hd_t *hd, *hd0;
|
||||
hd0 = hd_list(hd_data, hw_monitor, 1, NULL);
|
||||
for (hd = hd0; hd; hd = hd->next)
|
||||
hd_t *hd, *hd0;
|
||||
hd0 = hd_list(hd_data, hw_monitor, 1, NULL);
|
||||
for (hd = hd0; hd; hd = hd->next)
|
||||
{
|
||||
if(hd->model)
|
||||
{
|
||||
if(hd->model)
|
||||
{
|
||||
strcpy(src_model, hd->model);
|
||||
}
|
||||
}
|
||||
free(hd_data);
|
||||
if(strlen(src_model) == 0)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
else{
|
||||
strcpy(model, src_model);
|
||||
strcpy(src_model, hd->model);
|
||||
}
|
||||
}
|
||||
free(hd_data);
|
||||
if(strlen(src_model) == 0)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
else{
|
||||
strcpy(model, str_model);
|
||||
strcpy(model, src_model);
|
||||
}
|
||||
}
|
||||
else{
|
||||
strcpy(model, edid_text);
|
||||
strcpy(model, cmd_val);
|
||||
free(cmd_val);
|
||||
}
|
||||
if(strlen(model) == 0)
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
strstripspace(model);
|
||||
pclose(fp);
|
||||
return model;
|
||||
err_out:
|
||||
free(model);
|
||||
pclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -570,3 +570,15 @@ int kdk_printer_get_job_status(const char *printername, int jobid)
|
|||
return state;
|
||||
}
|
||||
|
||||
inline void kdk_printer_freeall(char **list)
|
||||
{
|
||||
if (! list)
|
||||
return;
|
||||
size_t index = 0;
|
||||
while (list[index])
|
||||
{
|
||||
free(list[index]);
|
||||
index ++;
|
||||
}
|
||||
free(list);
|
||||
}
|
||||
|
|
|
@ -254,6 +254,13 @@ extern int kdk_printer_get_job_status(const char *printername, int jobid);
|
|||
*/
|
||||
extern char* kdk_printer_get_filename(const char *url);
|
||||
|
||||
/**
|
||||
* @brief 用于回收字符串列表
|
||||
*
|
||||
* @param ptr 字符串列表
|
||||
*/
|
||||
extern inline void kdk_printer_freeall(char **ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkybios.h"
|
||||
#include <stdlib.h>
|
||||
int main()
|
||||
{
|
||||
char *vendor = kdk_bios_get_vendor();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "libkync.h"
|
||||
#include "../libkync.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "../libkyprinter.h"
|
||||
#include "../libkync.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
@ -13,7 +12,7 @@ int main()
|
|||
printf("%zd: %s , %d\n", index + 1, printers[index], status);
|
||||
index++;
|
||||
}
|
||||
kdk_nc_freeall(printers);
|
||||
kdk_printer_freeall(printers);
|
||||
//获取可用打印机列表
|
||||
index = 0;
|
||||
char **available_printers = kdk_printer_get_available_list();
|
||||
|
@ -23,7 +22,7 @@ int main()
|
|||
printf("%zd: %s , %d\n", index + 1, available_printers[index], status);
|
||||
index++;
|
||||
}
|
||||
kdk_nc_freeall(available_printers);
|
||||
kdk_printer_freeall(available_printers);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "../libkyprinter.h"
|
||||
#include "../libkync.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
|
@ -45,6 +44,6 @@ int main()
|
|||
index++;
|
||||
free(filename);
|
||||
}
|
||||
kdk_nc_freeall(printers);
|
||||
kdk_printer_freeall(printers);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ find_package(Qt5 COMPONENTS Core DBus REQUIRED)
|
|||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||
include_directories(${Qt5DBus_INCLUDE_DIRS})
|
||||
ADD_EXECUTABLE(kySdkDbus kysdkdbus.cpp main.cpp)
|
||||
target_link_libraries(kySdkDbus kysysinfo kyhw kydiskinfo kyrtinfo kynetinfo kyrealtime kydiskinfo kylocation kypackage Qt5::Core Qt5::DBus)
|
||||
target_link_libraries(kySdkDbus kysysinfo kyhw kyprinter kyusb kydiskinfo kyrtinfo kynetinfo kyrealtime kydiskinfo kylocation kypackage Qt5::Core Qt5::DBus)
|
||||
|
||||
|
||||
ADD_EXECUTABLE(kySdkDbus-session kysdkrest.cpp main_rest.cpp)
|
||||
|
|
|
@ -763,9 +763,10 @@ char **kdk_net_get_up_port()
|
|||
if (flag)
|
||||
{
|
||||
index++;
|
||||
result = (char **)realloc(result, sizeof(char *) * (index + 1 + 1)); // 以NULL结尾
|
||||
if (!result)
|
||||
char **tmp = (char **)realloc(result, sizeof(char *) * (index + 1 + 1)); // 以NULL结尾
|
||||
if (!tmp)
|
||||
goto error;
|
||||
result = tmp;
|
||||
result[index] = (char *)calloc(1, 8);
|
||||
if (!result[index])
|
||||
goto error;
|
||||
|
@ -812,9 +813,14 @@ char **kdk_net_get_up_port()
|
|||
|
||||
return result;
|
||||
error:
|
||||
for (int i = 0; result[i]; i++)
|
||||
// for (int i = 0; result[i]; i++)
|
||||
// {
|
||||
// free(result[i]);
|
||||
// }
|
||||
while (index)
|
||||
{
|
||||
free(result[i]);
|
||||
free(result[index - 1]);
|
||||
index--;
|
||||
}
|
||||
free(result);
|
||||
result = NULL;
|
||||
|
|
|
@ -7,6 +7,9 @@ set_target_properties(kyrealtime PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
|||
add_executable(kyrealtime-test test/kyrealtime-test.c)
|
||||
target_link_libraries(kyrealtime-test kyrealtime)
|
||||
|
||||
add_executable(realtimeinfo-test test/realtimeinfo-test.cpp)
|
||||
target_link_libraries(realtimeinfo-test kyrealtime)
|
||||
|
||||
install(TARGETS kyrealtime
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#include "libkyrealtimeinfo.h"
|
||||
|
||||
float (*net_speed)(const char *) = kdk_real_get_net_speed;
|
||||
double (*cpu_temperature)() = kdk_real_get_cpu_temperature;
|
||||
int (*disk_temperature)(const char *name) = kdk_real_get_disk_temperature;
|
||||
int (*disk_rate)(const char *name) = kdk_real_get_disk_rate;
|
||||
float (*if_speed)(const char *nc) = kdk_real_get_if_speed;
|
||||
|
||||
RealTimeInfo::RealTimeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_io_speed()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_net_speed(const char *nc)
|
||||
{
|
||||
return net_speed(nc);
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_if_speed(const char *nc)
|
||||
{
|
||||
return if_speed(nc);
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_cpu_temperature()
|
||||
{
|
||||
return cpu_temperature();
|
||||
}
|
||||
|
||||
float RealTimeInfo::kdk_real_get_disk_temperature(const char *name)
|
||||
{
|
||||
return disk_temperature(name);
|
||||
}
|
||||
|
||||
int RealTimeInfo::kdk_real_get_disk_rate(const char *name)
|
||||
{
|
||||
return disk_rate(name);
|
||||
}
|
|
@ -1,7 +1,20 @@
|
|||
#ifndef LIBKYREALTIMEINFO_H
|
||||
#define LIBKYREALTIMEINFO_H
|
||||
|
||||
#if __cplusplus
|
||||
/**
|
||||
* @file libkyrtinfo.h
|
||||
* @author liuyunhe (liuyunhe@kylinos.cn)
|
||||
* @brief 瞬时信息
|
||||
* @version 0.1
|
||||
* @date 2023-2-17
|
||||
*
|
||||
* @copyright Copyright (c) 2021
|
||||
* @defgroup 获取瞬时信息
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
@ -45,8 +58,29 @@ extern int kdk_real_get_disk_rate(const char *name);
|
|||
*/
|
||||
extern float kdk_real_get_if_speed(const char *nc);
|
||||
|
||||
#if __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************
|
||||
* 类已弃用 为之前已引用了c++接口的应用保留
|
||||
* 新应用获取瞬时信息请使用上面的c接口
|
||||
************************************/
|
||||
#ifdef __cplusplus
|
||||
|
||||
#define REAL_TIME_EXPORT __attribute__((visibility("default")))
|
||||
class REAL_TIME_EXPORT RealTimeInfo
|
||||
{
|
||||
public:
|
||||
RealTimeInfo();
|
||||
public:
|
||||
float kdk_real_get_io_speed();
|
||||
float kdk_real_get_net_speed(const char *nc);
|
||||
float kdk_real_get_if_speed(const char *nc);
|
||||
float kdk_real_get_cpu_temperature();
|
||||
float kdk_real_get_disk_temperature(const char *name);
|
||||
int kdk_real_get_disk_rate(const char *name);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // LIBKYREALTIMEINFO_H
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkyrealtimeinfo.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main()
|
||||
{
|
||||
if(argc < 3)
|
||||
{
|
||||
printf("./kyrealtime-test <网卡名> <磁盘名>\n");
|
||||
return 0;
|
||||
}
|
||||
printf("netSpeed : %f\n", kdk_real_get_net_speed(argv[argc - 2]));
|
||||
// if(argc < 3)
|
||||
// {
|
||||
// printf("./kyrealtime-test <网卡名> <磁盘名>\n");
|
||||
// return 0;
|
||||
// }
|
||||
printf("netSpeed : %f\n", kdk_real_get_net_speed("enaftgm1i0"));
|
||||
printf("cpuTemp: %f\n", kdk_real_get_cpu_temperature());
|
||||
printf("diskTemp : %d\n", kdk_real_get_disk_temperature(argv[argc - 1]));
|
||||
printf("diskRate : %d\n", kdk_real_get_disk_rate(argv[argc -1]));
|
||||
printf("ifnetSpeed : %f\n", kdk_real_get_if_speed(argv[argc - 2]));
|
||||
printf("diskTemp : %d\n", kdk_real_get_disk_temperature("/dev/nvme0n1"));
|
||||
printf("diskRate : %d\n", kdk_real_get_disk_rate("/dev/nvme0n1"));
|
||||
printf("ifnetSpeed : %f\n", kdk_real_get_if_speed("enaftgm1i0"));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#include "../libkyrealtimeinfo.h"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
RealTimeInfo info;
|
||||
std::cout << "Of speed:" << info.kdk_real_get_net_speed("enp3s0") << std::endl;
|
||||
std::cout << "If speed:" << info.kdk_real_get_if_speed("enp3s0") << std::endl;
|
||||
std::cout << "cpu Temp:" << info.kdk_real_get_cpu_temperature() << std::endl;
|
||||
std::cout << "Disk Temp:" << info.kdk_real_get_disk_temperature("/dev/sda") << std::endl;
|
||||
std::cout << "Disk rate:" << info.kdk_real_get_disk_rate("/dev/sda") << std::endl;
|
||||
return 0;
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
#include <utmp.h>
|
||||
#include <time.h>
|
||||
#include "pci/pci.h"
|
||||
#include <locale.h>
|
||||
|
||||
#define SAFE_FREE(x) if (x) {free(x); x = NULL;}
|
||||
#define KYLIN_ACTIVATION_DBUS_ADDRESS "org.freedesktop.activation"
|
||||
|
@ -31,7 +32,7 @@
|
|||
#define BUF_SIZE 1024
|
||||
|
||||
#define LOCALEDIR "/usr/share/locale/"
|
||||
#define GETTEXT_PACKAGE "kysdk_system_version"
|
||||
#define GETTEXT_PACKAGE "kysdk-sysinfo"
|
||||
|
||||
struct device
|
||||
{
|
||||
|
@ -108,6 +109,9 @@ char* kdk_system_get_systemName()
|
|||
|
||||
char* kdk_system_get_version(bool verbose)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
char *sysversion = NULL;
|
||||
if (verbose)
|
||||
{
|
||||
|
@ -126,18 +130,58 @@ char* kdk_system_get_version(bool verbose)
|
|||
}
|
||||
else
|
||||
{
|
||||
FILE *fp = fopen("/etc/os-release", "r");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
|
||||
sysversion = get_val_from_file(fp, "VERSION");
|
||||
if (!sysversion)
|
||||
char *version_us =NULL;
|
||||
char *version = (char *)malloc(sizeof(char) * 128);
|
||||
if(!version)
|
||||
{
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
strstrip(sysversion, '\"');
|
||||
memset(version, 0, 128);
|
||||
FILE *fp = fopen("/etc/os-release", "r");
|
||||
if (!fp)
|
||||
{
|
||||
free(version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
version_us = get_val_from_file(fp, "VERSION_US");
|
||||
if (!version_us)
|
||||
{
|
||||
fclose(fp);
|
||||
free(version);
|
||||
return NULL;
|
||||
}
|
||||
strstrip(version_us, '\"');
|
||||
strstrip(version_us, '\n');
|
||||
strstrip(version_us, '\"');
|
||||
fclose(fp);
|
||||
if(strcmp(version_us, "Kylin Linux Desktop V10 (SP1)") == 0)
|
||||
{
|
||||
sprintf(version, gettext("Kylin Linux Desktop V10 (SP1)"));
|
||||
}
|
||||
free(version_us);
|
||||
if(strlen(version) == 0)
|
||||
{
|
||||
fp = fopen("/etc/os-release", "r");
|
||||
if (!fp)
|
||||
{
|
||||
free(version);
|
||||
return NULL;
|
||||
}
|
||||
sysversion = get_val_from_file(fp, "VERSION");
|
||||
if (!sysversion)
|
||||
{
|
||||
fclose(fp);
|
||||
free(version);
|
||||
return NULL;
|
||||
}
|
||||
strstrip(sysversion, '\"');
|
||||
fclose(fp);
|
||||
free(version);
|
||||
}
|
||||
else{
|
||||
return version;
|
||||
}
|
||||
}
|
||||
strstrip(sysversion, '\n');
|
||||
strstrip(sysversion, '\"');
|
||||
|
|
|
@ -520,22 +520,51 @@ void *actionDateChanged(void *ptr)
|
|||
DBusConnection *conn = NULL;
|
||||
conn = ptr;
|
||||
char strpath[128] = "\0";
|
||||
char canonical_filename[100] = "\0";
|
||||
char filename[100] = "\0";
|
||||
char fname[100] = "\0";
|
||||
|
||||
int fd = inotify_init();
|
||||
|
||||
char *homeDir = NULL;
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(strpath, "%s/.config/kydate/", homeDir);
|
||||
if (!realpath(homeDir, fname) || !verify_file(fname))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", fname);
|
||||
sprintf(strpath, "%s/.config/kydate/", fname);
|
||||
if (access(strpath, F_OK) != 0)
|
||||
{
|
||||
int status = mkdir(strpath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if (status != 0) {
|
||||
return NULL;
|
||||
if (!realpath(strpath, filename))
|
||||
{
|
||||
if(!verify_file(filename))
|
||||
{
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
int status = mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if (status != 0) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// if(!realpath(path, canonical_filename) || !verify_file(canonical_filename))
|
||||
// {
|
||||
// close(fd);
|
||||
// return NULL;
|
||||
// }
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
if(!verify_file(canonical_filename))
|
||||
{
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
FILE *fp = fopen(path, "w");
|
||||
FILE *fp = fopen(canonical_filename, "w");
|
||||
if(!fp)
|
||||
{
|
||||
close(fd);
|
||||
|
@ -546,7 +575,20 @@ void *actionDateChanged(void *ptr)
|
|||
else{
|
||||
if(access(path, F_OK) != 0)
|
||||
{
|
||||
FILE *fp = fopen(path, "w");
|
||||
// if(!realpath(path, canonical_filename) || !verify_file(canonical_filename))
|
||||
// {
|
||||
// close(fd);
|
||||
// return NULL;
|
||||
// }
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
if(!verify_file(canonical_filename))
|
||||
{
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
FILE *fp = fopen(canonical_filename, "w");
|
||||
if(!fp)
|
||||
{
|
||||
close(fd);
|
||||
|
@ -582,9 +624,14 @@ int monitorSystemDateChange(int fd){
|
|||
|
||||
char *homeDir = NULL;
|
||||
char *realpath_res = NULL;
|
||||
char filename[100] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
|
|
|
@ -313,6 +313,7 @@ int kdk_system_set_dateformat(char *date)
|
|||
int status;
|
||||
int mark = 0;
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -329,7 +330,11 @@ int kdk_system_set_dateformat(char *date)
|
|||
}
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/", filename);
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
if(!verify_file(canonical_filename))
|
||||
|
@ -343,7 +348,7 @@ int kdk_system_set_dateformat(char *date)
|
|||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
char tpath[100] = {0};
|
||||
|
||||
|
@ -451,9 +456,14 @@ int kdk_system_set_24_timeformat()
|
|||
int status = 0;
|
||||
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/", filename);
|
||||
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
|
@ -468,7 +478,7 @@ int kdk_system_set_24_timeformat()
|
|||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
GKeyFile *config = g_key_file_new();
|
||||
GError *gerr = NULL;
|
||||
|
@ -494,9 +504,14 @@ int kdk_system_set_12_timeformat()
|
|||
int status = 0;
|
||||
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/", filename);
|
||||
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
|
@ -511,7 +526,7 @@ int kdk_system_set_12_timeformat()
|
|||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char tpath[100] = {0};
|
||||
|
||||
|
@ -538,10 +553,16 @@ char* kdk_system_get_now_dateformat()
|
|||
char *value = NULL;
|
||||
char *tvalue = malloc(sizeof(char) * 128);
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
char *lang = getenv("LANG");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -602,10 +623,16 @@ char* kdk_system_get_now_timeformat()
|
|||
char value[64] = "\0";
|
||||
char *tvalue = malloc(sizeof(char) * 128);
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
char *lang = getenv("LANG");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -679,6 +706,7 @@ kdk_dateinfo *kdk_system_tran_dateformat(struct tm *ptr)
|
|||
char tmpe[64];
|
||||
char stmp[64];
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -687,7 +715,13 @@ kdk_dateinfo *kdk_system_tran_dateformat(struct tm *ptr)
|
|||
}
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
int ptr_year = ptr->tm_year;
|
||||
ptr->tm_year = ptr->tm_year - 1900;
|
||||
int ptr_mon = ptr->tm_mon;
|
||||
|
@ -888,10 +922,17 @@ char* kdk_system_nowtime()
|
|||
char *value = (char*)malloc(sizeof(char) * 128);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -979,6 +1020,7 @@ char* kdk_system_nowdate()
|
|||
char *value = malloc(sizeof(char) * 64);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -987,7 +1029,13 @@ char* kdk_system_nowdate()
|
|||
}
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -1117,7 +1165,32 @@ char* kdk_system_shortweek()
|
|||
p = localtime(¤t);
|
||||
if(strstr(lang, "en_US"))
|
||||
{
|
||||
strftime(tmpe, sizeof(tmpe), "%a", localtime(¤t));
|
||||
switch (p->tm_wday)
|
||||
{
|
||||
case 0:
|
||||
strcpy(tmpe, "Sun");
|
||||
break;
|
||||
case 1:
|
||||
strcpy(tmpe, "Mon");
|
||||
break;
|
||||
case 2:
|
||||
strcpy(tmpe, "Tue");
|
||||
break;
|
||||
case 3:
|
||||
strcpy(tmpe, "Wed");
|
||||
break;
|
||||
case 4:
|
||||
strcpy(tmpe, "Thu");
|
||||
break;
|
||||
case 5:
|
||||
strcpy(tmpe, "Fri");
|
||||
break;
|
||||
case 6:
|
||||
strcpy(tmpe, "Sat");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch (p->tm_wday)
|
||||
{
|
||||
|
@ -1304,10 +1377,17 @@ char* kdk_system_second()
|
|||
char *value = (char *)malloc(sizeof(char) * 64);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -1535,6 +1615,7 @@ char* kdk_system_gjx_time(char *date)
|
|||
char *value = (char*)malloc(sizeof(char) * 100);
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -1543,7 +1624,13 @@ char* kdk_system_gjx_time(char *date)
|
|||
}
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -1725,9 +1812,14 @@ int kdk_system_set_long_dateformat(char *format)
|
|||
GError* gerr = NULL;
|
||||
int status = 0;
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/", filename);
|
||||
|
||||
if (!realpath(path, canonical_filename))
|
||||
{
|
||||
|
@ -1742,7 +1834,7 @@ int kdk_system_set_long_dateformat(char *format)
|
|||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
char tpath[100] = {0};
|
||||
|
||||
|
@ -1822,6 +1914,7 @@ int kdk_system_set_short_dateformat(char *format)
|
|||
int status = 0;
|
||||
int mark = 0;
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
int sdate = 0;
|
||||
int len = 0;
|
||||
|
||||
|
@ -1840,22 +1933,26 @@ int kdk_system_set_short_dateformat(char *format)
|
|||
}
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/", homeDir);
|
||||
|
||||
if (!realpath(path, canonical_filename))
|
||||
if (!realpath(homeDir, canonical_filename) || !verify_file(canonical_filename))
|
||||
{
|
||||
if(!verify_file(canonical_filename))
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf(path, "%s/.config/kydate/", canonical_filename);
|
||||
if (!realpath(path, filename))
|
||||
{
|
||||
if(!verify_file(filename))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
status = mkdir(canonical_filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
status = mkdir(filename, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if (status != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
memset(path, 0, sizeof(path));
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", canonical_filename);
|
||||
char tpath[100] = {0};
|
||||
|
||||
char *home = getlogin();
|
||||
|
@ -1957,10 +2054,16 @@ char* kdk_system_get_longformat_date()
|
|||
}
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -2038,6 +2141,7 @@ char* kdk_system_get_shortformat_date()
|
|||
}
|
||||
GKeyFile *config = g_key_file_new();
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -2045,7 +2149,12 @@ char* kdk_system_get_shortformat_date()
|
|||
env_time = " ";
|
||||
}
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(value);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -2155,10 +2264,16 @@ char* kdk_system_get_longformat()
|
|||
return NULL;
|
||||
}
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
char *lang = getenv("LANG");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -2201,6 +2316,7 @@ char* kdk_system_get_shortformat()
|
|||
return NULL;
|
||||
}
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -2209,8 +2325,13 @@ char* kdk_system_get_shortformat()
|
|||
}
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
char *lang = getenv("LANG");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
|
@ -2269,10 +2390,16 @@ char* kdk_system_longformat_transform(struct tm *ptr)
|
|||
}
|
||||
char tmp[64];
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
int ptr_year = ptr->tm_year;
|
||||
ptr->tm_year = ptr->tm_year - 1900;
|
||||
int ptr_mon = ptr->tm_mon;
|
||||
|
@ -2346,6 +2473,7 @@ char* kdk_system_shortformat_transform(struct tm *ptr)
|
|||
char *tvalue = (char *)malloc(sizeof(char) * 64);
|
||||
char tmp[64];
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -2353,7 +2481,12 @@ char* kdk_system_shortformat_transform(struct tm *ptr)
|
|||
env_time = " ";
|
||||
}
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", filename);
|
||||
int ptr_year = ptr->tm_year;
|
||||
ptr->tm_year = ptr->tm_year - 1900;
|
||||
int ptr_mon = ptr->tm_mon;
|
||||
|
@ -2600,6 +2733,7 @@ kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr)
|
|||
char tmpe[64];
|
||||
char stmp[64];
|
||||
char canonical_filename[PATH_MAX] = "\0";
|
||||
char filename[PATH_MAX] = "\0";
|
||||
|
||||
char *env_time = getenv("LC_TIME");
|
||||
if(!env_time)
|
||||
|
@ -2608,11 +2742,17 @@ kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr)
|
|||
}
|
||||
char *lang = getenv("LANG");
|
||||
homeDir = getenv("HOME");
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", homeDir);
|
||||
if (!realpath(homeDir, canonical_filename) || !verify_file(canonical_filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", canonical_filename);
|
||||
// memset(canonical_filename, 0, sizeof(canonical_filename));
|
||||
|
||||
if (access(path, F_OK) == 0)
|
||||
{
|
||||
if (!realpath(path, canonical_filename) || !verify_file(canonical_filename))
|
||||
if (!realpath(path, filename) || !verify_file(filename))
|
||||
{
|
||||
free(tvalue);
|
||||
return NULL;
|
||||
|
@ -2621,13 +2761,13 @@ kdk_timeinfo *kdk_system_timeformat_transform(struct tm *ptr)
|
|||
|
||||
GKeyFile *config = g_key_file_new();
|
||||
kdk_timeinfo *res = (kdk_timeinfo *)calloc(1, sizeof(kdk_timeinfo));
|
||||
FILE *fp = fopen(canonical_filename, "r");
|
||||
FILE *fp = fopen(filename, "r");
|
||||
if(!fp)
|
||||
{
|
||||
strcpy(tvalue, "24小时制");
|
||||
}
|
||||
else{
|
||||
g_key_file_load_from_file(config, canonical_filename, 0, NULL);
|
||||
g_key_file_load_from_file(config, filename, 0, NULL);
|
||||
char *gkey = g_key_file_get_string(config, "DATEFORMAT", "TIME_FORMAT", NULL);
|
||||
if(gkey == NULL)
|
||||
{
|
||||
|
|
|
@ -171,8 +171,9 @@ int monitorSystemTimeChange()
|
|||
return -1;
|
||||
}
|
||||
|
||||
u_int64_t dep;
|
||||
ssize_t ret = read(fd, &dep, sizeof(u_int64_t));
|
||||
// u_int64_t dep;
|
||||
char dep[8] = "\0";
|
||||
ssize_t ret = read(fd, dep, sizeof(dep));
|
||||
close(fd);
|
||||
if (ret == -1 && errno == ECANCELED)
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue