aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-27 20:14:06 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-28 14:31:59 +1000
commit1756cc5943aa545f2f18fff60d56ad0886ef6145 (patch)
tree7bbc6daad68365a33898e54ee1a1161b4cfd596a /include
parent0c970511cc230abd19c1a30058174cbf03222648 (diff)
downloadbusybox-w32-1756cc5943aa545f2f18fff60d56ad0886ef6145.tar.gz
busybox-w32-1756cc5943aa545f2f18fff60d56ad0886ef6145.tar.bz2
busybox-w32-1756cc5943aa545f2f18fff60d56ad0886ef6145.zip
libbb/strbuf_file: stdio emulation layer for handling with Winsock handles
not really robust, but enough to make wget works
Diffstat (limited to 'include')
-rw-r--r--include/strbuf_file.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/include/strbuf_file.h b/include/strbuf_file.h
new file mode 100644
index 000000000..73eff9193
--- /dev/null
+++ b/include/strbuf_file.h
@@ -0,0 +1,69 @@
1#include "strbuf.h"
2
3struct strbuf_file {
4 struct strbuf input;
5 int has_error;
6 int fd;
7};
8
9struct strbuf_file *sfdopen(int fd, const char *mode);
10int sfclose(struct strbuf_file *sf);
11int sfprintf(struct strbuf_file *sf, const char *fmt, ...);
12void sfclearerr(struct strbuf_file *sf);
13int sfread(char *buf, int size, int n, struct strbuf_file *sf);
14char *sfgets(char *buf, int size, struct strbuf_file *sf);
15int sfgetc(struct strbuf_file *sf);
16
17#ifdef REPLACE_STDIO
18
19#ifdef FILE
20#undef FILE
21#endif
22#define FILE struct strbuf_file
23
24#ifdef fdopen
25#undef fdopen
26#endif
27#define fdopen(fd,mode) sfdopen(fd,mode)
28
29#ifdef fclose
30#undef fclose
31#endif
32#define fclose(fp) sfclose(fp)
33
34#ifdef fprintf
35#undef fprintf
36#endif
37#define fprintf sfprintf
38
39#ifdef fread
40#undef fread
41#endif
42#define fread(buf,s,n,fp) sfread(buf,s,n,fp)
43
44#ifdef clearerr
45#undef clearerr
46#endif
47#define clearerr(fp) sfclearerr(fp)
48
49#ifdef ferror
50#undef ferror
51#endif
52#define ferror(fp) ((fp)->has_error)
53
54#ifdef fgets
55#undef fgets
56#endif
57#define fgets(buf,n,fp) sfgets(buf,n,fp)
58
59#ifdef getc
60#undef getc
61#endif
62#define getc(fp) sfgetc(fp)
63
64#ifdef fflush
65#undef fflush
66#endif
67#define fflush(fp) 0
68
69#endif