X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=libsysfs%2Fsysfs.h;h=2add8227a49a544f28c1af2ada6f2c37be892c9f;hb=1196e46c339e0df96ee972a5bae5cc8f84bf8990;hp=49c9285bc37aa1c874ca4fa6833cc8a429608d87;hpb=95a6f4c8acafe7031087667aa556a50a6a091c93;p=elogind.git diff --git a/libsysfs/sysfs.h b/libsysfs/sysfs.h index 49c9285bc..2add8227a 100644 --- a/libsysfs/sysfs.h +++ b/libsysfs/sysfs.h @@ -3,7 +3,7 @@ * * Internal Header Definitions for libsysfs * - * Copyright (C) IBM Corp. 2003 + * Copyright (C) IBM Corp. 2003-2005 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,18 +27,36 @@ #include #include #include +#include #include #include #include #include +#define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1) +#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1) + +#define safestrcpymax(to, from, max) \ +do { \ + to[max-1] = '\0'; \ + strncpy(to, from, max-1); \ +} while (0) + +#define safestrcatmax(to, from, max) \ +do { \ + to[max-1] = '\0'; \ + strncat(to, from, max - strlen(to)-1); \ +} while (0) + +extern struct sysfs_attribute *get_attribute(void *dev, const char *name); +extern struct dlist *read_dir_subdirs(const char *path); +extern struct dlist *read_dir_links(const char *path); +extern struct dlist *get_attributes_list(void *dev); + /* Debugging */ #ifdef DEBUG -#include "../logging.h" -#define dprintf(format, arg...) \ - do { \ - log_message (LOG_DEBUG , "%s: " format , __FUNCTION__ , ## arg); \ - } while (0) +#include "../logging.h" +#define dprintf(format, arg...) dbg(format, ## arg) #else #define dprintf(format, arg...) do { } while (0) #endif