Mercurial > mplayer.hg
comparison libmpdemux/pnm.c @ 10281:54bcbf28698a
Networking support under MinGW.
Patch by flo/yepyep <flodt8@yahoo.de>.
author | diego |
---|---|
date | Wed, 11 Jun 2003 16:48:09 +0000 |
parents | 939ff11825de |
children | a4cba6e2dfde |
comparison
equal
deleted
inserted
replaced
10280:24145d6b5883 | 10281:54bcbf28698a |
---|---|
24 */ | 24 */ |
25 | 25 |
26 #include <unistd.h> | 26 #include <unistd.h> |
27 #include <stdio.h> | 27 #include <stdio.h> |
28 #include <assert.h> | 28 #include <assert.h> |
29 #include <sys/socket.h> | |
30 //#include <netinet/in.h> | |
31 //#include <netdb.h> | |
32 #include <string.h> | 29 #include <string.h> |
33 #include <sys/stat.h> | 30 #include <sys/stat.h> |
34 #include <fcntl.h> | 31 #include <fcntl.h> |
35 #include <errno.h> | 32 #include <errno.h> |
36 #include <stdlib.h> | 33 #include <stdlib.h> |
37 #include <sys/time.h> | 34 #include <sys/time.h> |
38 #include <inttypes.h> | 35 #include <inttypes.h> |
36 | |
37 #include "config.h" | |
38 #ifndef HAVE_WINSOCK2 | |
39 #define closesocket close | |
40 #include <sys/socket.h> | |
41 //#include <netinet/in.h> | |
42 //#include <netdb.h> | |
43 #else | |
44 #include <winsock2.h> | |
45 #endif | |
39 | 46 |
40 #include "pnm.h" | 47 #include "pnm.h" |
41 //#include "libreal/rmff.h" | 48 //#include "libreal/rmff.h" |
42 | 49 |
43 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ | 50 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ |
205 n = send (s, &buf[total], len - total, 0); | 212 n = send (s, &buf[total], len - total, 0); |
206 | 213 |
207 if (n > 0) | 214 if (n > 0) |
208 total += n; | 215 total += n; |
209 else if (n < 0) { | 216 else if (n < 0) { |
217 #ifndef HAVE_WINSOCK2 | |
210 if ((timeout>0) && ((errno == EAGAIN) || (errno == EINPROGRESS))) { | 218 if ((timeout>0) && ((errno == EAGAIN) || (errno == EINPROGRESS))) { |
219 #else | |
220 if ((timeout>0) && ((errno == EAGAIN) || (WSAGetLastError() == WSAEINPROGRESS))) { | |
221 #endif | |
211 sleep (1); timeout--; | 222 sleep (1); timeout--; |
212 } else | 223 } else |
213 return -1; | 224 return -1; |
214 } | 225 } |
215 } | 226 } |
808 return this->header_len; | 819 return this->header_len; |
809 } | 820 } |
810 | 821 |
811 void pnm_close(pnm_t *p) { | 822 void pnm_close(pnm_t *p) { |
812 | 823 |
813 if (p->s >= 0) close(p->s); | 824 if (p->s >= 0) closesocket(p->s); |
814 free(p->path); | 825 free(p->path); |
815 free(p); | 826 free(p); |
816 } | 827 } |
817 | 828 |