修改使用gcc14编译时的问题
This commit is contained in:
parent
19ad180020
commit
ed72f6d833
|
@ -167,7 +167,7 @@ static int get_disk_identifier(int fd, kdk_diskinfo *di)
|
|||
}
|
||||
|
||||
char *model = strndup((char*)&hd[27], 40);
|
||||
char *fwrev = strndup(&hd[23], 8); // 固件版本
|
||||
char *fwrev = strndup((char*)&hd[23], 8); // 固件版本
|
||||
char *serno = strndup((char*)&hd[10], 20);
|
||||
|
||||
di->serial = malloc(strlen(serno) + 1);
|
||||
|
@ -440,9 +440,9 @@ kdk_diskinfo *_kdk_get_diskinfo(const char *diskname)
|
|||
char *dn = diskname + pos;
|
||||
// klog_debug("%s\n", dn);
|
||||
|
||||
const char *dev_PP = NULL;
|
||||
const char *serial = NULL;
|
||||
const char *dev_P = NULL;
|
||||
struct udev_device *dev_PP = NULL;
|
||||
struct udev_device *serial = NULL;
|
||||
struct udev_device *dev_P = NULL;
|
||||
const char *serial_val = NULL;
|
||||
|
||||
dev_block = udev_device_new_from_subsystem_sysname(udev,"block",dn);
|
||||
|
@ -1289,7 +1289,7 @@ static int getDiskType(char *diskname)
|
|||
return diskinfo->disk_type;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return DISK_TYPE_NONE;
|
||||
}
|
||||
|
||||
static char *getDiskVersion(char *diskname)
|
||||
|
|
|
@ -74,7 +74,7 @@ int** kdk_bluetooth_get_device_id()
|
|||
free(id);
|
||||
return 0;
|
||||
}
|
||||
id[i] = di.dev_id;
|
||||
id[i] = (int*)di.dev_id;
|
||||
}
|
||||
// i = i + 1;
|
||||
id[i] = 0;
|
||||
|
@ -878,7 +878,7 @@ kdk_major_class kdk_bluetooth_get_major_class(int id)
|
|||
num_rsp = hci_inquiry(id, len, max_rsp, NULL, &ii, flags);
|
||||
if (num_rsp < 0)
|
||||
{
|
||||
close(sock);
|
||||
hci_close_dev(sock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -888,11 +888,11 @@ kdk_major_class kdk_bluetooth_get_major_class(int id)
|
|||
// printf("\t%s\tclock offset: 0x%4.4x\tclass: %2.2x\n",
|
||||
// addr, btohs((ii + i)->clock_offset),
|
||||
// (ii + i)->dev_class[0]);
|
||||
currnode = (kdk_major_class *)calloc(1, sizeof(major_class));
|
||||
currnode = (kdk_major_class)calloc(1, sizeof(major_class));
|
||||
if (!currnode)
|
||||
{
|
||||
free(ii);
|
||||
close(sock);
|
||||
hci_close_dev(sock);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -964,7 +964,7 @@ kdk_major_class kdk_bluetooth_get_major_class(int id)
|
|||
}
|
||||
|
||||
free(ii);
|
||||
close(sock);
|
||||
hci_close_dev(sock);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <dirent.h>
|
||||
#include "sys/sysinfo.h"
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include "unistd.h"
|
||||
#ifdef __linux__
|
||||
#include <sys/utsname.h>
|
||||
|
|
|
@ -22,27 +22,26 @@
|
|||
|
||||
#define _GNU_SOURCE # required for NI_NUMERICHOST
|
||||
#include "libkync.h"
|
||||
#include <cstring-extension.h>
|
||||
#include <errno.h>
|
||||
#include <kerr.h>
|
||||
#include <libkylog.h>
|
||||
#include "cstring-extension.h"
|
||||
#include "kerr.h"
|
||||
#include "libkylog.h"
|
||||
#include "sdkmarcos.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <kysdk/kysdk-base/sdkmarcos.h>
|
||||
#include <dirent.h>
|
||||
#include <glib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/if.h>
|
||||
#include <unistd.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <glib.h>
|
||||
#include <linux/sockios.h>
|
||||
#include <linux/ethtool.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#include <libnl3/netlink/netlink.h>
|
||||
|
@ -982,7 +981,7 @@ static void get_ipv6_addr_cache_cb(struct nl_object *obj, void *arg)
|
|||
char tmpbuf[bufsiz];
|
||||
char broadcast[bufsiz];
|
||||
|
||||
struct get_ipv6_addr_ctx_t *ctx = (struct get_ipv_addr_ctx_t *)arg;
|
||||
struct get_ipv6_addr_ctx_t *ctx = (struct get_ipv6_addr_ctx_t *)arg;
|
||||
struct rtnl_addr *rtnl_addr = (struct rtnl_addr *)obj;
|
||||
|
||||
if (rtnl_addr_get_ifindex(rtnl_addr) == ctx->index) {
|
||||
|
@ -1223,14 +1222,14 @@ char *kdk_nc_get_conn_type(const char *nc)
|
|||
if (!client) {
|
||||
klog_err("Error creating NMClient: %s\n", error->message);
|
||||
g_error_free(error);
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NMDevice *device = nm_client_get_device_by_iface(client, nc);
|
||||
if (!device)
|
||||
{
|
||||
klog_err("Failed to get device for interface eth0\n");
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
int type = nm_device_get_device_type(device);
|
||||
|
||||
|
@ -1396,7 +1395,7 @@ char *kdk_nc_get_speed(const char *nc)
|
|||
memset(&ifr, 0, sizeof(ifr));
|
||||
strcpy(ifr.ifr_name, nc);
|
||||
|
||||
ifr.ifr_data = &ecmd;
|
||||
ifr.ifr_data = (char*)&ecmd;
|
||||
int fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (!ioctl(fd, SIOCETHTOOL, &ifr)) {
|
||||
sprintf(speed, "%d Mb/s", ecmd.speed);
|
||||
|
|
|
@ -838,7 +838,7 @@ void kdk_usb_free_usb_info(pUsbInfo list)
|
|||
return;
|
||||
while (list)
|
||||
{
|
||||
pUsbInfo* tmp = list;
|
||||
pUsbInfo tmp = list;
|
||||
list = list->next;
|
||||
free(tmp);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -39,10 +38,10 @@ int main()
|
|||
char *packettype = "\0";
|
||||
char *features = "\0";
|
||||
char *bus = "\0";
|
||||
int **id = kdk_bluetooth_get_device_id();
|
||||
int *id = (int *)kdk_bluetooth_get_device_id();
|
||||
if(NULL == id)
|
||||
return 0;
|
||||
do
|
||||
for(; id[i]; i++)
|
||||
{
|
||||
printf("id = %d\n",id[i]);
|
||||
|
||||
|
@ -136,8 +135,8 @@ int main()
|
|||
kdk_bluetooth_free_major_class(major);
|
||||
}
|
||||
|
||||
free(id[i]);
|
||||
}while(id[i]);
|
||||
free(id);
|
||||
// free((int*)id[i]);
|
||||
}
|
||||
free((int**)id);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "../libkydisplay.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static _print_hw(struct HWInfo *hw)
|
||||
static void _print_hw(struct HWInfo *hw)
|
||||
{
|
||||
struct HWInfo *tmp = hw;
|
||||
while (tmp)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "../libkyprinter.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
|
@ -132,9 +132,7 @@ void* kdk_jpeg_encoder_init()
|
|||
klog_err("load %s failed\n",JPEG_ENCODER_LIB);
|
||||
return NULL;
|
||||
}
|
||||
get_handle p_get_handle = NULL;
|
||||
|
||||
*(void **) (&p_get_handle) = dlsym(libHandle, JPEG_ENCODER_GET_HANDLE);
|
||||
get_handle p_get_handle = dlsym(libHandle, JPEG_ENCODER_GET_HANDLE);
|
||||
if(!p_get_handle)
|
||||
{
|
||||
klog_err("undefined symbol:%s\n",JPEG_ENCODER_GET_HANDLE);
|
||||
|
@ -148,8 +146,7 @@ void* kdk_jpeg_encoder_init()
|
|||
klog_err("get image process handle failed\n");
|
||||
return NULL;
|
||||
}
|
||||
handle_init p_handle_init = NULL;
|
||||
*(void **) (&p_handle_init) = dlsym(libHandle, JPEG_ENCODER_HANDLE_INIT);
|
||||
handle_init p_handle_init = dlsym(libHandle, JPEG_ENCODER_HANDLE_INIT);
|
||||
if(!p_handle_init)
|
||||
{
|
||||
klog_err("undefined symbol:%s\n",JPEG_ENCODER_HANDLE_INIT);
|
||||
|
@ -182,15 +179,14 @@ int kdk_jpeg_encode_to_file(void *handle, char*srcFile, char *destFile)
|
|||
klog_err("load %s failed\n",JPEG_ENCODER_LIB);
|
||||
return -1;
|
||||
}
|
||||
get_handle p_encode_image = NULL;
|
||||
*(void **) (&p_encode_image) = (get_handle)dlsym(libHandle, JPEG_ENCODER_IMAGE_ENCODE);
|
||||
encode_image p_encode_image = dlsym(libHandle, JPEG_ENCODER_IMAGE_ENCODE);
|
||||
if(!p_encode_image)
|
||||
{
|
||||
klog_err("undefined symbol:%s\n",JPEG_ENCODER_IMAGE_ENCODE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = p_encode_image(handle , raw_data, width, height, destFile);
|
||||
int ret = p_encode_image(handle , (unsigned char*)raw_data, width, height, destFile);
|
||||
if (ret == -1) {
|
||||
klog_err("jpeg ecode image failed\n");
|
||||
kdk_jpeg_encoder_release(handle);
|
||||
|
@ -211,8 +207,7 @@ void kdk_jpeg_encoder_release(void* handle)
|
|||
klog_err("load %s failed\n",JPEG_ENCODER_LIB);
|
||||
return;
|
||||
}
|
||||
handle_release p_release_handle = NULL;
|
||||
*(void **) (&p_release_handle) = (handle_release)dlsym(libHandle, JPEG_ENCODER_HANDLE_RELEASE);
|
||||
handle_release p_release_handle = dlsym(libHandle, JPEG_ENCODER_HANDLE_RELEASE);
|
||||
if(!p_release_handle)
|
||||
{
|
||||
klog_err("undefined symbol:%s\n",JPEG_ENCODER_HANDLE_RELEASE);
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "stdio.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../libkylocation.h"
|
||||
|
||||
int main()
|
||||
|
|
|
@ -1320,7 +1320,7 @@ int kdk_net_get_link_type()
|
|||
if (sockfd < 0)
|
||||
{
|
||||
klog_err("[%s]->Socket creation failed\n", __func__);
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
ifc.ifc_len = sizeof(buf);
|
||||
|
@ -1329,7 +1329,7 @@ int kdk_net_get_link_type()
|
|||
{
|
||||
klog_err("[%s]->ioctl failed\n", __func__);
|
||||
close(sockfd);
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct ifreq *it = ifc.ifc_req;
|
||||
|
@ -1837,7 +1837,7 @@ Dhcp4Config *kdk_net_get_ipv4_dhcp_config()
|
|||
|
||||
for (int i = 0; 1; i++)
|
||||
{
|
||||
char *path[128];
|
||||
char path[128];
|
||||
memset(path, 0, 128);
|
||||
sprintf(path, "/org/freedesktop/NetworkManager/DHCP4Config/%d", i);
|
||||
// 创建DBus方法调用消息
|
||||
|
@ -2008,7 +2008,7 @@ Dhcp6Config *kdk_net_get_ipv6_dhcp_config()
|
|||
|
||||
for (int i = 0; 1; i++)
|
||||
{
|
||||
char *path[128];
|
||||
char path[128];
|
||||
memset(path, 0, 128);
|
||||
sprintf(path, "/org/freedesktop/NetworkManager/DHCP6Config/%d", i);
|
||||
// 创建DBus方法调用消息
|
||||
|
|
|
@ -203,7 +203,7 @@ static int get_desktop_info(char *dir_path, kdk_startmenu_list *programlist)
|
|||
static char *read_default_app(const char *filetype)
|
||||
{
|
||||
char *homeDir = getenv("HOME");
|
||||
char *filepath[PROGRAM_SIZE] = {0};
|
||||
char filepath[PROGRAM_SIZE] = {0};
|
||||
sprintf(filepath, "%s/.config/mimeapps.list", homeDir);
|
||||
FILE *fp = fopen(filepath, "r");
|
||||
char line[1024], *val = NULL;
|
||||
|
@ -526,7 +526,7 @@ char **kdk_package_get_code_path(const char *name)
|
|||
int kdk_package_get_file_count(const char *name)
|
||||
{
|
||||
if (NULL == name)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
int result = 0;
|
||||
char cmd[128];
|
||||
|
@ -560,7 +560,7 @@ int kdk_package_is_removable(const char *name)
|
|||
int kdk_package_verify_disk_space(const char *path)
|
||||
{
|
||||
if (NULL == path)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
int result = 0;
|
||||
|
||||
|
@ -657,7 +657,7 @@ kdk_startmenu_list *kdk_package_get_startmenu_list(void)
|
|||
get_desktop_info(KDK_DEKSTOP_FILE_PATH, programlist);
|
||||
|
||||
char *homeDir = getenv("HOME");
|
||||
char *filepath[PROGRAM_SIZE] = {0};
|
||||
char filepath[PROGRAM_SIZE] = {0};
|
||||
sprintf(filepath, "%s%s", homeDir, KDK_LOCALE_DEKSTOP_FILE_PATH);
|
||||
get_desktop_info(filepath, programlist);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "../libkypackages.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void print_package(kdk_package_t *package)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ static void *printStatus(DBusConnection *ptr, char *buf)
|
|||
dbus_message_unref(msg);
|
||||
// free(buf);
|
||||
}
|
||||
return ;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// 回调函数,当键值变化时被调用
|
||||
|
@ -115,7 +115,7 @@ void *actionDateChanged(void *ptr)
|
|||
|
||||
for (;;)
|
||||
g_main_context_iteration(NULL, TRUE);
|
||||
return ;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *version = "0.1";
|
||||
|
|
|
@ -2151,7 +2151,7 @@ int get_process_info(process_info *info, unsigned int *proc_num)
|
|||
sscanf(drd->d_name, "%ld", &(proc_info->proc_pid));
|
||||
get_proc_name(proc_info->proc_pid, proc_info->proc_name);
|
||||
|
||||
get_proc_state(proc_info->proc_pid, &(proc_info->proc_state));
|
||||
get_proc_state(proc_info->proc_pid, proc_info->proc_state);
|
||||
|
||||
get_proc_command(proc_info->proc_pid, proc_info->proc_command);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "ifaddrs.h"
|
||||
#include "math.h"
|
||||
#include "sys/types.h"
|
||||
#include <dbus-1.0/dbus/dbus.h>
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ char *kdk_storage_get_default_desktop_path()
|
|||
sprintf(path, "%s/%s", getenv("HOME"), "desktop");
|
||||
if (0 == access(path, F_OK))
|
||||
return strdup(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *kdk_storage_get_default_documents_path()
|
||||
|
@ -239,6 +240,7 @@ char *kdk_storage_get_default_documents_path()
|
|||
sprintf(path, "%s/%s", getenv("HOME"), "documents");
|
||||
if (0 == access(path, F_OK))
|
||||
return strdup(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *kdk_storage_get_default_internetCache_path(char *name)
|
||||
|
@ -272,6 +274,7 @@ char *kdk_storage_get_default_download_path()
|
|||
sprintf(path, "%s/%s", getenv("HOME"), "download");
|
||||
if (0 == access(path, F_OK))
|
||||
return strdup(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *kdk_storage_get_file_ContentType(char *file_name)
|
||||
|
@ -315,7 +318,7 @@ char *kdk_storage_get_file_dateChange(char *file_name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *time[32];
|
||||
char time[32];
|
||||
strftime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_ctime));
|
||||
|
||||
return strdup(time);
|
||||
|
@ -331,7 +334,7 @@ char *kdk_storage_get_file_dateModify(char *file_name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *time[32];
|
||||
char time[32];
|
||||
strftime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_mtime));
|
||||
|
||||
return strdup(time);
|
||||
|
@ -347,7 +350,7 @@ char *kdk_storage_get_file_dateAccess(char *file_name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char *time[32];
|
||||
char time[32];
|
||||
strftime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", localtime(&file_stat.st_atime));
|
||||
|
||||
return strdup(time);
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "pci/pci.h"
|
||||
#include "sys/sysinfo.h"
|
||||
#include <pthread.h>
|
||||
#include <glib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define SAFE_FREE(x) \
|
||||
if (x) \
|
||||
|
@ -1675,7 +1677,7 @@ char **kdk_system_get_shutdown_time()
|
|||
if ((strncmp(u->ut_user, "shutdown", 8) == 0))
|
||||
{
|
||||
#if __WORDSIZE_TIME64_COMPAT32
|
||||
time_t tmp = (time_t *)((long)(u->ut_tv.tv_sec));
|
||||
time_t tmp = (time_t)(u->ut_tv.tv_sec);
|
||||
info = gmtime(&tmp);
|
||||
#else
|
||||
info = gmtime((time_t *)(&u->ut_tv.tv_sec));
|
||||
|
@ -2698,7 +2700,7 @@ static volatile int running = 0;
|
|||
static char *curr_user = NULL;
|
||||
CallBack _callback = NULL;
|
||||
|
||||
static void signal_handler(DBusConnection *connection, DBusMessage *message, void *user_data)
|
||||
static DBusHandlerResult signal_handler(DBusConnection *connection, DBusMessage *message, void *user_data)
|
||||
{
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
|
@ -2729,12 +2731,12 @@ static void signal_handler(DBusConnection *connection, DBusMessage *message, voi
|
|||
dbus_message_iter_next(&value_iter);
|
||||
dbus_message_iter_get_basic(&value_iter, &session_path);
|
||||
|
||||
//切换tty会出发信号,切换到tty1 tty2等终端,但这些没有用户登录时,不相应
|
||||
// 切换tty会出发信号,切换到tty1 tty2等终端,但这些没有用户登录时,不相应
|
||||
if (0 == strcmp("/", session_path))
|
||||
{
|
||||
// free(curr_user);
|
||||
// curr_user = NULL;
|
||||
return;
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
// 创建DBus方法调用消息
|
||||
|
@ -2753,7 +2755,7 @@ static void signal_handler(DBusConnection *connection, DBusMessage *message, voi
|
|||
{
|
||||
klog_err("Error sending message: %s\n", err.message);
|
||||
dbus_error_free(&err);
|
||||
return 1;
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
// 处理响应
|
||||
|
@ -2775,10 +2777,9 @@ static void signal_handler(DBusConnection *connection, DBusMessage *message, voi
|
|||
free(curr_user);
|
||||
curr_user = strdup(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
void *dbus_listener_thread(void *data)
|
||||
|
@ -3026,18 +3027,17 @@ unsigned int kdk_system_get_thread_nums()
|
|||
return threadCount;
|
||||
}
|
||||
|
||||
#define LOAD_AVG_INIT {0.0, 0.0, 0.0}
|
||||
kdk_loadavg kdk_system_get_loadavg()
|
||||
{
|
||||
struct sysinfo info;
|
||||
kdk_loadavg loadAvg;
|
||||
kdk_loadavg loadAvg = LOAD_AVG_INIT;
|
||||
int rc = sysinfo(&info);
|
||||
if (!rc) {
|
||||
loadAvg.loadavg_1m = info.loads[0];
|
||||
loadAvg.loadavg_5m = info.loads[1];
|
||||
loadAvg.loadavg_15m = info.loads[2];
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
return loadAvg;
|
||||
}
|
||||
#undef LOAD_AVG_INIT
|
||||
|
|
|
@ -231,7 +231,7 @@ out:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void *print_longDate(DBusConnection *ptr)
|
||||
static void print_longDate(DBusConnection *ptr)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
|
@ -319,7 +319,7 @@ out:
|
|||
return ;
|
||||
}
|
||||
|
||||
static void *print_shortDate(DBusConnection *ptr)
|
||||
static void print_shortDate(DBusConnection *ptr)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
|
@ -454,7 +454,7 @@ out:
|
|||
return ;
|
||||
}
|
||||
|
||||
static void *print_Time(DBusConnection *ptr)
|
||||
static void print_Time(DBusConnection *ptr)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
|
@ -537,6 +537,41 @@ out:
|
|||
return ;
|
||||
}
|
||||
|
||||
int monitorSystemDateChange(int fd){
|
||||
|
||||
char *homeDir = NULL;
|
||||
char *realpath_res = NULL;
|
||||
char filename[PATH_MAX_H] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
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;
|
||||
struct inotify_event *event;
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int ret = read(fd, buf, sizeof(buf) - 1);
|
||||
event = (struct inotify_event *)&buf[0];
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stdout, "%s --- %s\n", event->name, "IN_DELETE | IN_MODIFY");
|
||||
if (event->mask & (IN_DELETE | IN_DELETE_SELF))
|
||||
{
|
||||
int fdate = inotify_add_watch(fd, path, IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY | IN_MOVE_SELF );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *actionDateChanged(void *ptr)
|
||||
{
|
||||
DBusConnection *conn = NULL;
|
||||
|
@ -553,7 +588,7 @@ void *actionDateChanged(void *ptr)
|
|||
homeDir = getenv("HOME");
|
||||
if (!realpath(homeDir, fname) || !verify_file(fname))
|
||||
{
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
sprintf(path, "%s/.config/kydate/dateformat.conf", fname);
|
||||
sprintf(strpath, "%s/.config/kydate/", fname);
|
||||
|
@ -642,41 +677,6 @@ void *actionDateChanged(void *ptr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int monitorSystemDateChange(int fd){
|
||||
|
||||
char *homeDir = NULL;
|
||||
char *realpath_res = NULL;
|
||||
char filename[PATH_MAX_H] = "\0";
|
||||
|
||||
homeDir = getenv("HOME");
|
||||
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;
|
||||
struct inotify_event *event;
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int ret = read(fd, buf, sizeof(buf) - 1);
|
||||
event = (struct inotify_event *)&buf[0];
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stdout, "%s --- %s\n", event->name, "IN_DELETE | IN_MODIFY");
|
||||
if (event->mask & (IN_DELETE | IN_DELETE_SELF))
|
||||
{
|
||||
int fdate = inotify_add_watch(fd, path, IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY | IN_MOVE_SELF );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *version = "0.1";
|
||||
GMainLoop *mainloop;
|
||||
|
||||
|
|
Loading…
Reference in New Issue