diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2000-02-16 19:47:51 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-02-16 19:47:51 +0000 |
commit | ca6e1c26e8ac218f83b0cec7616cb26dab979947 (patch) | |
tree | 8962df12664e64e831aa8d5e4bba857fa6592593 /ext | |
parent | d4935d7f25ace6b599fe75f422b41624ca6bf4a6 (diff) | |
download | perl-ca6e1c26e8ac218f83b0cec7616cb26dab979947.tar.gz |
Fcntl: more O_ constants, move SEEK_ to @EXPORT_OK
(tag :seek), add S_I constants (and functions) (tag :mode);
refer only to the SEEK_ of Fcntl, not the ones from
POSIX or IO::; add SHUT_ to Socket; get trigonometric
functions from Math::Trig instead of POSIX.
p4raw-id: //depot/cfgperl@5118
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Fcntl/Fcntl.pm | 201 | ||||
-rw-r--r-- | ext/Fcntl/Fcntl.xs | 225 | ||||
-rw-r--r-- | ext/Socket/Socket.pm | 114 | ||||
-rw-r--r-- | ext/Socket/Socket.xs | 18 |
4 files changed, 538 insertions, 20 deletions
diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 43bec9903e..8758359532 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -37,8 +37,21 @@ applications the newer versions of these constants are suggested (O_APPEND, O_ASYNC, O_CREAT, O_DEFER, O_EXCL, O_NDELAY, O_NONBLOCK, O_SYNC, O_TRUNC). -Please refer to your native fcntl() and open() documentation to see -what constants are implemented in your system. +For ease of use also the SEEK_* constants (for seek() and sysseek(), +e.g. SEEK_END) and the S_I* constants (for chmod() and stat()) are +available for import. They can be imported either separately or using +the tags C<:seek> and C<:mode>. + +Please refer to your native fcntl(2), open(2), fseek(3), lseek(2) +(equal to Perl's seek() and sysseek(), respectively), and chmod(2) +documentation to see what constants are implemented in your system. + +See L<perlopentut> to learn about the uses of the O_* constants +with sysopen(). + +See L<perlfunc/seek> and L<perlfunc/sysseek> about the SEEK_* constants. + +See L<perlfunc/stat> about the S_I* constants. =cut @@ -90,31 +103,32 @@ $VERSION = "1.03"; F_WRDNY F_WRLCK O_ACCMODE + O_ALIAS O_APPEND O_ASYNC O_BINARY O_CREAT O_DEFER + O_DIRECT + O_DIRECTORY O_DSYNC O_EXCL O_EXLOCK O_LARGEFILE O_NDELAY O_NOCTTY + O_NOFOLLOW O_NONBLOCK O_RDONLY O_RDWR + O_RSRC O_RSYNC O_SHLOCK O_SYNC + O_TEMPORARY O_TEXT O_TRUNC O_WRONLY - O_ALIAS - O_RSRC - SEEK_SET - SEEK_CUR - SEEK_END ); # Other items we are prepared to export if requested @@ -135,14 +149,183 @@ $VERSION = "1.03"; LOCK_NB LOCK_SH LOCK_UN + S_ISUID S_ISGID S_ISVTX S_ISTXT + _S_IFMT S_IFREG S_IFDIR S_IFLNK + S_IFSOCK S_IFBLK S_IFCHR S_IFIFO S_IFWHT S_ENFMT + S_IRUSR S_IWUSR S_IXUSR S_IRWXU + S_IRGRP S_IWGRP S_IXGRP S_IRWXG + S_IROTH S_IWOTH S_IXOTH S_IRWXO + S_IREAD S_IWRITE S_IEXEC + &S_ISREG &S_ISDIR &S_ISLNK &S_ISSOCK &S_ISBLK &S_ISCHR &S_ISFIFO + &S_ISWHT &S_ISENFMT &S_IFMT &S_IMODE + SEEK_SET + SEEK_CUR + SEEK_END ); # Named groups of exports %EXPORT_TAGS = ( 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)], 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FEXCL FLARGEFILE - FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)], + FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)], + 'seek' => [qw(SEEK_SET SEEK_CUR SEEK_END)], + 'mode' => [qw(S_ISUID S_ISGID S_ISVTX S_ISTXT + _S_IFMT S_IFREG S_IFDIR S_IFLNK + S_IFSOCK S_IFBLK S_IFCHR S_IFIFO S_IFWHT S_ENFMT + S_IRUSR S_IWUSR S_IXUSR S_IRWXU + S_IRGRP S_IWGRP S_IXGRP S_IRWXG + S_IROTH S_IWOTH S_IXOTH S_IRWXO + S_IREAD S_IWRITE S_IEXEC + &S_ISREG &S_ISDIR &S_ISLNK &S_ISSOCK + &S_ISBLK &S_ISCHR &S_ISFIFO + &S_ISWHT &S_ISENFMT + &S_IFMT &S_IMODE + )], ); +sub FD_CLOEXEC (); + +sub F_ALLOCSP (); +sub F_ALLOCSP64 (); +sub F_COMPAT (); +sub F_DUP2FD (); +sub F_DUPFD (); +sub F_EXLCK (); +sub F_FREESP (); +sub F_FREESP64 (); +sub F_FSYNC (); +sub F_FSYNC64 (); +sub F_GETFD (); +sub F_GETFL (); +sub F_GETLK (); +sub F_GETLK64 (); +sub F_GETOWN (); +sub F_NODNY (); +sub F_POSIX (); +sub F_RDACC (); +sub F_RDDNY (); +sub F_RDLCK (); +sub F_RWACC (); +sub F_RWDNY (); +sub F_SETFD (); +sub F_SETFL (); +sub F_SETLK (); +sub F_SETLK64 (); +sub F_SETLKW (); +sub F_SETLKW64 (); +sub F_SETOWN (); +sub F_SHARE (); +sub F_SHLCK (); +sub F_UNLCK (); +sub F_UNSHARE (); +sub F_WRACC (); +sub F_WRDNY (); +sub F_WRLCK (); + +sub O_ACCMODE (); +sub O_ALIAS (); +sub O_APPEND (); +sub O_ASYNC (); +sub O_BINARY (); +sub O_CREAT (); +sub O_DEFER (); +sub O_DIRECT (); +sub O_DIRECTORY (); +sub O_DSYNC (); +sub O_EXCL (); +sub O_EXLOCK (); +sub O_LARGEFILE (); +sub O_NDELAY (); +sub O_NOCTTY (); +sub O_NOFOLLOW (); +sub O_NONBLOCK (); +sub O_RDONLY (); +sub O_RDWR (); +sub O_RSRC (); +sub O_RSYNC (); +sub O_SHLOCK (); +sub O_SYNC (); +sub O_TEMPORARY (); +sub O_TEXT (); +sub O_TRUNC (); +sub O_WRONLY (); + +sub FAPPEND (); +sub FASYNC (); +sub FCREAT (); +sub FDEFER (); +sub FDSYNC (); +sub FEXCL (); +sub FLARGEFILE (); +sub FNDELAY (); +sub FNONBLOCK (); +sub FRSYNC (); +sub FSYNC (); +sub FTRUNC (); + +sub LOCK_EX (); +sub LOCK_NB (); +sub LOCK_SH (); +sub LOCK_UN (); + +sub SEEK_SET (); +sub SEEK_CUR (); +sub SEEK_END (); + +sub S_ISUID (); +sub S_ISGID (); +sub S_ISVTX (); +sub S_ISTXT (); +sub _S_IFMT (); +sub S_IFMT (;$); +sub S_IMODE ($); +sub S_IFREG (); +sub S_IFDIR (); +sub S_IFLNK (); +sub S_IFSOCK (); +sub S_IFBLK (); +sub S_IFCHR (); +sub S_IFIFO (); +sub S_IFWHT (); +sub S_ENFMT (); +sub S_IRUSR (); +sub S_IWUSR (); +sub S_IXUSR (); +sub S_IRWXU (); +sub S_IRGRP (); +sub S_IWGRP (); +sub S_IXGRP (); +sub S_IRWXG (); +sub S_IROTH (); +sub S_IWOTH (); +sub S_IXOTH (); +sub S_IRWXO (); +sub S_IREAD (); +sub S_IWRITE (); +sub S_IEXEC (); + +sub S_IFREG (); +sub S_IFDIR (); +sub S_IFLNK (); +sub S_IFSOCK (); +sub S_IFBLK (); +sub S_IFCHR (); +sub S_IFIFO (); +sub S_IFWHT (); +sub S_IFENFMT (); + +sub S_IFMT (;$) { @_ ? ( $_[0] & _S_IFMT ) : _S_IFMT } +sub S_IMODE ($) { $_[0] & 07777 } + +sub S_ISREG ($) { ( $_[0] & _S_IFMT ) == S_IFREG } +sub S_ISDIR ($) { ( $_[0] & _S_IFMT ) == S_IFDIR } +sub S_ISLNK ($) { ( $_[0] & _S_IFMT ) == S_IFLNK } +sub S_ISSOCK ($) { ( $_[0] & _S_IFMT ) == S_IFSOCK } +sub S_ISBLK ($) { ( $_[0] & _S_IFMT ) == S_IFBLK } +sub S_ISCHR ($) { ( $_[0] & _S_IFMT ) == S_IFCHR } +sub S_ISFIFO ($) { ( $_[0] & _S_IFMT ) == S_IFIFO } +sub S_ISWHT ($) { ( $_[0] & _S_IFMT ) == S_ISWHT } +sub S_ISENFMT ($) { ( $_[0] & _S_IFMT ) == S_ISENFMT } + sub AUTOLOAD { (my $constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, 0); @@ -157,7 +340,7 @@ sub AUTOLOAD { "; } } - *$AUTOLOAD = sub { $val }; + *$AUTOLOAD = sub () { $val }; goto &$AUTOLOAD; } diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs index 08252b6538..8d4a073658 100644 --- a/ext/Fcntl/Fcntl.xs +++ b/ext/Fcntl/Fcntl.xs @@ -45,6 +45,14 @@ constant(char *name, int arg) { errno = 0; switch (*name) { + case '_': + if (strEQ(name, "_S_IFMT")) /* Yes, _S_IFMT. */ +#ifdef S_IFMT + return S_IFMT; +#else + goto not_there; +#endif + break; case 'F': if (strnEQ(name, "F_", 2)) { if (strEQ(name, "F_ALLOCSP")) @@ -414,6 +422,18 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "O_DIRECT")) +#ifdef O_DIRECT + return O_DIRECT; +#else + goto not_there; +#endif + if (strEQ(name, "O_DIRECTORY")) +#ifdef O_DIRECTORY + return O_DIRECTORY; +#else + goto not_there; +#endif if (strEQ(name, "O_DSYNC")) #ifdef O_DSYNC return O_DSYNC; @@ -450,6 +470,12 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "O_NOFOLLOW")) +#ifdef O_NOFOLLOW + return O_NOFOLLOW; +#else + goto not_there; +#endif if (strEQ(name, "O_NONBLOCK")) #ifdef O_NONBLOCK return O_NONBLOCK; @@ -486,6 +512,12 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "O_TEMPORARY")) +#ifdef O_TEMPORARY + return O_TEMPORARY; +#else + goto not_there; +#endif if (strEQ(name, "O_TEXT")) #ifdef O_TEXT return O_TEXT; @@ -520,25 +552,198 @@ constant(char *name, int arg) goto not_there; break; case 'S': - if (strEQ(name, "SEEK_CUR")) + switch (name[1]) { + case '_': + if (strEQ(name, "S_ISUID")) +#ifdef S_ISUID + return S_ISUID; +#else + goto not_there; +#endif + if (strEQ(name, "S_ISGID")) +#ifdef S_ISGID + return S_ISGID; +#else + goto not_there; +#endif + if (strEQ(name, "S_ISVTX")) +#ifdef S_ISVTX + return S_ISVTX; +#else + goto not_there; +#endif + if (strEQ(name, "S_ISTXT")) +#ifdef S_ISTXT + return S_ISTXT; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFREG")) +#ifdef S_IFREG + return S_IFREG; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFDIR")) +#ifdef S_IFDIR + return S_IFDIR; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFLNK")) +#ifdef S_IFLNK + return S_IFLNK; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFSOCK")) +#ifdef S_IFSOCK + return S_IFSOCK; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFBLK")) +#ifdef S_IFBLK + return S_IFBLK; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFCHR")) +#ifdef S_IFCHR + return S_IFCHR; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFIFO")) +#ifdef S_IFIFO + return S_IFIFO; +#else + goto not_there; +#endif + if (strEQ(name, "S_IFWHT")) +#ifdef S_IFWHT + return S_IFWHT; +#else + goto not_there; +#endif + if (strEQ(name, "S_ENFMT")) +#ifdef S_ENFMT + return S_ENFMT; +#else + goto not_there; +#endif + if (strEQ(name, "S_IRUSR")) +#ifdef S_IRUSR + return S_IRUSR; +#else + goto not_there; +#endif + if (strEQ(name, "S_IWUSR")) +#ifdef S_IWUSR + return S_IWUSR; +#else + goto not_there; +#endif + if (strEQ(name, "S_IXUSR")) +#ifdef S_IXUSR + return S_IXUSR; +#else + goto not_there; +#endif + if (strEQ(name, "S_IRWXU")) +#ifdef S_IRWXU + return S_IRWXU; +#else + goto not_there; +#endif + if (strEQ(name, "S_IRGRP")) +#ifdef S_IRGRP + return S_IRGRP; +#else + goto not_there; +#endif + if (strEQ(name, "S_IWGRP")) +#ifdef S_IWGRP + return S_IWGRP; +#else + goto not_there; +#endif + if (strEQ(name, "S_IXGRP")) +#ifdef S_IXGRP + return S_IXGRP; +#else + goto not_there; +#endif + if (strEQ(name, "S_IRWXG")) +#ifdef S_IRWXG + return S_IRWXG; +#else + goto not_there; +#endif + if (strEQ(name, "S_IROTH")) +#ifdef S_IROTH + return S_IROTH; +#else + goto not_there; +#endif + if (strEQ(name, "S_IWOTH")) +#ifdef S_IWOTH + return S_IWOTH; +#else + goto not_there; +#endif + if (strEQ(name, "S_IXOTH")) +#ifdef S_IXOTH + return S_IXOTH; +#else + goto not_there; +#endif + if (strEQ(name, "S_IRWXO")) +#ifdef S_IRWXO + return S_IRWXO; +#else + goto not_there; +#endif + if (strEQ(name, "S_IREAD")) +#ifdef S_IREAD + return S_IREAD; +#else + goto not_there; +#endif + if (strEQ(name, "S_IWRITE")) +#ifdef S_IWRITE + return S_IWRITE; +#else + goto not_there; +#endif + if (strEQ(name, "S_IEXEC")) +#ifdef S_IEXEC + return S_IEXEC; +#else + goto not_there; +#endif + break; + case 'E': + if (strEQ(name, "SEEK_CUR")) #ifdef SEEK_CUR - return SEEK_CUR; + return SEEK_CUR; #else - goto not_there; + return 1; #endif - if (strEQ(name, "SEEK_END")) + if (strEQ(name, "SEEK_END")) #ifdef SEEK_END - return SEEK_END; + return SEEK_END; #else - goto not_there; + return 2; #endif - if (strEQ(name, "SEEK_SET")) + if (strEQ(name, "SEEK_SET")) #ifdef SEEK_SET - return SEEK_SET; + return SEEK_SET; #else - goto not_there; + return 0; #endif - break; + break; + } } errno = EINVAL; return 0; diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm index cec13ac47f..f83cb18399 100644 --- a/ext/Socket/Socket.pm +++ b/ext/Socket/Socket.pm @@ -244,6 +244,9 @@ use XSLoader (); SCM_CREDS SCM_RIGHTS SCM_TIMESTAMP + SHUT_RD + SHUT_RDWR + SHUT_WR SOCK_DGRAM SOCK_RAW SOCK_RDM @@ -320,6 +323,115 @@ sub sockaddr_un { } } +sub INADDR_ANY (); +sub INADDR_BROADCAST (); +sub INADDR_LOOPBACK (); +sub INADDR_LOOPBACK (); + +sub AF_802 (); +sub AF_APPLETALK (); +sub AF_CCITT (); +sub AF_CHAOS (); +sub AF_DATAKIT (); +sub AF_DECnet (); +sub AF_DLI (); +sub AF_ECMA (); +sub AF_GOSIP (); +sub AF_HYLINK (); +sub AF_IMPLINK (); +sub AF_INET (); +sub AF_LAT (); +sub AF_MAX (); +sub AF_NBS (); +sub AF_NIT (); +sub AF_NS (); +sub AF_OSI (); +sub AF_OSINET (); +sub AF_PUP (); +sub AF_SNA (); +sub AF_UNIX (); +sub AF_UNSPEC (); +sub AF_X25 (); +sub IOV_MAX (); +sub MSG_BCAST (); +sub MSG_CTLFLAGS (); +sub MSG_CTLIGNORE (); +sub MSG_CTRUNC (); +sub MSG_DONTROUTE (); +sub MSG_DONTWAIT (); +sub MSG_EOF (); +sub MSG_EOR (); +sub MSG_ERRQUEUE (); +sub MSG_FIN (); +sub MSG_MAXIOVLEN (); +sub MSG_MCAST (); +sub MSG_NOSIGNAL (); +sub MSG_OOB (); +sub MSG_PEEK (); +sub MSG_PROXY (); +sub MSG_RST (); +sub MSG_SYN (); +sub MSG_TRUNC (); +sub MSG_URG (); +sub MSG_WAITALL (); +sub PF_802 (); +sub PF_APPLETALK (); +sub PF_CCITT (); +sub PF_CHAOS (); +sub PF_DATAKIT (); +sub PF_DECnet (); +sub PF_DLI (); +sub PF_ECMA (); +sub PF_GOSIP (); +sub PF_HYLINK (); +sub PF_IMPLINK (); +sub PF_INET (); +sub PF_LAT (); +sub PF_MAX (); +sub PF_NBS (); +sub PF_NIT (); +sub PF_NS (); +sub PF_OSI (); +sub PF_OSINET (); +sub PF_PUP (); +sub PF_SNA (); +sub PF_UNIX (); +sub PF_UNSPEC (); +sub PF_X25 (); +sub SCM_CONNECT (); +sub SCM_CREDENTIALS (); +sub SCM_CREDS (); +sub SCM_RIGHTS (); +sub SCM_TIMESTAMP (); +sub SHUT_RD (); +sub SHUT_RDWR (); +sub SHUT_WR (); +sub SOCK_DGRAM (); +sub SOCK_RAW (); +sub SOCK_RDM (); +sub SOCK_SEQPACKET (); +sub SOCK_STREAM (); +sub SOL_SOCKET (); +sub SOMAXCONN (); +sub SO_ACCEPTCONN (); +sub SO_BROADCAST (); +sub SO_DEBUG (); +sub SO_DONTLINGER (); +sub SO_DONTROUTE (); +sub SO_ERROR (); +sub SO_KEEPALIVE (); +sub SO_LINGER (); +sub SO_OOBINLINE (); +sub SO_RCVBUF (); +sub SO_RCVLOWAT (); +sub SO_RCVTIMEO (); +sub SO_REUSEADDR (); +sub SO_SNDBUF (); +sub SO_SNDLOWAT (); +sub SO_SNDTIMEO (); +sub SO_TYPE (); +sub SO_USELOOPBACK (); +sub UIO_MAXIOV (); sub AUTOLOAD { my($constname); @@ -329,7 +441,7 @@ sub AUTOLOAD { my ($pack,$file,$line) = caller; croak "Your vendor has not defined Socket macro $constname, used"; } - eval "sub $AUTOLOAD { $val }"; + eval "sub $AUTOLOAD () { $val }"; goto &$AUTOLOAD; } diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 6abc647c2f..752c3ddb10 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -662,6 +662,24 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "SHUT_RD")) +#ifdef SHUT_RD + return SHUT_RD; +#else + return 0; +#endif + if (strEQ(name, "SHUT_RDWR")) +#ifdef SHUT_RDWR + return SHUT_RDWR; +#else + return 2; +#endif + if (strEQ(name, "SHUT_WR")) +#ifdef SHUT_WR + return SHUT_WR; +#else + return 1; +#endif if (strEQ(name, "SOCK_DGRAM")) #ifdef SOCK_DGRAM return SOCK_DGRAM; |