Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

apr_user.h

Go to the documentation of this file.
00001 /* Copyright 2000-2004 The Apache Software Foundation
00002  *
00003  * Licensed under the Apache License, Version 2.0 (the "License");
00004  * you may not use this file except in compliance with the License.
00005  * You may obtain a copy of the License at
00006  *
00007  *     http://www.apache.org/licenses/LICENSE-2.0
00008  *
00009  * Unless required by applicable law or agreed to in writing, software
00010  * distributed under the License is distributed on an "AS IS" BASIS,
00011  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012  * See the License for the specific language governing permissions and
00013  * limitations under the License.
00014  */
00015 
00016 #ifndef APR_USER_H
00017 #define APR_USER_H
00018 
00019 /**
00020  * @file apr_user.h
00021  * @brief APR User ID Services 
00022  */
00023 
00024 #include "apr.h"
00025 #include "apr_errno.h"
00026 #include "apr_pools.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif /* __cplusplus */
00031 
00032 /**
00033  * @defgroup apr_user User and Group ID Services
00034  * @ingroup APR 
00035  * @{
00036  */
00037 
00038 /**
00039  * Structure for determining user ownership.
00040  */
00041 #ifdef WIN32
00042 typedef PSID                      apr_uid_t;
00043 #else
00044 typedef uid_t                     apr_uid_t;
00045 #endif
00046 
00047 /**
00048  * Structure for determining group ownership.
00049  */
00050 #ifdef WIN32
00051 typedef PSID                      apr_gid_t;
00052 #else
00053 typedef gid_t                     apr_gid_t;
00054 #endif
00055 
00056 #if APR_HAS_USER 
00057 
00058 /**
00059  * Get the userid (and groupid) of the calling process
00060  * @param userid   Returns the user id
00061  * @param groupid  Returns the user's group id
00062  * @param p The pool from which to allocate working space
00063  * @remark This function is available only if APR_HAS_USER is defined.
00064  */
00065 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid,
00066                                           apr_gid_t *groupid,
00067                                           apr_pool_t *p);
00068 
00069 /**
00070  * Get the user name for a specified userid
00071  * @param username Pointer to new string containing user name (on output)
00072  * @param userid The userid
00073  * @param p The pool from which to allocate the string
00074  * @remark This function is available only if APR_HAS_USER is defined.
00075  */
00076 APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid,
00077                                            apr_pool_t *p);
00078 
00079 /**
00080  * Get the userid (and groupid) for the specified username
00081  * @param userid   Returns the user id
00082  * @param groupid  Returns the user's group id
00083  * @param username The username to lookup
00084  * @param p The pool from which to allocate working space
00085  * @remark This function is available only if APR_HAS_USER is defined.
00086  */
00087 APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid,
00088                                       const char *username, apr_pool_t *p);
00089 
00090 /**
00091  * Get the home directory for the named user
00092  * @param dirname Pointer to new string containing directory name (on output)
00093  * @param username The named user
00094  * @param p The pool from which to allocate the string
00095  * @remark This function is available only if APR_HAS_USER is defined.
00096  */
00097 APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, 
00098                                                const char *username, 
00099                                                apr_pool_t *p);
00100 
00101 /**
00102  * Compare two user identifiers for equality.
00103  * @param left One uid to test
00104  * @param right Another uid to test
00105  * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
00106  * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
00107  * @remark This function is available only if APR_HAS_USER is defined.
00108  */
00109 #if defined(WIN32)
00110 APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right);
00111 #else
00112 #define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
00113 #endif
00114 
00115 /**
00116  * Get the group name for a specified groupid
00117  * @param groupname Pointer to new string containing group name (on output)
00118  * @param groupid The groupid
00119  * @param p The pool from which to allocate the string
00120  * @remark This function is available only if APR_HAS_USER is defined.
00121  */
00122 APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, 
00123                                              apr_gid_t groupid, apr_pool_t *p);
00124 
00125 /**
00126  * Get the groupid for a specified group name
00127  * @param groupid Pointer to the group id (on output)
00128  * @param groupname The group name to look up
00129  * @param p The pool from which to allocate the string
00130  * @remark This function is available only if APR_HAS_USER is defined.
00131  */
00132 APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, 
00133                                       const char *groupname, apr_pool_t *p);
00134 
00135 /**
00136  * Compare two group identifiers for equality.
00137  * @param left One gid to test
00138  * @param right Another gid to test
00139  * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
00140  * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
00141  * @remark This function is available only if APR_HAS_USER is defined.
00142  */
00143 #if defined(WIN32)
00144 APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right);
00145 #else
00146 #define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
00147 #endif
00148 
00149 #endif  /* ! APR_HAS_USER */
00150 
00151 /** @} */
00152 
00153 #ifdef __cplusplus
00154 }
00155 #endif
00156 
00157 #endif  /* ! APR_USER_H */

Generated on Sat Apr 2 21:46:29 2005 for Apache Portable Runtime by  doxygen 1.3.9.1