xattr.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {
  2. * Copyright (c) 2004-2005 Apple Computer, Inc. All rights reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * The contents of this file constitute Original Code as defined in and
  7. * are subject to the Apple Public Source License Version 1.1 (the
  8. * "License"). You may not use this file except in compliance with the
  9. * License. Please obtain a copy of the License at
  10. * http://www.apple.com/publicsource and read it before using this file.
  11. *
  12. * This Original Code and all software distributed under the License are
  13. * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
  17. * License for the specific language governing rights and limitations
  18. * under the License.
  19. *
  20. * @APPLE_LICENSE_HEADER_END@
  21. }
  22. { Pascal Translation: Peter N Lewis, <[email protected]>, August 2006 }
  23. {
  24. Modified for use with Free Pascal
  25. Version 200
  26. Please report any bugs to <[email protected]>
  27. }
  28. {$mode macpas}
  29. {$packenum 1}
  30. {$macro on}
  31. {$inline on}
  32. {$CALLING MWPASCAL}
  33. unit xattr;
  34. interface
  35. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  36. {$setc GAP_INTERFACES_VERSION := $0200}
  37. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  38. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  39. {$endc}
  40. {$ifc defined CPUPOWERPC and defined CPUI386}
  41. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  42. {$endc}
  43. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  44. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  45. {$endc}
  46. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  47. {$setc __ppc__ := 1}
  48. {$elsec}
  49. {$setc __ppc__ := 0}
  50. {$endc}
  51. {$ifc not defined __i386__ and defined CPUI386}
  52. {$setc __i386__ := 1}
  53. {$elsec}
  54. {$setc __i386__ := 0}
  55. {$endc}
  56. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  57. {$error Conflicting definitions for __ppc__ and __i386__}
  58. {$endc}
  59. {$ifc defined __ppc__ and __ppc__}
  60. {$setc TARGET_CPU_PPC := TRUE}
  61. {$setc TARGET_CPU_X86 := FALSE}
  62. {$elifc defined __i386__ and __i386__}
  63. {$setc TARGET_CPU_PPC := FALSE}
  64. {$setc TARGET_CPU_X86 := TRUE}
  65. {$elsec}
  66. {$error Neither __ppc__ nor __i386__ is defined.}
  67. {$endc}
  68. {$setc TARGET_CPU_PPC_64 := FALSE}
  69. {$ifc defined FPC_BIG_ENDIAN}
  70. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  71. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  72. {$elifc defined FPC_LITTLE_ENDIAN}
  73. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  74. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  75. {$elsec}
  76. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  77. {$endc}
  78. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  79. {$setc CALL_NOT_IN_CARBON := FALSE}
  80. {$setc OLDROUTINENAMES := FALSE}
  81. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  82. {$setc OPAQUE_UPP_TYPES := TRUE}
  83. {$setc OTCARBONAPPLICATION := TRUE}
  84. {$setc OTKERNEL := FALSE}
  85. {$setc PM_USE_SESSION_APIS := TRUE}
  86. {$setc TARGET_API_MAC_CARBON := TRUE}
  87. {$setc TARGET_API_MAC_OS8 := FALSE}
  88. {$setc TARGET_API_MAC_OSX := TRUE}
  89. {$setc TARGET_CARBON := TRUE}
  90. {$setc TARGET_CPU_68K := FALSE}
  91. {$setc TARGET_CPU_MIPS := FALSE}
  92. {$setc TARGET_CPU_SPARC := FALSE}
  93. {$setc TARGET_OS_MAC := TRUE}
  94. {$setc TARGET_OS_UNIX := FALSE}
  95. {$setc TARGET_OS_WIN32 := FALSE}
  96. {$setc TARGET_RT_MAC_68881 := FALSE}
  97. {$setc TARGET_RT_MAC_CFM := FALSE}
  98. {$setc TARGET_RT_MAC_MACHO := TRUE}
  99. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  100. {$setc TYPE_BOOL := FALSE}
  101. {$setc TYPE_EXTENDED := FALSE}
  102. {$setc TYPE_LONGLONG := TRUE}
  103. uses MacTypes;
  104. {$ALIGN POWER}
  105. const
  106. // Options for pathname based xattr calls
  107. XATTR_NOFOLLOW = $0001; // Don't follow symbolic links
  108. // Options for setxattr calls
  109. XATTR_CREATE = $0002; // set the value, fail if attr already exists
  110. XATTR_REPLACE = $0004; // set the value, fail if attr does not exist
  111. // Set this to bypass authorization checking (eg. if doing auth-related work)
  112. XATTR_NOSECURITY = $0008;
  113. const
  114. XATTR_MAXNAMELEN = 127;
  115. const
  116. XATTR_FINDERINFO_NAME = 'com.apple.FinderInfo';
  117. const
  118. XATTR_RESOURCEFORK_NAME = 'com.apple.ResourceFork';
  119. function getxattr( path: ConstCStringPtr; name: ConstCStringPtr; value: UnivPtr; siz: size_t; position: UInt32; options: SInt32 ): ssize_t; external name '_getxattr';
  120. function fgetxattr( fd: SInt32; name: ConstCStringPtr; value: UnivPtr; siz: size_t; position: UInt32; options: SInt32 ): ssize_t; external name '_fgetxattr';
  121. function setxattr( path: ConstCStringPtr; name: ConstCStringPtr; value: {const} UnivPtr; siz: size_t; position: UInt32; options: SInt32 ): SInt32; external name '_setxattr';
  122. function fsetxattr( fd: SInt32; name: ConstCStringPtr; value: {const} UnivPtr; siz: size_t; position: UInt32; options: SInt32 ): SInt32; external name '_fsetxattr';
  123. function removexattr( path: ConstCStringPtr; name: ConstCStringPtr; options: SInt32 ): SInt32; external name '_removexattr';
  124. function fremovexattr( fd: SInt32; name: ConstCStringPtr; options: SInt32 ): SInt32; external name '_fremovexattr';
  125. function listxattr( path: ConstCStringPtr; namebuff: UnivPtr; siz: size_t; options: SInt32 ): ssize_t; external name '_listxattr';
  126. function flistxattr( fd: SInt32; namebuff: UnivPtr; siz: size_t; options: SInt32 ): ssize_t; external name '_flistxattr';
  127. end.