8 #define netread(fd, ptr, len) read(fd, ptr, len)
9 #define netwrite(fd, ptr, len) write(fd, ptr, len)
10 #define netclose(fd) close(fd)
13 #define netread(fd, ptr, len) recv(fd, ptr, len, 0)
14 #define netwrite(fd, ptr, len) send(fd, ptr, len, 0)
15 #define netclose(fd) closesocket(fd)
18 // FIXME: currently I/O is unbuffered
20 #define KNF_TYPE_LOCAL 1
21 #define KNF_TYPE_FTP 2
22 #define KNF_TYPE_HTTP 3
24 typedef struct knetFile_s
30 // the following are for FTP only
31 int ctrl_fd
, pasv_ip
[4], pasv_port
, max_response
, no_reconnect
, is_ready
;
32 char * response
, *retr
, *size_cmd
;
33 int64_t seek_offset
; // for lazy seek
36 // the following are for HTTP only
37 char * path
, *http_host
;
40 #define knet_tell(fp) ((fp)->offset)
41 #define knet_fileno(fp) ((fp)->fd)
48 int knet_win32_init();
49 void knet_win32_destroy();
52 knetFile
* knet_open ( const char * fn
, const char * mode
);
55 This only works with local files.
57 knetFile
* knet_dopen ( int fd
, const char * mode
);
60 If ->is_ready==0, this routine updates ->fd; otherwise, it simply
63 off_t
knet_read ( knetFile
* fp
, void * buf
, off_t len
);
66 This routine only sets ->offset and ->is_ready=0. It does not
67 communicate with the FTP server.
69 off_t
knet_seek ( knetFile
* fp
, int64_t off
, int whence
);
70 int knet_close ( knetFile
* fp
);