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