Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJ_TYPES_H__
00021 #define __PJ_TYPES_H__
00022
00023
00033 #include <pj/config.h>
00034
00035 PJ_BEGIN_DECL
00036
00037
00038
00040 typedef int pj_int32_t;
00041
00043 typedef unsigned int pj_uint32_t;
00044
00046 typedef short pj_int16_t;
00047
00049 typedef unsigned short pj_uint16_t;
00050
00052 typedef signed char pj_int8_t;
00053
00055 typedef unsigned char pj_uint8_t;
00056
00058 typedef size_t pj_size_t;
00059
00061 typedef long pj_ssize_t;
00062
00064 typedef int pj_status_t;
00065
00067 typedef int pj_bool_t;
00068
00071 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
00072 typedef wchar_t pj_char_t;
00073 #else
00074 typedef char pj_char_t;
00075 #endif
00076
00079 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
00080 # define PJ_T(literal_str) L##literal_str
00081 #else
00082 # define PJ_T(literal_str) literal_str
00083 #endif
00084
00085
00087 #define PJ_SUCCESS 0
00088
00090 #define PJ_TRUE 1
00091
00093 #define PJ_FALSE 0
00094
00098 #if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
00099 typedef pj_int64_t pj_off_t;
00100 #else
00101 typedef pj_ssize_t pj_off_t;
00102 #endif
00103
00104
00105
00106
00107
00112 struct pj_str_t
00113 {
00115 char *ptr;
00116
00118 pj_ssize_t slen;
00119 };
00120
00126 typedef union pj_timestamp
00127 {
00128 struct
00129 {
00130 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
00131 pj_uint32_t lo;
00132 pj_uint32_t hi;
00133 #else
00134 pj_uint32_t hi;
00135 pj_uint32_t lo;
00136 #endif
00137 } u32;
00139 #if PJ_HAS_INT64
00140 pj_uint64_t u64;
00141 #endif
00142 } pj_timestamp;
00143
00144
00145
00150 typedef void pj_list_type;
00151
00155 typedef struct pj_list pj_list;
00156
00160 typedef struct pj_hash_table_t pj_hash_table_t;
00161
00165 typedef struct pj_hash_entry pj_hash_entry;
00166
00172 typedef struct pj_hash_iterator_t
00173 {
00174 pj_uint32_t index;
00175 pj_hash_entry *entry;
00176 } pj_hash_iterator_t;
00177
00178
00182 typedef struct pj_pool_factory pj_pool_factory;
00183
00187 typedef struct pj_pool_t pj_pool_t;
00188
00192 typedef struct pj_caching_pool pj_caching_pool;
00193
00198 typedef struct pj_str_t pj_str_t;
00199
00203 typedef struct pj_ioqueue_t pj_ioqueue_t;
00204
00209 typedef struct pj_ioqueue_key_t pj_ioqueue_key_t;
00210
00214 typedef struct pj_timer_heap_t pj_timer_heap_t;
00215
00219 typedef struct pj_timer_entry pj_timer_entry;
00220
00224 typedef struct pj_atomic_t pj_atomic_t;
00225
00229 typedef PJ_ATOMIC_VALUE_TYPE pj_atomic_value_t;
00230
00231
00232
00234 typedef struct pj_thread_t pj_thread_t;
00235
00237 typedef struct pj_lock_t pj_lock_t;
00238
00240 typedef struct pj_mutex_t pj_mutex_t;
00241
00243 typedef struct pj_sem_t pj_sem_t;
00244
00246 typedef struct pj_event_t pj_event_t;
00247
00249 typedef struct pj_pipe_t pj_pipe_t;
00250
00252 typedef void *pj_oshandle_t;
00253
00255 typedef long pj_sock_t;
00256
00258 typedef void pj_sockaddr_t;
00259
00261 typedef struct pj_sockaddr_in pj_sockaddr_in;
00262
00264 typedef unsigned int pj_color_t;
00265
00267 typedef int pj_exception_id_t;
00268
00269
00270
00272 #define PJ_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
00273
00275 #define PJ_MAXINT32 0x7FFFFFFFL
00276
00280 #define PJ_MAX_OBJ_NAME 32
00281
00282
00283
00284
00285
00298 PJ_DECL(pj_status_t) pj_init(void);
00299
00300
00304 PJ_DECL(void) pj_shutdown(void);
00305
00309 typedef void (*pj_exit_callback)(void);
00310
00319 PJ_DECL(pj_status_t) pj_atexit(pj_exit_callback func);
00320
00321
00322
00330 PJ_INLINE(pj_int16_t) pj_swap16(pj_int16_t val16)
00331 {
00332 pj_uint8_t *p = (pj_uint8_t*)&val16;
00333 pj_uint8_t tmp = *p;
00334 *p = *(p+1);
00335 *(p+1) = tmp;
00336 return val16;
00337 }
00338
00346 PJ_INLINE(pj_int32_t) pj_swap32(pj_int32_t val32)
00347 {
00348 pj_uint8_t *p = (pj_uint8_t*)&val32;
00349 pj_uint8_t tmp = *p;
00350 *p = *(p+3);
00351 *(p+3) = tmp;
00352 tmp = *(p+1);
00353 *(p+1) = *(p+2);
00354 *(p+2) = tmp;
00355 return val32;
00356 }
00357
00358
00373 typedef struct pj_time_val
00374 {
00376 long sec;
00377
00379 long msec;
00380
00381 } pj_time_val;
00382
00387 PJ_DECL(void) pj_time_val_normalize(pj_time_val *t);
00388
00398 #define PJ_TIME_VAL_MSEC(t) ((t).sec * 1000 + (t).msec)
00399
00408 #define PJ_TIME_VAL_EQ(t1, t2) ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
00409
00418 #define PJ_TIME_VAL_GT(t1, t2) ((t1).sec>(t2).sec || \
00419 ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
00420
00429 #define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
00430 PJ_TIME_VAL_EQ(t1,t2))
00431
00440 #define PJ_TIME_VAL_LT(t1, t2) (!(PJ_TIME_VAL_GTE(t1,t2)))
00441
00450 #define PJ_TIME_VAL_LTE(t1, t2) (!PJ_TIME_VAL_GT(t1, t2))
00451
00460 #define PJ_TIME_VAL_ADD(t1, t2) do { \
00461 (t1).sec += (t2).sec; \
00462 (t1).msec += (t2).msec; \
00463 pj_time_val_normalize(&(t1)); \
00464 } while (0)
00465
00466
00475 #define PJ_TIME_VAL_SUB(t1, t2) do { \
00476 (t1).sec -= (t2).sec; \
00477 (t1).msec -= (t2).msec; \
00478 pj_time_val_normalize(&(t1)); \
00479 } while (0)
00480
00481
00486 typedef struct pj_parsed_time
00487 {
00489 int wday;
00490
00491
00492
00493
00494
00495
00497 int day;
00498
00500 int mon;
00501
00505 int year;
00506
00508 int sec;
00509
00511 int min;
00512
00514 int hour;
00515
00517 int msec;
00518
00519 } pj_parsed_time;
00520
00521
00526
00527
00528
00529
00533 enum {
00534 PJ_TERM_COLOR_R = 2,
00535 PJ_TERM_COLOR_G = 4,
00536 PJ_TERM_COLOR_B = 1,
00537 PJ_TERM_COLOR_BRIGHT = 8
00538 };
00539
00540
00541
00542
00543 PJ_END_DECL
00544
00545
00546 #endif
00547