diff --git a/CHANGES b/CHANGES index 7801067..10e3ed1 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ add lose32 support (broken, please don't use!) head -1 -> head -n 1 apending 0 bytes to an empty array would fail it + remove socket_sendfile now that we have io_sendfile 0.16: add buffer_fromsa (make buffer from stralloc) diff --git a/GNUmakefile b/GNUmakefile index 17105ac..b5a4b66 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -242,7 +242,7 @@ socket_remote6.o: havesl.h fmt_xlong.o scan_xlong.o fmt_ip6_flat.o $(TEXTCODE_OBJS): haveinline.h dep: haveip6.h haven2i.h havesl.h haveinline.h iopause.h select.h haveepoll.h havekqueue.h havedevpoll.h - gcc -I. -MM $(wildcard */*.c) t.c > dep + gcc -I. -MM */*.c t.c > dep libdep: for i in $(LIBS); do (echo -n $$i|tr a-z A-Z|sed 's/.A$$/_OBJS=/'; echo $${i%.a}/*.c|sed -e 's@[^/]*/\([^.]*\)\.c@\1.o @g'); done > libdep diff --git a/socket.h b/socket.h index 228407d..40063da 100644 --- a/socket.h +++ b/socket.h @@ -51,8 +51,6 @@ void socket_tryreservein(int s,int size); const char* socket_getifname(uint32 _interface); uint32 socket_getifidx(const char* ifname); -int socket_sendfile(int out,int in,uint32 offset,uint32 bytes); - int noipv6; #ifdef __MINGW32__ diff --git a/socket/socket_sendfile.3 b/socket/socket_sendfile.3 deleted file mode 100644 index 7413a04..0000000 --- a/socket/socket_sendfile.3 +++ /dev/null @@ -1,35 +0,0 @@ -.TH socket_sendfile 3 -.SH NAME -socket_sendfile \- send a file over a TCP socket -.SH SYNTAX -.B #include - -int \fBsocket_sendfile\fP(int \fIout\fR, int \fIin\fR, uint32 \fIoffset\fR, - uint32 \fIbytes\fR); -.SH DESCRIPTION -socket_sendfile sends \fIbytes\fR bytes starting at \fIoffset\fR in the -file \fIin\fR to the socket connected to file descriptor \fIout\fR. - -The socket must be connected. - -Note that the underlying sendfile system call is system specific and -currently only implemented on Linux. On other operating systems, it is -emulated with a read/write loop. -.SH RETURN VALUE -socket_sendfile returns 0 if the data was sent successfully. If not, -it returns -1 and sets errno appropriately. -.SH EXAMPLE - #include - #include - - int \fIs\fR; - char \fIip\fR[4]; - uint16 \fIp\fR; - int \fIfd\fR = open_read("/etc/passwd"); - - \fIs\fR = socket_tcp4(); - socket_connect4(s,ip,p); - socket_sendfile(s,fd,0,23); - -.SH "SEE ALSO" -socket_send6(3) diff --git a/socket/socket_sendfile.c b/socket/socket_sendfile.c deleted file mode 100644 index 80308bf..0000000 --- a/socket/socket_sendfile.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include "socket.h" - -#ifdef __linux__ - -#ifdef __GLIBC__ -#include -#else -#ifdef __dietlibc__ -#include -#else -#include -_syscall4(int,sendfile,int,out,int,in,long *,offset,unsigned long,count) -#endif -#endif - -int socket_sendfile(int out,int in,uint32 offset,uint32 bytes) { - off_t tmp=offset; - return sendfile(out,in,&tmp,bytes); -} - -#else - -#ifdef _HPUX_SOURCE - -/* http://www.devresource.hp.com/STK/man/10.30/sendfile_2.html */ -#include -int socket_sendfile(int out,int in,uint32 offset,uint32 bytes) { - return sendfile(out,in,offset,bytes,0,0); -} - -#else - -#define BUFSIZE 16384 - -int socket_sendfile(int out,int in,uint32 offset,uint32 bytes) { - char buf[BUFSIZE]; - int n,m; - uint32 sent=0; - if (lseek(in,offset,SEEK_SET) != offset) - return -1; - while (bytes>0) { - char* tmp=buf; - if ((n=read(in,tmp,(bytes0) { - if ((m=write(out,tmp,n))<0) - goto abort; - sent+=m; - n-=m; - tmp+=m; - } - } -abort: - return sent; -} - -#endif - -#endif