Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
2.8 KiB

  1. package Fcntl;
  2. =head1 NAME
  3. Fcntl - load the C Fcntl.h defines
  4. =head1 SYNOPSIS
  5. use Fcntl;
  6. use Fcntl qw(:DEFAULT :flock);
  7. =head1 DESCRIPTION
  8. This module is just a translation of the C F<fnctl.h> file.
  9. Unlike the old mechanism of requiring a translated F<fnctl.ph>
  10. file, this uses the B<h2xs> program (see the Perl source distribution)
  11. and your native C compiler. This means that it has a
  12. far more likely chance of getting the numbers right.
  13. =head1 NOTE
  14. Only C<#define> symbols get translated; you must still correctly
  15. pack up your own arguments to pass as args for locking functions, etc.
  16. =head1 EXPORTED SYMBOLS
  17. By default your system's F_* and O_* constants (eg, F_DUPFD and
  18. O_CREAT) and the FD_CLOEXEC constant are exported into your namespace.
  19. You can request that the flock() constants (LOCK_SH, LOCK_EX, LOCK_NB
  20. and LOCK_UN) be provided by using the tag C<:flock>. See L<Exporter>.
  21. You can request that the old constants (FAPPEND, FASYNC, FCREAT,
  22. FDEFER, FEXCL, FNDELAY, FNONBLOCK, FSYNC, FTRUNC) be provided for
  23. compatibility reasons by using the tag C<:Fcompat>. For new
  24. applications the newer versions of these constants are suggested
  25. (O_APPEND, O_ASYNC, O_CREAT, O_DEFER, O_EXCL, O_NDELAY, O_NONBLOCK,
  26. O_SYNC, O_TRUNC).
  27. Please refer to your native fcntl() and open() documentation to see
  28. what constants are implemented in your system.
  29. =cut
  30. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
  31. require Exporter;
  32. require DynaLoader;
  33. @ISA = qw(Exporter DynaLoader);
  34. $VERSION = "1.03";
  35. # Items to export into callers namespace by default
  36. # (move infrequently used names to @EXPORT_OK below)
  37. @EXPORT =
  38. qw(
  39. FD_CLOEXEC
  40. F_DUPFD
  41. F_EXLCK
  42. F_GETFD
  43. F_GETFL
  44. F_GETLK
  45. F_GETOWN
  46. F_POSIX
  47. F_RDLCK
  48. F_SETFD
  49. F_SETFL
  50. F_SETLK
  51. F_SETLKW
  52. F_SETOWN
  53. F_SHLCK
  54. F_UNLCK
  55. F_WRLCK
  56. O_ACCMODE
  57. O_APPEND
  58. O_ASYNC
  59. O_BINARY
  60. O_CREAT
  61. O_DEFER
  62. O_DSYNC
  63. O_EXCL
  64. O_EXLOCK
  65. O_NDELAY
  66. O_NOCTTY
  67. O_NONBLOCK
  68. O_RDONLY
  69. O_RDWR
  70. O_RSYNC
  71. O_SHLOCK
  72. O_SYNC
  73. O_TEXT
  74. O_TRUNC
  75. O_WRONLY
  76. );
  77. # Other items we are prepared to export if requested
  78. @EXPORT_OK = qw(
  79. FAPPEND
  80. FASYNC
  81. FCREAT
  82. FDEFER
  83. FEXCL
  84. FNDELAY
  85. FNONBLOCK
  86. FSYNC
  87. FTRUNC
  88. LOCK_EX
  89. LOCK_NB
  90. LOCK_SH
  91. LOCK_UN
  92. );
  93. # Named groups of exports
  94. %EXPORT_TAGS = (
  95. 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)],
  96. 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FEXCL
  97. FNDELAY FNONBLOCK FSYNC FTRUNC)],
  98. );
  99. sub AUTOLOAD {
  100. (my $constname = $AUTOLOAD) =~ s/.*:://;
  101. my $val = constant($constname, 0);
  102. if ($! != 0) {
  103. if ($! =~ /Invalid/) {
  104. $AutoLoader::AUTOLOAD = $AUTOLOAD;
  105. goto &AutoLoader::AUTOLOAD;
  106. }
  107. else {
  108. my ($pack,$file,$line) = caller;
  109. die "Your vendor has not defined Fcntl macro $constname, used at $file line $line.
  110. ";
  111. }
  112. }
  113. *$AUTOLOAD = sub { $val };
  114. goto &$AUTOLOAD;
  115. }
  116. bootstrap Fcntl $VERSION;
  117. 1;