diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-03-26 00:23:38 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-03-26 00:23:38 +0000 |
commit | 63a347c7a3ed87c3e11eda9e379b25371182e278 (patch) | |
tree | 5c33b4c9e157314291ddd759f586d5d7ff37ab67 /ext/IO/IO.xs | |
parent | 4ddf6213325a6e94c722116190f88d13ab30b7fc (diff) | |
download | perl-63a347c7a3ed87c3e11eda9e379b25371182e278.tar.gz |
Implement IO::Socket::atmark(), inspired by Lincoln Stein's
IO::Sockatmark().
p4raw-id: //depot/perl@9354
Diffstat (limited to 'ext/IO/IO.xs')
-rw-r--r-- | ext/IO/IO.xs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs index 942a799357..4987b3d555 100644 --- a/ext/IO/IO.xs +++ b/ext/IO/IO.xs @@ -17,6 +17,12 @@ # include <fcntl.h> #endif +#ifndef SIOCATMARK +# ifdef I_SYS_SOCKIO +# include <sys/sockio.h> +# endif +#endif + #ifdef PerlIO typedef int SysRet; typedef PerlIO * InputStream; @@ -262,7 +268,6 @@ CODE: MODULE = IO PACKAGE = IO::Handle PREFIX = f - int ungetc(handle, c) InputStream handle @@ -408,6 +413,32 @@ fsync(handle) RETVAL +MODULE = IO PACKAGE = IO::Socket + +SysRet +sockatmark (sock) + InputStream sock + PROTOTYPE: $ + PREINIT: + int fd,flag,result; + CODE: + { + fd = PerlIO_fileno(sock); +#ifdef HAS_SOCKATMARK + flag = sockatmark(fd); +#else +# ifdef SIOCATMARK + if (ioctl(fd, SIOCATMARK, &flag) != 0) + XSRETURN_UNDEF; +# else + not_here("IO::Socket::atmark"); +# endif + RETVAL = flag; +#endif + } + OUTPUT: + RETVAL + BOOT: { HV *stash; @@ -471,3 +502,4 @@ BOOT: newCONSTSUB(stash,"SEEK_END", newSViv(SEEK_END)); #endif } + |