summaryrefslogtreecommitdiff
path: root/src/libudev
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-01-09 17:45:59 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-01-09 17:45:59 -0500
commitf62066f5da62f622ccf5ebad03e56c7839d1fd53 (patch)
tree2e978756393fbc73087288f54387b1127ce7b555 /src/libudev
parentc57e300090145dc185bd3f85d7d8dcf1cb85fa81 (diff)
src/libudev/util.h: add missing FOREACH_LINE
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev')
-rw-r--r--src/libudev/util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libudev/util.h b/src/libudev/util.h
index 88bd771a82..22f48b44ad 100644
--- a/src/libudev/util.h
+++ b/src/libudev/util.h
@@ -278,6 +278,15 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar) (const void *, const void *, void *),
void *arg);
+#define FOREACH_LINE(line, f, on_error) \
+ for (;;) \
+ if (!fgets(line, sizeof(line), f)) { \
+ if (ferror(f)) { \
+ on_error; \
+ } \
+ break; \
+ } else
+
static inline void _reset_errno_(int *saved_errno) {
errno = *saved_errno;
}