From ac88732c4568487a2aa5fbad75ba393744f616ba Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Fri, 6 Aug 1999 11:59:11 +0000 Subject: More Fcntl constants. (This process really needs to be automated, at least partly, see the Errno extension.) Now also the SEEK_ constants are available via the Fcntl. Yes, this is redundant (IO::Seekable and POSIX supply them already), but now Fcntl is a one-stop shopping mall for all your file-related constants. p4raw-id: //depot/cfgperl@3929 --- ext/Fcntl/Fcntl.pm | 27 +++++++++- ext/Fcntl/Fcntl.xs | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 2 deletions(-) (limited to 'ext/Fcntl') diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 0f70840075..699ee4a517 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -53,15 +53,28 @@ $VERSION = "1.03"; @EXPORT = qw( FD_CLOEXEC + F_ALLOCSP + F_ALLOCSP64 + F_COMPAT + F_DUP2FD F_DUPFD F_EXLCK + F_FREESP + F_FREESP64 + F_FSYNC + F_FSYNC64 F_GETFD F_GETFL F_GETLK F_GETLK64 F_GETOWN + F_NODNY F_POSIX + F_RDACC + F_RDDNY F_RDLCK + F_RWACC + F_RWDNY F_SETFD F_SETFL F_SETLK @@ -69,8 +82,12 @@ $VERSION = "1.03"; F_SETLKW F_SETLKW64 F_SETOWN + F_SHARE F_SHLCK F_UNLCK + F_UNSHARE + F_WRACC + F_WRDNY F_WRLCK O_ACCMODE O_APPEND @@ -93,6 +110,9 @@ $VERSION = "1.03"; O_TEXT O_TRUNC O_WRONLY + SEEK_SET + SEEK_CUR + SEEK_END ); # Other items we are prepared to export if requested @@ -101,9 +121,12 @@ $VERSION = "1.03"; FASYNC FCREAT FDEFER + FDSYNC FEXCL + FLARGEFILE FNDELAY FNONBLOCK + FRSYNC FSYNC FTRUNC LOCK_EX @@ -114,8 +137,8 @@ $VERSION = "1.03"; # Named groups of exports %EXPORT_TAGS = ( 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)], - 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FEXCL - FNDELAY FNONBLOCK FSYNC FTRUNC)], + 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FEXCL FLARGEFILE + FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)], ); sub AUTOLOAD { diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs index bc16cc9645..0dab7f17e4 100644 --- a/ext/Fcntl/Fcntl.xs +++ b/ext/Fcntl/Fcntl.xs @@ -15,6 +15,10 @@ #endif #endif +#ifdef I_UNISTD +#include +#endif + /* This comment is a kludge to get metaconfig to see the symbols VAL_O_NONBLOCK VAL_EAGAIN @@ -43,6 +47,30 @@ constant(char *name, int arg) switch (*name) { case 'F': if (strnEQ(name, "F_", 2)) { + if (strEQ(name, "F_ALLOCSP")) +#ifdef F_ALLOCSP + return F_ALLOCSP; +#else + goto not_there; +#endif + if (strEQ(name, "F_ALLOCSP64")) +#ifdef F_ALLOCSP64 + return F_ALLOCSP64; +#else + goto not_there; +#endif + if (strEQ(name, "F_COMPAT")) +#ifdef F_COMPAT + return F_COMPAT; +#else + goto not_there; +#endif + if (strEQ(name, "F_DUP2FD")) +#ifdef F_DUP2FD + return F_DUP2FD; +#else + goto not_there; +#endif if (strEQ(name, "F_DUPFD")) #ifdef F_DUPFD return F_DUPFD; @@ -54,6 +82,30 @@ constant(char *name, int arg) return F_EXLCK; #else goto not_there; +#endif + if (strEQ(name, "F_FREESP")) +#ifdef F_FREESP + return F_FREESP; +#else + goto not_there; +#endif + if (strEQ(name, "F_FREESP64")) +#ifdef F_FREESP64 + return F_FREESP64; +#else + goto not_there; +#endif + if (strEQ(name, "F_FSYNC")) +#ifdef F_FSYNC + return F_FSYNC; +#else + goto not_there; +#endif + if (strEQ(name, "F_FSYNC64")) +#ifdef F_FSYNC64 + return F_FSYNC64; +#else + goto not_there; #endif if (strEQ(name, "F_GETFD")) #ifdef F_GETFD @@ -84,18 +136,48 @@ constant(char *name, int arg) return F_GETOWN; #else goto not_there; +#endif + if (strEQ(name, "F_NODNY")) +#ifdef F_NODNY + return F_NODNY; +#else + goto not_there; #endif if (strEQ(name, "F_POSIX")) #ifdef F_POSIX return F_POSIX; #else goto not_there; +#endif + if (strEQ(name, "F_RDACC")) +#ifdef F_RDACC + return F_RDACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_RDDNY")) +#ifdef F_RDDNY + return F_RDDNY; +#else + goto not_there; #endif if (strEQ(name, "F_RDLCK")) #ifdef F_RDLCK return F_RDLCK; #else goto not_there; +#endif + if (strEQ(name, "F_RWACC")) +#ifdef F_RWACC + return F_RWACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_RWDNY")) +#ifdef F_RWDNY + return F_RWDNY; +#else + goto not_there; #endif if (strEQ(name, "F_SETFD")) #ifdef F_SETFD @@ -138,6 +220,12 @@ constant(char *name, int arg) return F_SETOWN; #else goto not_there; +#endif + if (strEQ(name, "F_SHARE")) +#ifdef F_SHARE + return F_SHARE; +#else + goto not_there; #endif if (strEQ(name, "F_SHLCK")) #ifdef F_SHLCK @@ -150,6 +238,24 @@ constant(char *name, int arg) return F_UNLCK; #else goto not_there; +#endif + if (strEQ(name, "F_UNSHARE")) +#ifdef F_UNSHARE + return F_UNSHARE; +#else + goto not_there; +#endif + if (strEQ(name, "F_WRACC")) +#ifdef F_WRACC + return F_WRACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_WRDNY")) +#ifdef F_WRDNY + return F_WRDNY; +#else + goto not_there; #endif if (strEQ(name, "F_WRLCK")) #ifdef F_WRLCK @@ -189,12 +295,24 @@ constant(char *name, int arg) return FDEFER; #else goto not_there; +#endif + if (strEQ(name, "FDSYNC")) +#ifdef FDSYNC + return FDSYNC; +#else + goto not_there; #endif if (strEQ(name, "FEXCL")) #ifdef FEXCL return FEXCL; #else goto not_there; +#endif + if (strEQ(name, "FLARGEFILE")) +#ifdef FLARGEFILE + return FLARGEFILE; +#else + goto not_there; #endif if (strEQ(name, "FNDELAY")) #ifdef FNDELAY @@ -207,6 +325,12 @@ constant(char *name, int arg) return FNONBLOCK; #else goto not_there; +#endif + if (strEQ(name, "FRSYNC")) +#ifdef FRSYNC + return FRSYNC; +#else + goto not_there; #endif if (strEQ(name, "FSYNC")) #ifdef FSYNC @@ -383,6 +507,26 @@ constant(char *name, int arg) } else goto not_there; break; + case 'S': + if (strEQ(name, "SEEK_CUR")) +#ifdef SEEK_CUR + return SEEK_CUR; +#else + goto not_there; +#endif + if (strEQ(name, "SEEK_END")) +#ifdef SEEK_END + return SEEK_END; +#else + goto not_there; +#endif + if (strEQ(name, "SEEK_SET")) +#ifdef SEEK_SET + return SEEK_SET; +#else + goto not_there; +#endif + break; } errno = EINVAL; return 0; -- cgit v1.2.1