aboutsummaryrefslogtreecommitdiffstats
path: root/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tcp.c b/tcp.c
index 454df75..50ae891 100644
--- a/tcp.c
+++ b/tcp.c
@@ -179,6 +179,32 @@ int unix_connect(char *path)
return sock;
}
+int cdev_connect(char *path)
+{
+ struct stat st;
+ char *opts;
+ int fd;
+
+ opts = strchr(path,',');
+ if (opts) {
+ *opts = 0;
+ opts++;
+ }
+
+ fd = open(path, O_RDWR);
+ if (fd == -1) {
+ fprintf(stderr, "open %s: %s\n", path, strerror(errno));
+ return -1;
+ }
+ fstat(fd, &st);
+ if (!S_ISCHR(st.st_mode)) {
+ fprintf(stderr, "not a character device: %s\n", path);
+ close(fd);
+ return -1;
+ }
+ return fd;
+}
+
int pipe_connect(char *path)
{
struct stat st;