]> git.donarmstrong.com Git - samtools.git/blob - knetfile.h
* samtools-0.1.4-18 (r363)
[samtools.git] / knetfile.h
1 #ifndef KNETFILE_H
2 #define KNETFILE_H
3
4 #include <stdint.h>
5 #include <fcntl.h>
6
7 // FIXME: currently I/O is unbuffered
8
9 #define KNF_TYPE_LOCAL 1
10 #define KNF_TYPE_FTP   2
11 #define KNF_TYPE_HTTP  3
12
13 typedef struct knetFile_s {
14         int type, fd;
15         int64_t offset;
16         char *host;
17
18         // the following are for FTP only
19         int ctrl_fd, pasv_ip[4], pasv_port, max_response, no_reconnect, is_ready;
20         char *response, *retr;
21         int64_t seek_offset; // for lazy seek
22 } knetFile;
23
24 #define knet_tell(fp) ((fp)->offset)
25 #define knet_fileno(fp) ((fp)->fd)
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31         knetFile *knet_open(const char *fn, const char *mode);
32         knetFile *knet_dopen(int fd, const char *mode);
33         off_t knet_read(knetFile *fp, void *buf, off_t len);
34         int knet_seek(knetFile *fp, off_t off, int whence);
35         int knet_close(knetFile *fp);
36
37 #ifdef __cplusplus
38 }
39 #endif
40
41 #endif