소스 검색

add isastream (obsolete STREAMS junk)

apparently some packages see stropts.h and want to be able to use
this. the implementation checks that the file descriptor is valid by
using fcntl/F_GETFD so it can report an error if not (as specified).
Rich Felker 13 년 전
부모
커밋
106e75f712
2개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      include/stropts.h
  2. 7 0
      src/misc/isastream.c

+ 2 - 1
include/stropts.h

@@ -129,7 +129,8 @@ struct str_list {
 	struct str_mlist *sl_modlist;
 };
 
-int ioctl (int, int, ...);
+int isastream(int);
+int ioctl(int, int, ...);
 
 #ifdef __cplusplus
 }

+ 7 - 0
src/misc/isastream.c

@@ -0,0 +1,7 @@
+#include <stropts.h>
+#include <fcntl.h>
+
+int isastream(int fd)
+{
+	return fcntl(fd, F_GETFD) < 0 ? -1 : 0;
+}