apr  1.7.0
About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).
  Fossies Dox: apr-1.7.0.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

apr_portable.h
Go to the documentation of this file.
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 /* This header file is where you should put ANY platform specific information.
18  * This should be the only header file that programs need to include that
19  * actually has platform dependent code which refers to the .
20  */
21 #ifndef APR_PORTABLE_H
22 #define APR_PORTABLE_H
23 
28 #include "apr.h"
29 #include "apr_pools.h"
30 #include "apr_thread_proc.h"
31 #include "apr_file_io.h"
32 #include "apr_network_io.h"
33 #include "apr_errno.h"
34 #include "apr_global_mutex.h"
35 #include "apr_proc_mutex.h"
36 #include "apr_time.h"
37 #include "apr_dso.h"
38 #include "apr_shm.h"
39 
40 #if APR_HAVE_DIRENT_H
41 #include <dirent.h>
42 #endif
43 #if APR_HAVE_FCNTL_H
44 #include <fcntl.h>
45 #endif
46 #if APR_HAVE_PTHREAD_H
47 #include <pthread.h>
48 #endif
49 #if APR_HAVE_SEMAPHORE_H
50 #include <semaphore.h>
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif /* __cplusplus */
56 
63 #ifdef WIN32
64 /* The primitives for Windows types */
65 typedef HANDLE apr_os_file_t;
66 typedef HANDLE apr_os_dir_t;
67 typedef SOCKET apr_os_sock_t;
69 typedef HANDLE apr_os_thread_t;
70 typedef HANDLE apr_os_proc_t;
71 typedef DWORD apr_os_threadkey_t;
72 typedef FILETIME apr_os_imp_time_t;
73 typedef SYSTEMTIME apr_os_exp_time_t;
75 typedef HANDLE apr_os_shm_t;
76 
77 #elif defined(OS2)
78 typedef HFILE apr_os_file_t;
79 typedef HDIR apr_os_dir_t;
80 typedef int apr_os_sock_t;
81 typedef HMTX apr_os_proc_mutex_t;
82 typedef TID apr_os_thread_t;
83 typedef PID apr_os_proc_t;
84 typedef PULONG apr_os_threadkey_t;
85 typedef struct timeval apr_os_imp_time_t;
86 typedef struct tm apr_os_exp_time_t;
87 typedef HMODULE apr_os_dso_handle_t;
88 typedef void* apr_os_shm_t;
89 
90 #elif defined(__BEOS__)
91 #include <kernel/OS.h>
92 #include <kernel/image.h>
93 
94 struct apr_os_proc_mutex_t {
95  sem_id sem;
96  int32 ben;
97 };
98 
99 typedef int apr_os_file_t;
100 typedef DIR apr_os_dir_t;
101 typedef int apr_os_sock_t;
103 typedef thread_id apr_os_thread_t;
104 typedef thread_id apr_os_proc_t;
105 typedef int apr_os_threadkey_t;
106 typedef struct timeval apr_os_imp_time_t;
107 typedef struct tm apr_os_exp_time_t;
108 typedef image_id apr_os_dso_handle_t;
109 typedef void* apr_os_shm_t;
110 
111 #elif defined(NETWARE)
112 typedef int apr_os_file_t;
113 typedef DIR apr_os_dir_t;
114 typedef int apr_os_sock_t;
115 typedef NXMutex_t apr_os_proc_mutex_t;
116 typedef NXThreadId_t apr_os_thread_t;
117 typedef long apr_os_proc_t;
118 typedef NXKey_t apr_os_threadkey_t;
119 typedef struct timeval apr_os_imp_time_t;
120 typedef struct tm apr_os_exp_time_t;
121 typedef void * apr_os_dso_handle_t;
122 typedef void* apr_os_shm_t;
123 
124 #else
125 /* Any other OS should go above this one. This is the lowest common
126  * denominator typedefs for all UNIX-like systems. :)
127  */
128 
131 #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
132 
133  int crossproc;
134 #endif
135 #if APR_HAS_PROC_PTHREAD_SERIALIZE
136 
137  pthread_mutex_t *pthread_interproc;
138 #endif
139 #if APR_HAS_THREADS
140  /* If no threads, no need for thread locks */
141 #if APR_USE_PTHREAD_SERIALIZE
142 
143  pthread_mutex_t *intraproc;
144 #endif
145 #endif
146 #if APR_HAS_POSIXSEM_SERIALIZE
147 
148  sem_t *psem_interproc;
149 #endif
150 };
151 
152 typedef int apr_os_file_t;
153 typedef DIR apr_os_dir_t;
154 typedef int apr_os_sock_t;
158 #if APR_HAS_THREADS && APR_HAVE_PTHREAD_H
159 typedef pthread_t apr_os_thread_t;
160 typedef pthread_key_t apr_os_threadkey_t;
162 #endif
163 typedef pid_t apr_os_proc_t;
164 typedef struct timeval apr_os_imp_time_t;
165 typedef struct tm apr_os_exp_time_t;
169 #if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
170 #include <dl.h>
171 typedef shl_t apr_os_dso_handle_t;
172 #elif defined(DARWIN)
173 #include <mach-o/dyld.h>
174 typedef NSModule apr_os_dso_handle_t;
175 #else
176 typedef void * apr_os_dso_handle_t;
177 #endif
178 typedef void* apr_os_shm_t;
180 #endif
181 
192  struct sockaddr *local;
193  struct sockaddr *remote;
194  int family;
195  int type;
196  int protocol;
197 };
198 
200 
201 #if APR_PROC_MUTEX_IS_GLOBAL || defined(DOXYGEN)
202 
203 #define apr_os_global_mutex_t apr_os_proc_mutex_t
204 
205 #define apr_os_global_mutex_get apr_os_proc_mutex_get
206 #else
207 
213 #if APR_HAS_THREADS
214  apr_thread_mutex_t *thread_mutex;
215 #endif /* APR_HAS_THREADS */
216  };
218 
219 APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex,
221 #endif
222 
223 
233 
241 
249 
255 APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
257 
267 APR_DECLARE(apr_status_t) apr_os_proc_mutex_get_ex(apr_os_proc_mutex_t *ospmutex,
270 
276 APR_DECLARE(apr_status_t) apr_os_exp_time_get(apr_os_exp_time_t **ostime,
278 
284 APR_DECLARE(apr_status_t) apr_os_imp_time_get(apr_os_imp_time_t **ostime,
286 
292 APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
294 
295 #if APR_HAS_THREADS || defined(DOXYGEN)
296 
305 APR_DECLARE(apr_status_t) apr_os_thread_get(apr_os_thread_t **thethd,
306  apr_thread_t *thd);
307 
313 APR_DECLARE(apr_status_t) apr_os_threadkey_get(apr_os_threadkey_t *thekey,
315 
322 APR_DECLARE(apr_status_t) apr_os_thread_put(apr_thread_t **thd,
323  apr_os_thread_t *thethd,
324  apr_pool_t *cont);
325 
333  apr_os_threadkey_t *thekey,
334  apr_pool_t *cont);
338 APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void);
339 
346 APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1,
347  apr_os_thread_t tid2);
348 
350 #endif /* APR_HAS_THREADS */
351 
361 APR_DECLARE(apr_status_t) apr_os_file_put(apr_file_t **file,
363  apr_int32_t flags, apr_pool_t *cont);
364 
373 APR_DECLARE(apr_status_t) apr_os_pipe_put(apr_file_t **file,
375  apr_pool_t *cont);
376 
387 APR_DECLARE(apr_status_t) apr_os_pipe_put_ex(apr_file_t **file,
389  int register_cleanup,
390  apr_pool_t *cont);
391 
400  apr_pool_t *cont);
401 
415  apr_pool_t *cont);
416 
429  apr_pool_t *cont);
430 
437 APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
439  apr_pool_t *cont);
440 
453 APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
456  int register_cleanup,
457  apr_pool_t *cont);
458 
465 APR_DECLARE(apr_status_t) apr_os_imp_time_put(apr_time_t *aprtime,
467  apr_pool_t *cont);
468 
475 APR_DECLARE(apr_status_t) apr_os_exp_time_put(apr_time_exp_t *aprtime,
477  apr_pool_t *cont);
478 
488 APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **shm,
490  apr_pool_t *cont);
491 
492 
493 #if APR_HAS_DSO || defined(DOXYGEN)
494 
504 APR_DECLARE(apr_status_t) apr_os_dso_handle_put(apr_dso_handle_t **dso,
505  apr_os_dso_handle_t thedso,
506  apr_pool_t *pool);
507 
513 APR_DECLARE(apr_status_t) apr_os_dso_handle_get(apr_os_dso_handle_t *dso,
514  apr_dso_handle_t *aprdso);
515 
517 #endif /* APR_HAS_DSO */
518 
519 
520 #if APR_HAS_OS_UUID
521 
524 APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data);
525 #endif
526 
527 
532 APR_DECLARE(const char*) apr_os_default_encoding(apr_pool_t *pool);
533 
534 
541 APR_DECLARE(const char*) apr_os_locale_encoding(apr_pool_t *pool);
542 
545 #ifdef __cplusplus
546 }
547 #endif
548 
549 #endif /* ! APR_PORTABLE_H */
apr_os_sock_info_t
Definition: apr_portable.h:190
pool
const char int apr_pool_t * pool
Definition: apr_cstr.h:82
apr_os_proc_mutex_t
Definition: apr_portable.h:130
apr_os_proc_t
pid_t apr_os_proc_t
Definition: apr_portable.h:163
apr_dir_t
Definition: apr_arch_file_io.h:124
apr_os_threadkey_get
apr_status_t apr_os_threadkey_get(apr_os_threadkey_t *thekey, apr_threadkey_t *key)
Definition: threadpriv.c:82
mech
apr_proc_mutex_t apr_lockmech_e * mech
Definition: apr_portable.h:268
apr_errno.h
APR Error Codes.
apr_proc_mutex.h
APR Process Locking Routines.
apr_threadkey_t
Definition: apr_arch_threadproc.h:57
DWORD
typedef DWORD(WINAPI *apr_winapi_fpt_GetCompressedFileSizeA)(IN LPCSTR lpFileName
dir
apr_dir_t * dir
Definition: apr_portable.h:240
apr_thread_mutex_t
Definition: apr_arch_thread_mutex.h:28
apr_os_global_mutex_t::pool
apr_pool_t * pool
Definition: apr_portable.h:211
os_sock_info
apr_os_sock_info_t * os_sock_info
Definition: apr_portable.h:428
apr_os_sock_info_t::os_sock
apr_os_sock_t * os_sock
Definition: apr_portable.h:191
ostime
apr_os_imp_time_t ** ostime
Definition: apr_portable.h:466
apr_os_file_t
int apr_os_file_t
Definition: apr_portable.h:152
aprtime
apr_time_exp_t * aprtime
Definition: apr_portable.h:277
ospmutex
apr_os_proc_mutex_t * ospmutex
Definition: apr_portable.h:438
apr_os_sock_info_t::local
struct sockaddr * local
Definition: apr_portable.h:192
shm
apr_shm_t * shm
Definition: apr_portable.h:293
apr_os_sock_info_t::type
int type
Definition: apr_portable.h:195
apr_os_sock_get
apr_status_t apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock)
Definition: sockets.c:506
apr_os_sock_t
int apr_os_sock_t
Definition: apr_portable.h:154
apr_time.h
APR Time Library.
sockaddr
apr_sockaddr_t * sockaddr
Definition: apr_network_io.h:796
apr_os_exp_time_t
struct tm apr_os_exp_time_t
Definition: apr_portable.h:165
pmutex
apr_global_mutex_t * pmutex
Definition: apr_portable.h:220
apr_network_io.h
APR Network library.
HANDLE
typedef HANDLE(WINAPI *apr_winapi_fpt_CreateToolhelp32Snapshot)(DWORD dwFlags
apr_thread_proc.h
APR Thread and Process Library.
apr_os_proc_mutex_t
struct apr_os_proc_mutex_t apr_os_proc_mutex_t
Definition: apr_portable.h:155
apr_dso.h
APR Dynamic Object Handling Routines.
apr_os_dir_put
apr_status_t apr_os_dir_put(apr_dir_t **dir, apr_os_dir_t *thedir, apr_pool_t *pool)
Definition: dir.c:362
apr_os_imp_time_t
struct timeval apr_os_imp_time_t
Definition: apr_portable.h:164
apr_os_global_mutex_t
Definition: apr_portable.h:210
sock
apr_socket_t * sock
Definition: apr_portable.h:248
apr_global_mutex_t
Definition: apr_arch_global_mutex.h:23
apr_global_mutex.h
APR Global Locking Routines.
apr_socket_t
Definition: apr_arch_networkio.h:37
apr_os_sock_put
apr_status_t apr_os_sock_put(apr_socket_t **sock, apr_os_sock_t *thesock, apr_pool_t *cont)
Definition: sockets.c:550
apr_os_thread_equal
int apr_os_thread_equal(apr_os_thread_t tid1, apr_os_thread_t tid2)
Definition: thread.c:117
apr_thread_t
Definition: apr_arch_threadproc.h:42
apr_file_t
Definition: apr_arch_file_io.h:97
apr_os_dir_t
DIR apr_os_dir_t
Definition: apr_portable.h:153
apr_os_sock_info_t::protocol
int protocol
Definition: apr_portable.h:196
apr_pool_t
Definition: apr_pools.c:577
apr_time_exp_t
Definition: apr_time.h:97
apr_file_io.h
APR File I/O Handling.
apr_os_sock_make
apr_status_t apr_os_sock_make(apr_socket_t **apr_sock, apr_os_sock_info_t *os_sock_info, apr_pool_t *cont)
Definition: sockets.c:512
register_cleanup
apr_os_file_t int register_cleanup
Definition: apr_portable.h:388
apr_os_shm_t
void * apr_os_shm_t
Definition: apr_portable.h:178
apr_os_dso_handle_t
void * apr_os_dso_handle_t
Definition: apr_portable.h:176
osshm
apr_os_shm_t * osshm
Definition: apr_portable.h:489
apr_shm.h
APR Shared Memory Routines.
apr_time_t
apr_int64_t apr_time_t
Definition: apr_time.h:45
thedir
apr_os_dir_t * thedir
Definition: apr_portable.h:399
cont
apr_os_file_t apr_int32_t apr_pool_t * cont
Definition: apr_portable.h:362
flags
apr_os_file_t apr_int32_t flags
Definition: apr_portable.h:362
apr_os_sock_info_t::remote
struct sockaddr * remote
Definition: apr_portable.h:193
apr_proc_mutex_t
Definition: apr_arch_proc_mutex.h:27
thesock
apr_os_sock_t * thesock
Definition: apr_portable.h:414
apr_status_t
int apr_status_t
Definition: apr_errno.h:44
apr_os_global_mutex_t::proc_mutex
apr_proc_mutex_t * proc_mutex
Definition: apr_portable.h:212
thefile
apr_os_file_t * thefile
Definition: apr_portable.h:362
apr_pools.h
APR memory allocation.
key
const char * key
Definition: apr_file_io.h:851
apr_shm_t
Definition: apr_arch_shm.h:61
tm
apr_size_t apr_size_t const char apr_time_exp_t * tm
Definition: apr_time.h:219
apr_os_thread_current
apr_os_thread_t apr_os_thread_current()
Definition: thread.c:142
apr_dso_handle_t
Definition: apr_arch_dso.h:35
apr_os_dir_get
apr_status_t apr_os_dir_get(apr_os_dir_t **thedir, apr_dir_t *dir)
Definition: dir.c:353
file
apr_file_t * file
Definition: apr_portable.h:232
APR_DECLARE
APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex
Definition: apr_atomic.c:21
apr_os_sock_info_t::family
int family
Definition: apr_portable.h:194
apr_os_threadkey_put
apr_status_t apr_os_threadkey_put(apr_threadkey_t **key, apr_os_threadkey_t *thekey, apr_pool_t *pool)
Definition: threadpriv.c:89
apr_lockmech_e
apr_lockmech_e
Definition: apr_proc_mutex.h:46