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 

 


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