diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-13 22:43:15 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-20 19:14:35 +0200 |
commit | 7ea0d136d0e819ddec8a5f794fa537b761ae4a3d (patch) | |
tree | c532929f7742fc107c683d3d1153e7b47b246aec /win32 | |
parent | cd30b61a228591076fa68b28e30f4198057cb211 (diff) | |
download | busybox-w32-7ea0d136d0e819ddec8a5f794fa537b761ae4a3d.tar.gz busybox-w32-7ea0d136d0e819ddec8a5f794fa537b761ae4a3d.tar.bz2 busybox-w32-7ea0d136d0e819ddec8a5f794fa537b761ae4a3d.zip |
win32: remove git.c (probably not correct)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'win32')
-rw-r--r-- | win32/git.c | 91 | ||||
-rw-r--r-- | win32/strbuf.c | 18 |
2 files changed, 17 insertions, 92 deletions
diff --git a/win32/git.c b/win32/git.c deleted file mode 100644 index 668f8c118..000000000 --- a/win32/git.c +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | #include "libbb.h" | ||
2 | #include "git.h" | ||
3 | |||
4 | #define die bb_error_msg_and_die | ||
5 | |||
6 | /* | ||
7 | * xwrite() is the same a write(), but it automatically restarts write() | ||
8 | * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT | ||
9 | * GUARANTEE that "len" bytes is written even if the operation is successful. | ||
10 | */ | ||
11 | ssize_t _xwrite(int fd, const void *buf, size_t len) | ||
12 | { | ||
13 | ssize_t nr; | ||
14 | while (1) { | ||
15 | nr = write(fd, buf, len); | ||
16 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
17 | continue; | ||
18 | return nr; | ||
19 | } | ||
20 | } | ||
21 | |||
22 | ssize_t _xread(int fd, void *buf, size_t len) | ||
23 | { | ||
24 | ssize_t nr; | ||
25 | while (1) { | ||
26 | nr = read(fd, buf, len); | ||
27 | if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) | ||
28 | continue; | ||
29 | return nr; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | ssize_t write_in_full(int fd, const void *buf, size_t count) | ||
34 | { | ||
35 | const char *p = buf; | ||
36 | ssize_t total = 0; | ||
37 | |||
38 | while (count > 0) { | ||
39 | ssize_t written = _xwrite(fd, p, count); | ||
40 | if (written < 0) | ||
41 | return -1; | ||
42 | if (!written) { | ||
43 | errno = ENOSPC; | ||
44 | return -1; | ||
45 | } | ||
46 | count -= written; | ||
47 | p += written; | ||
48 | total += written; | ||
49 | } | ||
50 | |||
51 | return total; | ||
52 | } | ||
53 | |||
54 | |||
55 | void *xcalloc(size_t nmemb, size_t size) | ||
56 | { | ||
57 | void *ret = calloc(nmemb, size); | ||
58 | if (!ret && (!nmemb || !size)) | ||
59 | ret = calloc(1, 1); | ||
60 | if (!ret) { | ||
61 | ret = calloc(nmemb, size); | ||
62 | if (!ret && (!nmemb || !size)) | ||
63 | ret = calloc(1, 1); | ||
64 | if (!ret) | ||
65 | die("Out of memory, calloc failed"); | ||
66 | } | ||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * This is like mktime, but without normalization of tm_wday and tm_yday. | ||
72 | */ | ||
73 | time_t tm_to_time_t(const struct tm *tm) | ||
74 | { | ||
75 | static const int mdays[] = { | ||
76 | 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 | ||
77 | }; | ||
78 | int year = tm->tm_year - 70; | ||
79 | int month = tm->tm_mon; | ||
80 | int day = tm->tm_mday; | ||
81 | |||
82 | if (year < 0 || year > 129) /* algo only works for 1970-2099 */ | ||
83 | return -1; | ||
84 | if (month < 0 || month > 11) /* array bounds */ | ||
85 | return -1; | ||
86 | if (month < 2 || (year + 2) % 4) | ||
87 | day--; | ||
88 | return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24*60*60UL + | ||
89 | tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec; | ||
90 | } | ||
91 | |||
diff --git a/win32/strbuf.c b/win32/strbuf.c index 98659d448..27a8157b2 100644 --- a/win32/strbuf.c +++ b/win32/strbuf.c | |||
@@ -90,6 +90,22 @@ void strbuf_tolower(struct strbuf *sb) | |||
90 | sb->buf[i] = tolower(sb->buf[i]); | 90 | sb->buf[i] = tolower(sb->buf[i]); |
91 | } | 91 | } |
92 | 92 | ||
93 | void *xcalloc(size_t nmemb, size_t size) | ||
94 | { | ||
95 | void *ret = calloc(nmemb, size); | ||
96 | if (!ret && (!nmemb || !size)) | ||
97 | ret = calloc(1, 1); | ||
98 | if (!ret) { | ||
99 | ret = calloc(nmemb, size); | ||
100 | if (!ret && (!nmemb || !size)) | ||
101 | ret = calloc(1, 1); | ||
102 | if (!ret) | ||
103 | die("Out of memory, calloc failed"); | ||
104 | } | ||
105 | return ret; | ||
106 | } | ||
107 | |||
108 | |||
93 | struct strbuf **strbuf_split(const struct strbuf *sb, int delim) | 109 | struct strbuf **strbuf_split(const struct strbuf *sb, int delim) |
94 | { | 110 | { |
95 | int alloc = 2, pos = 0; | 111 | int alloc = 2, pos = 0; |
@@ -266,7 +282,7 @@ ssize_t strbuf_read(struct strbuf *sb, int fd, size_t hint) | |||
266 | for (;;) { | 282 | for (;;) { |
267 | ssize_t cnt; | 283 | ssize_t cnt; |
268 | 284 | ||
269 | cnt = _xread(fd, sb->buf + sb->len, sb->alloc - sb->len - 1); | 285 | cnt = read(fd, sb->buf + sb->len, sb->alloc - sb->len - 1); |
270 | if (cnt < 0) { | 286 | if (cnt < 0) { |
271 | if (oldalloc == 0) | 287 | if (oldalloc == 0) |
272 | strbuf_release(sb); | 288 | strbuf_release(sb); |