chiark / gitweb /
[PATCH] conditional remove of trailing sysfs whitespace
[elogind.git] / udev.h
diff --git a/udev.h b/udev.h
index 3b676acf40d99ab1a7a137dbbe49804b80f6ecde..32fda379e54e467965bce37735580ab2540c6f92 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -85,6 +85,24 @@ do { \
        strncat(to, from, maxsize - strlen(to)-1); \
 } while (0)
 
+#define strintcat(to, i) \
+do { \
+       to[sizeof(to)-1] = '\0'; \
+       snprintf((to) + strlen(to), sizeof(to) - strlen(to)-1, "%u", i); \
+} while (0)
+
+#define strnintcat(to, i, maxsize) \
+do { \
+       to[maxsize-1] = '\0'; \
+       snprintf((to) + strlen(to), maxsize - strlen(to)-1, "%u", i); \
+} while (0)
+
+#define foreach_strpart(str, separator, pos, len) \
+       for(pos = str, len = 0; \
+           (pos) < ((str) + strlen(str)); \
+           pos = pos + len + strspn(pos, separator), len = strcspn(pos, separator)) \
+               if (len > 0)
+
 static inline char *get_action(void)
 {
        char *action;