BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

types.h
Go to the documentation of this file.
1 /* $Id: types.h 4704 2014-01-16 05:30:46Z ming $ */
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 
284 #define PJ_MAXINT32 0x7FFFFFFFL
285 
289 #define PJ_MAX_OBJ_NAME 32
290 
291 /* ************************************************************************* */
292 /*
293  * General.
294  */
307 PJ_DECL(pj_status_t) pj_init(void);
308 
309 
313 PJ_DECL(void) pj_shutdown(void);
314 
318 typedef void (*pj_exit_callback)(void);
319 
328 PJ_DECL(pj_status_t) pj_atexit(pj_exit_callback func);
329 
330 
331 
340 {
341  pj_uint8_t *p = (pj_uint8_t*)&val16;
342  pj_uint8_t tmp = *p;
343  *p = *(p+1);
344  *(p+1) = tmp;
345  return val16;
346 }
347 
356 {
357  pj_uint8_t *p = (pj_uint8_t*)&val32;
358  pj_uint8_t tmp = *p;
359  *p = *(p+3);
360  *(p+3) = tmp;
361  tmp = *(p+1);
362  *(p+1) = *(p+2);
363  *(p+2) = tmp;
364  return val32;
365 }
366 
367 
382 typedef struct pj_time_val
383 {
385  long sec;
386 
388  long msec;
389 
390 } pj_time_val;
391 
396 PJ_DECL(void) pj_time_val_normalize(pj_time_val *t);
397 
407 #define PJ_TIME_VAL_MSEC(t) ((t).sec * 1000 + (t).msec)
408 
417 #define PJ_TIME_VAL_EQ(t1, t2) ((t1).sec==(t2).sec && (t1).msec==(t2).msec)
418 
427 #define PJ_TIME_VAL_GT(t1, t2) ((t1).sec>(t2).sec || \
428  ((t1).sec==(t2).sec && (t1).msec>(t2).msec))
429 
438 #define PJ_TIME_VAL_GTE(t1, t2) (PJ_TIME_VAL_GT(t1,t2) || \
439  PJ_TIME_VAL_EQ(t1,t2))
440 
449 #define PJ_TIME_VAL_LT(t1, t2) (!(PJ_TIME_VAL_GTE(t1,t2)))
450 
459 #define PJ_TIME_VAL_LTE(t1, t2) (!PJ_TIME_VAL_GT(t1, t2))
460 
469 #define PJ_TIME_VAL_ADD(t1, t2) do { \
470  (t1).sec += (t2).sec; \
471  (t1).msec += (t2).msec; \
472  pj_time_val_normalize(&(t1)); \
473  } while (0)
474 
475 
484 #define PJ_TIME_VAL_SUB(t1, t2) do { \
485  (t1).sec -= (t2).sec; \
486  (t1).msec -= (t2).msec; \
487  pj_time_val_normalize(&(t1)); \
488  } while (0)
489 
490 
495 typedef struct pj_parsed_time
496 {
498  int wday;
499 
500  /* This represents day of the year, 0-365, where zero means
501  * 1st of January.
502  */
503  /*int yday; */
504 
506  int day;
507 
509  int mon;
510 
514  int year;
515 
517  int sec;
518 
520  int min;
521 
523  int hour;
524 
526  int msec;
527 
529 
530 
535 /* ************************************************************************* */
536 /*
537  * Terminal.
538  */
542 enum {
547 };
548 
549 
550 
551 
553 
554 
555 #endif /* __PJ_TYPES_H__ */
556 
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:523
Definition: pool.h:808
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:509
Definition: types.h:382
Definition: types.h:543
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:651
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:520
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
void(* pj_exit_callback)(void)
Definition: types.h:318
Definition: types.h:545
int wday
Definition: types.h:498
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
Definition: types.h:546
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:1067
Definition: types.h:544
pj_constants_
Definition: types.h:90
Definition: types.h:96
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:1066
long pj_sock_t
Definition: types.h:263
#define PJ_INLINE(type)
Definition: config.h:960
long msec
Definition: types.h:388
int sec
Definition: types.h:517
unsigned int pj_color_t
Definition: types.h:273
pj_int16_t pj_swap16(pj_int16_t val16)
Definition: types.h:339
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:506
int year
Definition: types.h:514
PJ_ATOMIC_VALUE_TYPE pj_atomic_value_t
Definition: types.h:231
unsigned char pj_uint8_t
Definition: types.h:55
Definition: pool.h:313
int msec
Definition: types.h:526
struct pj_timestamp::@7 u32
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:385
pj_int32_t pj_swap32(pj_int32_t val32)
Definition: types.h:355
PJLIB Main configuration settings.
void pj_shutdown(void)
Definition: sock.h:512
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:495
size_t pj_size_t
Definition: types.h:58
Definition: types.h:99

 


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