X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=libsysfs%2Fsysfs.h;h=838427797dda5570cc567cefe89a560c117d0377;hb=18614ab25d4208749a3d85ced33acc6679c60fce;hp=1b800ddcd2311104697370c5d03093c8200b1b43;hpb=df41554d990fd9e69495253b4dc1979c6cd8621f;p=elogind.git diff --git a/libsysfs/sysfs.h b/libsysfs/sysfs.h index 1b800ddcd..838427797 100644 --- a/libsysfs/sysfs.h +++ b/libsysfs/sysfs.h @@ -27,19 +27,36 @@ #include #include #include +#include #include #include #include #include -#include "dlist.h" + +#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