00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef APR_PORTABLE_H
00022 #define APR_PORTABLE_H
00023 
00024 
00025 
00026 
00027 
00028 #include "apr.h"
00029 #include "apr_pools.h"
00030 #include "apr_thread_proc.h"
00031 #include "apr_file_io.h"
00032 #include "apr_network_io.h"
00033 #include "apr_errno.h"
00034 #include "apr_global_mutex.h"
00035 #include "apr_proc_mutex.h"
00036 #include "apr_time.h"
00037 #include "apr_dso.h"
00038 #include "apr_shm.h"
00039 
00040 #if APR_HAVE_DIRENT_H
00041 #include <dirent.h>
00042 #endif
00043 #if APR_HAVE_FCNTL_H
00044 #include <fcntl.h>
00045 #endif
00046 #if APR_HAVE_PTHREAD_H
00047 #include <pthread.h>
00048 #endif
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 #ifdef WIN32
00061 
00062 typedef HANDLE                apr_os_file_t;
00063 typedef HANDLE                apr_os_dir_t;
00064 typedef SOCKET                apr_os_sock_t;
00065 typedef HANDLE                apr_os_proc_mutex_t;
00066 typedef HANDLE                apr_os_thread_t;
00067 typedef HANDLE                apr_os_proc_t;
00068 typedef DWORD                 apr_os_threadkey_t; 
00069 typedef FILETIME              apr_os_imp_time_t;
00070 typedef SYSTEMTIME            apr_os_exp_time_t;
00071 typedef HANDLE                apr_os_dso_handle_t;
00072 typedef HANDLE                apr_os_shm_t;
00073 
00074 #elif defined(OS2)
00075 typedef HFILE                 apr_os_file_t;
00076 typedef HDIR                  apr_os_dir_t;
00077 typedef int                   apr_os_sock_t;
00078 typedef HMTX                  apr_os_proc_mutex_t;
00079 typedef TID                   apr_os_thread_t;
00080 typedef PID                   apr_os_proc_t;
00081 typedef PULONG                apr_os_threadkey_t; 
00082 typedef struct timeval        apr_os_imp_time_t;
00083 typedef struct tm             apr_os_exp_time_t;
00084 typedef HMODULE               apr_os_dso_handle_t;
00085 typedef void*                 apr_os_shm_t;
00086 
00087 #elif defined(__BEOS__)
00088 #include <kernel/OS.h>
00089 #include <kernel/image.h>
00090 
00091 struct apr_os_proc_mutex_t {
00092         sem_id sem;
00093         int32  ben;
00094 };
00095 
00096 typedef int                   apr_os_file_t;
00097 typedef DIR                   apr_os_dir_t;
00098 typedef int                   apr_os_sock_t;
00099 typedef struct apr_os_proc_mutex_t  apr_os_proc_mutex_t;
00100 typedef thread_id             apr_os_thread_t;
00101 typedef thread_id             apr_os_proc_t;
00102 typedef int                   apr_os_threadkey_t;
00103 typedef struct timeval        apr_os_imp_time_t;
00104 typedef struct tm             apr_os_exp_time_t;
00105 typedef image_id              apr_os_dso_handle_t;
00106 typedef void*                 apr_os_shm_t;
00107 
00108 #elif defined(NETWARE)
00109 typedef int                   apr_os_file_t;
00110 typedef DIR                   apr_os_dir_t;
00111 typedef int                   apr_os_sock_t;
00112 typedef NXMutex_t             apr_os_proc_mutex_t;
00113 typedef NXThreadId_t          apr_os_thread_t;
00114 typedef long                  apr_os_proc_t;
00115 typedef NXKey_t               apr_os_threadkey_t; 
00116 typedef struct timeval        apr_os_imp_time_t;
00117 typedef struct tm             apr_os_exp_time_t;
00118 typedef void *                apr_os_dso_handle_t;
00119 typedef void*                 apr_os_shm_t;
00120 
00121 #else
00122 
00123 
00124 
00125 
00126 
00127 struct apr_os_proc_mutex_t {
00128 #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
00129 
00130     int crossproc;
00131 #endif
00132 #if APR_HAS_PROC_PTHREAD_SERIALIZE
00133 
00134     pthread_mutex_t *pthread_interproc;
00135 #endif
00136 #if APR_HAS_THREADS
00137     
00138 #if APR_USE_PTHREAD_SERIALIZE
00139  
00140     pthread_mutex_t *intraproc;
00141 #endif
00142 #endif
00143 };
00144 
00145 typedef int                   apr_os_file_t;        
00146 typedef DIR                   apr_os_dir_t;         
00147 typedef int                   apr_os_sock_t;        
00148 typedef struct apr_os_proc_mutex_t  apr_os_proc_mutex_t; 
00149 
00150 
00151 #if APR_HAS_THREADS && APR_HAVE_PTHREAD_H 
00152 typedef pthread_t             apr_os_thread_t;      
00153 typedef pthread_key_t         apr_os_threadkey_t;   
00154 
00155 #endif
00156 typedef pid_t                 apr_os_proc_t;        
00157 typedef struct timeval        apr_os_imp_time_t;    
00158 typedef struct tm             apr_os_exp_time_t;    
00159 
00160 
00161 
00162 #if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
00163 #include <dl.h>
00164 typedef shl_t                 apr_os_dso_handle_t;
00165 #elif defined(DARWIN)
00166 #include <mach-o/dyld.h>
00167 typedef NSModule              apr_os_dso_handle_t;
00168 #else
00169 typedef void *                apr_os_dso_handle_t;
00170 #endif
00171 typedef void*                 apr_os_shm_t;         
00172 
00173 #endif
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 struct apr_os_sock_info_t {
00184     apr_os_sock_t *os_sock; 
00185     struct sockaddr *local; 
00186     struct sockaddr *remote; 
00187     int family;             
00188     int type;               
00189     int protocol;           
00190 };
00191 
00192 typedef struct apr_os_sock_info_t apr_os_sock_info_t;
00193 
00194 #if APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN)
00195 
00196 #define apr_os_global_mutex_t apr_os_proc_mutex_t
00197 
00198 #define apr_os_global_mutex_get apr_os_proc_mutex_get
00199 #else
00200 
00201 
00202 
00203     struct apr_os_global_mutex_t {
00204         apr_pool_t *pool;
00205         apr_proc_mutex_t *proc_mutex;
00206 #if APR_HAS_THREADS
00207         apr_thread_mutex_t *thread_mutex;
00208 #endif 
00209     };
00210     typedef struct apr_os_global_mutex_t apr_os_global_mutex_t;
00211 
00212 APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, 
00213                                                 apr_global_mutex_t *pmutex);
00214 #endif
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 APR_DECLARE(apr_status_t) apr_os_file_get(apr_os_file_t *thefile,
00225                                           apr_file_t *file);
00226 
00227 
00228 
00229 
00230 
00231    
00232 APR_DECLARE(apr_status_t) apr_os_dir_get(apr_os_dir_t **thedir, 
00233                                          apr_dir_t *dir);
00234 
00235 
00236 
00237 
00238 
00239 
00240 APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock,
00241                                           apr_socket_t *sock);
00242 
00243 
00244 
00245 
00246 
00247 
00248 APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, 
00249                                                 apr_proc_mutex_t *pmutex);
00250 
00251 
00252 
00253 
00254 
00255 
00256 APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime,
00257                                  apr_time_exp_t *aprtime);
00258 
00259 
00260 
00261 
00262 
00263 
00264 APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime, 
00265                                               apr_time_t *aprtime);
00266 
00267 
00268 
00269 
00270 
00271    
00272 APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
00273                                          apr_shm_t *shm);
00274 
00275 #if APR_HAS_THREADS || defined(DOXYGEN)
00276 
00277 
00278 
00279 
00280 
00281 
00282 
00283 
00284 
00285 APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd, 
00286                                             apr_thread_t *thd);
00287 
00288 
00289 
00290 
00291 
00292 
00293 APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey,
00294                                                apr_threadkey_t *key);
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd,
00303                                             apr_os_thread_t *thethd,
00304                                             apr_pool_t *cont);
00305 
00306 
00307 
00308 
00309 
00310 
00311 
00312 APR_DECLARE(apr_status_t) apr_os_threadkey_put(apr_threadkey_t **key,
00313                                                apr_os_threadkey_t *thekey,
00314                                                apr_pool_t *cont);
00315 
00316 
00317 
00318 APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void);
00319 
00320 
00321 
00322 
00323 
00324 
00325  
00326 APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1, 
00327                                      apr_os_thread_t tid2);
00328 
00329 
00330 #endif 
00331 
00332 
00333 
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file,
00342                                           apr_os_file_t *thefile,
00343                                           apr_int32_t flags, apr_pool_t *cont); 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file,
00354                                           apr_os_file_t *thefile,
00355                                           apr_pool_t *cont);
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file,
00368                                              apr_os_file_t *thefile,
00369                                              int register_cleanup,
00370                                              apr_pool_t *cont);
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 APR_DECLARE(apr_status_t) apr_os_dir_put(apr_dir_t **dir,
00379                                          apr_os_dir_t *thedir,
00380                                          apr_pool_t *cont); 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 
00390 APR_DECLARE(apr_status_t) apr_os_sock_put(apr_socket_t **sock, 
00391                                           apr_os_sock_t *thesock, 
00392                                           apr_pool_t *cont);
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00400 
00401 
00402 
00403 
00404 APR_DECLARE(apr_status_t) apr_os_sock_make(apr_socket_t **apr_sock,
00405                                            apr_os_sock_info_t *os_sock_info,
00406                                            apr_pool_t *cont);
00407 
00408 
00409 
00410 
00411 
00412 
00413 
00414 APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
00415                                                 apr_os_proc_mutex_t *ospmutex,
00416                                                 apr_pool_t *cont); 
00417 
00418 
00419 
00420 
00421 
00422 
00423 
00424 APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime,
00425                                               apr_os_imp_time_t **ostime,
00426                                               apr_pool_t *cont); 
00427 
00428 
00429 
00430 
00431 
00432 
00433 
00434 APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime,
00435                                               apr_os_exp_time_t **ostime,
00436                                               apr_pool_t *cont); 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm,
00448                                          apr_os_shm_t *osshm,
00449                                          apr_pool_t *cont); 
00450 
00451 
00452 #if APR_HAS_DSO || defined(DOXYGEN)
00453 
00454 
00455 
00456 
00457 
00458 
00459 
00460 
00461 
00462 
00463 APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **dso,
00464                                                 apr_os_dso_handle_t thedso,
00465                                                 apr_pool_t *pool);
00466 
00467 
00468 
00469 
00470 
00471 
00472 APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso,
00473                                                 apr_dso_handle_t *aprdso);
00474 
00475 
00476 #endif 
00477 
00478 
00479 #if APR_HAS_OS_UUID
00480 
00481 
00482 
00483 APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data);
00484 #endif
00485 
00486 
00487 
00488 
00489 
00490 
00491 APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool);
00492 
00493 
00494 
00495 
00496 
00497 
00498 
00499 
00500 APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool);
00501 
00502 
00503 
00504 #ifdef __cplusplus
00505 }
00506 #endif
00507 
00508 #endif