From ed72f6d833d6a66d8a1219d3be5258475f69c862 Mon Sep 17 00:00:00 2001 From: tianshaoshuai Date: Fri, 6 Sep 2024 10:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8gcc14?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/disk/libkydiskinfo.c | 10 ++-- src/hardware/libkybluetooth.c | 10 ++-- src/hardware/libkycpu.c | 1 + src/hardware/libkync.c | 29 +++++---- src/hardware/libkyusb.c | 2 +- src/hardware/test/kybluetooth-test.c | 11 ++-- src/hardware/test/kydisplay-test.c | 1 + src/hardware/test/kyhw-test.c | 2 +- src/hardware/test/kyprinterprint-test.c | 2 + src/image/libkyimageproc.c | 15 ++--- src/location/test/kylocation-test.c | 3 +- src/net/libkynetinfo.c | 8 +-- src/packages/libkypackages.c | 8 +-- src/packages/test/kypackage-test.c | 1 + src/powermanagement/powermanager.c | 4 +- src/proc/libkyprocess.c | 2 +- src/realtime/libkyrealtimeinfo.c | 1 + src/storage/libkystorage.c | 9 ++- src/systeminfo/libkysysinfo.c | 22 +++---- src/systemtime/date.c | 78 ++++++++++++------------- 20 files changed, 111 insertions(+), 108 deletions(-) diff --git a/src/disk/libkydiskinfo.c b/src/disk/libkydiskinfo.c index fb9622b..aae95b2 100644 --- a/src/disk/libkydiskinfo.c +++ b/src/disk/libkydiskinfo.c @@ -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) diff --git a/src/hardware/libkybluetooth.c b/src/hardware/libkybluetooth.c index 0df3990..4a19bc5 100644 --- a/src/hardware/libkybluetooth.c +++ b/src/hardware/libkybluetooth.c @@ -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; } diff --git a/src/hardware/libkycpu.c b/src/hardware/libkycpu.c index b44168f..7dd83a5 100644 --- a/src/hardware/libkycpu.c +++ b/src/hardware/libkycpu.c @@ -31,6 +31,7 @@ #include #include "sys/sysinfo.h" #include +#include #include "unistd.h" #ifdef __linux__ #include diff --git a/src/hardware/libkync.c b/src/hardware/libkync.c index 72b734c..107fa1e 100644 --- a/src/hardware/libkync.c +++ b/src/hardware/libkync.c @@ -22,27 +22,26 @@ #define _GNU_SOURCE # required for NI_NUMERICHOST #include "libkync.h" -#include -#include -#include -#include +#include "cstring-extension.h" +#include "kerr.h" +#include "libkylog.h" +#include "sdkmarcos.h" + #include +#include +#include #include -#include +#include +#include #include #include -#include -#include +#include #include #include #include #include -#include -#include -#include #include #include -#include #include #include @@ -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); diff --git a/src/hardware/libkyusb.c b/src/hardware/libkyusb.c index 64735c2..558cd60 100644 --- a/src/hardware/libkyusb.c +++ b/src/hardware/libkyusb.c @@ -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); } diff --git a/src/hardware/test/kybluetooth-test.c b/src/hardware/test/kybluetooth-test.c index 7f9858a..4f53ee7 100644 --- a/src/hardware/test/kybluetooth-test.c +++ b/src/hardware/test/kybluetooth-test.c @@ -24,7 +24,6 @@ #include #include - 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; } diff --git a/src/hardware/test/kydisplay-test.c b/src/hardware/test/kydisplay-test.c index 3dc1c98..4236663 100644 --- a/src/hardware/test/kydisplay-test.c +++ b/src/hardware/test/kydisplay-test.c @@ -22,6 +22,7 @@ #include "../libkydisplay.h" #include +#include int main() { diff --git a/src/hardware/test/kyhw-test.c b/src/hardware/test/kyhw-test.c index a5e1e1d..01dd60f 100644 --- a/src/hardware/test/kyhw-test.c +++ b/src/hardware/test/kyhw-test.c @@ -24,7 +24,7 @@ #include #include -static _print_hw(struct HWInfo *hw) +static void _print_hw(struct HWInfo *hw) { struct HWInfo *tmp = hw; while (tmp) diff --git a/src/hardware/test/kyprinterprint-test.c b/src/hardware/test/kyprinterprint-test.c index 76f8845..a0a41c8 100644 --- a/src/hardware/test/kyprinterprint-test.c +++ b/src/hardware/test/kyprinterprint-test.c @@ -22,6 +22,8 @@ #include "../libkyprinter.h" #include +#include +#include int main() { diff --git a/src/image/libkyimageproc.c b/src/image/libkyimageproc.c index 5595556..895ce75 100644 --- a/src/image/libkyimageproc.c +++ b/src/image/libkyimageproc.c @@ -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); diff --git a/src/location/test/kylocation-test.c b/src/location/test/kylocation-test.c index 7c2228f..53b4911 100644 --- a/src/location/test/kylocation-test.c +++ b/src/location/test/kylocation-test.c @@ -20,7 +20,8 @@ * */ -#include "stdio.h" +#include +#include #include "../libkylocation.h" int main() diff --git a/src/net/libkynetinfo.c b/src/net/libkynetinfo.c index 0730b11..22790fe 100644 --- a/src/net/libkynetinfo.c +++ b/src/net/libkynetinfo.c @@ -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方法调用消息 diff --git a/src/packages/libkypackages.c b/src/packages/libkypackages.c index acf0318..4fdad20 100644 --- a/src/packages/libkypackages.c +++ b/src/packages/libkypackages.c @@ -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); diff --git a/src/packages/test/kypackage-test.c b/src/packages/test/kypackage-test.c index 203b178..14e519e 100644 --- a/src/packages/test/kypackage-test.c +++ b/src/packages/test/kypackage-test.c @@ -22,6 +22,7 @@ #include "../libkypackages.h" #include +#include static void print_package(kdk_package_t *package) { diff --git a/src/powermanagement/powermanager.c b/src/powermanagement/powermanager.c index 27e740b..67584ed 100644 --- a/src/powermanagement/powermanager.c +++ b/src/powermanagement/powermanager.c @@ -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"; diff --git a/src/proc/libkyprocess.c b/src/proc/libkyprocess.c index 099ba3f..f551b2f 100644 --- a/src/proc/libkyprocess.c +++ b/src/proc/libkyprocess.c @@ -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); diff --git a/src/realtime/libkyrealtimeinfo.c b/src/realtime/libkyrealtimeinfo.c index 42cb4c0..5b8ba46 100644 --- a/src/realtime/libkyrealtimeinfo.c +++ b/src/realtime/libkyrealtimeinfo.c @@ -28,6 +28,7 @@ #include "stdlib.h" #include "string.h" #include "ifaddrs.h" +#include "math.h" #include "sys/types.h" #include diff --git a/src/storage/libkystorage.c b/src/storage/libkystorage.c index 9000758..b8251ab 100644 --- a/src/storage/libkystorage.c +++ b/src/storage/libkystorage.c @@ -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); diff --git a/src/systeminfo/libkysysinfo.c b/src/systeminfo/libkysysinfo.c index e9aa000..2a63597 100644 --- a/src/systeminfo/libkysysinfo.c +++ b/src/systeminfo/libkysysinfo.c @@ -41,6 +41,8 @@ #include "pci/pci.h" #include "sys/sysinfo.h" #include +#include +#include #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 diff --git a/src/systemtime/date.c b/src/systemtime/date.c index eda04e6..319f804 100644 --- a/src/systemtime/date.c +++ b/src/systemtime/date.c @@ -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;