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