diff options
author | Dan McGee <dpmcgee@gmail.com> | 2009-04-19 11:54:26 -0500 |
---|---|---|
committer | Dan McGee <dpmcgee@gmail.com> | 2009-04-19 11:54:26 -0500 |
commit | 7db9c29af1dbd403f880e61e5e71e022f0597165 (patch) | |
tree | 3bd90320236d2ae951697a1c49f4003443564368 /util.c | |
parent | 8e55b21c2caacab9fd5f7c4917c4109e04af05b5 (diff) | |
download | onkyocontrol-7db9c29af1dbd403f880e61e5e71e022f0597165.tar.gz onkyocontrol-7db9c29af1dbd403f880e61e5e71e022f0597165.zip |
Add some stuff to util
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -18,15 +18,34 @@ */ #include <stdlib.h> /* malloc */ +#include <sys/stat.h> /* open */ +#include <fcntl.h> /* open */ #include <unistd.h> /* close, read, write */ #include <errno.h> /* for errno refs */ #include <string.h> /* memcpy */ #include "onkyo.h" -void xclose(int fd) +int xopen(const char *path, int oflag) { - while(close(fd) && errno == EINTR); + int fd; + while(1) { + fd = open(path, oflag); + if ((fd < 0) && errno == EINTR) + continue; + return(fd); + } +} + +int xclose(int fd) +{ + int nr; + while(1) { + nr = close(fd); + if((nr < 0) && errno == EINTR) + continue; + return(nr); + } } ssize_t xread(int fd, void *buf, size_t len) @@ -87,3 +106,4 @@ char *strdup(const char *s) } #endif /* strdup */ +/* vim: set ts=4 sw=4 noet: */ |