BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

types.h
Go to the documentation of this file.
1 /* $Id$ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_TYPES_H__
21 #define __PJ_TYPES_H__
22 
23 
33 #include <pj/config.h>
34 
36 
37 /* ************************************************************************* */
38 
40 typedef int pj_int32_t;
41 
43 typedef unsigned int pj_uint32_t;
44 
46 typedef short pj_int16_t;
47 
49 typedef unsigned short pj_uint16_t;
50 
52 typedef signed char pj_int8_t;
53 
55 typedef unsigned char pj_uint8_t;
56 
58 typedef size_t pj_size_t;
59 
61 #if defined(PJ_WIN64) && PJ_WIN64!=0
62  typedef pj_int64_t pj_ssize_t;
63 #else
64  typedef long pj_ssize_t;
65 #endif
66 
68 typedef int pj_status_t;
69 
71 typedef int pj_bool_t;
72 
75 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
76  typedef wchar_t pj_char_t;
77 #else
78  typedef char pj_char_t;
79 #endif
80 
83 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
84 # define PJ_T(literal_str) L##literal_str
85 #else
86 # define PJ_T(literal_str) literal_str
87 #endif
88 
91 {
94 
97 
100 };
101 
105 #if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0
106 typedef pj_int64_t pj_off_t;
107 #else
109 #endif
110 
111 /* ************************************************************************* */
112 /*
113  * Data structure types.
114  */
119 struct pj_str_t
120 {
122  char *ptr;
123 
126 };
127 
133 typedef union pj_timestamp
134 {
135  struct
136  {
137 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
138  pj_uint32_t lo;
139  pj_uint32_t hi;
140 #else
143 #endif
144  } u32;
146 #if PJ_HAS_INT64
147  pj_uint64_t u64;
148 #endif
149 } pj_timestamp;
150 
151 
152 
157 typedef void pj_list_type;
158 
162 typedef struct pj_list pj_list;
163 
168 
173 
179 typedef struct pj_hash_iterator_t
180 {
184 
185 
189 typedef struct pj_pool_factory pj_pool_factory;
190 
194 typedef struct pj_pool_t pj_pool_t;
195 
199 typedef struct pj_caching_pool pj_caching_pool;
200 
205 typedef struct pj_str_t pj_str_t;
206 
210 typedef struct pj_ioqueue_t pj_ioqueue_t;
211 
217 
222 
226 typedef struct pj_atomic_t pj_atomic_t;
227 
231 typedef PJ_ATOMIC_VALUE_TYPE pj_atomic_value_t;
232 
233 /* ************************************************************************* */
234 
236 typedef struct pj_thread_t pj_thread_t;
237 
239 typedef struct pj_lock_t pj_lock_t;
240 
243 
245 typedef struct pj_mutex_t pj_mutex_t;
246 
248 typedef struct pj_sem_t pj_sem_t;
249 
251 typedef struct pj_event_t pj_event_t;
252 
254 typedef struct pj_pipe_t pj_pipe_t;
255 
257 typedef void *pj_oshandle_t;
258 
260 #if defined(PJ_WIN64) && PJ_WIN64!=0
261  typedef pj_int64_t pj_sock_t;
262 #else
263  typedef long pj_sock_t;
264 #endif
265 
267 typedef void pj_sockaddr_t;
268 
270 typedef struct pj_sockaddr_in pj_sockaddr_in;
271 
273 typedef unsigned int pj_color_t;
274 
276 typedef int pj_exception_id_t;
277 
278 /* ************************************************************************* */
279 
281 #define PJ_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
282 
286 #define PJ_MAX_OBJ_NAME 32
287 
288 /* ************************************************************************* */
289 /*
290  * General.
291  */
304 PJ_DECL(pj_status_t) pj_init(void);
305 
306 
310 PJ_DECL(void) pj_shutdown(void);
311 
315 typedef void (*pj_exit_callback)(void);
316 
325 PJ_DECL(pj_status_t) pj_atexit(pj_exit_callback func);
326 
327 
328 
337 {
338  pj_uint8_t *p = (pj_uint8_t*)&val16;
339  pj_uint8_t tmp = *p;
340  *p = *(p+1);
341  *(p+1) = tmp;
342  return val16;
343 }
344 
353 {
354  pj_uint8_t *p = (pj_uint8_t*)&val32;
355  pj_uint8_t tmp = *p;
356  *p = *(p+3);
357  *(p+3) = tmp;
358  tmp = *(p+1);
359  *(p+1) = *(p+2);
360  *(p+2) = tmp;
361  return val32;
362 }
363 
364 
379 typedef struct pj_time_val
380 {
382  long sec;
383 
385  long msec;
386 
387 } pj_time_val;
388 
393 PJ_DECL(void) pj_time_val_normalize(pj_time_val *t);
394 
404 #define PJ_TIME_VAL_MSEC(t) ((t).sec * 1000 + (t).msec)
405 
414 #define PJ_TIME_VAL_EQ(t1, t2) ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
415 
424 #define PJ_TIME_VAL_GT(t1, t2) ((t1).sec>(t2).sec || \
425  ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
426 
435 #define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
436  PJ_TIME_VAL_EQ(t1,t2))
437 
446 #define PJ_TIME_VAL_LT(t1, t2) (!(PJ_TIME_VAL_GTE(t1,t2)))
447 
456 #define PJ_TIME_VAL_LTE(t1, t2) (!PJ_TIME_VAL_GT(t1, t2))
457 
466 #define PJ_TIME_VAL_ADD(t1, t2) do { \
467  (t1).sec += (t2).sec; \
468  (t1).msec += (t2).msec; \
469  pj_time_val_normalize(&(t1)); \
470  } while (0)
471 
472 
481 #define PJ_TIME_VAL_SUB(t1, t2) do { \
482  (t1).sec -= (t2).sec; \
483  (t1).msec -= (t2).msec; \
484  pj_time_val_normalize(&(t1)); \
485  } while (0)
486 
487 
492 typedef struct pj_parsed_time
493 {
495  int wday;
496 
497  /* This represents day of the year, 0-365, where zero means
498  * 1st of January.
499  */
500  /*int yday; */
501 
503  int day;
504 
506  int mon;
507 
511  int year;
512 
514  int sec;
515 
517  int min;
518 
520  int hour;
521 
523  int msec;
524 
526 
527 
532 /* ************************************************************************* */
533 /*
534  * Terminal.
535  */
539 enum {
544 };
545 
546 
547 
548 
550 
551 
552 #endif /* __PJ_TYPES_H__ */
553 
struct pj_timer_heap_t pj_timer_heap_t
Definition: types.h:221
pj_ssize_t slen
Definition: types.h:125
int hour
Definition: types.h:520
Definition: pool.h:823
char * ptr
Definition: types.h:122
PJ_BEGIN_DECL typedef int pj_int32_t
Definition: types.h:40
char pj_char_t
Definition: types.h:78
int pj_bool_t
Definition: types.h:71
struct pj_thread_t pj_thread_t
Definition: types.h:236
pj_uint32_t index
Definition: types.h:181
struct pj_hash_table_t pj_hash_table_t
Definition: types.h:167
struct pj_atomic_t pj_atomic_t
Definition: types.h:226
int mon
Definition: types.h:506
Definition: types.h:379
Definition: types.h:541
Definition: types.h:133
struct pj_event_t pj_event_t
Definition: types.h:251
int pj_exception_id_t
Definition: types.h:276
int pj_status_t
Definition: types.h:68
short pj_int16_t
Definition: types.h:46
pj_hash_entry * entry
Definition: types.h:182
Definition: pool.h:666
Definition: types.h:179
void pj_sockaddr_t
Definition: types.h:267
signed char pj_int8_t
Definition: types.h:52
Definition: types.h:119
int min
Definition: types.h:517
struct pj_pipe_t pj_pipe_t
Definition: types.h:254
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
void * pj_oshandle_t
Definition: types.h:257
int wday
Definition: types.h:495
struct pj_ioqueue_t pj_ioqueue_t
Definition: types.h:210
unsigned int pj_uint32_t
Definition: types.h:43
struct pj_lock_t pj_lock_t
Definition: types.h:239
pj_ssize_t pj_off_t
Definition: types.h:108
void pj_time_val_normalize(pj_time_val *t)
#define PJ_END_DECL
Definition: config.h:1281
pj_constants_
Definition: types.h:90
Definition: types.h:96
Definition: types.h:540
pj_status_t pj_atexit(pj_exit_callback func)
struct pj_hash_entry pj_hash_entry
Definition: types.h:172
#define PJ_BEGIN_DECL
Definition: config.h:1280
long pj_sock_t
Definition: types.h:263
#define PJ_INLINE(type)
Definition: config.h:1174
long msec
Definition: types.h:385
int sec
Definition: types.h:514
unsigned int pj_color_t
Definition: types.h:273
pj_int16_t pj_swap16(pj_int16_t val16)
Definition: types.h:336
pj_uint32_t hi
Definition: types.h:141
long pj_ssize_t
Definition: types.h:64
void pj_list_type
Definition: types.h:157
struct pj_sem_t pj_sem_t
Definition: types.h:248
int day
Definition: types.h:503
int year
Definition: types.h:511
PJ_ATOMIC_VALUE_TYPE pj_atomic_value_t
Definition: types.h:231
unsigned char pj_uint8_t
Definition: types.h:55
Definition: pool.h:310
int msec
Definition: types.h:523
Definition: types.h:542
Definition: types.h:543
pj_uint32_t lo
Definition: types.h:142
struct pj_ioqueue_key_t pj_ioqueue_key_t
Definition: types.h:216
long sec
Definition: types.h:382
pj_int32_t pj_swap32(pj_int32_t val32)
Definition: types.h:352
PJLIB Main configuration settings.
void pj_shutdown(void)
Definition: sock.h:534
Definition: types.h:93
unsigned short pj_uint16_t
Definition: types.h:49
struct pj_mutex_t pj_mutex_t
Definition: types.h:245
Definition: list.h:74
pj_status_t pj_init(void)
Definition: types.h:492
size_t pj_size_t
Definition: types.h:58
Definition: types.h:99
void(* pj_exit_callback)(void)
Definition: types.h:315

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.