Index: EcnlProtoTool/trunk/ntshell/src/fdtable.h
===================================================================
--- EcnlProtoTool/trunk/ntshell/src/fdtable.h	(revision 439)
+++ EcnlProtoTool/trunk/ntshell/src/fdtable.h	(revision 441)
@@ -35,93 +35,32 @@
  *  @(#) $Id$
  */
-#ifndef SOCKET_STUB_H
-#define SOCKET_STUB_H
+#ifndef _FDTABLE_H_
+#define _FDTABLE_H_
 
-struct addrinfo {
-	int ai_flags;
-	int ai_family;
-	int ai_socktype;
-	int ai_protocol;
-	socklen_t ai_addrlen;
-	struct sockaddr *ai_addr;
-	char *ai_canonname;
-	struct addrinfo *ai_next;
-};
+typedef const struct io_type_s IO_TYPE;
 
-typedef uint16_t in_port_t;
-typedef uint32_t in_addr_t;
-struct in_addr { in_addr_t s_addr; };
-
-struct sockaddr_in {
-	sa_family_t sin_family;
-	in_port_t sin_port;
-	struct in_addr sin_addr;
-	uint8_t sin_zero[8];
-};
-
-struct in6_addr
-{
-	union {
-		uint8_t __s6_addr[16];
-		uint16_t __s6_addr16[8];
-		uint32_t __s6_addr32[4];
-	} __in6_union;
-};
-//#define s6_addr __in6_union.__s6_addr
-//#define s6_addr16 __in6_union.__s6_addr16
-//#define s6_addr32 __in6_union.__s6_addr32
-
-struct sockaddr_in6
-{
-	sa_family_t     sin6_family;
-	in_port_t       sin6_port;
-	uint32_t        sin6_flowinfo;
-	struct in6_addr sin6_addr;
-	uint32_t        sin6_scope_id;
-};
-
-typedef struct socket_t {
-	int family;
-	int type;
-	int protocol;
-	int cepid;
-	int repid;
-	int backlog;
-	unsigned int flags;
-	union {
-		struct sockaddr_in laddr4;
-		struct sockaddr_in6 laddr6;
-	};
-	union {
-		struct sockaddr_in raddr4;
-		struct sockaddr_in6 raddr6;
-	};
-	int buf_size;
-	unsigned char *buf;
-} socket_t;
-
-struct _IO_FILE {
+struct SHELL_FILE {
 	int fd;
-	int type;
+	IO_TYPE *type;
 	int handle;
-	int (*close)(struct _IO_FILE *);
-	size_t (*read)(struct _IO_FILE *, unsigned char *, size_t);
-	size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t);
-	off_t (*seek)(struct _IO_FILE *, off_t, int);
-	int (*ioctl)(struct _IO_FILE *, int, void *);
 	int readevt_r;
 	int readevt_w;
 	int writeevt_r;
 	int writeevt_w;
+	int writable;
 	int errorevt_r;
 	int errorevt_w;
-	union {
-		FIL file;
-		struct {
-			FATFS_DIR dir;
-			struct dirent dirent;
-		};
-		socket_t socket;
-	};
+	void *exinf;
+};
+
+struct io_type_s {
+	const int (*close)(struct SHELL_FILE *);
+	const size_t (*read)(struct SHELL_FILE *, unsigned char *, size_t);
+	const size_t (*write)(struct SHELL_FILE *, const unsigned char *, size_t);
+	const off_t (*seek)(struct SHELL_FILE *, off_t, int);
+	const int (*ioctl)(struct SHELL_FILE *, int, void *);
+	const bool_t (*readable)(struct SHELL_FILE *);
+	const bool_t (*writable)(struct SHELL_FILE *);
+	const void (*delete)(struct SHELL_FILE *);
 };
 
@@ -136,68 +75,11 @@
 #endif
 
-extern int stdio_close(struct _IO_FILE *fp);
-extern size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
+struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable);
+int delete_fd_by_id(IO_TYPE *type, int id);
+struct SHELL_FILE *fd_to_fp(int fd);
+struct SHELL_FILE *id_to_fd(IO_TYPE *type, int id);
 
-extern int sio_close(struct _IO_FILE *fp);
-extern size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org);
-extern int sio_ioctl(struct _IO_FILE *fp, int req, void *arg);
-
-extern int file_close(struct _IO_FILE *fp);
-extern size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern off_t file_seek(struct _IO_FILE *fp, off_t ofs, int org);
-extern int file_ioctl(struct _IO_FILE *fp, int req, void *arg);
-
-extern int dir_close(struct _IO_FILE *fp);
-extern size_t dir_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t dir_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern off_t dir_seek(struct _IO_FILE *fp, off_t ofs, int org);
-extern int dir_ioctl(struct _IO_FILE *fp, int req, void *arg);
-
-extern int tcp_fd_close(struct _IO_FILE *fp);
-extern size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org);
-extern int tcp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg);
-
-extern int udp_fd_close(struct _IO_FILE *fp);
-extern size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
-extern size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
-extern off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org);
-extern int udp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg);
-
-struct _IO_FILE *fd_to_fp(int fd);
-
-struct _IO_FILE *new_sio_fd(int sioid);
-int delete_sio_fd(int sioid);
-struct _IO_FILE *sioid_to_fd(int sioid);
-
-struct _IO_FILE *new_file_fd(int fileid);
-int delete_file_fd(int fileid);
-struct _IO_FILE *fileid_to_fd(int fileid);
-
-struct _IO_FILE *new_dir_fd(int dirid);
-int delete_dir_fd(int dirid);
-struct _IO_FILE *dirid_to_fd(int dirid);
-
-struct _IO_FILE *new_tcp_fd(int tcpid);
-int delete_tcp_fd(int tcpid);
-struct _IO_FILE *tcpid_to_fd(int tcpid);
-
-struct _IO_FILE *new_udp_fd(int udpid);
-int delete_udp_fd(int udpid);
-struct _IO_FILE *udpid_to_fd(int udpid);
-
-int delete_tcp_rep(int repid);
+int delete_fp(struct SHELL_FILE *fp);
 void clean_fd();
 
-ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk);
-ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk);
-
-#endif // !SOCKET_STUB_H
+#endif /* _FDTABLE_H_ */
