apr_user.inc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. { Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {
  17. * @file apr_user.h
  18. * @brief APR User ID Services
  19. }
  20. {#include "apr.h"
  21. #include "apr_errno.h"
  22. #include "apr_pools.h"}
  23. {
  24. * @defgroup apr_user User and Group ID Services
  25. * @ingroup APR
  26. }
  27. {
  28. * Structure for determining user ownership.
  29. }
  30. type
  31. {$ifdef WINDOWS}
  32. apr_uid_t = PSID;
  33. {$else}
  34. apr_uid_t = uid_t;
  35. {$endif}
  36. Papr_uid_t = ^apr_uid_t;
  37. {
  38. * Structure for determining group ownership.
  39. }
  40. {$ifdef WINDOWS}
  41. apr_gid_t = PSID;
  42. {$else}
  43. apr_gid_t = gid_t;
  44. {$endif}
  45. Papr_gid_t = ^apr_gid_t;
  46. {$define APR_HAS_USER}
  47. {$ifdef APR_HAS_USER}
  48. {
  49. * Get the userid (and groupid) of the calling process
  50. * @param userid Returns the user id
  51. * @param groupid Returns the user's group id
  52. * @param p The pool from which to allocate working space
  53. * @remark This function is available only if APR_HAS_USER is defined.
  54. }
  55. function apr_uid_current(userid: Papr_uid_t; groupid: Papr_gid_t;
  56. p: Papr_pool_t): apr_status_t;
  57. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  58. external LibAPR name LibNamePrefix + 'apr_uid_current' + LibSuff12;
  59. {
  60. * Get the user name for a specified userid
  61. * @param username Pointer to new string containing user name (on output)
  62. * @param userid The userid
  63. * @param p The pool from which to allocate the string
  64. * @remark This function is available only if APR_HAS_USER is defined.
  65. }
  66. function apr_uid_name_get(username: PPChar; userid: apr_uid_t;
  67. p: Papr_pool_t): apr_status_t;
  68. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  69. external LibAPR name LibNamePrefix + 'apr_uid_name_get' + LibSuff12;
  70. {
  71. * Get the userid (and groupid) for the specified username
  72. * @param userid Returns the user id
  73. * @param groupid Returns the user's group id
  74. * @param username The username to lookup
  75. * @param p The pool from which to allocate working space
  76. * @remark This function is available only if APR_HAS_USER is defined.
  77. }
  78. function apr_uid_get(userid: Papr_uid_t; groupid: Papr_gid_t;
  79. const username: PChar; p: Papr_pool_t): apr_status_t;
  80. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  81. external LibAPR name LibNamePrefix + 'apr_uid_get' + LibSuff16;
  82. {
  83. * Get the home directory for the named user
  84. * @param dirname Pointer to new string containing directory name (on output)
  85. * @param username The named user
  86. * @param p The pool from which to allocate the string
  87. * @remark This function is available only if APR_HAS_USER is defined.
  88. }
  89. function apr_uid_homepath_get(dirname: PPChar; const username: PChar;
  90. p: Papr_pool_t): apr_status_t;
  91. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  92. external LibAPR name LibNamePrefix + 'apr_uid_homepath_get' + LibSuff12;
  93. {
  94. * Compare two user identifiers for equality.
  95. * @param left One uid to test
  96. * @param right Another uid to test
  97. * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
  98. * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
  99. * @remark This function is available only if APR_HAS_USER is defined.
  100. }
  101. {$ifdef WINDOWS}
  102. //APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right);
  103. {$else}
  104. //#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
  105. {$endif}
  106. {
  107. * Get the group name for a specified groupid
  108. * @param groupname Pointer to new string containing group name (on output)
  109. * @param groupid The groupid
  110. * @param p The pool from which to allocate the string
  111. * @remark This function is available only if APR_HAS_USER is defined.
  112. }
  113. function apr_gid_name_get(groupname: PPChar; groupid: apr_gid_t;
  114. p: Papr_pool_t): apr_status_t;
  115. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  116. external LibAPR name LibNamePrefix + 'apr_gid_name_get' + LibSuff12;
  117. {
  118. * Get the groupid for a specified group name
  119. * @param groupid Pointer to the group id (on output)
  120. * @param groupname The group name to look up
  121. * @param p The pool from which to allocate the string
  122. * @remark This function is available only if APR_HAS_USER is defined.
  123. }
  124. function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar;
  125. p: Papr_pool_t): apr_status_t;
  126. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
  127. external LibAPR name LibNamePrefix + 'apr_gid_get' + LibSuff12;
  128. {
  129. * Compare two group identifiers for equality.
  130. * @param left One gid to test
  131. * @param right Another gid to test
  132. * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
  133. * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
  134. * @remark This function is available only if APR_HAS_USER is defined.
  135. }
  136. {$ifdef WINDOWS}
  137. //APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right);
  138. {$else}
  139. //#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
  140. {$endif}
  141. {$endif} { ! APR_HAS_USER }