bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / include / apr_user.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  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 #ifndef APR_USER_H
18 #define APR_USER_H
19
20 /**
21  * @file apr_user.h
22  * @brief APR User ID Services 
23  */
24
25 #include "apr.h"
26 #include "apr_errno.h"
27 #include "apr_pools.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /**
34  * @defgroup apr_user User and Group ID Services
35  * @ingroup APR 
36  * @{
37  */
38
39 /**
40  * Structure for determining user ownership.
41  */
42 #ifdef WIN32
43 typedef PSID                      apr_uid_t;
44 #else
45 typedef uid_t                     apr_uid_t;
46 #endif
47
48 /**
49  * Structure for determining group ownership.
50  */
51 #ifdef WIN32
52 typedef PSID                      apr_gid_t;
53 #else
54 typedef gid_t                     apr_gid_t;
55 #endif
56
57 #if APR_HAS_USER 
58
59 /**
60  * Get the userid (and groupid) of the calling process
61  * @param userid   Returns the user id
62  * @param groupid  Returns the user's group id
63  * @param p The pool from which to allocate working space
64  * @remark This function is available only if APR_HAS_USER is defined.
65  */
66 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid,
67                                           apr_gid_t *groupid,
68                                           apr_pool_t *p);
69
70 /** @deprecated @see apr_uid_current */
71 APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid,
72                                              apr_gid_t *groupid,
73                                              apr_pool_t *p);
74 /**
75  * Get the user name for a specified userid
76  * @param username Pointer to new string containing user name (on output)
77  * @param userid The userid
78  * @param p The pool from which to allocate the string
79  * @remark This function is available only if APR_HAS_USER is defined.
80  */
81 APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid,
82                                            apr_pool_t *p);
83
84 /** @deprecated @see apr_uid_name_get */
85 APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid,
86                                            apr_pool_t *p);
87 /**
88  * Get the userid (and groupid) for the specified username
89  * @param userid   Returns the user id
90  * @param groupid  Returns the user's group id
91  * @param username The username to lookup
92  * @param p The pool from which to allocate working space
93  * @remark This function is available only if APR_HAS_USER is defined.
94  */
95 APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid,
96                                       const char *username, apr_pool_t *p);
97
98 /** @deprecated @see apr_uid_get */
99 APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid,
100                                          const char *username, apr_pool_t *p);
101
102 /**
103  * Get the home directory for the named user
104  * @param dirname Pointer to new string containing directory name (on output)
105  * @param username The named user
106  * @param p The pool from which to allocate the string
107  * @remark This function is available only if APR_HAS_USER is defined.
108  */
109 APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, 
110                                                const char *username, 
111                                                apr_pool_t *p);
112
113 /** @deprecated @see apr_uid_homepath_get */
114 APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, 
115                                                  const char *username, 
116                                                  apr_pool_t *p);
117
118 /**
119  * Compare two user identifiers for equality.
120  * @param left One uid to test
121  * @param right Another uid to test
122  * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
123  * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
124  * @remark This function is available only if APR_HAS_USER is defined.
125  */
126 #if defined(WIN32)
127 APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right);
128
129 /** @deprecated @see apr_uid_compare */
130 APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
131 #else
132 #define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
133 /** @deprecated @see apr_uid_compare */
134 #define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
135 #endif
136
137 /**
138  * Get the group name for a specified groupid
139  * @param groupname Pointer to new string containing group name (on output)
140  * @param groupid The groupid
141  * @param p The pool from which to allocate the string
142  * @remark This function is available only if APR_HAS_USER is defined.
143  */
144 APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, 
145                                              apr_gid_t groupid, apr_pool_t *p);
146
147 /** @deprecated @see apr_gid_name_get */
148 APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname, 
149                                              apr_gid_t groupid, apr_pool_t *p);
150
151 /** @deprecated @see apr_gid_name_get */
152 APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, 
153                                             apr_gid_t groupid, apr_pool_t *p);
154
155 /**
156  * Get the groupid for a specified group name
157  * @param groupid Pointer to the group id (on output)
158  * @param groupname The group name to look up
159  * @param p The pool from which to allocate the string
160  * @remark This function is available only if APR_HAS_USER is defined.
161  */
162 APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, 
163                                       const char *groupname, apr_pool_t *p);
164
165 /** @deprecated @see apr_gid_get */
166 APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, 
167                                           const char *groupname, apr_pool_t *p);
168
169 /**
170  * Compare two group identifiers for equality.
171  * @param left One gid to test
172  * @param right Another gid to test
173  * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
174  * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
175  * @remark This function is available only if APR_HAS_USER is defined.
176  */
177 #if defined(WIN32)
178 APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right);
179 /** @deprecated @see apr_gid_compare */
180 APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
181 #else
182 #define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
183 /** @deprecated @see apr_gid_compare */
184 #define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
185 #endif
186
187 #endif  /* ! APR_HAS_USER */
188
189 /** @} */
190
191 #ifdef __cplusplus
192 }
193 #endif
194
195 #endif  /* ! APR_USER_H */