remove socket_sendfile now that we have io_sendfile

make Makefile should also work with a BSD make ;)
master
leitner 21 years ago
parent 0f60bacb89
commit 0bae11b63e

@ -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)

@ -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

@ -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__

@ -1,35 +0,0 @@
.TH socket_sendfile 3
.SH NAME
socket_sendfile \- send a file over a TCP socket
.SH SYNTAX
.B #include <socket.h>
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 <socket.h>
#include <open.h>
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)

@ -1,60 +0,0 @@
#include <unistd.h>
#include "socket.h"
#ifdef __linux__
#ifdef __GLIBC__
#include <sys/sendfile.h>
#else
#ifdef __dietlibc__
#include <sys/sendfile.h>
#else
#include <linux/unistd.h>
_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 <sys/socket.h>
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,(bytes<BUFSIZE)?bytes:BUFSIZE))<=0)
return (sent?sent:-1);
while (n>0) {
if ((m=write(out,tmp,n))<0)
goto abort;
sent+=m;
n-=m;
tmp+=m;
}
}
abort:
return sent;
}
#endif
#endif
Loading…
Cancel
Save